From: Hillf Danton <dhillf@gmail.com>
To: Ying Han <yinghan@google.com>
Cc: Michal Hocko <mhocko@suse.cz>,
Johannes Weiner <hannes@cmpxchg.org>, Mel Gorman <mel@csn.ul.ie>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
Rik van Riel <riel@redhat.com>, Hugh Dickins <hughd@google.com>,
Dan Magenheimer <dan.magenheimer@oracle.com>,
linux-mm@kvack.org
Subject: Re: [PATCH V2 4/5] memcg: detect no memcgs above softlimit under zone reclaim.
Date: Sat, 14 Apr 2012 22:32:26 +0800 [thread overview]
Message-ID: <CAJd=RBB5oaPPXqQ0nLpThCFccbOF9vfgRS2+dTnpP4KBVCib6A@mail.gmail.com> (raw)
In-Reply-To: <1334181620-26890-1-git-send-email-yinghan@google.com>
On Thu, Apr 12, 2012 at 6:00 AM, Ying Han <yinghan@google.com> wrote:
> The function zone_reclaimable() marks zone->all_unreclaimable based on
> per-zone pages_scanned and reclaimable_pages. If all_unreclaimable is true,
> alloc_pages could go to OOM instead of getting stuck in page reclaim.
>
> In memcg kernel, cgroup under its softlimit is not targeted under global
> reclaim. It could be possible that all memcgs are under their softlimit for
> a particular zone. So the direct reclaim do_try_to_free_pages() will always
> return 1 which causes the caller __alloc_pages_direct_reclaim() enter tight
> loop.
>
> The reclaim priority check we put in should_reclaim_mem_cgroup() should help
> this case, but we still don't want to burn cpu cycles for first few priorities
> to get to that point. The idea is from LSF discussion where we detect it after
> the first round of scanning and restart the reclaim by not looking at softlimit
> at all. This allows us to make forward progress on shrink_zone() and free some
> pages on the zone.
>
> In order to do the detection for scanning all the memcgs under shrink_zone(),
> i have to change the mem_cgroup_iter() from shared walk to full walk. Otherwise,
> it would be very easy to skip lots of memcgs above softlimit and it causes the
> flag "ignore_softlimit" being mistakenly set.
>
Perhaps that detection could be covered by
return target_mem_cgroup ||
mem_cgroup_soft_limit_exceeded(memcg) ||
(priority <= DEF_PRIORITY - 3);
then consider replacing shared walk with full walk.
> Signed-off-by: Ying Han <yinghan@google.com>
> ---
> mm/vmscan.c | 23 ++++++++++++++++-------
> 1 files changed, 16 insertions(+), 7 deletions(-)
>
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 2dbc300..d65eae4 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -2158,21 +2158,25 @@ static void shrink_zone(int priority, struct zone *zone,
> struct scan_control *sc)
> {
> struct mem_cgroup *root = sc->target_mem_cgroup;
> - struct mem_cgroup_reclaim_cookie reclaim = {
> - .zone = zone,
> - .priority = priority,
> - };
> struct mem_cgroup *memcg;
> + int above_softlimit, ignore_softlimit = 0;
> +
>
> - memcg = mem_cgroup_iter(root, NULL, &reclaim);
> +restart:
> + above_softlimit = 0;
> + memcg = mem_cgroup_iter(root, NULL, NULL);
> do {
> struct mem_cgroup_zone mz = {
> .mem_cgroup = memcg,
> .zone = zone,
> };
>
> - if (should_reclaim_mem_cgroup(root, memcg, priority))
> + if (ignore_softlimit ||
> + should_reclaim_mem_cgroup(root, memcg, priority)) {
> +
> shrink_mem_cgroup_zone(priority, &mz, sc);
> + above_softlimit = 1;
> + }
>
> /*
> * Limit reclaim has historically picked one memcg and
> @@ -2188,8 +2192,13 @@ static void shrink_zone(int priority, struct zone *zone,
> mem_cgroup_iter_break(root, memcg);
> break;
> }
> - memcg = mem_cgroup_iter(root, memcg, &reclaim);
> + memcg = mem_cgroup_iter(root, memcg, NULL);
> } while (memcg);
> +
> + if (!above_softlimit) {
> + ignore_softlimit = 1;
> + goto restart;
> + }
> }
>
> /* Returns true if compaction should go ahead for a high-order request */
> --
> 1.7.7.3
>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
prev parent reply other threads:[~2012-04-14 14:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-11 22:00 [PATCH V2 4/5] memcg: detect no memcgs above softlimit under zone reclaim Ying Han
2012-04-14 14:32 ` Hillf Danton [this message]
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='CAJd=RBB5oaPPXqQ0nLpThCFccbOF9vfgRS2+dTnpP4KBVCib6A@mail.gmail.com' \
--to=dhillf@gmail.com \
--cc=dan.magenheimer@oracle.com \
--cc=hannes@cmpxchg.org \
--cc=hughd@google.com \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=linux-mm@kvack.org \
--cc=mel@csn.ul.ie \
--cc=mhocko@suse.cz \
--cc=riel@redhat.com \
--cc=yinghan@google.com \
/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;
as well as URLs for NNTP newsgroup(s).