Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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()

+6 -25
+4 -23
kernel/cgroup/cgroup-v1.c
··· 194 194 }; 195 195 196 196 /* 197 - * The following two functions "fix" the issue where there are more pids 198 - * than kmalloc will give memory for; in such cases, we use vmalloc/vfree. 199 - * TODO: replace with a kernel-wide solution to this problem 200 - */ 201 - #define PIDLIST_TOO_LARGE(c) ((c) * sizeof(pid_t) > (PAGE_SIZE * 2)) 202 - static void *pidlist_allocate(int count) 203 - { 204 - if (PIDLIST_TOO_LARGE(count)) 205 - return vmalloc(array_size(count, sizeof(pid_t))); 206 - else 207 - return kmalloc_array(count, sizeof(pid_t), GFP_KERNEL); 208 - } 209 - 210 - static void pidlist_free(void *p) 211 - { 212 - kvfree(p); 213 - } 214 - 215 - /* 216 197 * Used to destroy all pidlists lingering waiting for destroy timer. None 217 198 * should be left afterwards. 218 199 */ ··· 225 244 */ 226 245 if (!delayed_work_pending(dwork)) { 227 246 list_del(&l->links); 228 - pidlist_free(l->list); 247 + kvfree(l->list); 229 248 put_pid_ns(l->key.ns); 230 249 tofree = l; 231 250 } ··· 346 365 * show up until sometime later on. 347 366 */ 348 367 length = cgroup_task_count(cgrp); 349 - array = pidlist_allocate(length); 368 + array = kvmalloc_array(length, sizeof(pid_t), GFP_KERNEL); 350 369 if (!array) 351 370 return -ENOMEM; 352 371 /* now, populate the array */ ··· 371 390 372 391 l = cgroup_pidlist_find_create(cgrp, type); 373 392 if (!l) { 374 - pidlist_free(array); 393 + kvfree(array); 375 394 return -ENOMEM; 376 395 } 377 396 378 397 /* store array, freeing old if necessary */ 379 - pidlist_free(l->list); 398 + kvfree(l->list); 380 399 l->list = array; 381 400 l->length = length; 382 401 *lp = l;
+2 -2
kernel/cgroup/cgroup.c
··· 488 488 489 489 rcu_read_lock(); 490 490 css = cgroup_css(cgrp, ss); 491 - if (!css || !css_tryget_online(css)) 491 + if (css && !css_tryget_online(css)) 492 492 css = NULL; 493 493 rcu_read_unlock(); 494 494 ··· 2894 2894 do_each_subsys_mask(ss, ssid, ss_mask) { 2895 2895 if (printed) 2896 2896 seq_putc(seq, ' '); 2897 - seq_printf(seq, "%s", ss->name); 2897 + seq_puts(seq, ss->name); 2898 2898 printed = true; 2899 2899 } while_each_subsys_mask(); 2900 2900 if (printed)