linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Nhat Pham <nphamcs@gmail.com>
To: Zhongkun He <hezhongkun.hzk@bytedance.com>
Cc: akpm@linux-foundation.org, hannes@cmpxchg.org,
	yosryahmed@google.com,  sjenning@redhat.com, ddstreet@ieee.org,
	vitaly.wool@konsulko.com,  linux-mm@kvack.org,
	linux-kernel@vger.kernel.org,  Chris Li <chrisl@kernel.org>,
	weijie.yang@samsung.com
Subject: Re: [External] Re: [PATCH] mm: zswap: fix the lack of page lru flag in zswap_writeback_entry
Date: Sun, 7 Jan 2024 13:59:43 -0800	[thread overview]
Message-ID: <CAKEwX=Oj2dR6a4-DeccvcVdJ-J7b=83uCWQAf5u7U0sySudnkw@mail.gmail.com> (raw)
In-Reply-To: <CAKEwX=NuXR9Ot1eRFsp9n-3Tq9yhjD9up+jyvXeOzQ4xK9kEPA@mail.gmail.com>

On Sun, Jan 7, 2024 at 1:29 PM Nhat Pham <nphamcs@gmail.com> wrote:
>
> On Fri, Jan 5, 2024 at 6:10 AM Zhongkun He <hezhongkun.hzk@bytedance.com> wrote:
> >
> > > > There is another option here, which is not to move the page to the
> > > > tail of the inactive
> > > > list after end_writeback and delete the following code in
> > > > zswap_writeback_entry(),
> > > > which did not work properly. But the pages will not be released first.
> > > >
> > > > /* move it to the tail of the inactive list after end_writeback */
> > > > SetPageReclaim(page);
>
>
> Ok, so I took a look at the patch that originally introduced this
> piece of logic:
>
> https://github.com/torvalds/linux/commit/b349acc76b7f65400b85abd09a5379ddd6fa5a97
>
> Looks like it's not for the sake of correctness, but only as a
> best-effort optimization (reducing page scanning). If it doesn't bring
> any benefit (i.e due to the newly allocated page still on the cpu
> batch), then we can consider removing it. After all, if you're right
> and it's not really doing anything here - why bother. Perhaps we can
> replace this with some other mechanism to avoid it being scanned for
> reclaim.

For instance, we can grab the local lock, look for the folio in the
add batch and take the folio off it, then add it to the rotate batch
instead? Not sure if this is doable within folio_rotate_reclaimable(),
or you'll have to manually perform this yourself (and remove the
PG_reclaim flag set here so that folio_end_writeback() doesn't try to
handle it).

There is still some overhead with this, but at least we don't have to
*drain everything* (which looks like what's lru_add_drain() ->
lru_add_drain_cpu() is doing). The latter sounds expensive and
unnecessary, whereas this is just one element addition and one element
removal - and if IIUC the size of the per-cpu add batch is capped at
15, so lookup + removal (if possible) shouldn't be too expensive?

Just throwing ideas out there :)

>
> I would cc Weijie as well, as he is the original author of this.


  reply	other threads:[~2024-01-07 21:59 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-24 14:27 Zhongkun He
2023-12-29 19:44 ` Andrew Morton
2023-12-30  2:09 ` Nhat Pham
2024-01-02 11:39   ` [External] " Zhongkun He
2024-01-02 14:09     ` Zhongkun He
2024-01-02 23:27     ` Nhat Pham
2024-01-03 14:12       ` Zhongkun He
2024-01-04 19:42         ` Nhat Pham
2024-01-05 14:10           ` Zhongkun He
2024-01-07 18:53             ` Nhat Pham
2024-01-07 21:29             ` Nhat Pham
2024-01-07 21:59               ` Nhat Pham [this message]
2024-01-08 23:12                 ` Yosry Ahmed
2024-01-09  3:13                   ` Zhongkun He
2024-01-09 16:29                     ` Yosry Ahmed
2024-01-10  1:32                       ` Nhat Pham
2024-01-11  3:48                         ` Zhongkun He
2024-01-11 11:27                           ` Yosry Ahmed
2024-01-11 19:25                           ` Nhat Pham
2024-01-12  7:08                             ` Zhongkun He
2024-01-16 13:40                               ` Zhongkun He
2024-01-16 20:28                                 ` Yosry Ahmed
2024-01-17  9:52                                   ` Zhongkun He
2024-01-17 17:53                                     ` Yosry Ahmed
2024-01-17 19:29                                     ` Nhat Pham
2024-01-16 21:03                                 ` Matthew Wilcox
2024-01-17 10:41                                   ` Zhongkun He
2024-01-11  2:57                       ` Zhongkun He
2024-01-09  2:43                 ` Zhongkun He

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=Oj2dR6a4-DeccvcVdJ-J7b=83uCWQAf5u7U0sySudnkw@mail.gmail.com' \
    --to=nphamcs@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=chrisl@kernel.org \
    --cc=ddstreet@ieee.org \
    --cc=hannes@cmpxchg.org \
    --cc=hezhongkun.hzk@bytedance.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=sjenning@redhat.com \
    --cc=vitaly.wool@konsulko.com \
    --cc=weijie.yang@samsung.com \
    --cc=yosryahmed@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