[PATCH OLK-6.6 0/2] memcg: enable asynchronous reclaim for cgroup-v2
memcg: enable asynchronous reclaim for cgroup-v2 Chen Ridong (2): memcg: change CONFIG_MEMCG_V1_RECLAIM to CONFIG_MEMCG_QOS memcg: enable asynchronous reclaim for cgroup-v2 arch/arm64/configs/openeuler_defconfig | 2 +- arch/riscv/configs/openeuler_defconfig | 2 +- arch/x86/configs/openeuler_defconfig | 2 +- include/linux/memcontrol.h | 4 ++-- init/Kconfig | 10 +++++++-- mm/memcontrol.c | 30 ++++++++++++++++---------- 6 files changed, 32 insertions(+), 18 deletions(-) -- 2.34.1
hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/ID700L -------------------------------- The asynchronous reclaim will be enabled for cgroup-v2, to adapt that, rename the Kconfig CONFIG_MEMCG_V1_RECLAIM to CONFIG_MEMCG_QOS Signed-off-by: Chen Ridong <chenridong@huawei.com> --- arch/arm64/configs/openeuler_defconfig | 2 +- arch/riscv/configs/openeuler_defconfig | 2 +- arch/x86/configs/openeuler_defconfig | 2 +- include/linux/memcontrol.h | 4 ++-- init/Kconfig | 10 ++++++++-- mm/memcontrol.c | 22 +++++++++++----------- 6 files changed, 24 insertions(+), 18 deletions(-) diff --git a/arch/arm64/configs/openeuler_defconfig b/arch/arm64/configs/openeuler_defconfig index 409890bad06eb..ceaf4690c648c 100644 --- a/arch/arm64/configs/openeuler_defconfig +++ b/arch/arm64/configs/openeuler_defconfig @@ -162,7 +162,7 @@ CONFIG_CGROUPS=y CONFIG_PAGE_COUNTER=y # CONFIG_CGROUP_FAVOR_DYNMODS is not set CONFIG_MEMCG=y -CONFIG_MEMCG_V1_RECLAIM=y +CONFIG_MEMCG_QOS=y CONFIG_MEMCG_MEMFS_INFO=y CONFIG_MEMCG_OOM_PRIORITY=y CONFIG_MEMCG_SWAP_QOS=y diff --git a/arch/riscv/configs/openeuler_defconfig b/arch/riscv/configs/openeuler_defconfig index 61f2b2f12589d..4a9b4b7da9401 100644 --- a/arch/riscv/configs/openeuler_defconfig +++ b/arch/riscv/configs/openeuler_defconfig @@ -157,7 +157,7 @@ CONFIG_CGROUPS=y CONFIG_PAGE_COUNTER=y # CONFIG_CGROUP_FAVOR_DYNMODS is not set CONFIG_MEMCG=y -# CONFIG_MEMCG_V1_RECLAIM is not set +# CONFIG_MEMCG_QOS is not set # CONFIG_MEMCG_MEMFS_INFO is not set CONFIG_MEMCG_KMEM=y CONFIG_BLK_CGROUP=y diff --git a/arch/x86/configs/openeuler_defconfig b/arch/x86/configs/openeuler_defconfig index 7d030d2d7717c..c58a5c26a5607 100644 --- a/arch/x86/configs/openeuler_defconfig +++ b/arch/x86/configs/openeuler_defconfig @@ -181,7 +181,7 @@ CONFIG_CGROUPS=y CONFIG_PAGE_COUNTER=y # CONFIG_CGROUP_FAVOR_DYNMODS is not set CONFIG_MEMCG=y -CONFIG_MEMCG_V1_RECLAIM=y +CONFIG_MEMCG_QOS=y CONFIG_MEMCG_MEMFS_INFO=y CONFIG_MEMCG_OOM_PRIORITY=y CONFIG_MEMCG_SWAP_QOS=y diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 0ac5e1fda1fe8..89ef30f202754 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -399,7 +399,7 @@ struct mem_cgroup { struct lru_gen_mm_list mm_list; #endif -#ifdef CONFIG_MEMCG_V1_RECLAIM +#ifdef CONFIG_MEMCG_QOS int high_async_ratio; bool high_async_reclaim; #endif @@ -1257,7 +1257,7 @@ static inline void __memcg_memory_event(struct mem_cgroup *memcg, else cgroup_file_notify(&memcg->events_file); } -#ifndef CONFIG_MEMCG_V1_RECLAIM +#ifndef CONFIG_MEMCG_QOS if (!cgroup_subsys_on_dfl(memory_cgrp_subsys)) break; #endif diff --git a/init/Kconfig b/init/Kconfig index 2720083aaa17d..f2ab942668bee 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -985,10 +985,16 @@ 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" +config MEMCG_QOS + bool "Enable Per Memory Cgroup Qos" depends on MEMCG default n + help + This option enables Quality of Service (QoS) controls for + individual memory cgroups, including support for setting memory + watermarks and asynchronous reclaim mechanisms. + + If unsure, say "n". config MEMCG_MEMFS_INFO bool "Show memfs files that have pages charged in given memory cgroup" diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 7a8795130546d..ca320571575c5 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -2580,7 +2580,7 @@ static unsigned long reclaim_high(struct mem_cgroup *memcg, return nr_reclaimed; } -#ifdef CONFIG_MEMCG_V1_RECLAIM +#ifdef CONFIG_MEMCG_QOS static bool is_high_async_reclaim(struct mem_cgroup *memcg) { int ratio = READ_ONCE(memcg->high_async_ratio); @@ -2621,7 +2621,7 @@ static void high_work_func(struct work_struct *work) struct mem_cgroup *memcg = container_of(work, struct mem_cgroup, high_work); -#ifdef CONFIG_MEMCG_V1_RECLAIM +#ifdef CONFIG_MEMCG_QOS if (READ_ONCE(memcg->high_async_reclaim)) async_reclaim_high(memcg); else @@ -3017,7 +3017,7 @@ static int try_charge_memcg(struct mem_cgroup *memcg, gfp_t gfp_mask, } continue; } -#ifdef CONFIG_MEMCG_V1_RECLAIM +#ifdef CONFIG_MEMCG_QOS if (is_high_async_reclaim(memcg) && !mem_high) { WRITE_ONCE(memcg->high_async_reclaim, true); #ifdef CONFIG_MEMCG_SWAP_QOS @@ -5431,13 +5431,13 @@ static int mem_cgroup_oom_control_read(struct seq_file *sf, void *v) seq_printf(sf, "oom_kill_disable %d\n", READ_ONCE(memcg->oom_kill_disable)); seq_printf(sf, "under_oom %d\n", (bool)memcg->under_oom); /* - * When CONFIG_MEMCG_V1_RECLAIM=n, memory_events[MEMCG_OOM_KILL] equals - * memory_events_local[MEMCG_OOM_KILL]. When CONFIG_MEMCG_V1_RECLAIM=y,memory_events - * will contain sub cgroup counts. Therefore, oom_kill will show - * memory_events_local[MEMCG_OOM_KILL] + * When CONFIG_MEMCG_QOS=n, memory_events[MEMCG_OOM_KILL] equals + * memory_events_local[MEMCG_OOM_KILL]. When CONFIG_MEMCG_QOS=y, + * memory_events will contain sub cgroup counts. Therefore, oom_kill will + * show memory_events_local[MEMCG_OOM_KILL] */ seq_printf(sf, "oom_kill %lu\n", -#ifdef CONFIG_MEMCG_V1_RECLAIM +#ifdef CONFIG_MEMCG_QOS atomic_long_read(&memcg->memory_events_local[MEMCG_OOM_KILL])); #else atomic_long_read(&memcg->memory_events[MEMCG_OOM_KILL])); @@ -6095,7 +6095,7 @@ static ssize_t mem_cgroup_dpool_2M_write(struct kernfs_open_file *of, static int memory_stat_show(struct seq_file *m, void *v); -#ifdef CONFIG_MEMCG_V1_RECLAIM +#ifdef CONFIG_MEMCG_QOS 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); @@ -6382,7 +6382,7 @@ static struct cftype mem_cgroup_legacy_files[] = { .write = mem_cgroup_reset, .read_u64 = mem_cgroup_read_u64, }, -#ifdef CONFIG_MEMCG_V1_RECLAIM +#ifdef CONFIG_MEMCG_QOS { .name = "min", .flags = CFTYPE_NOT_ON_ROOT, @@ -6727,7 +6727,7 @@ mem_cgroup_css_alloc(struct cgroup_subsys_state *parent_css) #if defined(CONFIG_MEMCG_KMEM) && defined(CONFIG_ZSWAP) memcg->zswap_max = PAGE_COUNTER_MAX; #endif -#ifdef CONFIG_MEMCG_V1_RECLAIM +#ifdef CONFIG_MEMCG_QOS memcg->high_async_ratio = HIGH_ASYNC_RATIO_BASE; #endif page_counter_set_high(&memcg->swap, PAGE_COUNTER_MAX); -- 2.34.1
hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/ID700L -------------------------------- Enable asynchronous reclaim for cgroup-v2. Signed-off-by: Chen Ridong <chenridong@huawei.com> --- mm/memcontrol.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index ca320571575c5..eee855cde629b 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -8278,6 +8278,14 @@ static struct cftype memory_files[] = { .seq_show = memory_high_show, .write = memory_high_write, }, +#ifdef CONFIG_MEMCG_QOS + { + .name = "high_async_ratio", + .flags = CFTYPE_NOT_ON_ROOT, + .seq_show = memcg_high_async_ratio_show, + .write = memcg_high_async_ratio_write, + }, +#endif { .name = "max", .flags = CFTYPE_NOT_ON_ROOT, -- 2.34.1
反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://gitee.com/openeuler/kernel/pulls/19021 邮件列表地址:https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/OK4... FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://gitee.com/openeuler/kernel/pulls/19021 Mailing list address: https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/OK4...
participants (2)
-
Chen Ridong -
patchwork bot