linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: David Carlier <devnexen@gmail.com>
Cc: David Hildenbrand <david@kernel.org>,
	Kairui Song <kasong@tencent.com>, Chris Li <chrisl@kernel.org>,
	Kemeng Shi <shikemeng@huaweicloud.com>,
	Nhat Pham <nphamcs@gmail.com>, Baoquan He <bhe@redhat.com>,
	Barry Song <baohua@kernel.org>,
	Youngjun Park <youngjun.park@lge.com>,
	NeilBrown <neil@brown.name>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH v2] mm/page_io: fix PSWPIN undercount for large folios in sio_read_complete()
Date: Mon, 30 Mar 2026 15:20:28 -0700	[thread overview]
Message-ID: <20260330152028.fa5a9c8adf19c7904c9c5b63@linux-foundation.org> (raw)
In-Reply-To: <20260330071229.14614-1-devnexen@gmail.com>

On Mon, 30 Mar 2026 08:12:29 +0100 David Carlier <devnexen@gmail.com> 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).

Thanks.  What are the userspace-visible runtime effects of the bug? 
Just /proc/vmstat wrongness?

Seems pretty minor, and it's been in there for several years.  But I
guess I'll slip a cc:stable in there, let it trickle back at a later
time.

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


  reply	other threads:[~2026-03-30 22:20 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-30  7:12 David Carlier
2026-03-30 22:20 ` Andrew Morton [this message]
2026-03-31 22:33 ` Barry Song
2026-04-01  7:10   ` David CARLIER
2026-04-01  7:30     ` David Hildenbrand (Arm)
2026-04-01 20:22     ` Barry Song
2026-04-01  7:47 ` [PATCH v3] mm/page_io: use sio->len for PSWPIN accounting " David Carlier
2026-04-01  8:32   ` David Hildenbrand (Arm)
2026-04-01 22:58     ` Andrew Morton
2026-04-01 23:43   ` Barry Song
2026-04-02  3:07   ` Chris Li
2026-04-02  4:11   ` Matthew Wilcox
2026-04-02  5:51     ` Barry Song
2026-04-02  6:01     ` David CARLIER

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=20260330152028.fa5a9c8adf19c7904c9c5b63@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=baohua@kernel.org \
    --cc=bhe@redhat.com \
    --cc=chrisl@kernel.org \
    --cc=david@kernel.org \
    --cc=devnexen@gmail.com \
    --cc=kasong@tencent.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=neil@brown.name \
    --cc=nphamcs@gmail.com \
    --cc=shikemeng@huaweicloud.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox