From: Yosry Ahmed <yosryahmed@google.com>
To: Johannes Weiner <hannes@cmpxchg.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Michal Hocko <mhocko@kernel.org>,
Roman Gushchin <roman.gushchin@linux.dev>,
Shakeel Butt <shakeelb@google.com>,
Muchun Song <songmuchun@bytedance.com>,
Greg Thelen <gthelen@google.com>,
David Rientjes <rientjes@google.com>,
Cgroups <cgroups@vger.kernel.org>, Linux-MM <linux-mm@kvack.org>
Subject: Re: [PATCH] mm/vmscan: check references from all memcgs for swapbacked memory
Date: Wed, 5 Oct 2022 08:55:31 -0700 [thread overview]
Message-ID: <CAJD7tkYc2hTdOXedjfK60=Q=HAbHp6ch5cLH=C3GDakc6MdBmA@mail.gmail.com> (raw)
In-Reply-To: <Yz2oAjIRZKKwe8tY@cmpxchg.org>
On Wed, Oct 5, 2022 at 8:51 AM Johannes Weiner <hannes@cmpxchg.org> wrote:
>
> On Wed, Oct 05, 2022 at 07:54:25AM -0700, Yosry Ahmed wrote:
> > On Wed, Oct 5, 2022 at 7:04 AM Johannes Weiner <hannes@cmpxchg.org> wrote:
> > > Would you mind moving this to folio_referenced() directly? There is
> > > already a comment and branch in there that IMO would extend quite
> > > naturally to cover the new exception:
> > >
> > > /*
> > > * If we are reclaiming on behalf of a cgroup, skip
> > > * counting on behalf of references from different
> > > * cgroups
> > > */
> > > if (memcg) {
> > > rwc.invalid_vma = invalid_folio_referenced_vma;
> > > }
> > >
> > > That would keep the decision-making and doc in one place.
> >
> > Hi Johannes,
> >
> > Thanks for taking a look!
> >
> > I originally wanted to make the change in folio_referenced(). My only
> > concern was that it wouldn't be clear for people looking at reclaim
> > code in mm/vmscan.c. It would appear as if we are passing in the
> > target memcg to folio_referenced(), and only if you look within you
> > would realize that sometimes it ignores the passed memcg.
> >
> > It seemed to me that deciding whether we want to check references from
> > one memcg or all of them is a reclaim decision, while
> > folio_referenced() is just an rmap API that does what it is told: "if
> > I am passed a memcg, I only look at references coming from this
> > memcg". On the other hand, it looks like the doc has always lived in
> > folio_referenced()/page_referenced(), so I might be overthinking this
> > (I have been known to do this).
>
> I agree it would be nicer to have this policy in vmscan.c. OTOH it's a
> policy that applies to all folio_referenced() callers, and it's
> fragile to require them to opt into it individually.
>
> Vmscan is the only user of the function, so it's not the worst thing
> to treat it as an extension of the reclaim code.
>
> If it helps convince you, there is another, actually quite similar
> reclaim policy already encoded in folio_referenced():
>
> if (ptep_clear_flush_young_notify(vma, address,
> pvmw.pte)) {
> /*
> * Don't treat a reference through
> * a sequentially read mapping as such.
> * If the folio has been used in another mapping,
> * we will catch it; if this other mapping is
> * already gone, the unmap path will have set
> * the referenced flag or activated the folio.
> */
> if (likely(!(vma->vm_flags & VM_SEQ_READ)))
> referenced++;
> }
Thanks for clarifying. Will send v2 later today :)
prev parent reply other threads:[~2022-10-05 15:56 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-04 23:34 Yosry Ahmed
2022-10-05 2:11 ` Yosry Ahmed
2022-10-05 14:04 ` Johannes Weiner
2022-10-05 14:54 ` Yosry Ahmed
2022-10-05 15:51 ` Johannes Weiner
2022-10-05 15:55 ` Yosry Ahmed [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='CAJD7tkYc2hTdOXedjfK60=Q=HAbHp6ch5cLH=C3GDakc6MdBmA@mail.gmail.com' \
--to=yosryahmed@google.com \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=gthelen@google.com \
--cc=hannes@cmpxchg.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=rientjes@google.com \
--cc=roman.gushchin@linux.dev \
--cc=shakeelb@google.com \
--cc=songmuchun@bytedance.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