From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=115.124.30.112 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796196572; b=XNeTt86tNDkNegkyVF0UxOBEh+T4tokeSsaj39uqiyxnnuI+yQBpvtmzqCfZSq7wwblQ mevLVV8F0SpnBy6euoUQbi/JVOt9zNtwHqXGFCvjYHVTKVlKfbOuPGMwwCI6mpZpuLtgc M68two1ogZeVxn4kJ+jlc4sXLqUzelOgLMC7aMwZLj3xK1LBG0o918hGbRbpVx+7fCIWN uxCc4oawr1N1Lsj0O2cD4Mf/H6BVH1p1OeBjfs0Ueso0c7evNEuzWocRZkoLw98lornw6 AEsqHqZXtmvdKXrh6utSEwx1SW+ZajNxIuQx2qteD4tdtz+h/PwXzFivqKaQKsVIfQg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796196572; h=DMARC-Filter:DKIM-Signature:X-Alimail-AntiSpam:Received:Message-ID: Date:MIME-Version:User-Agent:Subject:To:Cc:References:From: In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=xAeVQPXuzyV0X79lFkXPVtzT0DtarNilaY89SeHqtWY=; b=YansuTowEPFV3rGQpujXgUU/5ls/R+JjFkTQcyz+PbrRBBIXoL6Gr1c/8cpmFuhjnWjl fihzvGkqtNmwpGkFpnbFrXteK0+nLIiwDp9b1XtMn7JM4LfcwIrMNQZQx+KWNFhBh53DP jZt1OCONFXim3ZmHOV4sX1+d7B0tiiSDPfuJ6T7ICV3ruPranZwKlgSd4h3MxtDvImRFE 0n6K4J/LUUDFGxcAJD1tRzDl2XSsVvo/rneU0MPe+528f3aFPF7BjHDjkHUrotHXTf7Z/ 1JAOlBzKHPjaLzjZ6d+3mCAbinQjIimkS4yb84vK7epURZ/N0swOAMPd4u+sMCNaMkQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=WMyQxmZD; arc=none smtp.remote-ip=115.124.30.112 Received: from out30-112.freemail.mail.aliyun.com (out30-112.freemail.mail.aliyun.com [115.124.30.112]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6194D606A31A; Wed, 2 Dec 2026 07:29:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6194D606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=WMyQxmZD DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1796196568; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=xAeVQPXuzyV0X79lFkXPVtzT0DtarNilaY89SeHqtWY=; b=WMyQxmZDl7evi2U0UyTBtx48XuA7FPHpzd+k8K/9cae5P3F761cH7JF0YrGvivXPq14mcVB2aBmA5TeRFN7LbL5D3G/WX7OObqGdhRgT1e8iHI2zEpwYMGJlVbKPjdQhYhBVnhWIaj2JFrzSEXNFQnu56hrZJkbs0glnYedcKnQ= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R161e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033037033178;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=80;SR=0;TI=SMTPD_---0XG87DUL_1796196559; Received: from 30.74.144.133(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0XG87DUL_1796196559 cluster:ay36) by smtp.aliyun-inc.com; Wed, 02 Dec 2026 15:29:23 +0800 Message-ID: <18f0d812-ed97-437b-8afb-54a55ca08850@linux.alibaba.com> Date: Wed, 2 Dec 2026 15:29:18 +0800 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 01/32] mm/shmem: count only the swapped pages in the requested range To: "David Hildenbrand (Arm)" , Hugh Dickins , Andrew Morton , Mike Rapoport , Peter Xu , Michal Hocko , Kiryl Shutsemau , Manfred Spraul , Davidlohr Bueso , Cyrill Gorcunov , Zi Yan , "Liam R. Howlett" , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Usama Arif , Lorenzo Stoakes , Rik van Riel , Vlastimil Babka , Harry Yoo , Jann Horn , Yang Shi , Zach O'Keefe , Song Liu , David Stevens , Kefeng Wang , Alex Williamson , Suren Baghdasaryan , Dave Jiang , Matthew Wilcox , Miaohe Lin , David Rientjes , Shakeel Butt , Jan Kara , Mel Gorman , Jason Gunthorpe , John Hubbard , Gerd Hoffmann , Vivek Kasireddy , Dave Airlie , Matthew Brost , Joshua Hahn , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple , Hagen Paul Pfeifer , James Bottomley , Felix Kuehling , Alex Sierra , Balbir Singh , Kairui Song , Qi Zheng , Axel Rasmussen , Yuanchu Xie , Wei Xu , Baoquan He , Oscar Salvador , Muchun Song , Dan Williams , Rakie Kim , Hao Li , Christoph Lameter , Roman Gushchin , Sebastian Andrzej Siewior , Clark Williams , Steven Rostedt , Alexei Starovoitov , Xu Xin , Chengming Zhou , Shivank Garg Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-cxl@vger.kernel.org, linux-rt-devel@lists.linux.dev, SJ Park , Chris Mason References: <20261129-fixes_core_3-v1-0-f66094116801@kernel.org> <20261129-fixes_core_3-v1-1-f66094116801@kernel.org> From: Baolin Wang In-Reply-To: <20261129-fixes_core_3-v1-1-f66094116801@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 11/29/26 6:06 PM, David Hildenbrand (Arm) wrote: > shmem_partial_swap_usage() counts whole swap entries even when only part > of an entry falls within the requested range. Further, when a walk > starts inside a large entry, xas_pause() can resume beyond its end and > skip subsequent entries. > > Consequently, we can overcount "Swap" in /proc//smaps and > smaps_rollup, especially for private writable mappings where the > function can be called once per empty PTE, but we can also undercount > it. > > Let's fix it by clamping each entry to the remaining range and advancing > "start" to avoid counting pages twice, and by using xas_set() to resume > at the first uncounted index after cond_resched_rcu(). > > This has low urgency, as it only affects the "Swap" statistics in > /proc//smaps and smaps_rollup. No need to CC stable. > > Fixes: 50f381eccefd ("mm: shmem: extend shmem_partial_swap_usage() to support large folio swap") > Reported-by: Chris Mason > Signed-off-by: David Hildenbrand (Arm) > --- Agree, this is not a stable fix. I remember I discussed with Hugh early on that the smaps accounting is tolerable here, since xas_get_order() in this function is not reliable either. Anyway, LGTM. Reviewed-by: Baolin Wang