From: Michal Hocko <mhocko@suse.cz>
To: Johannes Weiner <hannes@cmpxchg.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Rik van Riel <riel@redhat.com>, Mel Gorman <mgorman@suse.de>,
Hugh Dickins <hughd@google.com>,
Satoru Moriya <satoru.moriya@hds.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [patch 3/7] mm: vmscan: clarify how swappiness, highest priority, memcg interact
Date: Mon, 17 Dec 2012 21:05:47 +0100 [thread overview]
Message-ID: <20121217200547.GC16375@dhcp22.suse.cz> (raw)
In-Reply-To: <1355767957-4913-4-git-send-email-hannes@cmpxchg.org>
On Mon 17-12-12 13:12:33, Johannes Weiner wrote:
> A swappiness of 0 has a slightly different meaning for global reclaim
> (may swap if file cache really low) and memory cgroup reclaim (never
> swap, ever).
>
> In addition, global reclaim at highest priority will scan all LRU
> lists equal to their size and ignore other balancing heuristics.
> UNLESS swappiness forbids swapping, then the lists are balanced based
> on recent reclaim effectiveness. UNLESS file cache is running low,
> then anonymous pages are force-scanned.
>
> This (total mess of a) behaviour is implicit and not obvious from the
> way the code is organized. At least make it apparent in the code flow
> and document the conditions. It will be it easier to come up with
> sane semantics later.
>
> Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Reviewed-by: Michal Hocko <mhocko@suse.cz>
Thanks!
> ---
> mm/vmscan.c | 39 ++++++++++++++++++++++++++++++---------
> 1 file changed, 30 insertions(+), 9 deletions(-)
>
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 648a4db..c37deaf 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -1644,7 +1644,6 @@ static void get_scan_count(struct lruvec *lruvec, struct scan_control *sc,
> struct zone_reclaim_stat *reclaim_stat = &lruvec->reclaim_stat;
> u64 fraction[2], denominator;
> enum lru_list lru;
> - int noswap = 0;
> bool force_scan = false;
> struct zone *zone = lruvec_zone(lruvec);
>
> @@ -1665,13 +1664,38 @@ static void get_scan_count(struct lruvec *lruvec, struct scan_control *sc,
>
> /* If we have no swap space, do not bother scanning anon pages. */
> if (!sc->may_swap || (nr_swap_pages <= 0)) {
> - noswap = 1;
> fraction[0] = 0;
> fraction[1] = 1;
> denominator = 1;
> goto out;
> }
>
> + /*
> + * Global reclaim will swap to prevent OOM even with no
> + * swappiness, but memcg users want to use this knob to
> + * disable swapping for individual groups completely when
> + * using the memory controller's swap limit feature would be
> + * too expensive.
> + */
> + if (!global_reclaim(sc) && !vmscan_swappiness(sc)) {
> + fraction[0] = 0;
> + fraction[1] = 1;
> + denominator = 1;
> + goto out;
> + }
> +
> + /*
> + * Do not apply any pressure balancing cleverness when the
> + * system is close to OOM, scan both anon and file equally
> + * (unless the swappiness setting disagrees with swapping).
> + */
> + if (!sc->priority && vmscan_swappiness(sc)) {
> + fraction[0] = 1;
> + fraction[1] = 1;
> + denominator = 1;
> + goto out;
> + }
> +
> anon = get_lru_size(lruvec, LRU_ACTIVE_ANON) +
> get_lru_size(lruvec, LRU_INACTIVE_ANON);
> file = get_lru_size(lruvec, LRU_ACTIVE_FILE) +
> @@ -1753,13 +1777,10 @@ static void get_scan_count(struct lruvec *lruvec, struct scan_control *sc,
> unsigned long scan;
>
> size = get_lru_size(lruvec, lru);
> - if (sc->priority || noswap || !vmscan_swappiness(sc)) {
> - scan = size >> sc->priority;
> - if (!scan && force_scan)
> - scan = min(size, SWAP_CLUSTER_MAX);
> - scan = div64_u64(scan * fraction[file], denominator);
> - } else
> - scan = size;
> + scan = size >> sc->priority;
> + if (!scan && force_scan)
> + scan = min(size, SWAP_CLUSTER_MAX);
> + scan = div64_u64(scan * fraction[file], denominator);
> nr[lru] = scan;
> }
> }
> --
> 1.7.11.7
>
--
Michal Hocko
SUSE Labs
--
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/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2012-12-17 20:05 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-17 18:12 [patch 0/8] page reclaim bits v2 Johannes Weiner
2012-12-17 18:12 ` [patch 1/7] mm: memcg: only evict file pages when we have plenty Johannes Weiner
2012-12-17 18:15 ` Rik van Riel
2012-12-18 9:56 ` Mel Gorman
2012-12-17 18:12 ` [patch 2/7] mm: vmscan: save work scanning (almost) empty LRU lists Johannes Weiner
2012-12-19 23:59 ` Andrew Morton
2012-12-20 13:55 ` Michal Hocko
2012-12-21 3:02 ` Johannes Weiner
2012-12-17 18:12 ` [patch 3/7] mm: vmscan: clarify how swappiness, highest priority, memcg interact Johannes Weiner
2012-12-17 18:16 ` Rik van Riel
2012-12-17 19:37 ` Satoru Moriya
2012-12-17 20:05 ` Michal Hocko [this message]
2012-12-18 10:04 ` Mel Gorman
2012-12-18 15:16 ` Satoru Moriya
2012-12-17 18:12 ` [patch 4/7] mm: vmscan: improve comment on low-page cache handling Johannes Weiner
2012-12-17 18:12 ` [patch 5/7] mm: vmscan: clean up get_scan_count() Johannes Weiner
2012-12-20 0:08 ` Andrew Morton
2012-12-21 2:49 ` Johannes Weiner
2012-12-17 18:12 ` [patch 6/7] mm: vmscan: compaction works against zones, not lruvecs Johannes Weiner
2012-12-17 18:12 ` [patch 7/7] mm: reduce rmap overhead for ex-KSM page copies created on swap faults Johannes Weiner
2012-12-17 22:42 ` Hugh Dickins
2012-12-19 7:01 ` Simon Jeons
2012-12-19 17:58 ` Johannes Weiner
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=20121217200547.GC16375@dhcp22.suse.cz \
--to=mhocko@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=hughd@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@suse.de \
--cc=riel@redhat.com \
--cc=satoru.moriya@hds.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).