Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mm/rmap: not necessary to mask off FOLIO_PAGES_MAPPED

At this point, we are in an if branch conditional on (nr <
ENTIRELY_MAPPED), and FOLIO_PAGES_MAPPED is equal to (ENTIRELY_MAPPED -
1). This means the upper bits are already cleared.

It is not necessary to mask it off.

Link: https://lkml.kernel.org/r/20250817032647.29147-2-richard.weiyang@gmail.com
Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Acked-by: David Hildenbrand <david@redhat.com>
Cc: Rik van Riel <riel@surriel.com>
Cc: Liam R. Howlett <Liam.Howlett@oracle.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Harry Yoo <harry.yoo@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Wei Yang and committed by
Andrew Morton
e5e75892 658fa653

+1 -1
+1 -1
mm/rmap.c
··· 1748 1748 nr_pages = folio_large_nr_pages(folio); 1749 1749 if (level == PGTABLE_LEVEL_PMD) 1750 1750 nr_pmdmapped = nr_pages; 1751 - nr = nr_pages - (nr & FOLIO_PAGES_MAPPED); 1751 + nr = nr_pages - nr; 1752 1752 /* Raced ahead of another remove and an add? */ 1753 1753 if (unlikely(nr < 0)) 1754 1754 nr = 0;