]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
mm/huge_memory: mark racy access onhuge_anon_orders_always
authorRan Xiaokai <ran.xiaokai@zte.com.cn>
Wed, 15 May 2024 02:47:54 +0000 (10:47 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 11 Aug 2024 10:57:46 +0000 (12:57 +0200)
[ Upstream commit 7f83bf14603ef41a44dc907594d749a283e22c37 ]

huge_anon_orders_always is accessed lockless, it is better to use the
READ_ONCE() wrapper.  This is not fixing any visible bug, hopefully this
can cease some KCSAN complains in the future.  Also do that for
huge_anon_orders_madvise.

Link: https://lkml.kernel.org/r/20240515104754889HqrahFPePOIE1UlANHVAh@zte.com.cn
Signed-off-by: Ran Xiaokai <ran.xiaokai@zte.com.cn>
Acked-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Lu Zhongjun <lu.zhongjun@zte.com.cn>
Reviewed-by: xu xin <xu.xin16@zte.com.cn>
Cc: Yang Yang <yang.yang29@zte.com.cn>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Yang Shi <shy828301@gmail.com>
Cc: Zi Yan <ziy@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Stable-dep-of: 00f58104202c ("mm: fix khugepaged activation policy")
Signed-off-by: Sasha Levin <sashal@kernel.org>
include/linux/huge_mm.h

index c73ad77fa33d343437713d5e818ceb53341ed140..71945cf4c7a8ded5c63ec0d8620059c0662fbd57 100644 (file)
@@ -140,8 +140,8 @@ static inline bool hugepage_flags_enabled(void)
         * So we don't need to look at huge_anon_orders_inherit.
         */
        return hugepage_global_enabled() ||
-              huge_anon_orders_always ||
-              huge_anon_orders_madvise;
+              READ_ONCE(huge_anon_orders_always) ||
+              READ_ONCE(huge_anon_orders_madvise);
 }
 
 static inline int highest_order(unsigned long orders)