提交 d014172f 编写于 作者: L Lu Jialin 提交者: Zheng Zengkai

memcg: Modify memory.high_async_ratio changing scope

hulk inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I4IMAK
CVE: NA

--------

This patch changes HIGH_ASYNC_RATIO_BASE from 10 to 100 and changes
HIGH_ASYNC_RATIO_GAP from 1 to 10.
After this patch, user can set high_async_ratio from 0 to 99, which will
make memcg async reclaim more delicacy management.
If high_async_ratio is smaller than 10, try to reclaim all the pages of the
memcg.
Signed-off-by: NLu Jialin <lujialin4@huawei.com>
Reviewed-by: NKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 b901af70
...@@ -119,8 +119,8 @@ static bool do_memsw_account(void) ...@@ -119,8 +119,8 @@ static bool do_memsw_account(void)
*/ */
#define HIGH_ASYNC_RATIO_DEFAULT 0 #define HIGH_ASYNC_RATIO_DEFAULT 0
#define HIGH_ASYNC_RATIO_BASE 10 #define HIGH_ASYNC_RATIO_BASE 100
#define HIGH_ASYNC_RATIO_GAP 1 #define HIGH_ASYNC_RATIO_GAP 10
/* /*
* Cgroups above their limits are maintained in a RB-Tree, independent of * Cgroups above their limits are maintained in a RB-Tree, independent of
...@@ -2405,8 +2405,11 @@ static unsigned long reclaim_high(struct mem_cgroup *memcg, ...@@ -2405,8 +2405,11 @@ static unsigned long reclaim_high(struct mem_cgroup *memcg,
static unsigned long get_reclaim_pages(struct mem_cgroup *memcg) static unsigned long get_reclaim_pages(struct mem_cgroup *memcg)
{ {
unsigned long nr_pages = page_counter_read(&memcg->memory); unsigned long nr_pages = page_counter_read(&memcg->memory);
int ratio = READ_ONCE(memcg->high_async_ratio) - HIGH_ASYNC_RATIO_GAP; int ratio = READ_ONCE(memcg->high_async_ratio);
unsigned long safe_pages = READ_ONCE(memcg->memory.high) * ratio / unsigned long safe_pages;
ratio = ratio < HIGH_ASYNC_RATIO_GAP ? 0 : ratio - HIGH_ASYNC_RATIO_GAP;
safe_pages = READ_ONCE(memcg->memory.high) * ratio /
HIGH_ASYNC_RATIO_BASE; HIGH_ASYNC_RATIO_BASE;
return (nr_pages > safe_pages) ? (nr_pages - safe_pages) : return (nr_pages > safe_pages) ? (nr_pages - safe_pages) :
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册