From: Zhongkun He <hezhongkun.hzk@bytedance.com>
To: Yosry Ahmed <yosryahmed@google.com>
Cc: Nhat Pham <nphamcs@gmail.com>,
akpm@linux-foundation.org, hannes@cmpxchg.org,
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: Thu, 11 Jan 2024 10:57:00 +0800 [thread overview]
Message-ID: <CACSyD1OHLjM8SRURe4QdY5d=JNPY+ZS_goXOKOxO6nuBzxnoHg@mail.gmail.com> (raw)
In-Reply-To: <CAJD7tkY=zmGiPoWNjVaVeU+NPxV2t48J5-CxEP9=nBK8nAh0XA@mail.gmail.com>
On Wed, Jan 10, 2024 at 12:30 AM Yosry Ahmed <yosryahmed@google.com> wrote:
>
> On Mon, Jan 8, 2024 at 7:13 PM Zhongkun He <hezhongkun.hzk@bytedance.com> wrote:
> >
> > Hi Yosry, glad to hear from you and happy new year!
> >
> > > Sorry for being late to the party. It seems to me that all of this
> > > hassle can be avoided if lru_add_fn() did the right thing in this case
> > > and added the folio to the tail of the lru directly. I am no expert in
> > > how the page flags work here, but it seems like we can do something
> > > like this in lru_add_fn():
> > >
> > > if (folio_test_reclaim(folio))
> > > lruvec_add_folio_tail(lruvec, folio);
> > > else
> > > lruvec_add_folio(lruvec, folio);
> > >
> > > I think the main problem with this is that PG_reclaim is an alias to
> > > PG_readahead, so readahead pages will also go to the tail of the lru,
> > > which is probably not good.
> >
> > Agree with you, I will try it.
>
> +Matthew Wilcox
>
> I think we need to figure out if it's okay to do this first, because
> it will affect pages with PG_readahead as well.
Yes, I've tested it and there is one more thing
that needs to be modified.
+ if (folio_test_reclaim(folio))
+ lruvec_add_folio_tail(lruvec, folio);
+ else
+ lruvec_add_folio(lruvec, folio);
@@ -1583,10 +1583,8 @@ void folio_end_writeback(struct folio *folio)
* a gain to justify taking an atomic operation penalty at the
* end of every folio writeback.
*/
- if (folio_test_reclaim(folio)) {
+ if (folio_test_reclaim(folio) && folio_rotate_reclaimable(folio))
folio_clear_reclaim(folio);
- folio_rotate_reclaimable(folio);
- }
-void folio_rotate_reclaimable(struct folio *folio)
+bool folio_rotate_reclaimable(struct folio *folio)
{
if (success)
+ return true;
}
+ return false;
}
>
> >
> > >
> > > A more intrusive alternative is to introduce a folio_lru_add_tail()
> > > variant that always adds pages to the tail, and optionally call that
> > > from __read_swap_cache_async() instead of folio_lru_add() based on a
> > > new boolean argument. The zswap code can set that boolean argument
> > > during writeback to make sure newly allocated folios are always added
> > > to the tail of the lru.
> >
> > I have the same idea and also find it intrusive. I think the first solution
> > is very good and I will try it. If it works, I will send the next version.
>
> One way to avoid introducing folio_lru_add_tail() and blumping a
> boolean from zswap is to have a per-task context (similar to
> memalloc_nofs_save()), that makes folio_add_lru() automatically add
> folios to the tail of the LRU. I am not sure if this is an acceptable
> approach though in terms of per-task flags and such.
I got it.
next prev parent reply other threads:[~2024-01-11 2:57 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
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 [this message]
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='CACSyD1OHLjM8SRURe4QdY5d=JNPY+ZS_goXOKOxO6nuBzxnoHg@mail.gmail.com' \
--to=hezhongkun.hzk@bytedance.com \
--cc=akpm@linux-foundation.org \
--cc=chrisl@kernel.org \
--cc=ddstreet@ieee.org \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=nphamcs@gmail.com \
--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