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 63CA0C433F5 for ; Sun, 28 Nov 2021 06:35:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C8DF86B0075; Sun, 28 Nov 2021 01:35:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C3D4D6B0078; Sun, 28 Nov 2021 01:35:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AB6C06B007B; Sun, 28 Nov 2021 01:35:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0188.hostedemail.com [216.40.44.188]) by kanga.kvack.org (Postfix) with ESMTP id A03106B0075 for ; Sun, 28 Nov 2021 01:35:00 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 523C58B75D for ; Sun, 28 Nov 2021 06:34:50 +0000 (UTC) X-FDA: 78857375562.19.D9AAA17 Received: from mail-qt1-f173.google.com (mail-qt1-f173.google.com [209.85.160.173]) by imf17.hostedemail.com (Postfix) with ESMTP id EA708F0001C7 for ; Sun, 28 Nov 2021 06:34:49 +0000 (UTC) Received: by mail-qt1-f173.google.com with SMTP id t11so13143261qtw.3 for ; Sat, 27 Nov 2021 22:34:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to; bh=rKuklq8jxCETHcjcAENlFbP3nl/uNBZqDfuGt3bzd1Q=; b=N/urFmV2NmOFP42e1LVLW8fwa/hr9KDv3ZUpw+lC8WGtW8rc7tWztvbdFPuGBjub1O wspFhVe7cCjM3GiHaTs/o61wPhHvRulBbX8eWk+oUvPHasNmnTk9fguzetRPFqMAMSbw NSq70yUrota4HuwP2mw6e4EdU69PrQnC7+N7r+KW5WUjDm+ME76HZpk50UYeWuhhvrtv jzlo36RajlwI73FqiorEZUjBdSjpmlO3li6nkrgdjIjD0UyBvsHE9SsWB4qkZCd+owE5 cwmTSVDOhxhxddNAGQkE0CL6sKvMvIJPhAZNBZoNO0tLt8RIHXr/GUyMzCFG050MR/6f IXaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=rKuklq8jxCETHcjcAENlFbP3nl/uNBZqDfuGt3bzd1Q=; b=NUAum72KAuEay56eDqvpDBtX/N9XYy5Yonm2WqULHVlqFFkBvKWieLm5dYasNU9fuf lLdPH/Qm4b2kGNCto1CAkE7AWyY+mY7IuBWT5n6ugL3RB/+T33AFsC0hc1hrjl8qDNBE G9b8r2WKq2sIBbvXH3Hlbc0bpZ3sfXKqie/uz5EorRjnO3zg30mDkewVQ8C/NW638hzt +nQjOZzvsUdYcEJNOzuCOdgkNw32A7+a0oOvL2QrUx2i86oOyfwxI46a+Y3mpWY2A1+S LC2A8Hx4KCPLjjX1WaEASim/2f++lyhWK8ZhpdwzGgRoPkqj20XKh8YmaMOSbWs6L7yx j5KQ== X-Gm-Message-State: AOAM53362T0k+YoOM0NLvzghp5erVrOtDIBPsbsk5w0mbmMUhqvbq5qh gsmfM2kAGu3IcdWtbbOQTq0= X-Google-Smtp-Source: ABdhPJyJzVPAC11UsMz+HJsW0TzZJUpS9rijQwW94Vpknlgpg+/mG8cwCXUq1qsThYXJdJN6S8tP7Q== X-Received: by 2002:ac8:5fcc:: with SMTP id k12mr35432768qta.346.1638081289128; Sat, 27 Nov 2021 22:34:49 -0800 (PST) Received: from localhost ([66.216.211.25]) by smtp.gmail.com with ESMTPSA id f18sm6419326qko.34.2021.11.27.22.34.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Nov 2021 22:34:48 -0800 (PST) Date: Sat, 27 Nov 2021 22:34:47 -0800 From: Yury Norov To: =?utf-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= Cc: linux-kernel@vger.kernel.org, "James E.J. Bottomley" , "Martin K. Petersen" , "Paul E. McKenney" , "Rafael J. Wysocki" , Alexander Shishkin , Alexey Klimov , Amitkumar Karwar , Andi Kleen , Andrew Lunn , Andrew Morton , Andy Gross , Andy Lutomirski , Andy Shevchenko , Anup Patel , Ard Biesheuvel , Arnaldo Carvalho de Melo , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Christoph Hellwig , Christoph Lameter , Daniel Vetter , Dave Hansen , David Airlie , David Laight , Dennis Zhou , Dinh Nguyen , Geetha sowjanya , Geert Uytterhoeven , Greg Kroah-Hartman , Guo Ren , Hans de Goede , Heiko Carstens , Ian Rogers , Ingo Molnar , Jakub Kicinski , Jason Wessel , Jens Axboe , Jiri Olsa , Jonathan Cameron , Juri Lelli , Kalle Valo , Kees Cook , Krzysztof Kozlowski , Lee Jones , Marc Zyngier , Marcin Wojtas , Mark Gross , Mark Rutland , Matti Vaittinen , Mauro Carvalho Chehab , Mel Gorman , Michael Ellerman , Mike Marciniszyn , Nicholas Piggin , Palmer Dabbelt , Peter Zijlstra , Petr Mladek , Randy Dunlap , Rasmus Villemoes , Roy Pledge , Russell King , Saeed Mahameed , Sagi Grimberg , Sergey Senozhatsky , Solomon Peachy , Stephen Boyd , Stephen Rothwell , Steven Rostedt , Subbaraya Sundeep , Sudeep Holla , Sunil Goutham , Tariq Toukan , Tejun Heo , Thomas Bogendoerfer , Thomas Gleixner , Ulf Hansson , Vincent Guittot , Vineet Gupta , Viresh Kumar , Vivien Didelot , Vlastimil Babka , Will Deacon , bcm-kernel-feedback-list@broadcom.com, kvm@vger.kernel.org, linux-alpha@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org, linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-perf-users@vger.kernel.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-snps-arc@lists.infradead.org, linuxppc-dev@lists.ozlabs.org Subject: Re: [PATCH 7/9] lib/cpumask: add num_{possible,present,active}_cpus_{eq,gt,le} Message-ID: <20211128063447.GA270945@lapt> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: EA708F0001C7 X-Stat-Signature: aoqfry7tscptf3tcw47wdgaxhjxt1adz Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="N/urFmV2"; spf=pass (imf17.hostedemail.com: domain of yury.norov@gmail.com designates 209.85.160.173 as permitted sender) smtp.mailfrom=yury.norov@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-HE-Tag: 1638081289-844650 Content-Transfer-Encoding: quoted-printable 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: (restore CC list) On Sun, Nov 28, 2021 at 05:56:51AM +0100, Micha=C5=82 Miros=C5=82aw wrote= : > On Sat, Nov 27, 2021 at 07:57:02PM -0800, Yury Norov wrote: > > Add num_{possible,present,active}_cpus_{eq,gt,le} and replace num_*_c= pus() > > with one of new functions where appropriate. This allows num_*_cpus_*= () > > to return earlier depending on the condition. > [...] > > @@ -3193,7 +3193,7 @@ int __init pcpu_page_first_chunk(size_t reserve= d_size, > > =20 > > /* allocate pages */ > > j =3D 0; > > - for (unit =3D 0; unit < num_possible_cpus(); unit++) { > > + for (unit =3D 0; num_possible_cpus_gt(unit); unit++) { >=20 > This looks dubious. Only this? > The old version I could hope the compiler would call > num_possible_cpus() only once if it's marked const or pure, but the > alternative is going to count the bits every time making this a guarant= eed > O(n^2) even though the bitmap doesn't change. num_possible_cpus() is not const neither pure. This is O(n^2) before and = after.