From: Lu Jialin lujialin4@huawei.com
hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I4IMAK CVE: NA
-------------------------------
This reverts commit 84355bcc1e8008181ed3e7275b2cd60a45d7476d.
Signed-off-by: Lu Jialin lujialin4@huawei.com Reviewed-by: Xiu Jianfeng xiujianfeng@huawei.com Reviewed-by: Kefeng Wang wangkefeng.wang@huawei.com Signed-off-by: Zheng Zengkai zhengzengkai@huawei.com --- include/linux/memcontrol.h | 3 --- mm/memcontrol.c | 43 ++++++++------------------------------ mm/vmscan.c | 3 +-- 3 files changed, 10 insertions(+), 39 deletions(-)
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 3a4ea9ed39fd..6959aca37bc2 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -1895,9 +1895,6 @@ static inline void mem_cgroup_flush_foreign(struct bdi_writeback *wb)
#endif /* CONFIG_CGROUP_WRITEBACK */
-extern struct static_key_false memcg_kswapd_key; -#define mem_cgroup_kswapd_enabled static_branch_unlikely(&memcg_kswapd_key) - struct sock; bool mem_cgroup_charge_skmem(struct mem_cgroup *memcg, unsigned int nr_pages); void mem_cgroup_uncharge_skmem(struct mem_cgroup *memcg, unsigned int nr_pages); diff --git a/mm/memcontrol.c b/mm/memcontrol.c index a850d1f3fc5b..0b7fc99724f2 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -97,10 +97,6 @@ bool cgroup_memory_noswap __read_mostly; static DECLARE_WAIT_QUEUE_HEAD(memcg_cgwb_frn_waitq); #endif
-static bool cgroup_memory_kswapd = false; -DEFINE_STATIC_KEY_FALSE(memcg_kswapd_key); -EXPORT_SYMBOL(memcg_kswapd_key); - /* Whether legacy memory+swap accounting is active */ static bool do_memsw_account(void) { @@ -2371,15 +2367,10 @@ static void high_work_func(struct work_struct *work) { struct mem_cgroup *memcg;
- if (mem_cgroup_kswapd_enabled) { - current->flags |= PF_SWAPWRITE | PF_MEMALLOC | PF_KSWAPD; - memcg = container_of(work, struct mem_cgroup, high_work); - reclaim_high(memcg, MEMCG_CHARGE_BATCH, GFP_KERNEL); - current->flags &= ~(PF_SWAPWRITE | PF_MEMALLOC | PF_KSWAPD); - } else { - memcg = container_of(work, struct mem_cgroup, high_work); - reclaim_high(memcg, MEMCG_CHARGE_BATCH, GFP_KERNEL); - } + current->flags |= PF_SWAPWRITE | PF_MEMALLOC | PF_KSWAPD; + memcg = container_of(work, struct mem_cgroup, high_work); + reclaim_high(memcg, MEMCG_CHARGE_BATCH, GFP_KERNEL); + current->flags &= ~(PF_SWAPWRITE | PF_MEMALLOC | PF_KSWAPD); }
/* @@ -2549,17 +2540,11 @@ void mem_cgroup_handle_over_high(void) * memory.high is currently batched, whereas memory.max and the page * allocator run every time an allocation is made. */ - if (mem_cgroup_kswapd_enabled) { - current->flags |= PF_SWAPWRITE | PF_MEMALLOC | PF_KSWAPD; - nr_reclaimed = reclaim_high(memcg, - in_retry ? SWAP_CLUSTER_MAX : nr_pages, - GFP_KERNEL); - current->flags &= ~(PF_SWAPWRITE | PF_MEMALLOC | PF_KSWAPD); - } else { - nr_reclaimed = reclaim_high(memcg, - in_retry ? SWAP_CLUSTER_MAX : nr_pages, - GFP_KERNEL); - } + current->flags |= PF_SWAPWRITE | PF_MEMALLOC | PF_KSWAPD; + nr_reclaimed = reclaim_high(memcg, + in_retry ? SWAP_CLUSTER_MAX : nr_pages, + GFP_KERNEL); + current->flags &= ~(PF_SWAPWRITE | PF_MEMALLOC | PF_KSWAPD);
/* * memory.high is breached and reclaim is unable to keep up. Throttle @@ -5647,9 +5632,6 @@ mem_cgroup_css_alloc(struct cgroup_subsys_state *parent_css) struct mem_cgroup *memcg, *old_memcg; long error = -ENOMEM;
- if (cgroup_memory_kswapd) - static_branch_enable(&memcg_kswapd_key); - old_memcg = set_active_memcg(parent); memcg = mem_cgroup_alloc(); set_active_memcg(old_memcg); @@ -7464,13 +7446,6 @@ static int __init cgroup_memory(char *s) } __setup("cgroup.memory=", cgroup_memory);
-static int __init memcg_kswapd(char *s) -{ - cgroup_memory_kswapd = true; - return 0; -} -__setup("memcg_kswapd", memcg_kswapd); - /* * subsys_initcall() for memory controller. * diff --git a/mm/vmscan.c b/mm/vmscan.c index 5b5cc00b195b..7fec6cf7a0ae 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2843,9 +2843,8 @@ static bool is_memcg_kswapd_stopped(struct scan_control *sc) bool is_stop = false; unsigned long stop_flag = 0;
- if (!cgroup_reclaim(sc) || !mem_cgroup_kswapd_enabled) + if (!cgroup_reclaim(sc)) return false; - if (memcg->memory.max == PAGE_COUNTER_MAX) stop_flag = memcg->memory.high / 6; else