From: Johannes Weiner <hannes@cmpxchg.org>
To: Shakeel Butt <shakeelb@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Andrey Ryabinin <aryabinin@virtuozzo.com>,
Suren Baghdasaryan <surenb@google.com>,
Rik van Riel <riel@surriel.com>, Michal Hocko <mhocko@suse.com>,
Linux MM <linux-mm@kvack.org>, Cgroups <cgroups@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
Kernel Team <kernel-team@fb.com>
Subject: Re: [PATCH 2/3] mm: vmscan: detect file thrashing at the reclaim root
Date: Fri, 15 Nov 2019 11:07:22 -0500 [thread overview]
Message-ID: <20191115160722.GA309754@cmpxchg.org> (raw)
In-Reply-To: <CALvZod5y2NPPg=24q33=ktQqwyUsH1gpwHgROe5z_P+tW74SDw@mail.gmail.com>
On Thu, Nov 14, 2019 at 03:47:59PM -0800, Shakeel Butt wrote:
> On Thu, Nov 7, 2019 at 12:53 PM Johannes Weiner <hannes@cmpxchg.org> wrote:
> >
> > We use refault information to determine whether the cache workingset
> > is stable or transitioning, and dynamically adjust the inactive:active
> > file LRU ratio so as to maximize protection from one-off cache during
> > stable periods, and minimize IO during transitions.
> >
> > With cgroups and their nested LRU lists, we currently don't do this
> > correctly. While recursive cgroup reclaim establishes a relative LRU
> > order among the pages of all involved cgroups, refaults only affect
> > the local LRU order in the cgroup in which they are occuring. As a
> > result, cache transitions can take longer in a cgrouped system as the
> > active pages of sibling cgroups aren't challenged when they should be.
> >
> > [ Right now, this is somewhat theoretical, because the siblings, under
> > continued regular reclaim pressure, should eventually run out of
> > inactive pages - and since inactive:active *size* balancing is also
> > done on a cgroup-local level, we will challenge the active pages
> > eventually in most cases. But the next patch will move that relative
> > size enforcement to the reclaim root as well, and then this patch
> > here will be necessary to propagate refault pressure to siblings. ]
> >
> > This patch moves refault detection to the root of reclaim. Instead of
> > remembering the cgroup owner of an evicted page, remember the cgroup
> > that caused the reclaim to happen. When refaults later occur, they'll
> > correctly influence the cross-cgroup LRU order that reclaim follows.
>
> Can you please explain how "they'll correctly influence"? I see that
> if the refaulted page was evicted due to pressure in some ancestor,
> then that's ancestor's refault distance and active file size will be
> used to decide to activate the refaulted page but how that is
> influencing cross-cgroup LRUs?
I take it the next patch answered your question: Activating a page
inside a cgroup has an effect on how it's reclaimed relative to pages
in sibling cgroups. So the influence part isn't new with this change -
it's about recognizing that an activation has an effect on a wider
scope than just the local cgroup, and considering that scope when
making the decision whether to activate or not.
> > @@ -302,6 +330,17 @@ void workingset_refault(struct page *page, void *shadow)
> > */
> > refault_distance = (refault - eviction) & EVICTION_MASK;
> >
> > + /*
> > + * The activation decision for this page is made at the level
> > + * where the eviction occurred, as that is where the LRU order
> > + * during page reclaim is being determined.
> > + *
> > + * However, the cgroup that will own the page is the one that
> > + * is actually experiencing the refault event.
> > + */
> > + memcg = get_mem_cgroup_from_mm(current->mm);
>
> Why not page_memcg(page)? page is locked.
Nice catch! Indeed, the page is charged and locked at this point, so
we don't have to do another lookup and refcounting dance here.
Delta patch:
---
From 8984f37f3e88b1b39c7d6470b313730093b24474 Mon Sep 17 00:00:00 2001
From: Johannes Weiner <hannes@cmpxchg.org>
Date: Fri, 15 Nov 2019 09:14:04 -0500
Subject: [PATCH] mm: vmscan: detect file thrashing at the reclaim root fix
Shakeel points out that the page is locked and already charged by the
time we call workingset_refault(). Instead of doing another cgroup
lookup and reference from current->mm we can simply use page_memcg().
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
---
mm/workingset.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/mm/workingset.c b/mm/workingset.c
index f0885d9f41cd..474186b76ced 100644
--- a/mm/workingset.c
+++ b/mm/workingset.c
@@ -338,7 +338,7 @@ void workingset_refault(struct page *page, void *shadow)
* However, the cgroup that will own the page is the one that
* is actually experiencing the refault event.
*/
- memcg = get_mem_cgroup_from_mm(current->mm);
+ memcg = page_memcg(page);
lruvec = mem_cgroup_lruvec(memcg, pgdat);
inc_lruvec_state(lruvec, WORKINGSET_REFAULT);
@@ -349,7 +349,7 @@ void workingset_refault(struct page *page, void *shadow)
* the memory was available to the page cache.
*/
if (refault_distance > active_file)
- goto out_memcg;
+ goto out;
SetPageActive(page);
advance_inactive_age(memcg, pgdat);
@@ -360,9 +360,6 @@ void workingset_refault(struct page *page, void *shadow)
SetPageWorkingset(page);
inc_lruvec_state(lruvec, WORKINGSET_RESTORE);
}
-
-out_memcg:
- mem_cgroup_put(memcg);
out:
rcu_read_unlock();
}
--
2.24.0
next prev parent reply other threads:[~2019-11-15 16:07 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-07 20:53 [PATCH 0/3] mm: fix page aging across multiple cgroups Johannes Weiner
2019-11-07 20:53 ` [PATCH 1/3] mm: vmscan: move file exhaustion detection to the node level Johannes Weiner
2019-11-10 22:02 ` Suren Baghdasaryan
2019-11-10 22:09 ` Khadarnimcaan Khadarnimcaan
2019-11-07 20:53 ` [PATCH 2/3] mm: vmscan: detect file thrashing at the reclaim root Johannes Weiner
2019-11-11 2:01 ` Suren Baghdasaryan
2019-11-12 17:45 ` Johannes Weiner
2019-11-12 18:45 ` Suren Baghdasaryan
2019-11-12 18:59 ` Johannes Weiner
2019-11-12 20:35 ` Suren Baghdasaryan
2019-11-14 23:47 ` Shakeel Butt
2019-11-15 16:07 ` Johannes Weiner [this message]
2019-11-15 16:52 ` Shakeel Butt
[not found] ` <20191107205334.158354-3-hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org>
2020-02-12 10:28 ` Joonsoo Kim
2020-02-12 10:28 ` Joonsoo Kim
2020-02-12 18:18 ` Johannes Weiner
2020-02-12 18:18 ` Johannes Weiner
[not found] ` <20200212181834.GD180867-druUgvl0LCNAfugRpC6u6w@public.gmane.org>
2020-02-14 1:17 ` Joonsoo Kim
2020-02-14 1:17 ` Joonsoo Kim
2019-11-07 20:53 ` [PATCH 3/3] mm: vmscan: enforce inactive:active ratio " Johannes Weiner
2019-11-11 2:15 ` Suren Baghdasaryan
2019-11-12 18:00 ` Johannes Weiner
2019-11-12 19:13 ` Suren Baghdasaryan
2019-11-12 20:34 ` Suren Baghdasaryan
2019-11-15 0:29 ` Shakeel Butt
2019-11-27 22:16 ` Shakeel Butt
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=20191115160722.GA309754@cmpxchg.org \
--to=hannes@cmpxchg.org \
--cc=akpm@linux-foundation.org \
--cc=aryabinin@virtuozzo.com \
--cc=cgroups@vger.kernel.org \
--cc=kernel-team@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=riel@surriel.com \
--cc=shakeelb@google.com \
--cc=surenb@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.