diff --git a/arch/arm64/configs/openeuler_defconfig b/arch/arm64/configs/openeuler_defconfig index dda5ad5b3673684984dd82e24a4ef8860a8e4ce8..ac21d0c6a3952d9f46c512bd326f413c81cf4c73 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 61f2b2f12589d475114fad1833c7ccb20ed5dd2e..4a9b4b7da940128a9c89f1db66dc18b5fd4bb50e 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 7d030d2d7717c936302f9ac7b3652124ff3fd7d3..c58a5c26a5607a0f312778e3422d4ad678eb2278 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 0ac5e1fda1fe82f063332822a4df2266adc9562f..89ef30f202754e0d85817a8974fd80a1a0e4722e 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 2720083aaa17d5d47cacdd37c51371e11e3aea97..f2ab942668bee6a93f1c8b7ba9b846c9e818b922 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 7a8795130546ddda47a5117dd4a4e21fce221466..eee855cde629b0fbc8dbef452cf4c82f578aff93 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); @@ -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,