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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 CCE1EC433F5 for ; Sun, 28 Nov 2021 23:36:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=+QUUYGxNbFfkAMxnCNWlxk1j7pvrKwTbzsEgz5uJ0ds=; b=hsgKqnKWkQXtNw v/4IxgFa+9Pomrp9DknqzRfQbrdWCCZVqMIS0cyoZO5+a3TmiINy83eUI5tNoPm9WjF+KOarW4cq4 kFFqp2+yUROt2nmKsBmA/+YLz9x9RtqW8uusa2HvKMcQqaYavAjv2RRtImb7GzYftxkNYfJF+4vn5 Ofl573U2UMvzm/ZJbR14KwG7Ws0++aLuIz+U1INoT6Breh6eig/36uBBON7uup3YftKfOODz/LyQs Vo3WTGxtzkWoxOHboQPibsYKw6oTTChv8VBAWzM2XeZbSmKayBkwhw9gi8XPJPqzvlTiUuneLqlUX tQUAO3ctc/8EeAuWoXbA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mrTil-00Gqgz-LJ; Sun, 28 Nov 2021 23:36:35 +0000 Received: from mail-qk1-x72f.google.com ([2607:f8b0:4864:20::72f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mrTih-00GqfR-2j; Sun, 28 Nov 2021 23:36:32 +0000 Received: by mail-qk1-x72f.google.com with SMTP id q64so20961388qkd.5; Sun, 28 Nov 2021 15:36:30 -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=Js4R5RhmLG0oOcaKrpqpNazYICXmZ0NRCDyJy/VsdQR5JlPmfB0E5W0w+H/pheomVq GITS0GahRJrGWqTcclHXhgus+YKq72ZuLy7Hvxt07Qgt0qjIPFiusUONu39LEhqKVc6O ITLMqi3LXm/N9e0YM5JmSKmYDx8zQ8AgL0Dsc2FtDlBkKaFLHuPsm4NmLC4wH9mGYbpC ySRkLf3BLqClxeS1sfCfJ+bslc6KQIUUXY1H9ctRCTfqXMtrY88RvcWlgnFWg+Oh/qPN p2u/sIuE64ck64GjldR+/BaHO06wY2w0BB5JKUEvaq3zSGv0h8Jc9gYUkcAPy5+PzDWm PJww== X-Gm-Message-State: AOAM531qbkncW/161iQlgQf3524EiFYhhr+o4MgKh5VR31+2plNydldC rw4peH0UXRopKOKxuPk4RWg= 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 Cc: Arnaldo Carvalho de Melo , Andy Gross , David Airlie , Alexey Klimov , Andi Kleen , Andrew Morton , Alexander Shishkin , Amitkumar Karwar , Andrew Lunn , Andy Shevchenko , Anup Patel , Ard Biesheuvel , Arnd Bergmann , Jens Axboe , bcm-kernel-feedback-list@broadcom.com, Borislav Petkov , Catalin Marinas , Christoph Lameter , Daniel Vetter , Dave Hansen , David Laight , Dennis Zhou , Dinh Nguyen , Geetha sowjanya , Geert Uytterhoeven , Greg Kroah-Hartman , Guo Ren , Heiko Carstens , Christoph Hellwig , Hans de Goede , Ian Rogers , Jason Wessel , "James E.J. Bottomley" , Jonathan Cameron , Jiri Olsa , Juri Lelli , Kees Cook , Krzysztof Kozlowski , Jakub Kicinski , Kalle Valo , kvm@vger.kernel.org, Lee Jones , linux-alpha@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Russell King , linux-crypto@vger.kernel.org, linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-perf-users@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Rasmus Villemoes , linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-snps-arc@lists.infradead.org, Andy Lutomirski , Mark Gross , Mark Rutland , "Martin K. Petersen" , Marc Zyngier , Matti Vaittinen , Mauro Carvalho Chehab , Mel Gorman , Mike Marciniszyn , Ingo Molnar , Michael Ellerman , Marcin Wojtas , Palmer Dabbelt , "Paul E. McKenney" , Peter Zijlstra , Solomon Peachy , Petr Mladek , "Rafael J. Wysocki" , Randy Dunlap , Steven Rostedt , Roy Pledge , Saeed Mahameed , Sagi Grimberg , Subbaraya Sundeep , Stephen Boyd , Sergey Senozhatsky , Stephen Rothwell , Sunil Goutham , Sudeep Holla , Tariq Toukan , Thomas Gleixner , Tejun Heo , Thomas Bogendoerfer , Ulf Hansson , Vlastimil Babka , Vineet Gupta , Vincent Guittot , Viresh Kumar , Vivien Didelot , Will Deacon 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-Disposition: inline In-Reply-To: <1638096766.3elxdzb8ly.astroid@bobo.none> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211128_153631_148408_8B33FE0E X-CRM114-Status: GOOD ( 19.58 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org 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. _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv