From: Nhat Pham <nphamcs@gmail.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: akpm@linux-foundation.org, hannes@cmpxchg.org,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
bfoster@redhat.com, arnd@arndb.de, linux-api@vger.kernel.org,
kernel-team@meta.com
Subject: Re: [PATCH v10 1/3] workingset: refactor LRU refault to expose refault recency check
Date: Tue, 21 Feb 2023 00:49:00 -0800 [thread overview]
Message-ID: <CAKEwX=NfD-57zAgXBoCVFVHu_TDbbnng3piZTu7iGjALpj=Tug@mail.gmail.com> (raw)
In-Reply-To: <Y/IQlWdD1NvcUROv@casper.infradead.org>
On Sun, Feb 19, 2023 at 4:05 AM Matthew Wilcox <willy@infradead.org> wrote:
>
> On Sat, Feb 18, 2023 at 11:33:16PM -0800, Nhat Pham wrote:
> > +++ b/mm/workingset.c
> > @@ -244,6 +244,30 @@ static void *lru_gen_eviction(struct folio *folio)
> > return pack_shadow(mem_cgroup_id(memcg), pgdat, token, refs);
> > }
> >
> > +/*
> > + * Test if the folio is recently evicted.
> > + *
> > + * As a side effect, also populates the references with
> > + * values unpacked from the shadow of the evicted folio.
> > + */
>
> I find this comment hard to understand. First it talks about "the
> folio", but it doesn't pass a folio. Then it talks about "the
> references", but I don't have any idea what those are either.
>
> I think what you mean is,
>
> * Test if the shadow entry is for a folio which was recently evicted.
> * Fills in @memcgid, @pgdat, @token and @workingset with values
> * extracted from the shadow entry.
I'll fix this comment in the next version. Thanks for the suggestion!
>
> > +static bool lru_gen_test_recent(void *shadow, bool file, int *memcgid,
> > + struct pglist_data **pgdat, unsigned long *token, bool *workingset)
> > +{
> > + struct mem_cgroup *eviction_memcg;
> > + struct lruvec *lruvec;
> > + struct lru_gen_struct *lrugen;
> > + unsigned long min_seq;
> > +
> > + unpack_shadow(shadow, memcgid, pgdat, token, workingset);
> > + eviction_memcg = mem_cgroup_from_id(*memcgid);
> > +
> > + lruvec = mem_cgroup_lruvec(eviction_memcg, *pgdat);
> > + lrugen = &lruvec->lrugen;
> > +
> > + min_seq = READ_ONCE(lrugen->min_seq[file]);
> > + return (*token >> LRU_REFS_WIDTH) == (min_seq & (EVICTION_MASK >> LRU_REFS_WIDTH));
> > +}
>
> [...]
>
> > +/*
> > + * Test if the folio is recently evicted by checking if
> > + * refault distance of shadow exceeds workingset size.
> > *
> > - * Calculates and evaluates the refault distance of the previously
> > - * evicted folio in the context of the node and the memcg whose memory
> > - * pressure caused the eviction.
> > + * As a side effect, populate workingset with the value
> > + * unpacked from shadow.
> > */
>
> 1. Shouldn't this be kernel-doc?
Hmm good point...
> 2. Again, don't use the term "side effect" here. It's just one of
> the things that the function _does_.
>
I'll fix this! Thanks for pointing it out.
next prev parent reply other threads:[~2023-02-21 8:49 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-19 7:33 [PATCH v10 0/3] cachestat: a new syscall for page cache state of files Nhat Pham
2023-02-19 7:33 ` [PATCH v10 1/3] workingset: refactor LRU refault to expose refault recency check Nhat Pham
2023-02-19 12:05 ` Matthew Wilcox
2023-02-21 8:49 ` Nhat Pham [this message]
2023-02-19 7:33 ` [PATCH v10 2/3] cachestat: implement cachestat syscall Nhat Pham
2023-02-19 9:44 ` kernel test robot
2023-02-19 9:45 ` kernel test robot
2023-02-19 9:45 ` kernel test robot
2023-02-19 10:36 ` kernel test robot
2023-02-19 12:21 ` Matthew Wilcox
2023-03-03 6:55 ` Nhat Pham
2023-03-03 7:03 ` Matthew Wilcox
2023-03-05 10:24 ` Nhat Pham
2023-03-05 10:32 ` Nhat Pham
2023-02-19 7:33 ` [PATCH v10 3/3] selftests: Add selftests for cachestat Nhat Pham
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='CAKEwX=NfD-57zAgXBoCVFVHu_TDbbnng3piZTu7iGjALpj=Tug@mail.gmail.com' \
--to=nphamcs@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=bfoster@redhat.com \
--cc=hannes@cmpxchg.org \
--cc=kernel-team@meta.com \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=willy@infradead.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