Commit 3ee8d6c5 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'for-5.4' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup

Pull cgroup updates from Tejun Heo:
 "Three minor cleanup patches"

* 'for-5.4' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup:
  Use kvmalloc in cgroups-v1
  cgroup: minor tweak for logic to get cgroup css
  cgroup: Replace a seq_printf() call by seq_puts() in cgroup_print_ss_mask()
parents b8456f94 653a23ca
...@@ -193,25 +193,6 @@ struct cgroup_pidlist { ...@@ -193,25 +193,6 @@ struct cgroup_pidlist {
struct delayed_work destroy_dwork; struct delayed_work destroy_dwork;
}; };
/*
* The following two functions "fix" the issue where there are more pids
* than kmalloc will give memory for; in such cases, we use vmalloc/vfree.
* TODO: replace with a kernel-wide solution to this problem
*/
#define PIDLIST_TOO_LARGE(c) ((c) * sizeof(pid_t) > (PAGE_SIZE * 2))
static void *pidlist_allocate(int count)
{
if (PIDLIST_TOO_LARGE(count))
return vmalloc(array_size(count, sizeof(pid_t)));
else
return kmalloc_array(count, sizeof(pid_t), GFP_KERNEL);
}
static void pidlist_free(void *p)
{
kvfree(p);
}
/* /*
* Used to destroy all pidlists lingering waiting for destroy timer. None * Used to destroy all pidlists lingering waiting for destroy timer. None
* should be left afterwards. * should be left afterwards.
...@@ -244,7 +225,7 @@ static void cgroup_pidlist_destroy_work_fn(struct work_struct *work) ...@@ -244,7 +225,7 @@ static void cgroup_pidlist_destroy_work_fn(struct work_struct *work)
*/ */
if (!delayed_work_pending(dwork)) { if (!delayed_work_pending(dwork)) {
list_del(&l->links); list_del(&l->links);
pidlist_free(l->list); kvfree(l->list);
put_pid_ns(l->key.ns); put_pid_ns(l->key.ns);
tofree = l; tofree = l;
} }
...@@ -365,7 +346,7 @@ static int pidlist_array_load(struct cgroup *cgrp, enum cgroup_filetype type, ...@@ -365,7 +346,7 @@ static int pidlist_array_load(struct cgroup *cgrp, enum cgroup_filetype type,
* show up until sometime later on. * show up until sometime later on.
*/ */
length = cgroup_task_count(cgrp); length = cgroup_task_count(cgrp);
array = pidlist_allocate(length); array = kvmalloc_array(length, sizeof(pid_t), GFP_KERNEL);
if (!array) if (!array)
return -ENOMEM; return -ENOMEM;
/* now, populate the array */ /* now, populate the array */
...@@ -390,12 +371,12 @@ static int pidlist_array_load(struct cgroup *cgrp, enum cgroup_filetype type, ...@@ -390,12 +371,12 @@ static int pidlist_array_load(struct cgroup *cgrp, enum cgroup_filetype type,
l = cgroup_pidlist_find_create(cgrp, type); l = cgroup_pidlist_find_create(cgrp, type);
if (!l) { if (!l) {
pidlist_free(array); kvfree(array);
return -ENOMEM; return -ENOMEM;
} }
/* store array, freeing old if necessary */ /* store array, freeing old if necessary */
pidlist_free(l->list); kvfree(l->list);
l->list = array; l->list = array;
l->length = length; l->length = length;
*lp = l; *lp = l;
......
...@@ -488,7 +488,7 @@ static struct cgroup_subsys_state *cgroup_tryget_css(struct cgroup *cgrp, ...@@ -488,7 +488,7 @@ static struct cgroup_subsys_state *cgroup_tryget_css(struct cgroup *cgrp,
rcu_read_lock(); rcu_read_lock();
css = cgroup_css(cgrp, ss); css = cgroup_css(cgrp, ss);
if (!css || !css_tryget_online(css)) if (css && !css_tryget_online(css))
css = NULL; css = NULL;
rcu_read_unlock(); rcu_read_unlock();
...@@ -2894,7 +2894,7 @@ static void cgroup_print_ss_mask(struct seq_file *seq, u16 ss_mask) ...@@ -2894,7 +2894,7 @@ static void cgroup_print_ss_mask(struct seq_file *seq, u16 ss_mask)
do_each_subsys_mask(ss, ssid, ss_mask) { do_each_subsys_mask(ss, ssid, ss_mask) {
if (printed) if (printed)
seq_putc(seq, ' '); seq_putc(seq, ' ');
seq_printf(seq, "%s", ss->name); seq_puts(seq, ss->name);
printed = true; printed = true;
} while_each_subsys_mask(); } while_each_subsys_mask();
if (printed) if (printed)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment