* [Patch v2 0/2] mm/rmap: small cleanup for __folio_remove_rmap()
@ 2025-08-17 3:26 Wei Yang
2025-08-17 3:26 ` [Patch v2 1/2] mm/rmap: not necessary to mask off FOLIO_PAGES_MAPPED Wei Yang
2025-08-17 3:26 ` [Patch v2 2/2] mm/rmap: use folio_large_nr_pages() when we are sure it is a large folio Wei Yang
0 siblings, 2 replies; 3+ messages in thread
From: Wei Yang @ 2025-08-17 3:26 UTC (permalink / raw)
To: akpm, david, lorenzo.stoakes, riel, Liam.Howlett, vbabka, harry.yoo
Cc: linux-mm, Wei Yang
During code reading, I found some small places where we can improve based on
the knowledge we already have.
Patch 1 remove a mask of on nr, since we are in an if branch conditional which
implies the upper bits are already clear.
Patch 2 use folio_large_nr_pages() to get the nr since we know this is a large
folio.
v2:
* remove patch 2
* adjust patch 1 changelog
* adjust cover letter description
Wei Yang (2):
mm/rmap: not necessary to mask off FOLIO_PAGES_MAPPED
mm/rmap: use folio_large_nr_pages() when we are sure it is a large
folio
mm/rmap.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Patch v2 1/2] mm/rmap: not necessary to mask off FOLIO_PAGES_MAPPED
2025-08-17 3:26 [Patch v2 0/2] mm/rmap: small cleanup for __folio_remove_rmap() Wei Yang
@ 2025-08-17 3:26 ` Wei Yang
2025-08-17 3:26 ` [Patch v2 2/2] mm/rmap: use folio_large_nr_pages() when we are sure it is a large folio Wei Yang
1 sibling, 0 replies; 3+ messages in thread
From: Wei Yang @ 2025-08-17 3:26 UTC (permalink / raw)
To: akpm, david, lorenzo.stoakes, riel, Liam.Howlett, vbabka, harry.yoo
Cc: linux-mm, Wei Yang
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.
Not necessary to mask off it.
Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.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>
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Acked-by: David Hildenbrand <david@redhat.com>
---
v2:
* adjust the changelog based on Lorenzo's comment
---
mm/rmap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/rmap.c b/mm/rmap.c
index 1c5988dbd1e7..a927437a56c2 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -1749,7 +1749,7 @@ static __always_inline void __folio_remove_rmap(struct folio *folio,
nr_pages = folio_large_nr_pages(folio);
if (level == PGTABLE_LEVEL_PMD)
nr_pmdmapped = nr_pages;
- nr = nr_pages - (nr & FOLIO_PAGES_MAPPED);
+ nr = nr_pages - nr;
/* Raced ahead of another remove and an add? */
if (unlikely(nr < 0))
nr = 0;
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Patch v2 2/2] mm/rmap: use folio_large_nr_pages() when we are sure it is a large folio
2025-08-17 3:26 [Patch v2 0/2] mm/rmap: small cleanup for __folio_remove_rmap() Wei Yang
2025-08-17 3:26 ` [Patch v2 1/2] mm/rmap: not necessary to mask off FOLIO_PAGES_MAPPED Wei Yang
@ 2025-08-17 3:26 ` Wei Yang
1 sibling, 0 replies; 3+ messages in thread
From: Wei Yang @ 2025-08-17 3:26 UTC (permalink / raw)
To: akpm, david, lorenzo.stoakes, riel, Liam.Howlett, vbabka, harry.yoo
Cc: linux-mm, Wei Yang
Non-large folio is handled at the beginning, so it is a large folio for
sure.
Use folio_large_nr_pages() here like elsewhere.
Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.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>
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Acked-by: David Hildenbrand <david@redhat.com>
---
mm/rmap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/rmap.c b/mm/rmap.c
index a927437a56c2..14cf3b24ae50 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -1703,7 +1703,7 @@ static __always_inline void __folio_remove_rmap(struct folio *folio,
nr = folio_sub_return_large_mapcount(folio, nr_pages, vma);
if (!nr) {
/* Now completely unmapped. */
- nr = folio_nr_pages(folio);
+ nr = folio_large_nr_pages(folio);
} else {
partially_mapped = nr < folio_large_nr_pages(folio) &&
!folio_entire_mapcount(folio);
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-08-17 3:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-17 3:26 [Patch v2 0/2] mm/rmap: small cleanup for __folio_remove_rmap() Wei Yang
2025-08-17 3:26 ` [Patch v2 1/2] mm/rmap: not necessary to mask off FOLIO_PAGES_MAPPED Wei Yang
2025-08-17 3:26 ` [Patch v2 2/2] mm/rmap: use folio_large_nr_pages() when we are sure it is a large folio Wei Yang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox