Thread (12 messages) flat view 12 messages, 3 authors, 2025-02-20

Re: [PATCH -next] uprobes: fix two zero old_folio bugs in __replace_page()

From: Oleg Nesterov <oleg@redhat.com>
Date: 2025-02-17 16:13:03
Also in: bpf, linux-perf-users, lkml

Can't comment, my understanding of mm/ is not enough these days.

Just one question...

On 02/17, Tong Tiangen wrote:
Fixes: 7396fa818d62 ("uprobes/core: Make background page replacement logic account for rss_stat counters")
Fixes: 2b1444983508 ("uprobes, mm, x86: Add the ability to install and remove uprobes breakpoints")
Are you sure this logic was wrong from the very beginning? Just curious.

Oleg.
quoted hunk ↗ jump to hunk
Signed-off-by: Tong Tiangen <redacted>
---
 kernel/events/uprobes.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index 46ddf3a2334d..ff5694acfa68 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -213,7 +213,8 @@ static int __replace_page(struct vm_area_struct *vma, unsigned long addr,
 		dec_mm_counter(mm, MM_ANONPAGES);
 
 	if (!folio_test_anon(old_folio)) {
-		dec_mm_counter(mm, mm_counter_file(old_folio));
+		if (!is_zero_folio(old_folio))
+			dec_mm_counter(mm, mm_counter_file(old_folio));
 		inc_mm_counter(mm, MM_ANONPAGES);
 	}
 
@@ -227,7 +228,8 @@ static int __replace_page(struct vm_area_struct *vma, unsigned long addr,
 	if (!folio_mapped(old_folio))
 		folio_free_swap(old_folio);
 	page_vma_mapped_walk_done(&pvmw);
-	folio_put(old_folio);
+	if (!is_zero_folio(old_folio))
+		folio_put(old_folio);
 
 	err = 0;
  unlock:
-- 
2.25.1
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help