From mboxrd@z Thu Jan 1 00:00:00 1970 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 6E8C6C433F5 for ; Fri, 11 Feb 2022 10:41:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D5A356B0073; Fri, 11 Feb 2022 05:41:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CE2ED6B0078; Fri, 11 Feb 2022 05:41:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B849B6B007D; Fri, 11 Feb 2022 05:41:55 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0008.hostedemail.com [216.40.44.8]) by kanga.kvack.org (Postfix) with ESMTP id A85226B0073 for ; Fri, 11 Feb 2022 05:41:55 -0500 (EST) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 6806B8249980 for ; Fri, 11 Feb 2022 10:41:55 +0000 (UTC) X-FDA: 79130158590.12.D5A53AB Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf22.hostedemail.com (Postfix) with ESMTP id AEC94C0008 for ; Fri, 11 Feb 2022 10:41:54 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 789FDB82953; Fri, 11 Feb 2022 10:41:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BD83AC340F0; Fri, 11 Feb 2022 10:41:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644576112; bh=pA9CzJ8siuC1/m8BcVTbkdCFB9w8GLlHir7PDat5MMc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=R6REYmn9p5d0Dktie5hyYrl81Dpvwawd+5wIRfLWRjn0ELZGEkuSyVC6bleX7E76i 9ADm3vADYXEl2vBayvLwzfqdLyMjNq0qWJMtiqCHSQ9eEKad+gy5nSMPDcCJ8etrk7 4QBh++afQ6nsD/s5IV8fRLPOxDQOACZHtceEijDNXCe8IBrAiVs+luIk8f8A9gt1qj rlSA7wUt1YEXEy/bTwvE+YDVVJy0e6f411N8hd5kctvQcNH+paLyMVR3SfXWK60QW3 e2vocYyaWOwf7p5OOir4f3iFpOHCl4e46tt4IZLjT5hV+rwj5FF+W/N0usy9g59f3M MbVWUxHw3Qsfg== Date: Fri, 11 Feb 2022 12:41:42 +0200 From: Mike Rapoport To: Yury Norov Cc: Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?utf-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH 47/49] nodemask: add num_node_state_eq() Message-ID: References: <20220210224933.379149-1-yury.norov@gmail.com> <20220210224933.379149-48-yury.norov@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220210224933.379149-48-yury.norov@gmail.com> X-Rspam-User: X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: AEC94C0008 X-Stat-Signature: wgut6btr4x85gxx4a6yink795me85ai4 Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=R6REYmn9; spf=pass (imf22.hostedemail.com: domain of rppt@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-HE-Tag: 1644576114-26606 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: On Thu, Feb 10, 2022 at 02:49:31PM -0800, Yury Norov wrote: > Page allocator uses num_node_state() to compare number of nodes with a > given number. The underlying code calls bitmap_weight(), and we can do > it more efficiently with num_node_state_eq because conditional nodes_weight > may stop traversing the nodemask earlier, as soon as condition is (or is > not) met. > > Signed-off-by: Yury Norov Acked-by: Mike Rapoport > --- > include/linux/nodemask.h | 5 +++++ > mm/page_alloc.c | 2 +- > 2 files changed, 6 insertions(+), 1 deletion(-) > > diff --git a/include/linux/nodemask.h b/include/linux/nodemask.h > index 197598e075e9..c5014dbf3cce 100644 > --- a/include/linux/nodemask.h > +++ b/include/linux/nodemask.h > @@ -466,6 +466,11 @@ static inline int num_node_state(enum node_states state) > return nodes_weight(node_states[state]); > } > > +static inline int num_node_state_eq(enum node_states state, int num) > +{ > + return nodes_weight_eq(node_states[state], num); > +} > + > #define for_each_node_state(__node, __state) \ > for_each_node_mask((__node), node_states[__state]) > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index cface1d38093..897e64b66ca4 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -8434,7 +8434,7 @@ void __init page_alloc_init(void) > int ret; > > #ifdef CONFIG_NUMA > - if (num_node_state(N_MEMORY) == 1) > + if (num_node_state_eq(N_MEMORY, 1)) > hashdist = 0; > #endif > > -- > 2.32.0 > > -- Sincerely yours, Mike.