From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792832508; b=Y0Ps29hfpU/w2YphGV5NhsynsuvgIl0UXVa3XuCAW8i2Wi8SfxiO1h50j8ijXROs6wPG 4OqE407nsM/2mHrpt4LMtnBbHUUZNd6oMZtJBR+WBSr3Wrc8gYPtKS63yYJgRWRhHjmBk TIiJuAS2/A2nwEuN03L3UxHLWMXQjkMAfhAFyheakjju2Lxv4rK8nIFMuBaQj4n+dTyDO DystlBojj7TuvqT9hLWC9ulu3f5SA2GOC4iijsAkVTkodaQJGorr37R0QuRI+IV9yh4dV XUM5rckAfbnrGGs61MqmDu/gG4eun4sBKy1epMCa8k5gGY34FSngmJPAmv3Vo0yHKjQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792832508; h=Received:DKIM-Signature:Date:To:From:Subject:Message-Id; bh=b4OzQxfboMwoM+2ifrlzUcYryUPZdXgp4GOMQ0i/tUg=; b=Ie6vPKnIES4LtNTzx5Z8G7NfhglosbFzYJHp76myVKoXIeXwIiFJxnQYf/CkWXuakszH V1UKd4SjBjOXTCWDapHobPmE+mHFIq9D1MfrGT4clpEmc9DOu3n3uDfVWFEv0YE7DiIF2 Cf4oiZFsPu7pXZEk3WDbmECh3oONmapiGA/zB+Yv045CGjIdOAFFYgsj6Y2d147HocILf qqGVEWgcYgRVUh/bcN/iq4sahfzxOQMVR8mYlWAL5bp+p6W2GBR/f40pEPUWVXYBgU2CF RCjKIACo/qUG2AbKoJp4hvAG3k08aBadXGccA9bTOyo4Dbir/bDr/aS7SnNf1WeG73Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=F9TF3WHo; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7EDAC606A31D; Sat, 24 Oct 2026 09:01:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=F9TF3WHo Received: by smtp.kernel.org (Postfix) with ESMTPSA id 490861F031E0; Sat, 24 Oct 2026 09:01:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1792832508; bh=b4OzQxfboMwoM+2ifrlzUcYryUPZdXgp4GOMQ0i/tUg=; h=Date:To:From:Subject; b=F9TF3WHoIQsVeEcFB1Bujr5xZuPWzh8YOzCu/VEnh5ZELZqZd2a0EBK2fFcARpZ1J xOWozv7n/tkSqLD2bXuTwRc3PvucBasmMSE6fxXEOQgs0Kswu526pZSUPGXukZUL6D Xrop7BhbOkeXSCpau3GAv/jemlqLBa4iJrKOnJ+A= Date: Sat, 24 Oct 2026 02:01:47 -0700 To: mm-commits@vger.kernel.org,stable@vger.kernel.org,sidhartha.kumar@oracle.com,osalvador@suse.de,muchun.song@linux.dev,ljs@kernel.org,error27@gmail.com,david@kernel.org,baolin.wang@linux.alibaba.com,tongweilin@linux.alibaba.com,akpm@linux-foundation.org From: Andrew Morton Subject: [merged mm-stable] ipc-shm-fix-rss-accounting-for-hugetlb-shared-memory.patch removed from -mm tree Message-Id: <20261024090148.490861F031E0@smtp.kernel.org> X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list The quilt patch titled Subject: ipc/shm: fix RSS accounting for hugetlb shared memory has been removed from the -mm tree. Its filename was ipc-shm-fix-rss-accounting-for-hugetlb-shared-memory.patch This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm ------------------------------------------------------ From: Weilin Tong Subject: ipc/shm: fix RSS accounting for hugetlb shared memory Date: Wed, 14 Oct 2026 16:22:18 +0800 Commit a08c7193e4f1 ("mm/filemap: remove hugetlb special casing in filemap.c") changed mapping->nrpages to count base pages for hugetlb folios. However, shm_add_rss_swap() still multiplies it by pages_per_huge_page(), overcounting RSS in both SHM_INFO and /proc/sysvipc/shm. Use mapping->nrpages for RSS accounting across all backing types, and account swap only for non-hugetlb shmem. Use READ_ONCE() for both counters instead of info->lock, which does not protect nrpages and cannot provide a consistent snapshot. Link: https://lore.kernel.org/20261014082218.2236088-1-tongweilin@linux.alibaba.com Fixes: a08c7193e4f1 ("mm/filemap: remove hugetlb special casing in filemap.c") Signed-off-by: Weilin Tong Signed-off-by: Andrew Morton Suggested-by: Muchun Song Acked-by: Muchun Song Cc: Oscar Salvador Cc: David Hildenbrand Cc: Sidhartha Kumar Cc: Lorenzo Stoakes Cc: Dan Carpenter Cc: Baolin Wang Cc: --- ipc/shm.c | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) --- a/ipc/shm.c~ipc-shm-fix-rss-accounting-for-hugetlb-shared-memory +++ a/ipc/shm.c @@ -936,26 +936,11 @@ static inline unsigned long copy_shminfo static void shm_add_rss_swap(struct shmid_kernel *shp, unsigned long *rss_add, unsigned long *swp_add) { - struct inode *inode; + struct inode *inode = file_inode(shp->shm_file); - inode = file_inode(shp->shm_file); - - if (is_file_hugepages(shp->shm_file)) { - struct address_space *mapping = inode->i_mapping; - struct hstate *h = hstate_file(shp->shm_file); - *rss_add += pages_per_huge_page(h) * mapping->nrpages; - } else { -#ifdef CONFIG_SHMEM - struct shmem_inode_info *info = SHMEM_I(inode); - - spin_lock_irq(&info->lock); - *rss_add += inode->i_mapping->nrpages; - *swp_add += info->swapped; - spin_unlock_irq(&info->lock); -#else - *rss_add += inode->i_mapping->nrpages; -#endif - } + *rss_add += READ_ONCE(inode->i_mapping->nrpages); + if (IS_ENABLED(CONFIG_SHMEM) && !is_file_hugepages(shp->shm_file)) + *swp_add += READ_ONCE(SHMEM_I(inode)->swapped); } /* _ Patches currently in -mm which might be from tongweilin@linux.alibaba.com are