Skip to content

Commit df620ec

Browse files
devnexenakpm00
authored andcommitted
mm/page_io: use sio->len for PSWPIN accounting in sio_read_complete()
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). Link: https://lore.kernel.org/20260402061408.36119-1-devnexen@gmail.com Signed-off-by: David Carlier <devnexen@gmail.com> Acked-by: David Hildenbrand (Arm) <david@kernel.org> Cc: Baoquan He <bhe@redhat.com> Cc: Chris Li <chrisl@kernel.org> Cc: Kairui Song <kasong@tencent.com> Cc: Kemeng Shi <shikemeng@huaweicloud.com> Cc: NeilBrown <neil@brown.name> Cc: Nhat Pham <nphamcs@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent cfe9a44 commit df620ec

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

mm/page_io.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ static void sio_read_complete(struct kiocb *iocb, long ret)
497497
folio_mark_uptodate(folio);
498498
folio_unlock(folio);
499499
}
500-
count_vm_events(PSWPIN, sio->pages);
500+
count_vm_events(PSWPIN, sio->len >> PAGE_SHIFT);
501501
} else {
502502
for (p = 0; p < sio->pages; p++) {
503503
struct folio *folio = page_folio(sio->bvec[p].bv_page);

0 commit comments

Comments
 (0)