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 C5F8AC433F5 for ; Mon, 29 Nov 2021 01:18:09 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4J2SCN1Hj1z3c6D for ; Mon, 29 Nov 2021 12:18:08 +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=FqHxiwrQ; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::72b; helo=mail-qk1-x72b.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=FqHxiwrQ; dkim-atps=neutral Received: from mail-qk1-x72b.google.com (mail-qk1-x72b.google.com [IPv6:2607:f8b0:4864:20::72b]) (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 4J2PyD5KQlz2ywd for ; Mon, 29 Nov 2021 10:36:34 +1100 (AEDT) Received: by mail-qk1-x72b.google.com with SMTP id q64so20961392qkd.5 for ; Sun, 28 Nov 2021 15:36:34 -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:references:mime-version :content-disposition:in-reply-to; bh=+pvPLMMOaG75eXeO+MYWVtFy7p98nfe1U4iD6DUFgqs=; b=FqHxiwrQ7QYivLGpovhQrNQCHUCj7LxMV2WH4G2Ujzkjgck5ZuLpYg6YmyS5/pcjd8 PioI6TsqEy6uPfhoz8wEavEgHnpCryLeBpBEb8dr5G6s12WteiFVLQFxrBR47EVsTB3X ndIWwpq8YabRGonzz7m7f+N7UJXzBMp2vfRHxXo9M1u6ZB6qiEh6DrJAZ2z7gRkAQ5sC IqRPeZsbgWqH6z7gZV/iyVzYOISv9QQ48jjOTsL+5HMXkolOWVbHK0gj+h+Ra3+OPnrQ HZwGnjmshXRb1nFHqTfVME98Ezv2622Zg9Ol7LGc837jR3cjnZ1W8PCl/MaA7m1eTWjV ggTQ== 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:references :mime-version:content-disposition:in-reply-to; bh=+pvPLMMOaG75eXeO+MYWVtFy7p98nfe1U4iD6DUFgqs=; b=EbdUsYYSkxcXPS4y8xWxe6PPaHyQKUHOIwmk42AhUI4dYL/C8LhbBv5Q/ZjZjlroPS glwSZ1H7v6EqUhReHolDQF8TXaPL/824kOtGhLmZUIQMhDxZUWQk42i0coI4jfPP79S2 ksZF/oly1Nu5bfHFQ0LYR9iFXTn+SF4w2kchNUS4afNOCxoREQy5JRyXcG14vbIyWqiz 7B/7xIQlD9ESJgOyjA6B+W+td+WPDVsxded6ZCM81sufVrXB7zl3g1YJoQ8+njI08vN4 wjm5Bq3a3ksmnR6huctm4NrFy2XGtUG+w4blJxaahIHdlsKPIeLcF0aPyh4F8fCqcDof vcbA== X-Gm-Message-State: AOAM532zk1bxez6Ajj4k79kfPesoWEEPGTZnUgbsMlfMwPibL0dyDRkC oGWSHr/CiSpTcA3a9GaGomk= X-Google-Smtp-Source: ABdhPJwjz8dPYMt9os+urjypBO3KPO0n0aAUmhuhKTUddMw0/hFm/BxjybZbsejId+j0oxfauAhjwQ== X-Received: by 2002:a05:620a:4491:: with SMTP id x17mr26762094qkp.528.1638142589577; Sun, 28 Nov 2021 15:36:29 -0800 (PST) Received: from localhost ([66.216.211.25]) by smtp.gmail.com with ESMTPSA id h19sm8013261qth.63.2021.11.28.15.36.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Nov 2021 15:36:28 -0800 (PST) Date: Sun, 28 Nov 2021 15:36:27 -0800 From: Yury Norov To: Nicholas Piggin Subject: Re: [PATCH 0/9] lib/bitmap: optimize bitmap_weight() usage Message-ID: <20211128233627.GA323159@lapt> References: <20211128035704.270739-1-yury.norov@gmail.com> <1638096766.3elxdzb8ly.astroid@bobo.none> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1638096766.3elxdzb8ly.astroid@bobo.none> X-Mailman-Approved-At: Mon, 29 Nov 2021 12:17:31 +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 , Andy Gross , Geert Uytterhoeven , Mel Gorman , Vineet Gupta , 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 , Sudeep Holla , linux-arm-kernel@lists.infradead.org, Stephen Boyd , Tariq Toukan , Dinh Nguyen , Jonathan Cameron , Ulf Hansson , Alexander Shishkin , Mike Marciniszyn , Rasmus Villemoes , Viresh Kumar , Subbaraya Sundeep , Will Deacon , Sagi Grimberg , linux-csky@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com, Kalle Valo , linux-snps-arc@lists.infradead.org, Kees Cook , Arnd Bergmann , "James E.J. Bottomley" , Steven Rostedt , Mark Gross , Borislav Petkov , Mauro Carvalho Chehab , Thomas Bogendoerfer , "Martin K. Petersen" , David Laight , linux-alpha@vger.kernel.org, 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 , Ingo Molnar , Jakub Kicinski , Vivien Didelot , Sunil Goutham , "Paul E. McKenney" , linux-s390@vger.kernel.org, Alexey Klimov , Heiko Carstens , Hans de Goede , 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" On Sun, Nov 28, 2021 at 09:08:41PM +1000, Nicholas Piggin wrote: > Excerpts from Yury Norov's message of November 28, 2021 1:56 pm: > > In many cases people use bitmap_weight()-based functions like this: > > > > if (num_present_cpus() > 1) > > do_something(); > > > > This may take considerable amount of time on many-cpus machines because > > num_present_cpus() will traverse every word of underlying cpumask > > unconditionally. > > > > We can significantly improve on it for many real cases if stop traversing > > the mask as soon as we count present cpus to any number greater than 1: > > > > if (num_present_cpus_gt(1)) > > do_something(); > > > > To implement this idea, the series adds bitmap_weight_{eq,gt,le} > > functions together with corresponding wrappers in cpumask and nodemask. > > There would be no change to callers if you maintain counters like what > is done for num_online_cpus() today. Maybe some fixes to arch code that > does not use set_cpu_possible() etc APIs required, but AFAIKS it would > be better to fix such cases anyway. Thanks, Nick. I'll try to do this.