summaryrefslogtreecommitdiff
path: root/mm/khugepaged.c
diff options
context:
space:
mode:
authorYanfei Xu <yanfei.xu@windriver.com>2021-05-04 18:34:12 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2021-05-05 11:27:21 -0700
commit89dc6a9682919dbd64213c630a71eedaa021d7e5 (patch)
tree263a679299230b85d8ef4d54c09661da7af81a81 /mm/khugepaged.c
parenta44f89dc6c5f8ba70240b81a570260d29d04bcb0 (diff)
downloadlwn-89dc6a9682919dbd64213c630a71eedaa021d7e5.tar.gz
lwn-89dc6a9682919dbd64213c630a71eedaa021d7e5.zip
mm/khugepaged.c: replace barrier() with READ_ONCE() for a selective variable
READ_ONCE() is more selective and lightweight. It is more appropriate that using a READ_ONCE() for the certain variable to prevent the compiler from reordering. Link: https://lkml.kernel.org/r/20210323092730.247583-1-yanfei.xu@windriver.com Signed-off-by: Yanfei Xu <yanfei.xu@windriver.com> Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Cc: Mike Kravetz <mike.kravetz@oracle.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/khugepaged.c')
-rw-r--r--mm/khugepaged.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index adf677246d86..a40a29414762 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -2202,11 +2202,9 @@ static void khugepaged_do_scan(void)
{
struct page *hpage = NULL;
unsigned int progress = 0, pass_through_head = 0;
- unsigned int pages = khugepaged_pages_to_scan;
+ unsigned int pages = READ_ONCE(khugepaged_pages_to_scan);
bool wait = true;
- barrier(); /* write khugepaged_pages_to_scan to local stack */
-
lru_add_drain_all();
while (progress < pages) {