linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "David Hildenbrand (Arm)" <david@kernel.org>
To: David Carlier <devnexen@gmail.com>,
	Kairui Song <kasong@tencent.com>, Chris Li <chrisl@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Kemeng Shi <shikemeng@huaweicloud.com>
Cc: linux-mm@kvack.org
Subject: Re: [PATCH] mm/page_io: fix PSWPIN undercount for large folios in sio_read_complete()
Date: Mon, 30 Mar 2026 08:37:53 +0200	[thread overview]
Message-ID: <9c0ae600-d73b-4e7b-90ec-4f858c665d80@kernel.org> (raw)
In-Reply-To: <20260323231315.240137-1-devnexen@gmail.com>

Hi,

please don't send patches a reply to other patches.

On 3/24/26 00:13, David Carlier wrote:
> 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. 
> For large folios this undercounts compared to the per-memcg path
> which correctly uses folio_nr_pages(), and compared to the bdev read
> paths which also use 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).


> 
> Fixes: 6a8c068774ad ("mm/page_io: use a folio in sio_read_complete()")

Is that commit really to blame? I don't see how that one would cause it.
It would rather be the code that actually made more than one page be
represented in a single entry.

Is maybe a1a0dfd56f97 ("mm: handle THP in swap_*page_fs()") to blame?

> 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);



-- 
Cheers,

David


      reply	other threads:[~2026-03-30  6:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-23 17:04 [PATCH] mm/page_io: use folios in sio_write_complete() David Carlier
2026-03-23 22:54 ` Andrew Morton
2026-03-23 23:07   ` David CARLIER
2026-03-23 23:13 ` [PATCH] mm/page_io: fix PSWPIN undercount for large folios in sio_read_complete() David Carlier
2026-03-30  6:37   ` David Hildenbrand (Arm) [this message]

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=9c0ae600-d73b-4e7b-90ec-4f858c665d80@kernel.org \
    --to=david@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=chrisl@kernel.org \
    --cc=devnexen@gmail.com \
    --cc=kasong@tencent.com \
    --cc=linux-mm@kvack.org \
    --cc=shikemeng@huaweicloud.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