
From: Chen Wandun <chenwandun@huawei.com> hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I4HOXK ------------------------------------------ In NUMA system, each node may have different pages, so pages that to reclaim should be calculated separately when the number of page cache beyond page cache limit. Signed-off-by: Chen Wandun <chenwandun@huawei.com> Reviewed-by: Kefeng Wang <wangkefeng.wang@huawei.com> Signed-off-by: Zheng Zengkai <zhengzengkai@huawei.com> --- mm/page_cache_limit.c | 52 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/mm/page_cache_limit.c b/mm/page_cache_limit.c index 4afc08373a35..33164e19cfa2 100644 --- a/mm/page_cache_limit.c +++ b/mm/page_cache_limit.c @@ -104,10 +104,60 @@ void wakeup_all_kpagecache_limitd(void) wakeup_kpagecache_limitd(nid); } +static unsigned long node_nr_page_cache(int nid) +{ + struct pglist_data *pgdat; + unsigned long num = 0; + + pgdat = NODE_DATA(nid); + if (!pgdat) + return 0; + + num = node_page_state(pgdat, NR_FILE_PAGES); + num -= node_page_state(pgdat, NR_SHMEM); + + return num; +} + +static unsigned long node_nr_page_reclaim(int nid) +{ + unsigned long nr_page_cache; + unsigned long nr_to_reclaim; + unsigned long total_pages; + + if (!node_pagecache_limit_pages[nid]) + return 0; + + nr_page_cache = node_nr_page_cache(nid); + if (!nr_page_cache) + return 0; + + if (nr_page_cache < node_pagecache_limit_pages[nid]) + return 0; + + total_pages = get_node_total_pages(nid); + nr_to_reclaim = nr_page_cache - node_pagecache_limit_pages[nid]; + nr_to_reclaim += total_pages * pagecache_reclaim_ratio / 100; + + return nr_to_reclaim; +} + +static void shrink_node_page_cache(int nid) +{ + unsigned long nr_to_reclaim; + + nr_to_reclaim = node_nr_page_reclaim(nid); +} + static void shrink_page_cache(void) { - if (!pagecache_overlimit()) + int nid; + + if (!pagecache_reclaim_enable || !pagecache_overlimit()) return; + + for_each_node_state(nid, N_MEMORY) + shrink_node_page_cache(nid); } static DECLARE_COMPLETION(setup_done); -- 2.20.1