ipc-shm-fix-rss-accounting-for-hugetlb-shared-memory.patch removed from -mm tree
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 <[email protected]>
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.
---
ipc/shm.c | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-)
ipc/shm.c renamed from ipc/shm.c~ipc-shm-fix-rss-accounting-for-hugetlb-shared-memory +4 -19
@@ -936,26 +936,11 @@ static inline unsigned long copy_shminfostatic 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 [email protected] are