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
125 125
126This is the basic mechanism which should do the right thing for user space task126This is the basic mechanism which should do the right thing for user space task
127in a simple scenario.127in a simple scenario.
128
129This freezer implementation is affected by shortcomings (see commit
13076f969e8948d8 ("cgroup: cgroup v2 freezer")) and cgroup v2 freezer is
131recommended.
Documentation/admin-guide/cgroup-v1/memory.rst+1−0
@@ -90,6 +90,7 @@ Brief summary of control files. · 89 unmodified lines
90 used.90 used.
91 memory.swappiness set/show swappiness parameter of vmscan91 memory.swappiness set/show swappiness parameter of vmscan
92 (See sysctl's vm.swappiness)92 (See sysctl's vm.swappiness)
93 Per memcg knob does not exist in cgroup v2.
93 memory.move_charge_at_immigrate This knob is deprecated.94 memory.move_charge_at_immigrate This knob is deprecated.
94 memory.oom_control set/show oom controls.95 memory.oom_control set/show oom controls.
95 This knob is deprecated and shouldn't be96 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
1076provided by a CPU, as well as the maximum desired frequency, which should not1076provided by a CPU, as well as the maximum desired frequency, which should not
1077be exceeded by a CPU.1077be exceeded by a CPU.
1078 1078
1079WARNING: cgroup2 doesn't yet support control of realtime processes. For1079WARNING: cgroup2 cpu controller doesn't yet fully support the control of
1080a kernel built with the CONFIG_RT_GROUP_SCHED option enabled for group1080realtime processes. For a kernel built with the CONFIG_RT_GROUP_SCHED option
1081scheduling of realtime processes, the cpu controller can only be enabled1081enabled for group scheduling of realtime processes, the cpu controller can only
1082when all RT processes are in the root cgroup. This limitation does1082be enabled when all RT processes are in the root cgroup. Be aware that system
1083not apply if CONFIG_RT_GROUP_SCHED is disabled. Be aware that system1083management software may already have placed RT processes into non-root cgroups
1084management software may already have placed RT processes into nonroot1084during the system boot process, and these processes may need to be moved to the
1085cgroups during the system boot process, and these processes may need1085root cgroup before the cpu controller can be enabled with a
1086to be moved to the root cgroup before the cpu controller can be enabled1086CONFIG_RT_GROUP_SCHED enabled kernel.
1087with a CONFIG_RT_GROUP_SCHED enabled kernel.1087
1088With CONFIG_RT_GROUP_SCHED disabled, this limitation does not apply and some of
1089the interface files either affect realtime processes or account for them. See
1090the following section for details. Only the cpu controller is affected by
1091CONFIG_RT_GROUP_SCHED. Other controllers can be used for the resource control of
1092realtime processes irrespective of CONFIG_RT_GROUP_SCHED.
1088 1093
1089 1094
1090CPU Interface Files1095CPU 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
659 struct blkcg_gq *blkg;659 struct blkcg_gq *blkg;
660 int i;660 int i;
661 661
662 pr_info_once("blkio.%s is deprecated\n", cftype->name);
662 mutex_lock(&blkcg_pol_mutex);663 mutex_lock(&blkcg_pol_mutex);
663 spin_lock_irq(&blkcg->lock);664 spin_lock_irq(&blkcg->lock);
664 665
@@ -1770,12 +1771,15 @@ int blkcg_policy_register(struct blkcg_policy *pol) · 1105 unmodified lines
1770 mutex_unlock(&blkcg_pol_mutex);1771 mutex_unlock(&blkcg_pol_mutex);
1771 1772
1772 /* everything is in place, add intf files for the new policy */1773 /* 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 {
1774 WARN_ON(cgroup_add_dfl_cftypes(&io_cgrp_subsys,1778 WARN_ON(cgroup_add_dfl_cftypes(&io_cgrp_subsys,
1775 pol->dfl_cftypes));1779 pol->dfl_cftypes));
1776 if (pol->legacy_cftypes)
1777 WARN_ON(cgroup_add_legacy_cftypes(&io_cgrp_subsys,1780 WARN_ON(cgroup_add_legacy_cftypes(&io_cgrp_subsys,
1778 pol->legacy_cftypes));1781 pol->legacy_cftypes));
1782 }
1779 mutex_unlock(&blkcg_pol_register_mutex);1783 mutex_unlock(&blkcg_pol_register_mutex);
1780 return 0;1784 return 0;
1781 1785
block/blk-ioprio.c+7−16
@@ -113,27 +113,18 @@ static void ioprio_free_cpd(struct blkcg_policy_data *cpd) · 112 unmodified lines
113 kfree(blkcg);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 */
125static struct cftype ioprio_files[] = {116static struct cftype ioprio_files[] = {
126 IOPRIO_ATTRS117 {
127};118 .name = "prio.class",
128 119 .seq_show = ioprio_show_prio_policy,
129/* cgroup v1 attributes */120 .write = ioprio_set_prio_policy,
130static struct cftype ioprio_legacy_files[] = {121 },
131 IOPRIO_ATTRS122 { } /* sentinel */
132};123};
133 124
134static struct blkcg_policy ioprio_policy = {125static struct blkcg_policy ioprio_policy = {
135 .dfl_cftypes = ioprio_files,126 .dfl_cftypes = ioprio_files,
136 .legacy_cftypes = ioprio_legacy_files,127 .legacy_cftypes = ioprio_files,
137 128
138 .cpd_alloc_fn = ioprio_alloc_cpd,129 .cpd_alloc_fn = ioprio_alloc_cpd,
139 .cpd_free_fn = ioprio_free_cpd,130 .cpd_free_fn = ioprio_free_cpd,
include/linux/cgroup-defs.h+2−3
@@ -619,9 +619,8 @@ struct cgroup_root { · 618 unmodified lines
619 */619 */
620struct cftype {620struct cftype {
621 /*621 /*
622 * By convention, the name should begin with the name of the622 * Name of the subsystem is prepended in cgroup_file_name().
623 * subsystem, followed by a period. Zero length string indicates623 * Zero length string indicates end of cftype array.
624 * end of cftype array.
625 */624 */
626 char name[MAX_CFTYPE_NAME];625 char name[MAX_CFTYPE_NAME];
627 unsigned long private;626 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
113 113
114int cgroup_add_dfl_cftypes(struct cgroup_subsys *ss, struct cftype *cfts);114int cgroup_add_dfl_cftypes(struct cgroup_subsys *ss, struct cftype *cfts);
115int cgroup_add_legacy_cftypes(struct cgroup_subsys *ss, struct cftype *cfts);115int cgroup_add_legacy_cftypes(struct cgroup_subsys *ss, struct cftype *cfts);
116int cgroup_add_cftypes(struct cgroup_subsys *ss, struct cftype *cfts);
116int cgroup_rm_cftypes(struct cftype *cfts);117int cgroup_rm_cftypes(struct cftype *cfts);
117void cgroup_file_notify(struct cgroup_file *cfile);118void cgroup_file_notify(struct cgroup_file *cfile);
118void cgroup_file_show(struct cgroup_file *cfile, bool show);119void 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
689 */690 */
690void cgroup_rstat_updated(struct cgroup *cgrp, int cpu);691void cgroup_rstat_updated(struct cgroup *cgrp, int cpu);
691void cgroup_rstat_flush(struct cgroup *cgrp);692void cgroup_rstat_flush(struct cgroup *cgrp);
692void cgroup_rstat_flush_hold(struct cgroup *cgrp);
693void cgroup_rstat_flush_release(struct cgroup *cgrp);
694 693
695/*694/*
696 * Basic resource stats.695 * Basic resource stats.
include/linux/misc_cgroup.h+0−6
@@ -60,7 +60,6 @@ struct misc_cg { · 59 unmodified lines
60 struct misc_res res[MISC_CG_RES_TYPES];60 struct misc_res res[MISC_CG_RES_TYPES];
61};61};
62 62
63u64 misc_cg_res_total_usage(enum misc_res_type type);
64int misc_cg_set_capacity(enum misc_res_type type, u64 capacity);63int misc_cg_set_capacity(enum misc_res_type type, u64 capacity);
65int misc_cg_try_charge(enum misc_res_type type, struct misc_cg *cg, u64 amount);64int misc_cg_try_charge(enum misc_res_type type, struct misc_cg *cg, u64 amount);
66void misc_cg_uncharge(enum misc_res_type type, struct misc_cg *cg, u64 amount);65void 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
104 103
105#else /* !CONFIG_CGROUP_MISC */104#else /* !CONFIG_CGROUP_MISC */
106 105
107static inline u64 misc_cg_res_total_usage(enum misc_res_type type)
108{
109 return 0;
110}
111
112static inline int misc_cg_set_capacity(enum misc_res_type type, u64 capacity)106static inline int misc_cg_set_capacity(enum misc_res_type type, u64 capacity)
113{107{
114 return 0;108 return 0;
init/Kconfig+3−2
@@ -1198,7 +1198,8 @@ config CPUSETS_V1 · 1197 unmodified lines
1198 help1198 help
1199 Legacy cgroup v1 cpusets controller which has been deprecated by1199 Legacy cgroup v1 cpusets controller which has been deprecated by
1200 cgroup v2 implementation. The v1 is there for legacy applications1200 cgroup v2 implementation. The v1 is there for legacy applications
1201 which haven't migrated to the new cgroup v2 interface yet. If you1201 which haven't migrated to the new cgroup v2 interface yet. Legacy
1202 interface includes cpuset filesystem and /proc/<pid>/cpuset. If you
1202 do not have any such application then you are completely fine leaving1203 do not have any such application then you are completely fine leaving
1203 this option disabled.1204 this option disabled.
1204 1205
@@ -1206,7 +1207,7 @@ config CPUSETS_V1 · 1 unmodified line
1206 1207
1207config PROC_PID_CPUSET1208config PROC_PID_CPUSET
1208 bool "Include legacy /proc/<pid>/cpuset file"1209 bool "Include legacy /proc/<pid>/cpuset file"
1209 depends on CPUSETS1210 depends on CPUSETS_V1
1210 default y1211 default y
1211 1212
1212config CGROUP_DEVICE1213config CGROUP_DEVICE
kernel/cgroup/cgroup-internal.h+1−0
@@ -168,6 +168,7 @@ struct cgroup_mgctx { · 167 unmodified lines
168 168
169extern struct cgroup_subsys *cgroup_subsys[];169extern struct cgroup_subsys *cgroup_subsys[];
170extern struct list_head cgroup_roots;170extern struct list_head cgroup_roots;
171extern bool cgrp_dfl_visible;
171 172
172/* iterate across the hierarchies */173/* iterate across the hierarchies */
173#define for_each_root(root) \174#define for_each_root(root) \
kernel/cgroup/cgroup-v1.c+7−0
@@ -673,6 +673,7 @@ struct cftype cgroup1_base_files[] = { · 672 unmodified lines
673int proc_cgroupstats_show(struct seq_file *m, void *v)673int proc_cgroupstats_show(struct seq_file *m, void *v)
674{674{
675 struct cgroup_subsys *ss;675 struct cgroup_subsys *ss;
676 bool cgrp_v1_visible = false;
676 int i;677 int i;
677 678
678 seq_puts(m, "#subsys_name\thierarchy\tnum_cgroups\tenabled\n");679 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
684 for_each_subsys(ss, i) {685 for_each_subsys(ss, i) {
685 if (cgroup1_subsys_absent(ss))686 if (cgroup1_subsys_absent(ss))
686 continue;687 continue;
688 cgrp_v1_visible |= ss->root != &cgrp_dfl_root;
689
687 seq_printf(m, "%s\t%d\t%d\t%d\n",690 seq_printf(m, "%s\t%d\t%d\t%d\n",
688 ss->legacy_name, ss->root->hierarchy_id,691 ss->legacy_name, ss->root->hierarchy_id,
689 atomic_read(&ss->root->nr_cgrps),692 atomic_read(&ss->root->nr_cgrps),
690 cgroup_ssid_enabled(i));693 cgroup_ssid_enabled(i));
691 }694 }
692 695
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
693 return 0;700 return 0;
694}701}
695 702
kernel/cgroup/cgroup.c+3−3
@@ -171,7 +171,7 @@ EXPORT_SYMBOL_GPL(cgrp_dfl_root); · 170 unmodified lines
171 * The default hierarchy always exists but is hidden until mounted for the171 * The default hierarchy always exists but is hidden until mounted for the
172 * first time. This is for backward compatibility.172 * first time. This is for backward compatibility.
173 */173 */
174static bool cgrp_dfl_visible;174bool cgrp_dfl_visible;
175 175
176/* some controllers are not supported in the default hierarchy */176/* some controllers are not supported in the default hierarchy */
177static u16 cgrp_dfl_inhibit_ss_mask;177static u16 cgrp_dfl_inhibit_ss_mask;
@@ -4447,7 +4447,7 @@ int cgroup_rm_cftypes(struct cftype *cfts) · 4269 unmodified lines
4447 * function currently returns 0 as long as @cfts registration is successful4447 * function currently returns 0 as long as @cfts registration is successful
4448 * even if some file creation attempts on existing cgroups fail.4448 * even if some file creation attempts on existing cgroups fail.
4449 */4449 */
4450static int cgroup_add_cftypes(struct cgroup_subsys *ss, struct cftype *cfts)4450int cgroup_add_cftypes(struct cgroup_subsys *ss, struct cftype *cfts)
4451{4451{
4452 int ret;4452 int ret;
4453 4453
@@ -5831,7 +5831,7 @@ int cgroup_mkdir(struct kernfs_node *parent_kn, const char *name, umode_t mode) · 1377 unmodified lines
5831 }5831 }
5832 5832
5833 /*5833 /*
5834 * This extra ref will be put in cgroup_free_fn() and guarantees5834 * This extra ref will be put in css_free_rwork_fn() and guarantees
5835 * that @cgrp->kn is always accessible.5835 * that @cgrp->kn is always accessible.
5836 */5836 */
5837 kernfs_get(cgrp->kn);5837 kernfs_get(cgrp->kn);
kernel/cgroup/cpuset-v1.c+49−0
@@ -1,5 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0-or-later1// SPDX-License-Identifier: GPL-2.0-or-later
2 2
3#include "cgroup-internal.h"
3#include "cpuset-internal.h"4#include "cpuset-internal.h"
4 5
5/*6/*
@@ -175,6 +176,7 @@ static int cpuset_write_s64(struct cgroup_subsys_state *css, struct cftype *cft, · 169 unmodified lines
175 176
176 switch (type) {177 switch (type) {
177 case FILE_SCHED_RELAX_DOMAIN_LEVEL:178 case FILE_SCHED_RELAX_DOMAIN_LEVEL:
179 pr_info_once("cpuset.%s is deprecated\n", cft->name);
178 retval = update_relax_domain_level(cs, val);180 retval = update_relax_domain_level(cs, val);
179 break;181 break;
180 default:182 default:
@@ -373,6 +375,46 @@ out: · 192 unmodified lines
373 return ret;375 return ret;
374}376}
375 377
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 */
384int 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;
411out_free:
412 kfree(buf);
413out:
414 return retval;
415}
416#endif /* CONFIG_PROC_PID_CPUSET */
417
376static u64 cpuset_read_u64(struct cgroup_subsys_state *css, struct cftype *cft)418static u64 cpuset_read_u64(struct cgroup_subsys_state *css, struct cftype *cft)
377{419{
378 struct cpuset *cs = css_cs(css);420 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
424 retval = cpuset_update_flag(CS_CPU_EXCLUSIVE, cs, val);466 retval = cpuset_update_flag(CS_CPU_EXCLUSIVE, cs, val);
425 break;467 break;
426 case FILE_MEM_EXCLUSIVE:468 case FILE_MEM_EXCLUSIVE:
469 pr_info_once("cpuset.%s is deprecated\n", cft->name);
427 retval = cpuset_update_flag(CS_MEM_EXCLUSIVE, cs, val);470 retval = cpuset_update_flag(CS_MEM_EXCLUSIVE, cs, val);
428 break;471 break;
429 case FILE_MEM_HARDWALL:472 case FILE_MEM_HARDWALL:
473 pr_info_once("cpuset.%s is deprecated\n", cft->name);
430 retval = cpuset_update_flag(CS_MEM_HARDWALL, cs, val);474 retval = cpuset_update_flag(CS_MEM_HARDWALL, cs, val);
431 break;475 break;
432 case FILE_SCHED_LOAD_BALANCE:476 case FILE_SCHED_LOAD_BALANCE:
477 pr_info_once("cpuset.%s is deprecated, use cpuset.cpus.partition instead\n", cft->name);
433 retval = cpuset_update_flag(CS_SCHED_LOAD_BALANCE, cs, val);478 retval = cpuset_update_flag(CS_SCHED_LOAD_BALANCE, cs, val);
434 break;479 break;
435 case FILE_MEMORY_MIGRATE:480 case FILE_MEMORY_MIGRATE:
481 pr_info_once("cpuset.%s is deprecated\n", cft->name);
436 retval = cpuset_update_flag(CS_MEMORY_MIGRATE, cs, val);482 retval = cpuset_update_flag(CS_MEMORY_MIGRATE, cs, val);
437 break;483 break;
438 case FILE_MEMORY_PRESSURE_ENABLED:484 case FILE_MEMORY_PRESSURE_ENABLED:
485 pr_info_once("cpuset.%s is deprecated, use memory.pressure with CONFIG_PSI instead\n", cft->name);
439 cpuset_memory_pressure_enabled = !!val;486 cpuset_memory_pressure_enabled = !!val;
440 break;487 break;
441 case FILE_SPREAD_PAGE:488 case FILE_SPREAD_PAGE:
489 pr_info_once("cpuset.%s is deprecated\n", cft->name);
442 retval = cpuset_update_flag(CS_SPREAD_PAGE, cs, val);490 retval = cpuset_update_flag(CS_SPREAD_PAGE, cs, val);
443 break;491 break;
444 case FILE_SPREAD_SLAB:492 case FILE_SPREAD_SLAB:
493 pr_warn_once("cpuset.%s is deprecated\n", cft->name);
445 retval = cpuset_update_flag(CS_SPREAD_SLAB, cs, val);494 retval = cpuset_update_flag(CS_SPREAD_SLAB, cs, val);
446 break;495 break;
447 default:496 default:
kernel/cgroup/cpuset.c+0−45
@@ -21,7 +21,6 @@ · 20 unmodified lines
21 * License. See the file COPYING in the main directory of the Linux21 * License. See the file COPYING in the main directory of the Linux
22 * distribution for more details.22 * distribution for more details.
23 */23 */
24#include "cgroup-internal.h"
25#include "cpuset-internal.h"24#include "cpuset-internal.h"
26 25
27#include <linux/init.h>26#include <linux/init.h>
@@ -4244,50 +4243,6 @@ void cpuset_print_current_mems_allowed(void) · 4216 unmodified lines
4244 rcu_read_unlock();4243 rcu_read_unlock();
4245}4244}
4246 4245
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 */
4257int 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;
4284out_free:
4285 kfree(buf);
4286out:
4287 return retval;
4288}
4289#endif /* CONFIG_PROC_PID_CPUSET */
4290
4291/* Display task mems_allowed in /proc/<pid>/status file. */4246/* Display task mems_allowed in /proc/<pid>/status file. */
4292void cpuset_task_status_allowed(struct seq_file *m, struct task_struct *task)4247void cpuset_task_status_allowed(struct seq_file *m, struct task_struct *task)
4293{4248{
kernel/cgroup/legacy_freezer.c+4−2
@@ -430,9 +430,11 @@ static ssize_t freezer_write(struct kernfs_open_file *of, · 429 unmodified lines
430 430
431 if (strcmp(buf, freezer_state_strs(0)) == 0)431 if (strcmp(buf, freezer_state_strs(0)) == 0)
432 freeze = false;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 freeze = true;436 freeze = true;
435 else437 } else
436 return -EINVAL;438 return -EINVAL;
437 439
438 freezer_change_state(css_freezer(of_css(of)), freeze);440 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
67 return type >= 0 && type < MISC_CG_RES_TYPES;67 return type >= 0 && type < MISC_CG_RES_TYPES;
68}68}
69 69
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 */
77u64 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}
84EXPORT_SYMBOL_GPL(misc_cg_res_total_usage);
85
86/**70/**
87 * misc_cg_set_capacity() - Set the capacity of the misc cgroup res.71 * misc_cg_set_capacity() - Set the capacity of the misc cgroup res.
88 * @type: Type of the misc res.72 * @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
299 spin_unlock_irq(&cgroup_rstat_lock);299 spin_unlock_irq(&cgroup_rstat_lock);
300}300}
301 301
302/* see cgroup_rstat_flush() */
303static 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 * cgroup_rstat_flush - flush stats in @cgrp's subtree303 * cgroup_rstat_flush - flush stats in @cgrp's subtree
338 * @cgrp: target cgroup304 * @cgrp: target cgroup
@@ -348,38 +314,30 @@ static void cgroup_rstat_flush_locked(struct cgroup *cgrp) · 9 unmodified lines
348 */314 */
349__bpf_kfunc void cgroup_rstat_flush(struct cgroup *cgrp)315__bpf_kfunc void cgroup_rstat_flush(struct cgroup *cgrp)
350{316{
317 int cpu;
318
351 might_sleep();319 might_sleep();
320 for_each_possible_cpu(cpu) {
321 struct cgroup *pos = cgroup_rstat_updated_list(cgrp, cpu);
352 322
353 __cgroup_rstat_lock(cgrp, -1);323 /* Reacquire for each CPU to avoid disabling IRQs too long */
354 cgroup_rstat_flush_locked(cgrp);324 __cgroup_rstat_lock(cgrp, cpu);
355 __cgroup_rstat_unlock(cgrp, -1);325 for (; pos; pos = pos->rstat_flush_next) {
356}326 struct cgroup_subsys_state *css;
357 327
358/**328 cgroup_base_stat_flush(pos, cpu);
359 * cgroup_rstat_flush_hold - flush stats in @cgrp's subtree and hold329 bpf_rstat_flush(pos, cgroup_parent(pos), cpu);
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 */
367void 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}
374 330
375/**331 rcu_read_lock();
376 * cgroup_rstat_flush_release - release cgroup_rstat_flush_hold()332 list_for_each_entry_rcu(css, &pos->rstat_css_list,
377 * @cgrp: cgroup used by tracepoint333 rstat_css_node)
378 */334 css->ss->css_rstat_flush(css, cpu);
379void cgroup_rstat_flush_release(struct cgroup *cgrp)335 rcu_read_unlock();
380 __releases(&cgroup_rstat_lock)336 }
381{337 __cgroup_rstat_unlock(cgrp, cpu);
382 __cgroup_rstat_unlock(cgrp, -1);338 if (!cond_resched())
339 cpu_relax();
340 }
383}341}
384 342
385int cgroup_rstat_init(struct cgroup *cgrp)343int 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
612void cgroup_base_stat_cputime_show(struct seq_file *seq)570void cgroup_base_stat_cputime_show(struct seq_file *seq)
613{571{
614 struct cgroup *cgrp = seq_css(seq)->cgroup;572 struct cgroup *cgrp = seq_css(seq)->cgroup;
615 u64 usage, utime, stime, ntime;573 struct cgroup_base_stat bstat;
616 574
617 if (cgroup_parent(cgrp)) {575 if (cgroup_parent(cgrp)) {
618 cgroup_rstat_flush_hold(cgrp);576 cgroup_rstat_flush(cgrp);
619 usage = cgrp->bstat.cputime.sum_exec_runtime;577 __cgroup_rstat_lock(cgrp, -1);
578 bstat = cgrp->bstat;
620 cputime_adjust(&cgrp->bstat.cputime, &cgrp->prev_cputime,579 cputime_adjust(&cgrp->bstat.cputime, &cgrp->prev_cputime,
621 &utime, &stime);580 &bstat.cputime.utime, &bstat.cputime.stime);
622 ntime = cgrp->bstat.ntime;581 __cgroup_rstat_unlock(cgrp, -1);
623 cgroup_rstat_flush_release(cgrp);
624 } else {582 } else {
625 /* cgrp->bstat of root is not actually used, reuse it */583 root_cgroup_cputime(&bstat);
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;
631 }584 }
632 585
633 do_div(usage, NSEC_PER_USEC);586 do_div(bstat.cputime.sum_exec_runtime, NSEC_PER_USEC);
634 do_div(utime, NSEC_PER_USEC);587 do_div(bstat.cputime.utime, NSEC_PER_USEC);
635 do_div(stime, NSEC_PER_USEC);588 do_div(bstat.cputime.stime, NSEC_PER_USEC);
636 do_div(ntime, NSEC_PER_USEC);589 do_div(bstat.ntime, NSEC_PER_USEC);
637 590
638 seq_printf(seq, "usage_usec %llu\n"591 seq_printf(seq, "usage_usec %llu\n"
639 "user_usec %llu\n"592 "user_usec %llu\n"
640 "system_usec %llu\n"593 "system_usec %llu\n"
641 "nice_usec %llu\n",594 "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);
643 599
644 cgroup_force_idle_show(seq, &cgrp->bstat);600 cgroup_force_idle_show(seq, &bstat);
645}601}
646 602
647/* Add bpf kfuncs for cgroup_rstat_updated() and cgroup_rstat_flush() */603/* 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
1855 if (val > MAX_SWAPPINESS)1855 if (val > MAX_SWAPPINESS)
1856 return -EINVAL;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 WRITE_ONCE(memcg->swappiness, val);1861 WRITE_ONCE(memcg->swappiness, val);
1860 else1862 } else
1861 WRITE_ONCE(vm_swappiness, val);1863 WRITE_ONCE(vm_swappiness, val);
1862 1864
1863 return 0;1865 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