]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm: page_counters: initialize usage using ATOMIC_LONG_INIT() macro
authorRoman Gushchin <roman.gushchin@linux.dev>
Fri, 26 Jul 2024 20:31:10 +0000 (20:31 +0000)
committerAndrew Morton <akpm@linux-foundation.org>
Mon, 2 Sep 2024 03:25:51 +0000 (20:25 -0700)
When a page_counter structure is initialized, there is no need to use an
atomic set operation to initialize the usage counter because at this point
the structure is not visible to anybody else.  ATOMIC_LONG_INIT() is what
should be used in such cases.

Link: https://lkml.kernel.org/r/20240726203110.1577216-4-roman.gushchin@linux.dev
Signed-off-by: Roman Gushchin <roman.gushchin@linux.dev>
Acked-by: Shakeel Butt <shakeel.butt@linux.dev>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Muchun Song <songmuchun@bytedance.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
include/linux/page_counter.h

index 1b3e92c09b80a1a55eb7b147cca55bfa3e9ba112..66ebf9a73158da1729c477d1e70581109273ceb5 100644 (file)
@@ -52,7 +52,7 @@ static inline void page_counter_init(struct page_counter *counter,
                                     struct page_counter *parent,
                                     bool protection_support)
 {
-       atomic_long_set(&counter->usage, 0);
+       counter->usage = (atomic_long_t)ATOMIC_LONG_INIT(0);
        counter->max = PAGE_COUNTER_MAX;
        counter->parent = parent;
        counter->protection_support = protection_support;