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 78647C433EF for ; Sun, 28 Nov 2021 11:09:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BA4B06B0075; Sun, 28 Nov 2021 06:09:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B533C6B0078; Sun, 28 Nov 2021 06:09:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A1B7D6B007B; Sun, 28 Nov 2021 06:09:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0032.hostedemail.com [216.40.44.32]) by kanga.kvack.org (Postfix) with ESMTP id 9235A6B0075 for ; Sun, 28 Nov 2021 06:09:00 -0500 (EST) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 54D208CA4D for ; Sun, 28 Nov 2021 11:08:50 +0000 (UTC) X-FDA: 78858066420.25.8B099E6 Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) by imf07.hostedemail.com (Postfix) with ESMTP id AEFAF10002C7 for ; Sun, 28 Nov 2021 11:08:45 +0000 (UTC) Received: by mail-pj1-f49.google.com with SMTP id w33-20020a17090a6ba400b001a722a06212so10033218pjj.0 for ; Sun, 28 Nov 2021 03:08:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:subject:to:references:in-reply-to:mime-version:message-id :content-transfer-encoding; bh=RLGVormZNrRFWCDJ7jdRt19siDEPnOtSgoMRMWSMPpw=; b=JS75cm1kNmau6QTu2rqjTEH1lacCTylUddbQig/MfaOv87fU1R4ixeZwUTvWkojCLe FVsH5wJQluo9fnDCJtLxlNsFRugI2zkbabpCQ9VhDSP+vCMkQ9XcDyPUZsKoAN0XUVPp aHUTDQx+GNGjfhDN5ufjzO429xe7p71bZ6QrT/eU2apwdj3VV4bcd4Oz9OEiXGFLWmkO KTg66HtHflRGYT80QQO1K0h4MxrasFS2dEY2Sip94P5OybBl2LvseRqW7ZJqQswnXYN6 Cntrs/UrWT/QrCgRauE5NdDXQthF0aHKCC9fzaz2Cb2jdPmYhTY0PX3z2F7VkaSzQTfW T9/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:subject:to:references:in-reply-to :mime-version:message-id:content-transfer-encoding; bh=RLGVormZNrRFWCDJ7jdRt19siDEPnOtSgoMRMWSMPpw=; b=TpBGZVAokmED2jur+4PzUeIODqW6OHWq7+W2vDox48UJ0fIUYmTOsOVPzS+/ljWW+l w4zzcEEwkoeu7utXe08BVXBatRoCWjY9joXRqE+KWFa9m54qveonmpAmvKHvT6WSAAni ROXKxtFnwYkCrtpkDXVZ6OLkFn6qHFpKX568pUOkKKp6bdhMviuEb5bGokM4XYKhHxml R264Zz5ma2H7j94iwyg//xp5FuOcVd2u7ndhmrjXpxoRvYvjyHQJ7chDX0O9B04hceM1 +K3mlPMGgY2uC5B/I9cdqeWHr5I4OX0YhCrqdAvjtNnzoUKLVjPDAUbW7QpWM1emUbz0 3VAQ== X-Gm-Message-State: AOAM533U5JgP8RrOs70SteGRl0K2jCPgJjrXlNYM09cHc3799hDZm8YB Gjak7W1Mtk0kuKRLh3qijKc= X-Google-Smtp-Source: ABdhPJwy0Op9mcVC2NuBsFMopKknqC2dkNsLfr7KDw0piI/fX2AvzDRr44yqwWjkuQxAQyAX4DCrnA== X-Received: by 2002:a17:902:7fc3:b0:144:e29c:228d with SMTP id t3-20020a1709027fc300b00144e29c228dmr51588052plb.4.1638097728470; Sun, 28 Nov 2021 03:08:48 -0800 (PST) Received: from localhost (115-64-213-93.static.tpgi.com.au. [115.64.213.93]) by smtp.gmail.com with ESMTPSA id 9sm9412647pgq.57.2021.11.28.03.08.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Nov 2021 03:08:48 -0800 (PST) Date: Sun, 28 Nov 2021 21:08:41 +1000 From: Nicholas Piggin Subject: Re: [PATCH 0/9] lib/bitmap: optimize bitmap_weight() usage To: 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 , Yury Norov References: <20211128035704.270739-1-yury.norov@gmail.com> In-Reply-To: <20211128035704.270739-1-yury.norov@gmail.com> MIME-Version: 1.0 Message-Id: <1638096766.3elxdzb8ly.astroid@bobo.none> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: AEFAF10002C7 X-Stat-Signature: 7mj5hyxrniorm9noucce6i9hmeh1r9ut Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=JS75cm1k; spf=pass (imf07.hostedemail.com: domain of npiggin@gmail.com designates 209.85.216.49 as permitted sender) smtp.mailfrom=npiggin@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-HE-Tag: 1638097725-722437 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: Excerpts from Yury Norov's message of November 28, 2021 1:56 pm: > In many cases people use bitmap_weight()-based functions like this: >=20 > if (num_present_cpus() > 1) > do_something(); >=20 > This may take considerable amount of time on many-cpus machines because > num_present_cpus() will traverse every word of underlying cpumask > unconditionally. >=20 > 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: >=20 > if (num_present_cpus_gt(1)) > do_something(); >=20 > 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