mm/rmap: cleanup partially-mapped handling in __folio_remove_rmap()
Subsystems (2)
PATCH 1/1 mm/rmap: cleanup partially-mapped handling in __folio_remove_rmap()
Let's simplify and reduce code indentation. In the RMAP_LEVEL_PTE case, we already check for nr when computing partially_mapped.
For RMAP_LEVEL_PMD, it's a bit more confusing. Likely, we don't need the "nr" check, but we could have "nr < nr_pmdmapped" also if we stumbled into the "/* Raced ahead of another remove and an add? */" case. So let's simply move the nr check in there.
Note that partially_mapped is always false for small folios.
No functional change intended.
--- mm/rmap.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
mm/rmap.c +4 -6
@@ -1551,11 +1551,12 @@ static __always_inline void __folio_remove_rmap(struct folio *folio, } } - partially_mapped = nr < nr_pmdmapped; + partially_mapped = nr && nr < nr_pmdmapped;break ; } -if (nr) { +if (partially_mapped &&folio_test_anon (folio) && +list_empty (&folio->_deferred_list))/* * Queue anon large folio for deferred split if at least one * page of the folio is unmapped and at least one page
@@ -1563,10 +1564,7 @@ static __always_inline void __folio_remove_rmap(struct folio *folio,* * Check partially_mapped first to ensure it is a large folio. */ -if (folio_test_anon (folio) && partially_mapped && -list_empty (&folio->_deferred_list)) -deferred_split_folio (folio); - } +deferred_split_folio (folio);__folio_mod_stat (folio, -nr, -nr_pmdmapped);/*
Signature · 1 line
2.45.2
Quoted 10 lines · David Hildenbrand
Let's simplify and reduce code indentation. In the
RMAP_LEVEL_PTEcase, we already check for nr when computingpartially_mapped.For
RMAP_LEVEL_PMD, it's a bit more confusing. Likely, we don't need the "nr" check, but we could have "nr <nr_pmdmapped" also if we stumbled into the "/* Raced ahead of another remove and an add? */" case. So let's simply move the nr check in there.Note that
partially_mappedis always false for small folios.
Quoted 7 lines
No functional change intended.
Cc Yosry Ahmed <[email protected]>Signed-off-by David Hildenbrand <[email protected]>--- mm/rmap.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
LGTM. Reviewed-by: Zi Yan <[email protected]>
--
Best Regards,
Yan, Zi
Quoted 9 lines · David Hildenbrand
Let's simplify and reduce code indentation. In the
RMAP_LEVEL_PTEcase, we already check for nr when computingpartially_mapped.For
RMAP_LEVEL_PMD, it's a bit more confusing. Likely, we don't need the "nr" check, but we could have "nr <nr_pmdmapped" also if we stumbled into the "/* Raced ahead of another remove and an add? */" case. So let's simply move the nr check in there.
Quoted 6 lines
Note that
partially_mappedis always false for small folios.No functional change intended.
Cc Yosry Ahmed <[email protected]>Signed-off-by David Hildenbrand <[email protected]>
Makes sense to me. FWIW:
Quoted 24 lines
--- mm/rmap.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)mm/rmap.c +3
-2@@ -1551,11 +1551,12 @@ static __always_inline void __folio_remove_rmap(struct folio *folio, } } - partially_mapped = nr < nr_pmdmapped; + partially_mapped = nr && nr < nr_pmdmapped;break ; } -if (nr) { +if (partially_mapped &&folio_test_anon (folio) && +list_empty (&folio->_deferred_list))/* * Queue anon large folio for deferred split if at least one * page of the folio is unmapped and at least one page
mm/rmap.c static __always_inline void __folio_remove_rmap(struct folio *folio, · line 1567
Quoted 8 lines
mm/rmap.c +1
-4@@ -1563,10 +1564,7 @@ static __always_inline void __folio_remove_rmap(struct folio *folio,* * Check partially_mapped first to ensure it is a large folio. */ -if (folio_test_anon (folio) && partially_mapped && -list_empty (&folio->_deferred_list)) -deferred_split_folio (folio); - } +deferred_split_folio (folio);
FWIW, I prefer moving the comment out of the one-line if block as you originally suggested in [1].
Quoted 6 lines
mm/rmap.c +0
-1__folio_mod_stat (folio, -nr, -nr_pmdmapped);/* -- 2.45.2
Quoted 57 lines · Yosry Ahmed
Quoted 9 lines · David Hildenbrand
Let's simplify and reduce code indentation. In the
RMAP_LEVEL_PTEcase, we already check for nr when computingpartially_mapped.For
RMAP_LEVEL_PMD, it's a bit more confusing. Likely, we don't need the "nr" check, but we could have "nr <nr_pmdmapped" also if we stumbled into the "/* Raced ahead of another remove and an add? */" case. So let's simply move the nr check in there.Quoted 6 lines
Note that
partially_mappedis always false for small folios.No functional change intended.
Cc Yosry Ahmed <[email protected]>Signed-off-by David Hildenbrand <[email protected]>Makes sense to me. FWIW:
Reviewed-by Yosry Ahmed <[email protected]>Quoted 24 lines
--- mm/rmap.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)mm/rmap.c +3
-2@@ -1551,11 +1551,12 @@ static __always_inline void __folio_remove_rmap(struct folio *folio, } } - partially_mapped = nr < nr_pmdmapped; + partially_mapped = nr && nr < nr_pmdmapped;break ; } -if (nr) { +if (partially_mapped &&folio_test_anon (folio) && +list_empty (&folio->_deferred_list))/* * Queue anon large folio for deferred split if at least one * page of the folio is unmapped and at least one page mm/rmap.c static __always_inline void __folio_remove_rmap(struct folio *folio, · line 1567
Quoted 8 lines
mm/rmap.c +1
-4@@ -1563,10 +1564,7 @@ static __always_inline void __folio_remove_rmap(struct folio *folio,* * Check partially_mapped first to ensure it is a large folio. */ -if (folio_test_anon (folio) && partially_mapped && -list_empty (&folio->_deferred_list)) -deferred_split_folio (folio); - } +deferred_split_folio (folio);FWIW, I prefer moving the comment out of the one-line if block as you originally suggested in [1].
Quoted 1 line
Sorry for the late reply, crazy times here.
Let me do that and resend, thanks!
Signature · 3 lines
Cheers, David / dhildenb