From: Ran Xiaokai Date: Wed, 15 May 2024 02:47:54 +0000 (+0800) Subject: mm/huge_memory: mark racy access onhuge_anon_orders_always X-Git-Tag: v6.10.4~123 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=82dd589d30099c9f5931748c64194ef7ab0841b2;p=thirdparty%2Fkernel%2Fstable.git mm/huge_memory: mark racy access onhuge_anon_orders_always [ 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 Acked-by: David Hildenbrand Reviewed-by: Lu Zhongjun Reviewed-by: xu xin Cc: Yang Yang Cc: Matthew Wilcox (Oracle) Cc: Yang Shi Cc: Zi Yan Signed-off-by: Andrew Morton Stable-dep-of: 00f58104202c ("mm: fix khugepaged activation policy") Signed-off-by: Sasha Levin --- diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h index c73ad77fa33d3..71945cf4c7a8d 100644 --- a/include/linux/huge_mm.h +++ b/include/linux/huge_mm.h @@ -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)