lkml.org 
[lkml]   [2022]   [Oct]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH RFC 05/10] mm/hugetlb: Make walk_hugetlb_range() RCU-safe
Date
RCU makes sure the pte_t* won't go away from under us.  Please refer to the
comment above huge_pte_offset() for more information.

Signed-off-by: Peter Xu <peterx@redhat.com>
---
mm/pagewalk.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/mm/pagewalk.c b/mm/pagewalk.c
index 7f1c9b274906..bbc71c750576 100644
--- a/mm/pagewalk.c
+++ b/mm/pagewalk.c
@@ -302,6 +302,9 @@ static int walk_hugetlb_range(unsigned long addr, unsigned long end,
const struct mm_walk_ops *ops = walk->ops;
int err = 0;

+ /* For huge_pte_offset() */
+ rcu_read_lock();
+
do {
next = hugetlb_entry_end(h, addr, end);
pte = huge_pte_offset(walk->mm, addr & hmask, sz);
@@ -315,6 +318,8 @@ static int walk_hugetlb_range(unsigned long addr, unsigned long end,
break;
} while (addr = next, addr != end);

+ rcu_read_unlock();
+
return err;
}

--
2.37.3
\
 
 \ /
  Last update: 2022-10-30 22:32    [W:0.179 / U:0.072 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site