Skip to content

Commit

Permalink
mm: page_counters: initialize usage using ATOMIC_LONG_INIT() macro
Browse files Browse the repository at this point in the history
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/[email protected]
Signed-off-by: Roman Gushchin <[email protected]>
Acked-by: Shakeel Butt <[email protected]>
Acked-by: Johannes Weiner <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: Muchun Song <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
rgushchin authored and akpm00 committed Sep 2, 2024
1 parent 941ce63 commit 57979fa
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion include/linux/page_counter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 57979fa

Please sign in to comment.