提交 9fea105d 编写于 作者: C Chen Wandun 提交者: Zheng Zengkai

mm/page_cache_limit: do shrink_page_cache when adding page to page cache

hulk inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I4HOXK

------------------------------------------

Add hooks in function add_to page_cache and add_to_page_cache_lru
Signed-off-by: NChen Wandun <chenwandun@huawei.com>
Reviewed-by: NKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 955d63ae
...@@ -19,9 +19,11 @@ unsigned long __shrink_node_page_cache(int nid, gfp_t mask, ...@@ -19,9 +19,11 @@ unsigned long __shrink_node_page_cache(int nid, gfp_t mask,
unsigned long nr_to_reclaim, enum page_cache_reclaim_flag flag); unsigned long nr_to_reclaim, enum page_cache_reclaim_flag flag);
void kpagecache_limitd_stop(int nid); void kpagecache_limitd_stop(int nid);
int kpagecache_limitd_run(int nid); int kpagecache_limitd_run(int nid);
void wakeup_all_kpagecache_limitd(void);
#else #else
static inline void kpagecache_limitd_stop(int nid) {} static inline void kpagecache_limitd_stop(int nid) {}
static inline int kpagecache_limitd_run(int nid) { return 0; } static inline int kpagecache_limitd_run(int nid) { return 0; }
static inline void wakeup_all_kpagecache_limitd(void) {}
#endif #endif
#endif #endif
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/hardirq.h> /* for in_interrupt() */ #include <linux/hardirq.h> /* for in_interrupt() */
#include <linux/hugetlb_inline.h> #include <linux/hugetlb_inline.h>
#include <linux/page_cache_limit.h>
struct pagevec; struct pagevec;
...@@ -777,6 +778,7 @@ static inline int add_to_page_cache(struct page *page, ...@@ -777,6 +778,7 @@ static inline int add_to_page_cache(struct page *page,
{ {
int error; int error;
wakeup_all_kpagecache_limitd();
__SetPageLocked(page); __SetPageLocked(page);
error = add_to_page_cache_locked(page, mapping, offset, gfp_mask); error = add_to_page_cache_locked(page, mapping, offset, gfp_mask);
if (unlikely(error)) if (unlikely(error))
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include <linux/psi.h> #include <linux/psi.h>
#include <linux/ramfs.h> #include <linux/ramfs.h>
#include <linux/page_idle.h> #include <linux/page_idle.h>
#include <linux/page_cache_limit.h>
#include "internal.h" #include "internal.h"
#define CREATE_TRACE_POINTS #define CREATE_TRACE_POINTS
...@@ -923,6 +924,7 @@ int add_to_page_cache_lru(struct page *page, struct address_space *mapping, ...@@ -923,6 +924,7 @@ int add_to_page_cache_lru(struct page *page, struct address_space *mapping,
void *shadow = NULL; void *shadow = NULL;
int ret; int ret;
wakeup_all_kpagecache_limitd();
__SetPageLocked(page); __SetPageLocked(page);
ret = __add_to_page_cache_locked(page, mapping, offset, ret = __add_to_page_cache_locked(page, mapping, offset,
gfp_mask, &shadow); gfp_mask, &shadow);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册