hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8JVN0
--------------------------------
Export memcg.min and memcg.low from cgroupv2 to cgroupv1, in order to reduce the negtive impact between cgroups when the system memory is insufficient.
Export memory.high from cgroupv2 to cgroupv1. Therefore, when the usage of the memcg is larger than memory.high, some pages will be reclaimed before return to userland, which will throttle the process.
Only export memory.{min/low/high} numbers in mem_cgroup_legacy_files and declare related functions in front of mem_cgroup_legacy_files. There is no need to other changes.
Signed-off-by: Lu Jialin lujialin4@huawei.com --- init/Kconfig | 5 +++++ mm/memcontrol.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+)
diff --git a/init/Kconfig b/init/Kconfig index f37422327249..d4d9ba7e1b48 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -944,6 +944,11 @@ config MEMCG help Provides control over the memory footprint of tasks in a cgroup.
+config MEMCG_V1_RECLAIM + bool "Enable Per Memory Cgroup Qos Reclaim in Cgroup V1" + depends on MEMCG + default n + config MEMCG_KMEM bool depends on MEMCG diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 8a881ab21f6c..546c28719950 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -5012,6 +5012,18 @@ static int mem_cgroup_slab_show(struct seq_file *m, void *p)
static int memory_stat_show(struct seq_file *m, void *v);
+#ifdef CONFIG_MEMCG_V1_RECLAIM +static int memory_min_show(struct seq_file *m, void *v); +static ssize_t memory_min_write(struct kernfs_open_file *of, + char *buf, size_t nbytes, loff_t off); +static int memory_low_show(struct seq_file *m, void *v); +static ssize_t memory_low_write(struct kernfs_open_file *of, + char *buf, size_t nbytes, loff_t off); +static int memory_high_show(struct seq_file *m, void *v); +static ssize_t memory_high_write(struct kernfs_open_file *of, + char *buf, size_t nbytes, loff_t off); +#endif + static struct cftype mem_cgroup_legacy_files[] = { { .name = "usage_in_bytes", @@ -5138,6 +5150,26 @@ static struct cftype mem_cgroup_legacy_files[] = { .write = mem_cgroup_reset, .read_u64 = mem_cgroup_read_u64, }, +#ifdef CONFIG_MEMCG_V1_RECLAIM + { + .name = "min", + .flags = CFTYPE_NOT_ON_ROOT, + .seq_show = memory_min_show, + .write = memory_min_write, + }, + { + .name = "low", + .flags = CFTYPE_NOT_ON_ROOT, + .seq_show = memory_low_show, + .write = memory_low_write, + }, + { + .name = "high", + .flags = CFTYPE_NOT_ON_ROOT, + .seq_show = memory_high_show, + .write = memory_high_write, + }, +#endif { }, /* terminate */ };