From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DA4033E1237 for ; Mon, 30 Mar 2026 22:20:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774909231; cv=none; b=gTR0LvolmzON2l/kQNJM0ddOstVJ2GvBBE0HMrkfm6qmOCrcs8mewBBQY3eYXXOd3ksUXxukqw5LtfvCry12d9/n0qKMoTEnc8mIl4ThGWVuKrk2nLp9FPnnbo3Yc0GFP60pa43wEqGyTcF+uL1nXkMRBCBM942PI2cCUAa11Ys= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774909231; c=relaxed/simple; bh=O38+3wGB1K/Bcl20TaXMCgTluv50pmECdZ6mPiI6auY=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=D9gIYovSIGPiWR+p63vFSBb3jBH5Bp3sf5mzrNBB/2p2rNLuloBLya2FRAnhQDQibY+TLSfg+t0WFujyiyPBqVPWebzrG4nhuL+9OCLDGlR95F7WHzOvAmjexgin5UfWzQVFrhAxRiG0NBQBgL7Ja2zyHBHTn1yhbfceRWT0juE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=GZPwof4m; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="GZPwof4m" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3FF28C2BCB0; Mon, 30 Mar 2026 22:20:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1774909229; bh=O38+3wGB1K/Bcl20TaXMCgTluv50pmECdZ6mPiI6auY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=GZPwof4muIY2wI3sdUX5XsgmMn1DFFsgIwqOMHbDbWxzBJ3VhrEv8sd+AJFQvKU3r 8UykO9lDFsInYxWReaeoSXPjQZZiJz+kiHsXRO3j3pyy1IzN3WQgC1kNCfny9L4EyI qLM16d1ahd6z0nCdjYujxAMTKHeya7gJO/7iffIY= Date: Mon, 30 Mar 2026 15:20:28 -0700 From: Andrew Morton To: David Carlier Cc: David Hildenbrand , Kairui Song , Chris Li , Kemeng Shi , Nhat Pham , Baoquan He , Barry Song , Youngjun Park , NeilBrown , 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() Message-Id: <20260330152028.fa5a9c8adf19c7904c9c5b63@linux-foundation.org> In-Reply-To: <20260330071229.14614-1-devnexen@gmail.com> References: <20260330071229.14614-1-devnexen@gmail.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Mon, 30 Mar 2026 08:12:29 +0100 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). 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 >