linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Roman Gushchin <roman.gushchin@linux.dev>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Muchun Song <muchun.song@linux.dev>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Michal Hocko <mhocko@kernel.org>,
	Shakeel Butt <shakeel.butt@linux.dev>,
	Frank van der Linden <fvdl@google.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Roman Gushchin <roman.gushchin@linux.dev>
Subject: [PATCH v1 4/4] mm: page_counters: initialize usage using ATOMIC_LONG_INIT() macro
Date: Fri,  3 May 2024 13:18:35 -0700	[thread overview]
Message-ID: <20240503201835.2969707-5-roman.gushchin@linux.dev> (raw)
In-Reply-To: <20240503201835.2969707-1-roman.gushchin@linux.dev>

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 --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;
 	}
 
-- 
2.43.2



      parent reply	other threads:[~2024-05-03 20:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-03 20:18 [PATCH v1 0/4] Page counters optimizations Roman Gushchin
2024-05-03 20:18 ` [PATCH v1 1/4] mm: memcg: convert enum res_type to mem_counter_type Roman Gushchin
2024-05-03 20:18 ` [PATCH v1 2/4] mm: memcg: merge multiple page_counters into a single structure Roman Gushchin
2024-05-03 21:11   ` Shakeel Butt
2024-05-03 21:18     ` Roman Gushchin
2024-05-08  0:26       ` T.J. Mercier
2024-05-08  2:07         ` Roman Gushchin
2024-05-10  7:15   ` kernel test robot
2024-05-03 20:18 ` [PATCH v1 3/4] mm: memcg: don't call propagate_protected_usage() needlessly Roman Gushchin
2024-05-03 20:18 ` Roman Gushchin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240503201835.2969707-5-roman.gushchin@linux.dev \
    --to=roman.gushchin@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=fvdl@google.com \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=muchun.song@linux.dev \
    --cc=shakeel.butt@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox