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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A5DFCC433F5 for ; Sun, 28 Nov 2021 07:05:14 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4J1zyJ6RLbz3cFg for ; Sun, 28 Nov 2021 18:05:12 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=N/urFmV2; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::829; helo=mail-qt1-x829.google.com; envelope-from=yury.norov@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=N/urFmV2; dkim-atps=neutral Received: from mail-qt1-x829.google.com (mail-qt1-x829.google.com [IPv6:2607:f8b0:4864:20::829]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4J1zHJ3kDtz2xXZ for ; Sun, 28 Nov 2021 17:34:51 +1100 (AEDT) Received: by mail-qt1-x829.google.com with SMTP id z9so13115420qtj.9 for ; Sat, 27 Nov 2021 22:34:51 -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=NO56SgbawPWFWjdWaTLIbwGP2ihh+sdxv+2uc8ZNxgVkdS3VlYvOikzehdp17akN7P EVezHFjFeWOzy/AjQCzpUnPPzmN09qjeWxby/tR4JXQFDpSJD7iI8eVYXf5AD+QiyfIt r3XNyVKPZEOtL6oQzqAJW89BU7p2jHJenFx1C0sT36YdmbjwIZHZEtfXxLAVXaPX3G1n dH007A/1X28nDXSesnsSWTz8DziDHD1QEbVBR0pxW/iAY8O0QKUt2DuG/j16cWbn0l0M Vt2BTMlBB2vWg+3h4xeObflLitKJn309vji+VvXVDkZ70yO6SpsfQ8PhFxO8ma6E6jcG fy8Q== X-Gm-Message-State: AOAM531jk0qW81k6Y6B7sxj4PLHe4neZIcN2sP59KyOZyXnS93ZF3q8N nKPlrdArk97emeq9jFo/6y8= 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=?= 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 Content-Transfer-Encoding: 8bit In-Reply-To: X-Mailman-Approved-At: Sun, 28 Nov 2021 18:04:00 +1100 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Juri Lelli , Andrew Lunn , "Rafael J. Wysocki" , Catalin Marinas , Guo Ren , Christoph Lameter , Christoph Hellwig , Andi Kleen , Vincent Guittot , Ingo Molnar , Geert Uytterhoeven , Mel Gorman , Viresh Kumar , Petr Mladek , Arnaldo Carvalho de Melo , Jens Axboe , Andy Lutomirski , Lee Jones , Greg Kroah-Hartman , Randy Dunlap , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Sergey Senozhatsky , Thomas Gleixner , linux-crypto@vger.kernel.org, Tejun Heo , Andrew Morton , Mark Rutland , Anup Patel , linux-ia64@vger.kernel.org, David Airlie , Roy Pledge , Dave Hansen , Solomon Peachy , Stephen Rothwell , Krzysztof Kozlowski , Dennis Zhou , Matti Vaittinen , linux-alpha@vger.kernel.org, Kalle Valo , Stephen Boyd , Tariq Toukan , Dinh Nguyen , Jonathan Cameron , Ulf Hansson , Alexander Shishkin , Mike Marciniszyn , Rasmus Villemoes , Subbaraya Sundeep , Will Deacon , Sagi Grimberg , linux-csky@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com, linux-arm-kernel@lists.infradead.org, linux-snps-arc@lists.infradead.org, Kees Cook , Arnd Bergmann , "James E.J. Bottomley" , Vineet Gupta , Steven Rostedt , Mark Gross , Borislav Petkov , Mauro Carvalho Chehab , Thomas Bogendoerfer , "Martin K. Petersen" , David Laight , Sudeep Holla , Geetha sowjanya , Ian Rogers , kvm@vger.kernel.org, Peter Zijlstra , Amitkumar Karwar , linux-mm@kvack.org, linux-riscv@lists.infradead.org, Jiri Olsa , Ard Biesheuvel , Marc Zyngier , Russell King , Andy Gross , Jakub Kicinski , Vivien Didelot , Sunil Goutham , "Paul E. McKenney" , linux-s390@vger.kernel.org, Alexey Klimov , Heiko Carstens , Hans de Goede , Nicholas Piggin , Marcin Wojtas , Vlastimil Babka , linuxppc-dev@lists.ozlabs.org, linux-mips@vger.kernel.org, Palmer Dabbelt , Daniel Vetter , Jason Wessel , Saeed Mahameed , Andy Shevchenko Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" (restore CC list) On Sun, Nov 28, 2021 at 05:56:51AM +0100, Michał Mirosław 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_*_cpus() > > 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 reserved_size, > > > > /* allocate pages */ > > j = 0; > > - for (unit = 0; unit < num_possible_cpus(); unit++) { > > + for (unit = 0; num_possible_cpus_gt(unit); unit++) { > > 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 guaranteed > 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.