Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=115.124.30.132 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796196571; b=CiHGX9Pmb+0Pc84Fur9BFN6ZW150bHTrKnAwBiLKRdAc5DWiUOTmTFT5Qd5f0zQSe8N3 3Bf+QkOttHhwTMqRbTfeaGIi7Esp+uHG1w5YhT4JBoZ+9MVQRH7jUZGPyQYs1iNw02fbg cUpRH1ZwkMDgDVuGrrAI+fokgDIbVfdwzKyM7hKuPAvPE/cewwbg9aJaK3Utr1OU0Qjyb R1/wEv2oAhCRW9kD7UAUIStyiQD3r95M7hkDrUvXXZuvGCpWlXTOMDBNwlzcUSE9BTXMh c8kJIRMFGZskFxIkdPdV4G5hUVCQy0EJfMC1ECXO+0KdK4aQouxnHCma6cZrRgbu8VA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796196571; 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=etXrifoU4QMrrnMtl/EjyP8iuCJCFVDasBHFtiCKlwq/q3fIw0qNHH11L0lzIFTa7/2L kKurQ78F3TlJgBv9R/7/G5xixXJvQaVd7OK3oR6ammiI3FYIlRjZPp/imHMougY7Hh/ot mfGLxWHmt+eteOyBJEvvU27yHz3iq2+uZpUKserF9lGYcVKI6UXpfyQZ41Dgdfl5PYqBW oaKEPwCw9n4gn7PZwLFl+tX/6kuThDN/EzOnWeC80ZUFX9bGnNbO8UMojvGt9lZ7aA/Pi 2qvVwFPyj787AW68Gg5LjOdaaFPlJ7zrKstV4MOin1kaFdYujTLXoM0fN1zpg0HGYEg== 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=kKZ00a3D; arc=none smtp.remote-ip=115.124.30.132 Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com [115.124.30.132]) (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 87A53606A31A for ; Wed, 2 Dec 2026 07:29:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 87A53606A31A 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, unprotected) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=kKZ00a3D DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1796196567; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=xAeVQPXuzyV0X79lFkXPVtzT0DtarNilaY89SeHqtWY=; b=kKZ00a3D5coFvU5/vHR6QbcgrGu0x1bCalHcwS37RvTYilNsg7KE+28DD5O045RM6hcJ2LboeDknAgCQLJ6Rzr9Ec8dj5yj/x+R5gf0tpxpXix1lbXJ3Gw9tkuC9FjzyHiW5+TsTvAbCKA2I1IApjBTVzCjOA0EO1XrDPZls+2Q= 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-rt-devel@lists.linux.dev 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