From patchwork Fri Jul 26 20:31:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Gushchin X-Patchwork-Id: 13743178 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id ABF77C3DA49 for ; Fri, 26 Jul 2024 20:31:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 175B56B0093; Fri, 26 Jul 2024 16:31:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1288D6B0095; Fri, 26 Jul 2024 16:31:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E219C6B0096; Fri, 26 Jul 2024 16:31:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id BBFB46B0093 for ; Fri, 26 Jul 2024 16:31:31 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 2E7E314014A for ; Fri, 26 Jul 2024 20:31:31 +0000 (UTC) X-FDA: 82383049182.01.8D0DE84 Received: from out-186.mta1.migadu.com (out-186.mta1.migadu.com [95.215.58.186]) by imf25.hostedemail.com (Postfix) with ESMTP id 7AED0A000D for ; Fri, 26 Jul 2024 20:31:28 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=tPfGve9A; spf=pass (imf25.hostedemail.com: domain of roman.gushchin@linux.dev designates 95.215.58.186 as permitted sender) smtp.mailfrom=roman.gushchin@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722025838; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=k2RQKi54iBuphHPxmjb/1iWIMtoBoWz8KpxZMw88GiU=; b=kaOQH7fKbwrB3JHe71v6aYtBSU/UfCSjopaOQ/1aAS/9IN6jbvbGaUpEqEiJWMAPIgHkGH AqRPkVlrqNdcPr/n+1UrvbNCfU+ZJT4FAUNi6BwDapMKMHaHtCMOFFeJ4t8L8jJ7K4Ej66 TDkkQSC5eDC0cot6t3hR8sf3Ql7jysg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722025838; a=rsa-sha256; cv=none; b=Ouuv0gd1+nzQ6MZa0P/t24yMDwSdNQU5ojftpqsqjHo6uTCeym/J4eDPnkocWJX/msdft+ 14B9fA9KNdQtbhWTRp1RqOpUCtRCzrYrxsUXHNEWxAUk2wLb/Pkytmq+3c8uWQCSD0ima9 XZyMWOwRaQhwI7lG7/MIH8aaAG2e8C8= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=tPfGve9A; spf=pass (imf25.hostedemail.com: domain of roman.gushchin@linux.dev designates 95.215.58.186 as permitted sender) smtp.mailfrom=roman.gushchin@linux.dev; dmarc=pass (policy=none) header.from=linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1722025886; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=k2RQKi54iBuphHPxmjb/1iWIMtoBoWz8KpxZMw88GiU=; b=tPfGve9AobnH69FXzvOlaxwcck8wXf2NYe8+7xG+07UVPVn7cVKNPa3aD5YxL59MvWNtuW UMgzDrPzE4lb7kiFnGPkzXy9VQDDNmj3q881cb9uV9IbAIrWZjny7wtw6d4ufzJ/QFBD7G xQh8n9ij+WXj7sJzVJ4CbBnbTW4cBGM= From: Roman Gushchin To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Johannes Weiner , Michal Hocko , Shakeel Butt , Muchun Song , Roman Gushchin Subject: [PATCH v3 3/3] mm: page_counters: initialize usage using ATOMIC_LONG_INIT() macro Date: Fri, 26 Jul 2024 20:31:10 +0000 Message-ID: <20240726203110.1577216-4-roman.gushchin@linux.dev> In-Reply-To: <20240726203110.1577216-1-roman.gushchin@linux.dev> References: <20240726203110.1577216-1-roman.gushchin@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 7AED0A000D X-Stat-Signature: pm1tsdj888zaqx4pxn3grdja3oyu47kg X-HE-Tag: 1722025888-898691 X-HE-Meta: U2FsdGVkX18WafaMLOVmDM7FTEs/LHto6PCCg7ItcMAgXqvzjOq9e2qjRlJpNapIeInqOrNo1ckxvUbZO+tE+YI3BQDI4H78J9+Y/rITjeEUoFoIGx/IdwfZMgG5p0xyI38fJkAd23rU7bfPqebxC3eHH3PowveA1LB57CrIV2SVwrVryLyPnXOe2rRZZIv3Q31LP/sICYAQ70aoYeUu2MUdX+UH4lnM73t3XY2sUSgP1rnvpoHuvUPJNegf/KdP5GfTJDpqXgKtE6FMnmSukSwdbfAgqgyn1Vffq1pw4ruV8LQgPjgnzKmEFRcINPK9kD4tbmAJInC5mkP+AV2mmgVIBxN8k7e/SP79BqEHu+WsnZ3qOYqi8Jsjtbnu1EeMerZGGhGcUNmqW8RCCqdW8puyePb8W2LS8tKut+I54gN1GnrDajd4ovB3+nwFthHKOavkvn3ks9uauPgVR9sxP7H8eTJaYsCUh7xrNGkljuPiIvkI/ieumkq1ln7XTwdCNRezlCJFfCKATLB5f+6OXqT0zDKbZiYnunmQyldHfIpdU/KJvuJwKHRdwXeCl9i4jprzXuC0D3qSTZNGsrVjdKG35rMI0Bg3aJcfdoiqmaoYiJAWxQIsSJI8mIItR+9djlZS6rY+wkxZq1RjwsOc5sZf4GsOWt8zXUrl97Tx4EiMeCxnGoo3ZkXXV8EJRECFnLuAKAJK6dzdkjG6mv8oFCMhRZZdo5iQ7CU4lHsUbnb3iMPyXWRjZKWRldJYKj6IgjCCSZD7hXEspHXxh0VYD9liJyDotYm/hSKct4lhlx8SupQhXgJep4uZcu8dOejXVARrcl/sMZ5PzQ2y5OffCll9zYAFOM2De4e/WkUbsQhRarfAclldtyy1+wHB3UFeZo1hRAmC/onHafcFBZQ1jB8zucLuNg6DRI0xGyCWMflE7it46TBMNO64S+5zSC/FeBXDMTIn5I/c9lZ3W6R 6dwipu0Y 3X0Jz3IBeRHp7PP8mKDIqEYd7b0HjMEf8e5mSisxA2qG6SBcgWWxMJ7k+dHGx8ZiZ56jVkiKDIEqCg/7uQvV4t1FZfOzM6cC2V4bZqiJTWUKH/FGhrXoVmqRZdXpW8fsQT0rzeCwzX3kfpPWBnVEtNKQnWw2Lj/7LGjIZ X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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 Acked-by: Shakeel Butt Acked-by: Johannes Weiner --- 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); counter->max = PAGE_COUNTER_MAX; counter->parent = parent; counter->protection_support = protection_support;