[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240726231110.GF1702603@cmpxchg.org>
Date: Fri, 26 Jul 2024 19:11:10 -0400
From: Johannes Weiner <hannes@...xchg.org>
To: Roman Gushchin <roman.gushchin@...ux.dev>
Cc: Andrew Morton <akpm@...ux-foundation.org>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org, Michal Hocko <mhocko@...nel.org>,
Shakeel Butt <shakeel.butt@...ux.dev>,
Muchun Song <muchun.song@...ux.dev>
Subject: Re: [PATCH v3 3/3] mm: page_counters: initialize usage using
ATOMIC_LONG_INIT() macro
On Fri, Jul 26, 2024 at 08:31:10PM +0000, Roman Gushchin wrote:
> 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.
>
> Signed-off-by: Roman Gushchin <roman.gushchin@...ux.dev>
> ---
> include/linux/page_counter.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/page_counter.h b/include/linux/page_counter.h
> index cf837d0f8ed1..5da11392b382 100644
> --- a/include/linux/page_counter.h
> +++ b/include/linux/page_counter.h
> @@ -53,7 +53,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);
Pretty cool that ATOMIC_LONG_INIT() return value needs a cast to
atomic_long_t! ^_^
Acked-by: Johannes Weiner <hannes@...xchg.org>
Powered by blists - more mailing lists