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

Configure Feed

Select the types of activity you want to include in your feed.

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

Pull cgroup updates from Tejun Heo:

- Add deprecation info messages to cgroup1-only features

- rstat updates including a bug fix and breaking up a critical section
to reduce interrupt latency impact

- Other misc and doc updates

* tag 'cgroup-for-6.15' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup:
cgroup: rstat: Cleanup flushing functions and locking
cgroup/rstat: avoid disabling irqs for O(num_cpu)
mm: Fix a build breakage in memcontrol-v1.c
blk-cgroup: Simplify policy files registration
cgroup: Update file naming comment
cgroup: Add deprecation message to legacy freezer controller
mm: Add transformation message for per-memcg swappiness
RFC cgroup/cpuset-v1: Add deprecation messages to sched_relax_domain_level
cgroup/cpuset-v1: Add deprecation messages to memory_migrate
cgroup/cpuset-v1: Add deprecation messages to mem_exclusive and mem_hardwall
cgroup: Print message when /proc/cgroups is read on v2-only system
cgroup/blkio: Add deprecation messages to reset_stats
cgroup/cpuset-v1: Add deprecation messages to memory_spread_page and memory_spread_slab
cgroup/cpuset-v1: Add deprecation messages to sched_load_balance and memory_pressure_enabled
cgroup, docs: Be explicit about independence of RT_GROUP_SCHED and non-cpu controllers
cgroup/rstat: Fix forceidle time in cpu.stat
cgroup/misc: Remove unused misc_cg_res_total_usage
cgroup/cpuset: Move procfs cpuset attribute under cgroup-v1.c
cgroup: update comment about dropping cgroup kn refs

+142 -188
+4
Documentation/admin-guide/cgroup-v1/freezer-subsystem.rst
··· 125 125 126 126 This is the basic mechanism which should do the right thing for user space task 127 127 in a simple scenario. 128 + 129 + This freezer implementation is affected by shortcomings (see commit 130 + 76f969e8948d8 ("cgroup: cgroup v2 freezer")) and cgroup v2 freezer is 131 + recommended.
+1
Documentation/admin-guide/cgroup-v1/memory.rst
··· 90 90 used. 91 91 memory.swappiness set/show swappiness parameter of vmscan 92 92 (See sysctl's vm.swappiness) 93 + Per memcg knob does not exist in cgroup v2. 93 94 memory.move_charge_at_immigrate This knob is deprecated. 94 95 memory.oom_control set/show oom controls. 95 96 This knob is deprecated and shouldn't be
+14 -9
Documentation/admin-guide/cgroup-v2.rst
··· 1076 1076 provided by a CPU, as well as the maximum desired frequency, which should not 1077 1077 be exceeded by a CPU. 1078 1078 1079 - WARNING: cgroup2 doesn't yet support control of realtime processes. For 1080 - a kernel built with the CONFIG_RT_GROUP_SCHED option enabled for group 1081 - scheduling of realtime processes, the cpu controller can only be enabled 1082 - when all RT processes are in the root cgroup. This limitation does 1083 - not apply if CONFIG_RT_GROUP_SCHED is disabled. Be aware that system 1084 - management software may already have placed RT processes into nonroot 1085 - cgroups during the system boot process, and these processes may need 1086 - to be moved to the root cgroup before the cpu controller can be enabled 1087 - with a CONFIG_RT_GROUP_SCHED enabled kernel. 1079 + WARNING: cgroup2 cpu controller doesn't yet fully support the control of 1080 + realtime processes. For a kernel built with the CONFIG_RT_GROUP_SCHED option 1081 + enabled for group scheduling of realtime processes, the cpu controller can only 1082 + be enabled when all RT processes are in the root cgroup. Be aware that system 1083 + management software may already have placed RT processes into non-root cgroups 1084 + during the system boot process, and these processes may need to be moved to the 1085 + root cgroup before the cpu controller can be enabled with a 1086 + CONFIG_RT_GROUP_SCHED enabled kernel. 1087 + 1088 + With CONFIG_RT_GROUP_SCHED disabled, this limitation does not apply and some of 1089 + the interface files either affect realtime processes or account for them. See 1090 + the following section for details. Only the cpu controller is affected by 1091 + CONFIG_RT_GROUP_SCHED. Other controllers can be used for the resource control of 1092 + realtime processes irrespective of CONFIG_RT_GROUP_SCHED. 1088 1093 1089 1094 1090 1095 CPU Interface Files
+6 -2
block/blk-cgroup.c
··· 659 659 struct blkcg_gq *blkg; 660 660 int i; 661 661 662 + pr_info_once("blkio.%s is deprecated\n", cftype->name); 662 663 mutex_lock(&blkcg_pol_mutex); 663 664 spin_lock_irq(&blkcg->lock); 664 665 ··· 1771 1770 mutex_unlock(&blkcg_pol_mutex); 1772 1771 1773 1772 /* everything is in place, add intf files for the new policy */ 1774 - if (pol->dfl_cftypes) 1773 + if (pol->dfl_cftypes == pol->legacy_cftypes) { 1774 + WARN_ON(cgroup_add_cftypes(&io_cgrp_subsys, 1775 + pol->dfl_cftypes)); 1776 + } else { 1775 1777 WARN_ON(cgroup_add_dfl_cftypes(&io_cgrp_subsys, 1776 1778 pol->dfl_cftypes)); 1777 - if (pol->legacy_cftypes) 1778 1779 WARN_ON(cgroup_add_legacy_cftypes(&io_cgrp_subsys, 1779 1780 pol->legacy_cftypes)); 1781 + } 1780 1782 mutex_unlock(&blkcg_pol_register_mutex); 1781 1783 return 0; 1782 1784
+7 -16
block/blk-ioprio.c
··· 113 113 kfree(blkcg); 114 114 } 115 115 116 - #define IOPRIO_ATTRS \ 117 - { \ 118 - .name = "prio.class", \ 119 - .seq_show = ioprio_show_prio_policy, \ 120 - .write = ioprio_set_prio_policy, \ 121 - }, \ 122 - { } /* sentinel */ 123 - 124 - /* cgroup v2 attributes */ 125 116 static struct cftype ioprio_files[] = { 126 - IOPRIO_ATTRS 127 - }; 128 - 129 - /* cgroup v1 attributes */ 130 - static struct cftype ioprio_legacy_files[] = { 131 - IOPRIO_ATTRS 117 + { 118 + .name = "prio.class", 119 + .seq_show = ioprio_show_prio_policy, 120 + .write = ioprio_set_prio_policy, 121 + }, 122 + { } /* sentinel */ 132 123 }; 133 124 134 125 static struct blkcg_policy ioprio_policy = { 135 126 .dfl_cftypes = ioprio_files, 136 - .legacy_cftypes = ioprio_legacy_files, 127 + .legacy_cftypes = ioprio_files, 137 128 138 129 .cpd_alloc_fn = ioprio_alloc_cpd, 139 130 .cpd_free_fn = ioprio_free_cpd,
+2 -3
include/linux/cgroup-defs.h
··· 619 619 */ 620 620 struct cftype { 621 621 /* 622 - * By convention, the name should begin with the name of the 623 - * subsystem, followed by a period. Zero length string indicates 624 - * end of cftype array. 622 + * Name of the subsystem is prepended in cgroup_file_name(). 623 + * Zero length string indicates end of cftype array. 625 624 */ 626 625 char name[MAX_CFTYPE_NAME]; 627 626 unsigned long private;
+1 -2
include/linux/cgroup.h
··· 113 113 114 114 int cgroup_add_dfl_cftypes(struct cgroup_subsys *ss, struct cftype *cfts); 115 115 int cgroup_add_legacy_cftypes(struct cgroup_subsys *ss, struct cftype *cfts); 116 + int cgroup_add_cftypes(struct cgroup_subsys *ss, struct cftype *cfts); 116 117 int cgroup_rm_cftypes(struct cftype *cfts); 117 118 void cgroup_file_notify(struct cgroup_file *cfile); 118 119 void cgroup_file_show(struct cgroup_file *cfile, bool show); ··· 690 689 */ 691 690 void cgroup_rstat_updated(struct cgroup *cgrp, int cpu); 692 691 void cgroup_rstat_flush(struct cgroup *cgrp); 693 - void cgroup_rstat_flush_hold(struct cgroup *cgrp); 694 - void cgroup_rstat_flush_release(struct cgroup *cgrp); 695 692 696 693 /* 697 694 * Basic resource stats.
-6
include/linux/misc_cgroup.h
··· 60 60 struct misc_res res[MISC_CG_RES_TYPES]; 61 61 }; 62 62 63 - u64 misc_cg_res_total_usage(enum misc_res_type type); 64 63 int misc_cg_set_capacity(enum misc_res_type type, u64 capacity); 65 64 int misc_cg_try_charge(enum misc_res_type type, struct misc_cg *cg, u64 amount); 66 65 void misc_cg_uncharge(enum misc_res_type type, struct misc_cg *cg, u64 amount); ··· 102 103 } 103 104 104 105 #else /* !CONFIG_CGROUP_MISC */ 105 - 106 - static inline u64 misc_cg_res_total_usage(enum misc_res_type type) 107 - { 108 - return 0; 109 - } 110 106 111 107 static inline int misc_cg_set_capacity(enum misc_res_type type, u64 capacity) 112 108 {
+3 -2
init/Kconfig
··· 1198 1198 help 1199 1199 Legacy cgroup v1 cpusets controller which has been deprecated by 1200 1200 cgroup v2 implementation. The v1 is there for legacy applications 1201 - which haven't migrated to the new cgroup v2 interface yet. If you 1201 + which haven't migrated to the new cgroup v2 interface yet. Legacy 1202 + interface includes cpuset filesystem and /proc/<pid>/cpuset. If you 1202 1203 do not have any such application then you are completely fine leaving 1203 1204 this option disabled. 1204 1205 ··· 1207 1206 1208 1207 config PROC_PID_CPUSET 1209 1208 bool "Include legacy /proc/<pid>/cpuset file" 1210 - depends on CPUSETS 1209 + depends on CPUSETS_V1 1211 1210 default y 1212 1211 1213 1212 config CGROUP_DEVICE
+1
kernel/cgroup/cgroup-internal.h
··· 168 168 169 169 extern struct cgroup_subsys *cgroup_subsys[]; 170 170 extern struct list_head cgroup_roots; 171 + extern bool cgrp_dfl_visible; 171 172 172 173 /* iterate across the hierarchies */ 173 174 #define for_each_root(root) \
+7
kernel/cgroup/cgroup-v1.c
··· 673 673 int proc_cgroupstats_show(struct seq_file *m, void *v) 674 674 { 675 675 struct cgroup_subsys *ss; 676 + bool cgrp_v1_visible = false; 676 677 int i; 677 678 678 679 seq_puts(m, "#subsys_name\thierarchy\tnum_cgroups\tenabled\n"); ··· 685 684 for_each_subsys(ss, i) { 686 685 if (cgroup1_subsys_absent(ss)) 687 686 continue; 687 + cgrp_v1_visible |= ss->root != &cgrp_dfl_root; 688 + 688 689 seq_printf(m, "%s\t%d\t%d\t%d\n", 689 690 ss->legacy_name, ss->root->hierarchy_id, 690 691 atomic_read(&ss->root->nr_cgrps), 691 692 cgroup_ssid_enabled(i)); 692 693 } 694 + 695 + if (cgrp_dfl_visible && !cgrp_v1_visible) 696 + pr_info_once("/proc/cgroups lists only v1 controllers, use cgroup.controllers of root cgroup for v2 info\n"); 697 + 693 698 694 699 return 0; 695 700 }
+3 -3
kernel/cgroup/cgroup.c
··· 171 171 * The default hierarchy always exists but is hidden until mounted for the 172 172 * first time. This is for backward compatibility. 173 173 */ 174 - static bool cgrp_dfl_visible; 174 + bool cgrp_dfl_visible; 175 175 176 176 /* some controllers are not supported in the default hierarchy */ 177 177 static u16 cgrp_dfl_inhibit_ss_mask; ··· 4447 4447 * function currently returns 0 as long as @cfts registration is successful 4448 4448 * even if some file creation attempts on existing cgroups fail. 4449 4449 */ 4450 - static int cgroup_add_cftypes(struct cgroup_subsys *ss, struct cftype *cfts) 4450 + int cgroup_add_cftypes(struct cgroup_subsys *ss, struct cftype *cfts) 4451 4451 { 4452 4452 int ret; 4453 4453 ··· 5831 5831 } 5832 5832 5833 5833 /* 5834 - * This extra ref will be put in cgroup_free_fn() and guarantees 5834 + * This extra ref will be put in css_free_rwork_fn() and guarantees 5835 5835 * that @cgrp->kn is always accessible. 5836 5836 */ 5837 5837 kernfs_get(cgrp->kn);
+49
kernel/cgroup/cpuset-v1.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0-or-later 2 2 3 + #include "cgroup-internal.h" 3 4 #include "cpuset-internal.h" 4 5 5 6 /* ··· 176 175 177 176 switch (type) { 178 177 case FILE_SCHED_RELAX_DOMAIN_LEVEL: 178 + pr_info_once("cpuset.%s is deprecated\n", cft->name); 179 179 retval = update_relax_domain_level(cs, val); 180 180 break; 181 181 default: ··· 375 373 return ret; 376 374 } 377 375 376 + #ifdef CONFIG_PROC_PID_CPUSET 377 + /* 378 + * proc_cpuset_show() 379 + * - Print tasks cpuset path into seq_file. 380 + * - Used for /proc/<pid>/cpuset. 381 + */ 382 + int proc_cpuset_show(struct seq_file *m, struct pid_namespace *ns, 383 + struct pid *pid, struct task_struct *tsk) 384 + { 385 + char *buf; 386 + struct cgroup_subsys_state *css; 387 + int retval; 388 + 389 + retval = -ENOMEM; 390 + buf = kmalloc(PATH_MAX, GFP_KERNEL); 391 + if (!buf) 392 + goto out; 393 + 394 + rcu_read_lock(); 395 + spin_lock_irq(&css_set_lock); 396 + css = task_css(tsk, cpuset_cgrp_id); 397 + retval = cgroup_path_ns_locked(css->cgroup, buf, PATH_MAX, 398 + current->nsproxy->cgroup_ns); 399 + spin_unlock_irq(&css_set_lock); 400 + rcu_read_unlock(); 401 + 402 + if (retval == -E2BIG) 403 + retval = -ENAMETOOLONG; 404 + if (retval < 0) 405 + goto out_free; 406 + seq_puts(m, buf); 407 + seq_putc(m, '\n'); 408 + retval = 0; 409 + out_free: 410 + kfree(buf); 411 + out: 412 + return retval; 413 + } 414 + #endif /* CONFIG_PROC_PID_CPUSET */ 415 + 378 416 static u64 cpuset_read_u64(struct cgroup_subsys_state *css, struct cftype *cft) 379 417 { 380 418 struct cpuset *cs = css_cs(css); ··· 466 424 retval = cpuset_update_flag(CS_CPU_EXCLUSIVE, cs, val); 467 425 break; 468 426 case FILE_MEM_EXCLUSIVE: 427 + pr_info_once("cpuset.%s is deprecated\n", cft->name); 469 428 retval = cpuset_update_flag(CS_MEM_EXCLUSIVE, cs, val); 470 429 break; 471 430 case FILE_MEM_HARDWALL: 431 + pr_info_once("cpuset.%s is deprecated\n", cft->name); 472 432 retval = cpuset_update_flag(CS_MEM_HARDWALL, cs, val); 473 433 break; 474 434 case FILE_SCHED_LOAD_BALANCE: 435 + pr_info_once("cpuset.%s is deprecated, use cpuset.cpus.partition instead\n", cft->name); 475 436 retval = cpuset_update_flag(CS_SCHED_LOAD_BALANCE, cs, val); 476 437 break; 477 438 case FILE_MEMORY_MIGRATE: 439 + pr_info_once("cpuset.%s is deprecated\n", cft->name); 478 440 retval = cpuset_update_flag(CS_MEMORY_MIGRATE, cs, val); 479 441 break; 480 442 case FILE_MEMORY_PRESSURE_ENABLED: 443 + pr_info_once("cpuset.%s is deprecated, use memory.pressure with CONFIG_PSI instead\n", cft->name); 481 444 cpuset_memory_pressure_enabled = !!val; 482 445 break; 483 446 case FILE_SPREAD_PAGE: 447 + pr_info_once("cpuset.%s is deprecated\n", cft->name); 484 448 retval = cpuset_update_flag(CS_SPREAD_PAGE, cs, val); 485 449 break; 486 450 case FILE_SPREAD_SLAB: 451 + pr_warn_once("cpuset.%s is deprecated\n", cft->name); 487 452 retval = cpuset_update_flag(CS_SPREAD_SLAB, cs, val); 488 453 break; 489 454 default:
-45
kernel/cgroup/cpuset.c
··· 21 21 * License. See the file COPYING in the main directory of the Linux 22 22 * distribution for more details. 23 23 */ 24 - #include "cgroup-internal.h" 25 24 #include "cpuset-internal.h" 26 25 27 26 #include <linux/init.h> ··· 4242 4243 4243 4244 rcu_read_unlock(); 4244 4245 } 4245 - 4246 - #ifdef CONFIG_PROC_PID_CPUSET 4247 - /* 4248 - * proc_cpuset_show() 4249 - * - Print tasks cpuset path into seq_file. 4250 - * - Used for /proc/<pid>/cpuset. 4251 - * - No need to task_lock(tsk) on this tsk->cpuset reference, as it 4252 - * doesn't really matter if tsk->cpuset changes after we read it, 4253 - * and we take cpuset_mutex, keeping cpuset_attach() from changing it 4254 - * anyway. 4255 - */ 4256 - int proc_cpuset_show(struct seq_file *m, struct pid_namespace *ns, 4257 - struct pid *pid, struct task_struct *tsk) 4258 - { 4259 - char *buf; 4260 - struct cgroup_subsys_state *css; 4261 - int retval; 4262 - 4263 - retval = -ENOMEM; 4264 - buf = kmalloc(PATH_MAX, GFP_KERNEL); 4265 - if (!buf) 4266 - goto out; 4267 - 4268 - rcu_read_lock(); 4269 - spin_lock_irq(&css_set_lock); 4270 - css = task_css(tsk, cpuset_cgrp_id); 4271 - retval = cgroup_path_ns_locked(css->cgroup, buf, PATH_MAX, 4272 - current->nsproxy->cgroup_ns); 4273 - spin_unlock_irq(&css_set_lock); 4274 - rcu_read_unlock(); 4275 - 4276 - if (retval == -E2BIG) 4277 - retval = -ENAMETOOLONG; 4278 - if (retval < 0) 4279 - goto out_free; 4280 - seq_puts(m, buf); 4281 - seq_putc(m, '\n'); 4282 - retval = 0; 4283 - out_free: 4284 - kfree(buf); 4285 - out: 4286 - return retval; 4287 - } 4288 - #endif /* CONFIG_PROC_PID_CPUSET */ 4289 4246 4290 4247 /* Display task mems_allowed in /proc/<pid>/status file. */ 4291 4248 void cpuset_task_status_allowed(struct seq_file *m, struct task_struct *task)
+4 -2
kernel/cgroup/legacy_freezer.c
··· 430 430 431 431 if (strcmp(buf, freezer_state_strs(0)) == 0) 432 432 freeze = false; 433 - else if (strcmp(buf, freezer_state_strs(CGROUP_FROZEN)) == 0) 433 + else if (strcmp(buf, freezer_state_strs(CGROUP_FROZEN)) == 0) { 434 + pr_info_once("Freezing with imperfect legacy cgroup freezer. " 435 + "See cgroup.freeze of cgroup v2\n"); 434 436 freeze = true; 435 - else 437 + } else 436 438 return -EINVAL; 437 439 438 440 freezer_change_state(css_freezer(of_css(of)), freeze);
-16
kernel/cgroup/misc.c
··· 68 68 } 69 69 70 70 /** 71 - * misc_cg_res_total_usage() - Get the current total usage of the resource. 72 - * @type: misc res type. 73 - * 74 - * Context: Any context. 75 - * Return: Current total usage of the resource. 76 - */ 77 - u64 misc_cg_res_total_usage(enum misc_res_type type) 78 - { 79 - if (valid_type(type)) 80 - return atomic64_read(&root_cg.res[type].usage); 81 - 82 - return 0; 83 - } 84 - EXPORT_SYMBOL_GPL(misc_cg_res_total_usage); 85 - 86 - /** 87 71 * misc_cg_set_capacity() - Set the capacity of the misc cgroup res. 88 72 * @type: Type of the misc res. 89 73 * @capacity: Supported capacity of the misc res on the host.
+36 -80
kernel/cgroup/rstat.c
··· 299 299 spin_unlock_irq(&cgroup_rstat_lock); 300 300 } 301 301 302 - /* see cgroup_rstat_flush() */ 303 - static void cgroup_rstat_flush_locked(struct cgroup *cgrp) 304 - __releases(&cgroup_rstat_lock) __acquires(&cgroup_rstat_lock) 305 - { 306 - int cpu; 307 - 308 - lockdep_assert_held(&cgroup_rstat_lock); 309 - 310 - for_each_possible_cpu(cpu) { 311 - struct cgroup *pos = cgroup_rstat_updated_list(cgrp, cpu); 312 - 313 - for (; pos; pos = pos->rstat_flush_next) { 314 - struct cgroup_subsys_state *css; 315 - 316 - cgroup_base_stat_flush(pos, cpu); 317 - bpf_rstat_flush(pos, cgroup_parent(pos), cpu); 318 - 319 - rcu_read_lock(); 320 - list_for_each_entry_rcu(css, &pos->rstat_css_list, 321 - rstat_css_node) 322 - css->ss->css_rstat_flush(css, cpu); 323 - rcu_read_unlock(); 324 - } 325 - 326 - /* play nice and yield if necessary */ 327 - if (need_resched() || spin_needbreak(&cgroup_rstat_lock)) { 328 - __cgroup_rstat_unlock(cgrp, cpu); 329 - if (!cond_resched()) 330 - cpu_relax(); 331 - __cgroup_rstat_lock(cgrp, cpu); 332 - } 333 - } 334 - } 335 - 336 302 /** 337 303 * cgroup_rstat_flush - flush stats in @cgrp's subtree 338 304 * @cgrp: target cgroup ··· 314 348 */ 315 349 __bpf_kfunc void cgroup_rstat_flush(struct cgroup *cgrp) 316 350 { 351 + int cpu; 352 + 317 353 might_sleep(); 354 + for_each_possible_cpu(cpu) { 355 + struct cgroup *pos = cgroup_rstat_updated_list(cgrp, cpu); 318 356 319 - __cgroup_rstat_lock(cgrp, -1); 320 - cgroup_rstat_flush_locked(cgrp); 321 - __cgroup_rstat_unlock(cgrp, -1); 322 - } 357 + /* Reacquire for each CPU to avoid disabling IRQs too long */ 358 + __cgroup_rstat_lock(cgrp, cpu); 359 + for (; pos; pos = pos->rstat_flush_next) { 360 + struct cgroup_subsys_state *css; 323 361 324 - /** 325 - * cgroup_rstat_flush_hold - flush stats in @cgrp's subtree and hold 326 - * @cgrp: target cgroup 327 - * 328 - * Flush stats in @cgrp's subtree and prevent further flushes. Must be 329 - * paired with cgroup_rstat_flush_release(). 330 - * 331 - * This function may block. 332 - */ 333 - void cgroup_rstat_flush_hold(struct cgroup *cgrp) 334 - __acquires(&cgroup_rstat_lock) 335 - { 336 - might_sleep(); 337 - __cgroup_rstat_lock(cgrp, -1); 338 - cgroup_rstat_flush_locked(cgrp); 339 - } 362 + cgroup_base_stat_flush(pos, cpu); 363 + bpf_rstat_flush(pos, cgroup_parent(pos), cpu); 340 364 341 - /** 342 - * cgroup_rstat_flush_release - release cgroup_rstat_flush_hold() 343 - * @cgrp: cgroup used by tracepoint 344 - */ 345 - void cgroup_rstat_flush_release(struct cgroup *cgrp) 346 - __releases(&cgroup_rstat_lock) 347 - { 348 - __cgroup_rstat_unlock(cgrp, -1); 365 + rcu_read_lock(); 366 + list_for_each_entry_rcu(css, &pos->rstat_css_list, 367 + rstat_css_node) 368 + css->ss->css_rstat_flush(css, cpu); 369 + rcu_read_unlock(); 370 + } 371 + __cgroup_rstat_unlock(cgrp, cpu); 372 + if (!cond_resched()) 373 + cpu_relax(); 374 + } 349 375 } 350 376 351 377 int cgroup_rstat_init(struct cgroup *cgrp) ··· 570 612 void cgroup_base_stat_cputime_show(struct seq_file *seq) 571 613 { 572 614 struct cgroup *cgrp = seq_css(seq)->cgroup; 573 - u64 usage, utime, stime, ntime; 615 + struct cgroup_base_stat bstat; 574 616 575 617 if (cgroup_parent(cgrp)) { 576 - cgroup_rstat_flush_hold(cgrp); 577 - usage = cgrp->bstat.cputime.sum_exec_runtime; 618 + cgroup_rstat_flush(cgrp); 619 + __cgroup_rstat_lock(cgrp, -1); 620 + bstat = cgrp->bstat; 578 621 cputime_adjust(&cgrp->bstat.cputime, &cgrp->prev_cputime, 579 - &utime, &stime); 580 - ntime = cgrp->bstat.ntime; 581 - cgroup_rstat_flush_release(cgrp); 622 + &bstat.cputime.utime, &bstat.cputime.stime); 623 + __cgroup_rstat_unlock(cgrp, -1); 582 624 } else { 583 - /* cgrp->bstat of root is not actually used, reuse it */ 584 - root_cgroup_cputime(&cgrp->bstat); 585 - usage = cgrp->bstat.cputime.sum_exec_runtime; 586 - utime = cgrp->bstat.cputime.utime; 587 - stime = cgrp->bstat.cputime.stime; 588 - ntime = cgrp->bstat.ntime; 625 + root_cgroup_cputime(&bstat); 589 626 } 590 627 591 - do_div(usage, NSEC_PER_USEC); 592 - do_div(utime, NSEC_PER_USEC); 593 - do_div(stime, NSEC_PER_USEC); 594 - do_div(ntime, NSEC_PER_USEC); 628 + do_div(bstat.cputime.sum_exec_runtime, NSEC_PER_USEC); 629 + do_div(bstat.cputime.utime, NSEC_PER_USEC); 630 + do_div(bstat.cputime.stime, NSEC_PER_USEC); 631 + do_div(bstat.ntime, NSEC_PER_USEC); 595 632 596 633 seq_printf(seq, "usage_usec %llu\n" 597 634 "user_usec %llu\n" 598 635 "system_usec %llu\n" 599 636 "nice_usec %llu\n", 600 - usage, utime, stime, ntime); 637 + bstat.cputime.sum_exec_runtime, 638 + bstat.cputime.utime, 639 + bstat.cputime.stime, 640 + bstat.ntime); 601 641 602 - cgroup_force_idle_show(seq, &cgrp->bstat); 642 + cgroup_force_idle_show(seq, &bstat); 603 643 } 604 644 605 645 /* Add bpf kfuncs for cgroup_rstat_updated() and cgroup_rstat_flush() */
+4 -2
mm/memcontrol-v1.c
··· 1855 1855 if (val > MAX_SWAPPINESS) 1856 1856 return -EINVAL; 1857 1857 1858 - if (!mem_cgroup_is_root(memcg)) 1858 + if (!mem_cgroup_is_root(memcg)) { 1859 + pr_info_once("Per memcg swappiness does not exist in cgroup v2. " 1860 + "See memory.reclaim or memory.swap.max there\n "); 1859 1861 WRITE_ONCE(memcg->swappiness, val); 1860 - else 1862 + } else 1861 1863 WRITE_ONCE(vm_swappiness, val); 1862 1864 1863 1865 return 0;