linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Yosry Ahmed <yosryahmed@google.com>
To: Zhongkun He <hezhongkun.hzk@bytedance.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>,
	Michal Hocko <mhocko@kernel.org>
Subject: Re: [External] Re: [PATCH] mm: zswap: fix the lack of page lru flag in zswap_writeback_entry
Date: Tue, 16 Jan 2024 12:28:46 -0800	[thread overview]
Message-ID: <CAJD7tkbfe5duVhN7kJhkQZLCbK48giVZ8LBx=RQDmp80oa2FDA@mail.gmail.com> (raw)
In-Reply-To: <CACSyD1Np1JbKB9punaigGbJ7y2ZWou1Sr7bczanHv4-1UQZ==A@mail.gmail.com>

On Tue, Jan 16, 2024 at 5:40 AM Zhongkun He
<hezhongkun.hzk@bytedance.com> wrote:
>
> > > > >
> > > > > Unless some page flag/readahead expert can confirm that the first
> > > > > option is safe, my vote is on this option. I mean, it's fairly minimal
> > > > > codewise, no? Just a bunch of plumbing. We can also keep the other
> > > > > call sites intact if we just rename the old versions - something along
> > > > > the line of:
> > > > >
> > > > > __read_swap_cache_async_head(..., bool add_to_lru_head)
> > > > > {
> > > > > ...
> > > > > if (add_to_lru_head)
> > > > >   folio_add_lru(folio)
> > > > > else
> > > > >   folio_add_lru_tail(folio);
> > > > > }
> > > > >
> > > > > __read_swap_cache_async(...)
> > > > > {
> > > > >    return __read_swap_cache_async_tail(..., true);
> > > > > }
> > > > >
> > > > > A bit boilerplate? Sure. But this seems safer, and I doubt it's *that*
> > > > > much more work.
> > > > >
> > > >
> > > > Yes, agree. I will try it again.
> > >
> > > Look forward to seeing it! Thanks for your patience and for working on this.
>
> Please forgive me for adding additional information about this patch.
>
> I have finished the opt for introducing a folio_add_lru_tail(), but
> there are many
> questions:
> 1) A new page can be move to LRU only by lru_add_fn, so
>     folio_add_lru_tail could not add pages to LRU for the following code
>     in folio_batch_move_lru(),which is added by Alex Shi for
>     serializing memcg changes in pagevec_lru_move_fn[1].
>
> /* block memcg migration while the folio moves between lru */
>         if (move_fn != lru_add_fn && !folio_test_clear_lru(folio))
>             continue;
> To achieve the goal, we need to add a new function like  lru_add_fn
> which does not have the lru flag and folio_add_lru_tail()
> +               if (move_fn != lru_add_fn && move_fn != lru_move_tail_fn_new &&
> +                       !folio_test_clear_lru(folio))
>
> 2)  __read_swap_cache_async has six parameters, so there is no space to
> add a new one, add_to_lru_head.
>
> So it seems a bit hacky just for a special case for the reasons above.

It's a lot of plumbing for sure. Adding a flag to current task_struct
is a less-noisy yet-still-hacky solution. I am not saying we should do
it, but it's an option. I am not sure how much task flags we have to
spare.

>
> Back to the beginning,  lru_add_drain() is the simplest option,which is common
> below the __read_swap_cache_async(). Please see the function
> swap_cluster_readahead()
> and swap_vma_readahead(), of course it has been batched.
>
> Or we should  leave this problem alone,before we can write back zswap
> in batches.

Calling lru_add_drain() for every written back page is an overkill
imo. If we have writeback batching at some point, it may make more
sense then.

Adding Michal Hocko was recently complaining [1] about lru_add_drain()
being called unnecessarily elsewhere.

[1]https://lore.kernel.org/linux-mm/ZaD9BNtXZfY2UtVI@tiehlicka/


  reply	other threads:[~2024-01-16 20:29 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 [this message]
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='CAJD7tkbfe5duVhN7kJhkQZLCbK48giVZ8LBx=RQDmp80oa2FDA@mail.gmail.com' \
    --to=yosryahmed@google.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=mhocko@kernel.org \
    --cc=nphamcs@gmail.com \
    --cc=sjenning@redhat.com \
    --cc=vitaly.wool@konsulko.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