History

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

Linus Torvalds committed 1 year ago

Commit 94dc2162 parents b05f8fb 093c88118 files · +142 −188Browse files

Unified · Split

18 files
  1. Documentation/admin-guide/cgroup-v1/freezer-subsystem.rst +4 −0
  2. Documentation/admin-guide/cgroup-v1/memory.rst +1 −0
  3. Documentation/admin-guide/cgroup-v2.rst +14 −9
  4. block/blk-cgroup.c +6 −2
  5. block/blk-ioprio.c +7 −16
  6. include/linux/cgroup-defs.h +2 −3
  7. include/linux/cgroup.h +1 −2
  8. include/linux/misc_cgroup.h +0 −6
  9. init/Kconfig +3 −2
  10. kernel/cgroup/cgroup-internal.h +1 −0
  11. kernel/cgroup/cgroup-v1.c +7 −0
  12. kernel/cgroup/cgroup.c +3 −3
  13. kernel/cgroup/cpuset-v1.c +49 −0
  14. kernel/cgroup/cpuset.c +0 −45
  15. kernel/cgroup/legacy_freezer.c +4 −2
  16. kernel/cgroup/misc.c +0 −16
  17. kernel/cgroup/rstat.c +36 −80
  18. mm/memcontrol-v1.c +4 −2
Documentation/admin-guide/cgroup-v1/freezer-subsystem.rst+4−0
@@ -125,3 +125,7 @@ to unfreeze all tasks in the container:: · 124 unmodified lines
125125
126126 This is the basic mechanism which should do the right thing for user space task
127127 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.
Documentation/admin-guide/cgroup-v1/memory.rst+1−0
@@ -90,6 +90,7 @@ Brief summary of control files. · 89 unmodified lines
9090 used.
9191 memory.swappiness set/show swappiness parameter of vmscan
9292 (See sysctl's vm.swappiness)
93+ Per memcg knob does not exist in cgroup v2.
9394 memory.move_charge_at_immigrate This knob is deprecated.
9495 memory.oom_control set/show oom controls.
9596 This knob is deprecated and shouldn't be
Documentation/admin-guide/cgroup-v2.rst+14−9
@@ -1076,15 +1076,20 @@ cpufreq governor about the minimum desired frequency which should always be · 1075 unmodified lines
10761076 provided by a CPU, as well as the maximum desired frequency, which should not
10771077 be exceeded by a CPU.
10781078
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.
10881093
10891094
10901095 CPU Interface Files
block/blk-cgroup.c+6−2
@@ -659,6 +659,7 @@ static int blkcg_reset_stats(struct cgroup_subsys_state *css, · 658 unmodified lines
659659 struct blkcg_gq *blkg;
660660 int i;
661661
662+ pr_info_once("blkio.%s is deprecated\n", cftype->name);
662663 mutex_lock(&blkcg_pol_mutex);
663664 spin_lock_irq(&blkcg->lock);
664665
@@ -1770,12 +1771,15 @@ int blkcg_policy_register(struct blkcg_policy *pol) · 1105 unmodified lines
17701771 mutex_unlock(&blkcg_pol_mutex);
17711772
17721773 /* everything is in place, add intf files for the new policy */
1773− if (pol->dfl_cftypes)
1774+ if (pol->dfl_cftypes == pol->legacy_cftypes) {
1775+ WARN_ON(cgroup_add_cftypes(&io_cgrp_subsys,
1776+ pol->dfl_cftypes));
1777+ } else {
17741778 WARN_ON(cgroup_add_dfl_cftypes(&io_cgrp_subsys,
17751779 pol->dfl_cftypes));
1776− if (pol->legacy_cftypes)
17771780 WARN_ON(cgroup_add_legacy_cftypes(&io_cgrp_subsys,
17781781 pol->legacy_cftypes));
1782+ }
17791783 mutex_unlock(&blkcg_pol_register_mutex);
17801784 return 0;
17811785
block/blk-ioprio.c+7−16
@@ -113,27 +113,18 @@ static void ioprio_free_cpd(struct blkcg_policy_data *cpd) · 112 unmodified lines
113113 kfree(blkcg);
114114 }
115115
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 */
125116 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 */
132123 };
133124
134125 static struct blkcg_policy ioprio_policy = {
135126 .dfl_cftypes = ioprio_files,
136− .legacy_cftypes = ioprio_legacy_files,
127+ .legacy_cftypes = ioprio_files,
137128
138129 .cpd_alloc_fn = ioprio_alloc_cpd,
139130 .cpd_free_fn = ioprio_free_cpd,
include/linux/cgroup-defs.h+2−3
@@ -619,9 +619,8 @@ struct cgroup_root { · 618 unmodified lines
619619 */
620620 struct cftype {
621621 /*
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.
625624 */
626625 char name[MAX_CFTYPE_NAME];
627626 unsigned long private;
include/linux/cgroup.h+1−2
@@ -113,6 +113,7 @@ int cgroup_transfer_tasks(struct cgroup *to, struct cgroup *from); · 112 unmodified lines
113113
114114 int cgroup_add_dfl_cftypes(struct cgroup_subsys *ss, struct cftype *cfts);
115115 int cgroup_add_legacy_cftypes(struct cgroup_subsys *ss, struct cftype *cfts);
116+int cgroup_add_cftypes(struct cgroup_subsys *ss, struct cftype *cfts);
116117 int cgroup_rm_cftypes(struct cftype *cfts);
117118 void cgroup_file_notify(struct cgroup_file *cfile);
118119 void cgroup_file_show(struct cgroup_file *cfile, bool show);
@@ -689,8 +690,6 @@ static inline void cgroup_path_from_kernfs_id(u64 id, char *buf, size_t buflen) · 570 unmodified lines
689690 */
690691 void cgroup_rstat_updated(struct cgroup *cgrp, int cpu);
691692 void cgroup_rstat_flush(struct cgroup *cgrp);
692−void cgroup_rstat_flush_hold(struct cgroup *cgrp);
693−void cgroup_rstat_flush_release(struct cgroup *cgrp);
694693
695694 /*
696695 * Basic resource stats.
include/linux/misc_cgroup.h+0−6
@@ -60,7 +60,6 @@ struct misc_cg { · 59 unmodified lines
6060 struct misc_res res[MISC_CG_RES_TYPES];
6161 };
6262
63−u64 misc_cg_res_total_usage(enum misc_res_type type);
6463 int misc_cg_set_capacity(enum misc_res_type type, u64 capacity);
6564 int misc_cg_try_charge(enum misc_res_type type, struct misc_cg *cg, u64 amount);
6665 void misc_cg_uncharge(enum misc_res_type type, struct misc_cg *cg, u64 amount);
@@ -104,11 +103,6 @@ static inline void put_misc_cg(struct misc_cg *cg) · 37 unmodified lines
104103
105104 #else /* !CONFIG_CGROUP_MISC */
106105
107−static inline u64 misc_cg_res_total_usage(enum misc_res_type type)
108−{
109− return 0;
110−}
111−
112106 static inline int misc_cg_set_capacity(enum misc_res_type type, u64 capacity)
113107 {
114108 return 0;
init/Kconfig+3−2
@@ -1198,7 +1198,8 @@ config CPUSETS_V1 · 1197 unmodified lines
11981198 help
11991199 Legacy cgroup v1 cpusets controller which has been deprecated by
12001200 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
12021203 do not have any such application then you are completely fine leaving
12031204 this option disabled.
12041205
@@ -1206,7 +1207,7 @@ config CPUSETS_V1 · 1 unmodified line
12061207
12071208 config PROC_PID_CPUSET
12081209 bool "Include legacy /proc/<pid>/cpuset file"
1209− depends on CPUSETS
1210+ depends on CPUSETS_V1
12101211 default y
12111212
12121213 config CGROUP_DEVICE
kernel/cgroup/cgroup-internal.h+1−0
@@ -168,6 +168,7 @@ struct cgroup_mgctx { · 167 unmodified lines
168168
169169 extern struct cgroup_subsys *cgroup_subsys[];
170170 extern struct list_head cgroup_roots;
171+extern bool cgrp_dfl_visible;
171172
172173 /* iterate across the hierarchies */
173174 #define for_each_root(root) \
kernel/cgroup/cgroup-v1.c+7−0
@@ -673,6 +673,7 @@ struct cftype cgroup1_base_files[] = { · 672 unmodified lines
673673 int proc_cgroupstats_show(struct seq_file *m, void *v)
674674 {
675675 struct cgroup_subsys *ss;
676+ bool cgrp_v1_visible = false;
676677 int i;
677678
678679 seq_puts(m, "#subsys_name\thierarchy\tnum_cgroups\tenabled\n");
@@ -684,12 +685,18 @@ int proc_cgroupstats_show(struct seq_file *m, void *v) · 5 unmodified lines
684685 for_each_subsys(ss, i) {
685686 if (cgroup1_subsys_absent(ss))
686687 continue;
688+ cgrp_v1_visible |= ss->root != &cgrp_dfl_root;
689+
687690 seq_printf(m, "%s\t%d\t%d\t%d\n",
688691 ss->legacy_name, ss->root->hierarchy_id,
689692 atomic_read(&ss->root->nr_cgrps),
690693 cgroup_ssid_enabled(i));
691694 }
692695
696+ if (cgrp_dfl_visible && !cgrp_v1_visible)
697+ pr_info_once("/proc/cgroups lists only v1 controllers, use cgroup.controllers of root cgroup for v2 info\n");
698+
699+
693700 return 0;
694701 }
695702
kernel/cgroup/cgroup.c+3−3
@@ -171,7 +171,7 @@ EXPORT_SYMBOL_GPL(cgrp_dfl_root); · 170 unmodified lines
171171 * The default hierarchy always exists but is hidden until mounted for the
172172 * first time. This is for backward compatibility.
173173 */
174−static bool cgrp_dfl_visible;
174+bool cgrp_dfl_visible;
175175
176176 /* some controllers are not supported in the default hierarchy */
177177 static u16 cgrp_dfl_inhibit_ss_mask;
@@ -4447,7 +4447,7 @@ int cgroup_rm_cftypes(struct cftype *cfts) · 4269 unmodified lines
44474447 * function currently returns 0 as long as @cfts registration is successful
44484448 * even if some file creation attempts on existing cgroups fail.
44494449 */
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)
44514451 {
44524452 int ret;
44534453
@@ -5831,7 +5831,7 @@ int cgroup_mkdir(struct kernfs_node *parent_kn, const char *name, umode_t mode) · 1377 unmodified lines
58315831 }
58325832
58335833 /*
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
58355835 * that @cgrp->kn is always accessible.
58365836 */
58375837 kernfs_get(cgrp->kn);
kernel/cgroup/cpuset-v1.c+49−0
@@ -1,5 +1,6 @@
11 // SPDX-License-Identifier: GPL-2.0-or-later
22
3+#include "cgroup-internal.h"
34 #include "cpuset-internal.h"
45
56 /*
@@ -175,6 +176,7 @@ static int cpuset_write_s64(struct cgroup_subsys_state *css, struct cftype *cft, · 169 unmodified lines
175176
176177 switch (type) {
177178 case FILE_SCHED_RELAX_DOMAIN_LEVEL:
179+ pr_info_once("cpuset.%s is deprecated\n", cft->name);
178180 retval = update_relax_domain_level(cs, val);
179181 break;
180182 default:
@@ -373,6 +375,46 @@ out: · 192 unmodified lines
373375 return ret;
374376 }
375377
378+#ifdef CONFIG_PROC_PID_CPUSET
379+/*
380+ * proc_cpuset_show()
381+ * - Print tasks cpuset path into seq_file.
382+ * - Used for /proc/<pid>/cpuset.
383+ */
384+int proc_cpuset_show(struct seq_file *m, struct pid_namespace *ns,
385+ struct pid *pid, struct task_struct *tsk)
386+{
387+ char *buf;
388+ struct cgroup_subsys_state *css;
389+ int retval;
390+
391+ retval = -ENOMEM;
392+ buf = kmalloc(PATH_MAX, GFP_KERNEL);
393+ if (!buf)
394+ goto out;
395+
396+ rcu_read_lock();
397+ spin_lock_irq(&css_set_lock);
398+ css = task_css(tsk, cpuset_cgrp_id);
399+ retval = cgroup_path_ns_locked(css->cgroup, buf, PATH_MAX,
400+ current->nsproxy->cgroup_ns);
401+ spin_unlock_irq(&css_set_lock);
402+ rcu_read_unlock();
403+
404+ if (retval == -E2BIG)
405+ retval = -ENAMETOOLONG;
406+ if (retval < 0)
407+ goto out_free;
408+ seq_puts(m, buf);
409+ seq_putc(m, '\n');
410+ retval = 0;
411+out_free:
412+ kfree(buf);
413+out:
414+ return retval;
415+}
416+#endif /* CONFIG_PROC_PID_CPUSET */
417+
376418 static u64 cpuset_read_u64(struct cgroup_subsys_state *css, struct cftype *cft)
377419 {
378420 struct cpuset *cs = css_cs(css);
@@ -424,24 +466,31 @@ static int cpuset_write_u64(struct cgroup_subsys_state *css, struct cftype *cft, · 45 unmodified lines
424466 retval = cpuset_update_flag(CS_CPU_EXCLUSIVE, cs, val);
425467 break;
426468 case FILE_MEM_EXCLUSIVE:
469+ pr_info_once("cpuset.%s is deprecated\n", cft->name);
427470 retval = cpuset_update_flag(CS_MEM_EXCLUSIVE, cs, val);
428471 break;
429472 case FILE_MEM_HARDWALL:
473+ pr_info_once("cpuset.%s is deprecated\n", cft->name);
430474 retval = cpuset_update_flag(CS_MEM_HARDWALL, cs, val);
431475 break;
432476 case FILE_SCHED_LOAD_BALANCE:
477+ pr_info_once("cpuset.%s is deprecated, use cpuset.cpus.partition instead\n", cft->name);
433478 retval = cpuset_update_flag(CS_SCHED_LOAD_BALANCE, cs, val);
434479 break;
435480 case FILE_MEMORY_MIGRATE:
481+ pr_info_once("cpuset.%s is deprecated\n", cft->name);
436482 retval = cpuset_update_flag(CS_MEMORY_MIGRATE, cs, val);
437483 break;
438484 case FILE_MEMORY_PRESSURE_ENABLED:
485+ pr_info_once("cpuset.%s is deprecated, use memory.pressure with CONFIG_PSI instead\n", cft->name);
439486 cpuset_memory_pressure_enabled = !!val;
440487 break;
441488 case FILE_SPREAD_PAGE:
489+ pr_info_once("cpuset.%s is deprecated\n", cft->name);
442490 retval = cpuset_update_flag(CS_SPREAD_PAGE, cs, val);
443491 break;
444492 case FILE_SPREAD_SLAB:
493+ pr_warn_once("cpuset.%s is deprecated\n", cft->name);
445494 retval = cpuset_update_flag(CS_SPREAD_SLAB, cs, val);
446495 break;
447496 default:
kernel/cgroup/cpuset.c+0−45
@@ -21,7 +21,6 @@ · 20 unmodified lines
2121 * License. See the file COPYING in the main directory of the Linux
2222 * distribution for more details.
2323 */
24−#include "cgroup-internal.h"
2524 #include "cpuset-internal.h"
2625
2726 #include <linux/init.h>
@@ -4244,50 +4243,6 @@ void cpuset_print_current_mems_allowed(void) · 4216 unmodified lines
42444243 rcu_read_unlock();
42454244 }
42464245
4247−#ifdef CONFIG_PROC_PID_CPUSET
4248−/*
4249− * proc_cpuset_show()
4250− * - Print tasks cpuset path into seq_file.
4251− * - Used for /proc/<pid>/cpuset.
4252− * - No need to task_lock(tsk) on this tsk->cpuset reference, as it
4253− * doesn't really matter if tsk->cpuset changes after we read it,
4254− * and we take cpuset_mutex, keeping cpuset_attach() from changing it
4255− * anyway.
4256− */
4257−int proc_cpuset_show(struct seq_file *m, struct pid_namespace *ns,
4258− struct pid *pid, struct task_struct *tsk)
4259−{
4260− char *buf;
4261− struct cgroup_subsys_state *css;
4262− int retval;
4263−
4264− retval = -ENOMEM;
4265− buf = kmalloc(PATH_MAX, GFP_KERNEL);
4266− if (!buf)
4267− goto out;
4268−
4269− rcu_read_lock();
4270− spin_lock_irq(&css_set_lock);
4271− css = task_css(tsk, cpuset_cgrp_id);
4272− retval = cgroup_path_ns_locked(css->cgroup, buf, PATH_MAX,
4273− current->nsproxy->cgroup_ns);
4274− spin_unlock_irq(&css_set_lock);
4275− rcu_read_unlock();
4276−
4277− if (retval == -E2BIG)
4278− retval = -ENAMETOOLONG;
4279− if (retval < 0)
4280− goto out_free;
4281− seq_puts(m, buf);
4282− seq_putc(m, '\n');
4283− retval = 0;
4284−out_free:
4285− kfree(buf);
4286−out:
4287− return retval;
4288−}
4289−#endif /* CONFIG_PROC_PID_CPUSET */
4290−
42914246 /* Display task mems_allowed in /proc/<pid>/status file. */
42924247 void cpuset_task_status_allowed(struct seq_file *m, struct task_struct *task)
42934248 {
kernel/cgroup/legacy_freezer.c+4−2
@@ -430,9 +430,11 @@ static ssize_t freezer_write(struct kernfs_open_file *of, · 429 unmodified lines
430430
431431 if (strcmp(buf, freezer_state_strs(0)) == 0)
432432 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");
434436 freeze = true;
435− else
437+ } else
436438 return -EINVAL;
437439
438440 freezer_change_state(css_freezer(of_css(of)), freeze);
kernel/cgroup/misc.c+0−16
@@ -67,22 +67,6 @@ static inline bool valid_type(enum misc_res_type type) · 66 unmodified lines
6767 return type >= 0 && type < MISC_CG_RES_TYPES;
6868 }
6969
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−
8670 /**
8771 * misc_cg_set_capacity() - Set the capacity of the misc cgroup res.
8872 * @type: Type of the misc res.
kernel/cgroup/rstat.c+36−80
@@ -299,40 +299,6 @@ static inline void __cgroup_rstat_unlock(struct cgroup *cgrp, int cpu_in_loop) · 298 unmodified lines
299299 spin_unlock_irq(&cgroup_rstat_lock);
300300 }
301301
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−
336302 /**
337303 * cgroup_rstat_flush - flush stats in @cgrp's subtree
338304 * @cgrp: target cgroup
@@ -348,38 +314,30 @@ static void cgroup_rstat_flush_locked(struct cgroup *cgrp) · 9 unmodified lines
348314 */
349315 __bpf_kfunc void cgroup_rstat_flush(struct cgroup *cgrp)
350316 {
317+ int cpu;
318+
351319 might_sleep();
320+ for_each_possible_cpu(cpu) {
321+ struct cgroup *pos = cgroup_rstat_updated_list(cgrp, cpu);
352322
353− __cgroup_rstat_lock(cgrp, -1);
354− cgroup_rstat_flush_locked(cgrp);
355− __cgroup_rstat_unlock(cgrp, -1);
356−}
323+ /* Reacquire for each CPU to avoid disabling IRQs too long */
324+ __cgroup_rstat_lock(cgrp, cpu);
325+ for (; pos; pos = pos->rstat_flush_next) {
326+ struct cgroup_subsys_state *css;
357327
358−/**
359− * cgroup_rstat_flush_hold - flush stats in @cgrp's subtree and hold
360− * @cgrp: target cgroup
361− *
362− * Flush stats in @cgrp's subtree and prevent further flushes. Must be
363− * paired with cgroup_rstat_flush_release().
364− *
365− * This function may block.
366− */
367−void cgroup_rstat_flush_hold(struct cgroup *cgrp)
368− __acquires(&cgroup_rstat_lock)
369−{
370− might_sleep();
371− __cgroup_rstat_lock(cgrp, -1);
372− cgroup_rstat_flush_locked(cgrp);
373−}
328+ cgroup_base_stat_flush(pos, cpu);
329+ bpf_rstat_flush(pos, cgroup_parent(pos), cpu);
374330
375−/**
376− * cgroup_rstat_flush_release - release cgroup_rstat_flush_hold()
377− * @cgrp: cgroup used by tracepoint
378− */
379−void cgroup_rstat_flush_release(struct cgroup *cgrp)
380− __releases(&cgroup_rstat_lock)
381−{
382− __cgroup_rstat_unlock(cgrp, -1);
331+ rcu_read_lock();
332+ list_for_each_entry_rcu(css, &pos->rstat_css_list,
333+ rstat_css_node)
334+ css->ss->css_rstat_flush(css, cpu);
335+ rcu_read_unlock();
336+ }
337+ __cgroup_rstat_unlock(cgrp, cpu);
338+ if (!cond_resched())
339+ cpu_relax();
340+ }
383341 }
384342
385343 int cgroup_rstat_init(struct cgroup *cgrp)
@@ -612,36 +570,34 @@ static void cgroup_force_idle_show(struct seq_file *seq, struct cgroup_base_stat · 226 unmodified lines
612570 void cgroup_base_stat_cputime_show(struct seq_file *seq)
613571 {
614572 struct cgroup *cgrp = seq_css(seq)->cgroup;
615− u64 usage, utime, stime, ntime;
573+ struct cgroup_base_stat bstat;
616574
617575 if (cgroup_parent(cgrp)) {
618− cgroup_rstat_flush_hold(cgrp);
619− usage = cgrp->bstat.cputime.sum_exec_runtime;
576+ cgroup_rstat_flush(cgrp);
577+ __cgroup_rstat_lock(cgrp, -1);
578+ bstat = cgrp->bstat;
620579 cputime_adjust(&cgrp->bstat.cputime, &cgrp->prev_cputime,
621− &utime, &stime);
622− ntime = cgrp->bstat.ntime;
623− cgroup_rstat_flush_release(cgrp);
580+ &bstat.cputime.utime, &bstat.cputime.stime);
581+ __cgroup_rstat_unlock(cgrp, -1);
624582 } else {
625− /* cgrp->bstat of root is not actually used, reuse it */
626− root_cgroup_cputime(&cgrp->bstat);
627− usage = cgrp->bstat.cputime.sum_exec_runtime;
628− utime = cgrp->bstat.cputime.utime;
629− stime = cgrp->bstat.cputime.stime;
630− ntime = cgrp->bstat.ntime;
583+ root_cgroup_cputime(&bstat);
631584 }
632585
633− do_div(usage, NSEC_PER_USEC);
634− do_div(utime, NSEC_PER_USEC);
635− do_div(stime, NSEC_PER_USEC);
636− do_div(ntime, NSEC_PER_USEC);
586+ do_div(bstat.cputime.sum_exec_runtime, NSEC_PER_USEC);
587+ do_div(bstat.cputime.utime, NSEC_PER_USEC);
588+ do_div(bstat.cputime.stime, NSEC_PER_USEC);
589+ do_div(bstat.ntime, NSEC_PER_USEC);
637590
638591 seq_printf(seq, "usage_usec %llu\n"
639592 "user_usec %llu\n"
640593 "system_usec %llu\n"
641594 "nice_usec %llu\n",
642− usage, utime, stime, ntime);
595+ bstat.cputime.sum_exec_runtime,
596+ bstat.cputime.utime,
597+ bstat.cputime.stime,
598+ bstat.ntime);
643599
644− cgroup_force_idle_show(seq, &cgrp->bstat);
600+ cgroup_force_idle_show(seq, &bstat);
645601 }
646602
647603 /* Add bpf kfuncs for cgroup_rstat_updated() and cgroup_rstat_flush() */
mm/memcontrol-v1.c+4−2
@@ -1855,9 +1855,11 @@ static int mem_cgroup_swappiness_write(struct cgroup_subsys_state *css, · 1854 unmodified lines
18551855 if (val > MAX_SWAPPINESS)
18561856 return -EINVAL;
18571857
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 ");
18591861 WRITE_ONCE(memcg->swappiness, val);
1860− else
1862+ } else
18611863 WRITE_ONCE(vm_swappiness, val);
18621864
18631865 return 0;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t