在 2025/2/18 0:12, Oleg Nesterov 写道:
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.
Yes, i checked the original code logic, and the put_page() didn't take
zero pages into account.
Add Morton,Peter and David for discussion.
Thanks,
Tong.
Signed-off-by: Tong Tiangen <tongtiangen@xxxxxxxxxx>
---
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
.