Re: [PATCH v3 2/3] mm: swap: drop dropbehind swap cache folios on writeback completion

Barry Song <[email protected]>
Newsgroups org.kernel.vger.linux-fsdevel,org.kernel.vger.linux-kernel,org.kvack.linux-mm
Message-ID <CAGsJ_4yb_5803vALp9YMHXRsTcqkDuXfGFLMcxpNDQXoqnsPWw@mail.gmail.com>
On Thu, Aug 20, 2026 at 11:38 PM Matthew Wilcox <[email protected]> wrote:
>
> On Thu, Aug 20, 2026 at 07:36:42PM +0800, Barry Song wrote:
> > > +void swap_writeback_dropbehind_folio(struct folio *folio)
> > > +{
> > > +       llist_add((struct llist_node *)&folio->lru,
> > > +                 raw_cpu_ptr(&swap_dropbehind_llist));
> > > +       queue_work(swap_dropbehind_wq, &swap_dropbehind_work);
> > > +}
> > > +
> >
> > This is good. For file dropbehind, I see both F2FS [1] and block
> > devices [2] reinventing workqueues in their own filesystems or
> > drivers, while folio_end_dropbehind() simply benefits from its safe,
> > sleepable context. This seems a bit odd.
> >
> > So I'm really curious whether this could be extended to file-backed
> > folios as well, so that those filesystems and device drivers don't
> > have to deal with this themselves.
>
> You should probably both be aware of Tal's series:
>
> https://lore.kernel.org/linux-mm/[email protected]/

Yes, thanks. I even asked a question there, but nobody has answered it yet. :-)

https://lore.kernel.org/linux-mm/CAGsJ_4wUvLoKGafR3U-ji1kUUaz6K_QdN6QxMT-apSaO5tXp0A@mail.gmail.com/

>
> In fact, I'd base this series on Tal's.  It would be considerably
> easier.

I assume there are two things which might be helpful?
1.  bio_in_atomic() helper
2.  bio_set_flag(bio, BIO_COMPLETE_IN_TASK);

Then, if this flag is set, we move the bio completion to a workqueue.
Right now,  Alexandre's approach is moving the folio dropbehind to workqueue
but not moving bio completion to workqueue.

+ if (swap_dropbehind) {
+     swap_writeback_dropbehind_folio(folio);
+     return;
+ }

Not sure which approach is better, but moving bio completion to a
workqueue seems to have less coupling with the LRU and related code.

Maybe we can reuse Tal's code, for example, bio_complete_in_task()?
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.