All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Kairui Song <ryncsn@gmail.com>
Cc: Christoph Hellwig <hch@lst.de>,
	baoquan.he@linux.dev, akpm@linux-foundation.org,
	chrisl@kernel.org, usama.arif@linux.dev, kasong@tencent.com,
	nphamcs@gmail.com, shikemeng@huaweicloud.com,
	youngjun.park@lge.com, linux-mm@kvack.org
Subject: Re: [PATCH 3/7] mm/swap: also use struct swap_iocb for block I/O
Date: Thu, 16 Jul 2026 14:19:53 +0200	[thread overview]
Message-ID: <20260716121953.GA28985@lst.de> (raw)
In-Reply-To: <alZ0fgRSy0RpHxcT@KASONG-MC4>

On Thu, Jul 16, 2026 at 12:03:22AM +0800, Kairui Song wrote:
> > -static void sio_write_complete(struct kiocb *iocb, long ret)
> > +static bool swap_can_merge(struct swap_io_ctx *ctx, struct folio *folio,
> > +		int rw)
> 
> Will a bool rw suits better?

Not really.  Bools as arguents always have the downside that it is
really hard to guess what they mean based on the callsite.

While READ/WRITE really should be enum, it's probably the best we have
right now.

> > -	bio_add_folio_nofail(&bio, folio, folio_size(folio), 0);
> 
> bio_add_folio_nofail also increased bi_vcnt, now it's open coded and
> bi_vcnt stays zero, it's not used right now, could there be any user
> of it in the future?

bi_vcnt only exists to assist bio_add_page*/bio_add_folio*. So if we
assign the bio_vecs manually we don't need it.  If we ever switch
to using bio_add_folio_nofail we'd need it, but then we'd already
maintain it in there :)

> So this removes swap_writepage_bdev_sync (which was calling submit_bio_wait),
> we are replying on a later swap_write_submit, and just add the folio to ctx.

For SWP_SYNCHRONOUS_IO, yes.

> Before the series, pageout will detect for writeback finished and clean
> pages under PAGE_SUCCESS, if the IO of a page is done and writeback flag
> cleaned, the page get released immediately. But now, almost all pages
> will be put back to the LRU waiting for rotation. This also make the
> reclaim have a stronger bias towards reclaim files, and anon reclaim
> become less effective.
> 
> I do observe a real performance regression with classical LRU and ZRAM,
> ordinary swap seems also very slightly effected but could be noise,
> test is done on my laptop by building the kernel using make -j12 and
> tinyconfig in a 2G VM with mild pressure:

> Before this series (with 8G ZRAM only):
> 175.39user 125.89system 0:40.54elapsed
> 26581840inputs+0outputs (1186391major+22698964minor)pagefaults
> 
> After this sereis:
> 165.59user 216.02system 1:04.06elapsed <- the problemic one.
> 53531464inputs+0outputs (2550441major+31974007minor)pagefaults
> 
> Because all anon folios will be derfer freed on next iteration of the LRU,
> which caused a much higher memory pressure.

So this is zswap which does set SWP_SYNCHRONOUS_IO.  I guess forcing
a submit after each bio_vec for SWP_SYNCHRONOUS_IO might make some
sense as a workaround, although it is a bit ugly.



  reply	other threads:[~2026-07-16 14:49 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-13  9:33 better block swap batching and a different take on swap_ops v5 Christoph Hellwig
2026-07-13  9:33 ` [PATCH 1/7] shmem: provide a shmem_write_folio wrapper Christoph Hellwig
2026-07-14 17:27   ` Kairui Song
2026-07-13  9:33 ` [PATCH 2/7] mm/swap: introduce struct swap_io_ctx Christoph Hellwig
2026-07-14  1:26   ` Baoquan He
2026-07-14  5:06     ` Christoph Hellwig
2026-07-13  9:33 ` [PATCH 3/7] mm/swap: also use struct swap_iocb for block I/O Christoph Hellwig
2026-07-15 16:03   ` Kairui Song
2026-07-16 12:19     ` Christoph Hellwig [this message]
2026-07-16 17:02       ` Kairui Song
2026-07-13  9:33 ` [PATCH 4/7] mm/swap: remove count_swpout_vm_event Christoph Hellwig
2026-07-13  9:33 ` [PATCH 5/7] mm/swap: use swap_ops to register swap device's methods Christoph Hellwig
2026-07-13  9:33 ` [PATCH 6/7] mm/swap: remove SWP_FS_OPS Christoph Hellwig
2026-07-13  9:33 ` [PATCH 7/7] mm/vmstat: add NRSWP{IN,OUT} counters Christoph Hellwig
2026-07-13 20:13 ` better block swap batching and a different take on swap_ops v5 Andrew Morton
2026-07-14  5:12   ` Christoph Hellwig
  -- strict thread matches above, loose matches on Subject: below --
2026-07-10  6:39 better block swap batching and a different take on swap_ops v4 Christoph Hellwig
2026-07-10  6:39 ` [PATCH 3/7] mm/swap: also use struct swap_iocb for block I/O Christoph Hellwig
2026-07-06 13:21 better block swap batching and a different take on swap_ops v3 Christoph Hellwig
2026-07-06 13:21 ` [PATCH 3/7] mm/swap: also use struct swap_iocb for block I/O Christoph Hellwig

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=20260716121953.GA28985@lst.de \
    --to=hch@lst.de \
    --cc=akpm@linux-foundation.org \
    --cc=baoquan.he@linux.dev \
    --cc=chrisl@kernel.org \
    --cc=kasong@tencent.com \
    --cc=linux-mm@kvack.org \
    --cc=nphamcs@gmail.com \
    --cc=ryncsn@gmail.com \
    --cc=shikemeng@huaweicloud.com \
    --cc=usama.arif@linux.dev \
    --cc=youngjun.park@lge.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.