Files
linux/ipc
Weilin Tong e387ebe5cd ipc/shm: fix RSS accounting for hugetlb shared memory
Commit a08c7193e4 ("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/[email protected]
Fixes: a08c7193e4 ("mm/filemap: remove hugetlb special casing in filemap.c")
Signed-off-by: Weilin Tong <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Suggested-by: Muchun Song <[email protected]>
Acked-by: Muchun Song <[email protected]>
Cc: Oscar Salvador <[email protected]>
Cc: David Hildenbrand <[email protected]>
Cc: Sidhartha Kumar <[email protected]>
Cc: Lorenzo Stoakes <[email protected]>
Cc: Dan Carpenter <[email protected]>
Cc: Baolin Wang <[email protected]>
Cc: <[email protected]>
2026-10-24 01:56:34 -07:00
..
2026-05-27 14:10:25 +02:00
2019-11-15 14:38:27 +01:00
2023-12-20 19:26:31 -05:00