* [PATCH] khugepaged: Raplace barrier() with READ_ONCE() for a selective variable
@ 2021-03-23 9:27 yanfei.xu
2021-03-23 10:21 ` Kirill A. Shutemov
0 siblings, 1 reply; 2+ messages in thread
From: yanfei.xu @ 2021-03-23 9:27 UTC (permalink / raw)
To: akpm; +Cc: linux-mm, linux-kernel
From: Yanfei Xu <yanfei.xu@windriver.com>
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.
Signed-off-by: Yanfei Xu <yanfei.xu@windriver.com>
---
mm/khugepaged.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index b81521dfbb1a..034d05a26cb0 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) {
--
2.27.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] khugepaged: Raplace barrier() with READ_ONCE() for a selective variable
2021-03-23 9:27 [PATCH] khugepaged: Raplace barrier() with READ_ONCE() for a selective variable yanfei.xu
@ 2021-03-23 10:21 ` Kirill A. Shutemov
0 siblings, 0 replies; 2+ messages in thread
From: Kirill A. Shutemov @ 2021-03-23 10:21 UTC (permalink / raw)
To: yanfei.xu; +Cc: akpm, linux-mm, linux-kernel
On Tue, Mar 23, 2021 at 05:27:30PM +0800, yanfei.xu@windriver.com wrote:
> From: Yanfei Xu <yanfei.xu@windriver.com>
>
> 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.
>
> Signed-off-by: Yanfei Xu <yanfei.xu@windriver.com>
Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
--
Kirill A. Shutemov
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-03-23 10:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-23 9:27 [PATCH] khugepaged: Raplace barrier() with READ_ONCE() for a selective variable yanfei.xu
2021-03-23 10:21 ` Kirill A. Shutemov
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.