Skip to contentSkip to conversation

mm: rmap: abstract updating per-node and per-memcg stats fix

PATCH In review Hugh Dickins 3 participants 3 messages Jun 12, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm: rmap: abstract updating per-node and per-memcg stats fix

/proc/meminfo is showing ridiculously large numbers on some lines:
__folio_remove_rmap()'s __folio_mod_stat() should be subtracting!

---
A fix for folding into mm-unstable, not needed for 6.10-rc.

 mm/rmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/rmap.c +1 -1
@@ -1567,7 +1567,7 @@ static __always_inline void __folio_remove_rmap(struct folio *folio,
 		    list_empty(&folio->_deferred_list))
 			deferred_split_folio(folio);
 	}
-	__folio_mod_stat(folio, nr, nr_pmdmapped);
+	__folio_mod_stat(folio, -nr, -nr_pmdmapped);
 
 	/*
 	 * It would be tidy to reset folio_test_anon mapping when fully
Signature · 1 line
2.35.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Hugh Dickins

/proc/meminfo is showing ridiculously large numbers on some lines:
__folio_remove_rmap()'s __folio_mod_stat() should be subtracting!

Thanks a lot for fixing this! I was just looking at a test failure report by the kernel robot caused by this [1].

Just to document my own stupidity here:

1. In [2], I sent a fix to use __mod_node_page_state() instead of __lruvec_stat_mod_folio() in __folio_remove_rmap(). I made the same mistake of replacing subtraction with addition.

2. In [3], I sent a v2 of that fix that kept the subtraction in __folio_remove_rmap() correctly.

3. In [4], I sent a cleanup on top of the fix, and that cleanup replaced the subtraction in __folio_remove_rmap() with an addition, again.

Apparently, I just suck at subtraction :)

[1]https://lore.kernel.org/linux-mm/[email protected]/ [2]https://lore.kernel.org/lkml/[email protected]/ [3]https://lore.kernel.org/lkml/[email protected]/ [4]https://lore.kernel.org/lkml/[email protected]/

Quoted 20 lines

---
A fix for folding into mm-unstable, not needed for 6.10-rc.

 mm/rmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/rmap.c +1 -2
@@ -1567,7 +1567,7 @@ static __always_inline void __folio_remove_rmap(struct folio *folio,
                    list_empty(&folio->_deferred_list))
                        deferred_split_folio(folio);
        }
-       __folio_mod_stat(folio, nr, nr_pmdmapped);
+       __folio_mod_stat(folio, -nr, -nr_pmdmapped);
 
        /*
         * It would be tidy to reset folio_test_anon mapping when fully
--

2.35.3

Acked-by on v1 1/1
#2 lore raw
In reply to Hugh Dickins
Quoted 13 lines · Hugh Dickins

/proc/meminfo is showing ridiculously large numbers on some lines:
__folio_remove_rmap()'s __folio_mod_stat() should be subtracting!

---
A fix for folding into mm-unstable, not needed for 6.10-rc.

  mm/rmap.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

mm/rmap.c static __always_inline void __folio_remove_rmap(struct folio *folio, · line 1573

Quoted 8 lines
mm/rmap.c +1 -1
@@ -1567,7 +1567,7 @@ static __always_inline void __folio_remove_rmap(struct folio *folio,
  		    list_empty(&folio->_deferred_list))
  			deferred_split_folio(folio);
  	}
-	__folio_mod_stat(folio, nr, nr_pmdmapped);
+	__folio_mod_stat(folio, -nr, -nr_pmdmapped);
 
  	/*
  	 * It would be tidy to reset folio_test_anon mapping when fully

Missed that detail, thanks!

Signature · 3 lines
Cheers,

David / dhildenb