From: Michal Hocko <mhocko@suse.com>
To: Yafang Shao <laoar.shao@gmail.com>
Cc: hannes@cmpxchg.org, akpm@linux-foundation.org, linux-mm@kvack.org
Subject: Re: [PATCH] mm, memcg: do full scan initially in force_empty
Date: Thu, 30 Jul 2020 13:26:20 +0200 [thread overview]
Message-ID: <20200730112620.GH18727@dhcp22.suse.cz> (raw)
In-Reply-To: <20200728074032.1555-1-laoar.shao@gmail.com>
On Tue 28-07-20 03:40:32, Yafang Shao wrote:
> Sometimes we use memory.force_empty to drop pages in a memcg to work
> around some memory pressure issues. When we use force_empty, we want the
> pages can be reclaimed ASAP, however force_empty reclaims pages as a
> regular reclaimer which scans the page cache LRUs from DEF_PRIORITY
> priority and finally it will drop to 0 to do full scan. That is a waste
> of time, we'd better do full scan initially in force_empty.
Do you have any numbers please?
> Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
> ---
> include/linux/swap.h | 3 ++-
> mm/memcontrol.c | 16 ++++++++++------
> mm/vmscan.c | 5 +++--
> 3 files changed, 15 insertions(+), 9 deletions(-)
>
> diff --git a/include/linux/swap.h b/include/linux/swap.h
> index 5b3216ba39a9..d88430f1b964 100644
> --- a/include/linux/swap.h
> +++ b/include/linux/swap.h
> @@ -364,7 +364,8 @@ extern int __isolate_lru_page(struct page *page, isolate_mode_t mode);
> extern unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *memcg,
> unsigned long nr_pages,
> gfp_t gfp_mask,
> - bool may_swap);
> + bool may_swap,
> + int priority);
> extern unsigned long mem_cgroup_shrink_node(struct mem_cgroup *mem,
> gfp_t gfp_mask, bool noswap,
> pg_data_t *pgdat,
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 13f559af1ab6..c873a98f8c7e 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -2237,7 +2237,8 @@ static void reclaim_high(struct mem_cgroup *memcg,
> READ_ONCE(memcg->memory.high))
> continue;
> memcg_memory_event(memcg, MEMCG_HIGH);
> - try_to_free_mem_cgroup_pages(memcg, nr_pages, gfp_mask, true);
> + try_to_free_mem_cgroup_pages(memcg, nr_pages, gfp_mask, true,
> + DEF_PRIORITY);
> } while ((memcg = parent_mem_cgroup(memcg)) &&
> !mem_cgroup_is_root(memcg));
> }
> @@ -2515,7 +2516,8 @@ static int try_charge(struct mem_cgroup *memcg, gfp_t gfp_mask,
> memcg_memory_event(mem_over_limit, MEMCG_MAX);
>
> nr_reclaimed = try_to_free_mem_cgroup_pages(mem_over_limit, nr_pages,
> - gfp_mask, may_swap);
> + gfp_mask, may_swap,
> + DEF_PRIORITY);
>
> if (mem_cgroup_margin(mem_over_limit) >= nr_pages)
> goto retry;
> @@ -3089,7 +3091,8 @@ static int mem_cgroup_resize_max(struct mem_cgroup *memcg,
> }
>
> if (!try_to_free_mem_cgroup_pages(memcg, 1,
> - GFP_KERNEL, !memsw)) {
> + GFP_KERNEL, !memsw,
> + DEF_PRIORITY)) {
> ret = -EBUSY;
> break;
> }
> @@ -3222,7 +3225,8 @@ static int mem_cgroup_force_empty(struct mem_cgroup *memcg)
> return -EINTR;
>
> progress = try_to_free_mem_cgroup_pages(memcg, 1,
> - GFP_KERNEL, true);
> + GFP_KERNEL, true,
> + 0);
> if (!progress) {
> nr_retries--;
> /* maybe some writeback is necessary */
> @@ -6065,7 +6069,7 @@ static ssize_t memory_high_write(struct kernfs_open_file *of,
> }
>
> reclaimed = try_to_free_mem_cgroup_pages(memcg, nr_pages - high,
> - GFP_KERNEL, true);
> + GFP_KERNEL, true, DEF_PRIORITY);
>
> if (!reclaimed && !nr_retries--)
> break;
> @@ -6113,7 +6117,7 @@ static ssize_t memory_max_write(struct kernfs_open_file *of,
>
> if (nr_reclaims) {
> if (!try_to_free_mem_cgroup_pages(memcg, nr_pages - max,
> - GFP_KERNEL, true))
> + GFP_KERNEL, true, DEF_PRIORITY))
> nr_reclaims--;
> continue;
> }
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 749d239c62b2..49298bb2892d 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -3315,7 +3315,8 @@ unsigned long mem_cgroup_shrink_node(struct mem_cgroup *memcg,
> unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *memcg,
> unsigned long nr_pages,
> gfp_t gfp_mask,
> - bool may_swap)
> + bool may_swap,
> + int priority)
> {
> unsigned long nr_reclaimed;
> unsigned long pflags;
> @@ -3326,7 +3327,7 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *memcg,
> (GFP_HIGHUSER_MOVABLE & ~GFP_RECLAIM_MASK),
> .reclaim_idx = MAX_NR_ZONES - 1,
> .target_mem_cgroup = memcg,
> - .priority = DEF_PRIORITY,
> + .priority = priority,
> .may_writepage = !laptop_mode,
> .may_unmap = 1,
> .may_swap = may_swap,
> --
> 2.18.1
--
Michal Hocko
SUSE Labs
next prev parent reply other threads:[~2020-07-30 11:26 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-28 7:40 [PATCH] mm, memcg: do full scan initially in force_empty Yafang Shao
2020-07-30 11:26 ` Michal Hocko [this message]
2020-07-31 1:50 ` Yafang Shao
2020-08-03 10:12 ` Michal Hocko
2020-08-03 13:20 ` Yafang Shao
2020-08-03 13:56 ` Michal Hocko
2020-08-03 14:18 ` Yafang Shao
2020-08-03 14:26 ` Yafang Shao
2020-08-03 14:37 ` Michal Hocko
2020-08-03 14:34 ` Michal Hocko
2020-08-03 15:26 ` Waiman Long
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200730112620.GH18727@dhcp22.suse.cz \
--to=mhocko@suse.com \
--cc=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=laoar.shao@gmail.com \
--cc=linux-mm@kvack.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox