diff mbox series

[v1,4/4] mm: page_counters: initialize usage using ATOMIC_LONG_INIT() macro

Message ID 20240503201835.2969707-5-roman.gushchin@linux.dev (mailing list archive)
State New
Headers show
Series Page counters optimizations | expand

Commit Message

Roman Gushchin May 3, 2024, 8:18 p.m. UTC
When a page_counter structure is initialized, there is no need to
use an atomic set operation to initialize usage counters because at
this point the structure is not visible to anybody else.
ATOMIC_LONG_INIT() is what should be used in such cases.

Signed-off-by: Roman Gushchin <roman.gushchin@linux.dev>
---
 include/linux/page_counter.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/include/linux/page_counter.h b/include/linux/page_counter.h
index 5d963f54fcb8..af636dd943a7 100644
--- a/include/linux/page_counter.h
+++ b/include/linux/page_counter.h
@@ -86,7 +86,7 @@  static inline void page_counter_init(struct page_counter *counter,
 	int i;
 
 	for (i = 0; i < __MCT_NR_ITEMS; i++) {
-		atomic_long_set(&counter->usage[i], 0);
+		counter->usage[i] = (atomic_long_t)ATOMIC_LONG_INIT(0);
 		counter->max[i] = PAGE_COUNTER_MAX;
 	}