public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 1/2] mm/page_io: use sio->len for PSWPIN accounting in sio_read_complete()
@ 2026-04-02  6:14 David Carlier
  2026-04-02  6:14 ` [PATCH v4 2/2] mm/page_io: rename swap_iocb->pages to swap_iocb->bvecs David Carlier
  2026-04-02  7:12 ` [PATCH v4 1/2] mm/page_io: use sio->len for PSWPIN accounting in sio_read_complete() David Hildenbrand (Arm)
  0 siblings, 2 replies; 5+ messages in thread
From: David Carlier @ 2026-04-02  6:14 UTC (permalink / raw)
  To: David Hildenbrand, Kairui Song, Chris Li, Andrew Morton,
	Kemeng Shi, Nhat Pham, Baoquan He, Youngjun Park, NeilBrown
  Cc: linux-kernel, linux-mm, David Carlier

sio_read_complete() uses sio->pages to account global PSWPIN vm events,
but sio->pages tracks the number of bvec entries (folios), not base
pages.

While large folios cannot currently reach this path (SWP_FS_OPS and
SWP_SYNCHRONOUS_IO are mutually exclusive, and mTHP swap-in allocation
is gated on SWP_SYNCHRONOUS_IO), the accounting is semantically
inconsistent with the per-memcg path which correctly uses
folio_nr_pages().

Use sio->len >> PAGE_SHIFT instead, which gives the correct base page
count since sio->len is accumulated via folio_size(folio).

Signed-off-by: David Carlier <devnexen@gmail.com>
---
 mm/page_io.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/page_io.c b/mm/page_io.c
index 63b262f4c5a9..1389cd57ca88 100644
--- a/mm/page_io.c
+++ b/mm/page_io.c
@@ -497,7 +497,7 @@ static void sio_read_complete(struct kiocb *iocb, long ret)
 			folio_mark_uptodate(folio);
 			folio_unlock(folio);
 		}
-		count_vm_events(PSWPIN, sio->pages);
+		count_vm_events(PSWPIN, sio->len >> PAGE_SHIFT);
 	} else {
 		for (p = 0; p < sio->pages; p++) {
 			struct folio *folio = page_folio(sio->bvec[p].bv_page);
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-04-02  7:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-02  6:14 [PATCH v4 1/2] mm/page_io: use sio->len for PSWPIN accounting in sio_read_complete() David Carlier
2026-04-02  6:14 ` [PATCH v4 2/2] mm/page_io: rename swap_iocb->pages to swap_iocb->bvecs David Carlier
2026-04-02  7:15   ` David Hildenbrand (Arm)
2026-04-02  7:19     ` David CARLIER
2026-04-02  7:12 ` [PATCH v4 1/2] mm/page_io: use sio->len for PSWPIN accounting in sio_read_complete() David Hildenbrand (Arm)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox