From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2BFAEC433FE for ; Sun, 23 Jan 2022 18:39:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239583AbiAWSjz (ORCPT ); Sun, 23 Jan 2022 13:39:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239568AbiAWSjw (ORCPT ); Sun, 23 Jan 2022 13:39:52 -0500 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FA6CC06173D; Sun, 23 Jan 2022 10:39:52 -0800 (PST) Received: by mail-pf1-x436.google.com with SMTP id 128so13764292pfe.12; Sun, 23 Jan 2022 10:39:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=/+jlT2lVXINBwoznetut/x5ZWQNE1yPkmkCWTyEGTdo=; b=WlBppxzgPlWg5Fo+7JOPT7hwoRV2dBbTOigaUI478r8KWllyra55XVUV9RfIMfsKlO lK/Z57nJOs3uZJYYR89Z627ep2lilGBNNvV51oOLJEUCil+VoUQzDO3iVymmYDo4Jr6e 8Pyu5ceHZYdzwjGEgpUaLqykJppsp8vGmwcMd0U3+Vf+sNStZCYZXINjTdKftHLtxeWb aBx2DfLfxsA1E9xout1XqlvKwHGiV9lsTjLlaQNrIs63fkeq/ynEUrmKNYiJo/0bdiFn HTpQbXeGvTWjrpcuEkQ2jAVwneAiSL0tCPDcazSQIsW+u1L8DjED/rWgyW5uC1H810jF Rw/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/+jlT2lVXINBwoznetut/x5ZWQNE1yPkmkCWTyEGTdo=; b=wTgqhyuCVM8sdtLxgQ4f8dLXBcPsA7S4AdHU82L8kLbPhCLao506z1diJaspBFp/gJ 4Jfhf7CDOs8fpYlG/1ubMgiFdxWml7Csl1eTFoadbmOVSP6U6glxW1Bh6/1eWx0ylGxL dgLPNPA0bXedJqWPFwc+WEkI1bIol5hThy0jm0IMck/jAT1QPKWPQma92UnNZuRQ8dKK YNEaGeKcuWYqYFdnoYlivUoDjCot81ZtZcPB/oBOpcGwIbtVP31A94Xxfz0dG6UKqnTM aR7sIJsW86ox5MdE7H/t2Lmqzpmg1O4oBS1t1/1Ts4jpqwTGBgQU4VZRWo7CGL1AC4TL 782w== X-Gm-Message-State: AOAM532dv9MgCuODvfLqhVBz3f4CDwbdnwOEYvUTy47eSqAMSCUA10OB bTecohEYwyNs1BWkftz6llk= X-Google-Smtp-Source: ABdhPJyHoKweRJ5zu+v4p1cIq4SLrkNpd6lpq/L4ePkg2QgQmYL9OAo+KD4DfHvS+HqH4DK46mH0xA== X-Received: by 2002:a63:2b03:: with SMTP id r3mr9393877pgr.201.1642963191866; Sun, 23 Jan 2022 10:39:51 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id c26sm9566324pgb.53.2022.01.23.10.39.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:39:51 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Florian Fainelli , Andrew Lunn , Vivien Didelot , Vladimir Oltean , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org Subject: [PATCH 01/54] net/dsa: don't use bitmap_weight() in b53_arl_read() Date: Sun, 23 Jan 2022 10:38:32 -0800 Message-Id: <20220123183925.1052919-2-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Don't call bitmap_weight() if the following code can get by without it. Signed-off-by: Yury Norov Acked-by: Florian Fainelli --- drivers/net/dsa/b53/b53_common.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_com= mon.c index 3867f3d4545f..9a10d80125d9 100644 --- a/drivers/net/dsa/b53/b53_common.c +++ b/drivers/net/dsa/b53/b53_common.c @@ -1620,12 +1620,8 @@ static int b53_arl_read(struct b53_device *dev, u64 = mac, return 0; } =20 - if (bitmap_weight(free_bins, dev->num_arl_bins) =3D=3D 0) - return -ENOSPC; - *idx =3D find_first_bit(free_bins, dev->num_arl_bins); - - return -ENOENT; + return *idx >=3D dev->num_arl_bins ? -ENOSPC : -ENOENT; } =20 static int b53_arl_op(struct b53_device *dev, int op, int port, --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63FAAC433F5 for ; Sun, 23 Jan 2022 18:40:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239617AbiAWSkB (ORCPT ); Sun, 23 Jan 2022 13:40:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239584AbiAWSjz (ORCPT ); Sun, 23 Jan 2022 13:39:55 -0500 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58292C06173B; Sun, 23 Jan 2022 10:39:55 -0800 (PST) Received: by mail-pj1-x1029.google.com with SMTP id l16so14124384pjl.4; Sun, 23 Jan 2022 10:39:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=JVlgIOfm3MirYG6wT3KmStCSBcBsfAc0KKMNuO1EDBQ=; b=IRJeAZll5KWb5nZplfSeU6guRB4GiFVlmwRWN5THO4+nOHnkye//P3+ooMx1qU0Idu fFZVRqj/QyGAVXmatp5tgfaYpJXYAtpnjBBxRWu5Wvkmnwsx3g8Tjgh9oQwBR2wPW++P wLdOy3uqaoPu+EyqNkH5kZ+fUz4ohWrcIVJxTC3MCifIpKCWGz1qFS6FNHxpXxFe0PoC AT3uXJOngA4y0EhtxI53KfYaPrJAqJrWOBT1HOtR03NOY7P0vt4kZgHhC2coLJKo7Us3 W80ZyTrpVomG2skPaPmorlVBJwVUANQ70fcVX6xsG5vtQhhZlfbAeqKRjnknAq4cVDJ8 6T7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JVlgIOfm3MirYG6wT3KmStCSBcBsfAc0KKMNuO1EDBQ=; b=LY27OMni/Ch9QPMSY9/fawSBd29VXXhViJjf7V5KOlyuU5a5Z0hVdoHGUVlkjOnoiJ 6E2TaawilckyX6XMpXTXUO9qcdgNGpgf/gLelj7ekTSZlP3e3wdCmwilKSMt/PVRwAwI H945s3KkQKZDuNSy2eid0mXDhohxrB5gIMHhs21TW9jLC0zQ1rghGes0NG3p0rlbF45I zOQ7DeKqs5JhhUIkEWAXmXcazyU0syqxqAsYtOirvlIUVxFhKSTY1TFIZw15ETsXk+4+ vqKMOV3v24tbaKbtm5euFuOs9DTbo5O5NgMog3NUWIHZ1F0g6GVQe7NxmHxRn/P/IQHE QXCw== X-Gm-Message-State: AOAM532vCQX9D/SVJ6A5fFxxob4yc7SlO/E4k+uvqZDn0pepd9vdvjN3 HaY7Gs9xANKkLwitvctgqkU= X-Google-Smtp-Source: ABdhPJxoxLg5zqGpwJYdAVGDViNYQ/g58elCQIgqh6DVg5oaESBFyRvjiA+IS22GevMehG0R2Obh9g== X-Received: by 2002:a17:90b:1e05:: with SMTP id pg5mr9787026pjb.188.1642963194829; Sun, 23 Jan 2022 10:39:54 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id h9sm2038248pfi.54.2022.01.23.10.39.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:39:54 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Florian Fainelli , "David S . Miller " , Jakub Kicinski , bcm-kernel-feedback-list@broadcom.com, netdev@vger.kernel.org Subject: [PATCH 02/54] net/ethernet: don't use bitmap_weight() in bcm_sysport_rule_set() Date: Sun, 23 Jan 2022 10:38:33 -0800 Message-Id: <20220123183925.1052919-3-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Don't call bitmap_weight() if the following code can get by without it. Signed-off-by: Yury Norov Acked-by: Florian Fainelli --- drivers/net/ethernet/broadcom/bcmsysport.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ether= net/broadcom/bcmsysport.c index 60dde29974bf..5284a5c961db 100644 --- a/drivers/net/ethernet/broadcom/bcmsysport.c +++ b/drivers/net/ethernet/broadcom/bcmsysport.c @@ -2180,13 +2180,9 @@ static int bcm_sysport_rule_set(struct bcm_sysport_p= riv *priv, if (nfc->fs.ring_cookie !=3D RX_CLS_FLOW_WAKE) return -EOPNOTSUPP; =20 - /* All filters are already in use, we cannot match more rules */ - if (bitmap_weight(priv->filters, RXCHK_BRCM_TAG_MAX) =3D=3D - RXCHK_BRCM_TAG_MAX) - return -ENOSPC; - index =3D find_first_zero_bit(priv->filters, RXCHK_BRCM_TAG_MAX); if (index >=3D RXCHK_BRCM_TAG_MAX) + /* All filters are already in use, we cannot match more rules */ return -ENOSPC; =20 /* Location is the classification ID, and index is the position --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D766C433EF for ; Sun, 23 Jan 2022 18:40:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239635AbiAWSkE (ORCPT ); Sun, 23 Jan 2022 13:40:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239588AbiAWSj6 (ORCPT ); Sun, 23 Jan 2022 13:39:58 -0500 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47680C06173D; Sun, 23 Jan 2022 10:39:58 -0800 (PST) Received: by mail-pl1-x62b.google.com with SMTP id c9so13468678plg.11; Sun, 23 Jan 2022 10:39:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=6Y67UpGJgCeGI3YjkkCV3h1RWBz0EaSLMoBqw+YNaKM=; b=fj2Be3j4ZXRuOSxn0ZBVfLiLCyC1T7HgxLBl1dbJ+1GQMBP1uFWdWTNbPb+uWf/xrO fEq/nS9cpgMQq4Z/EeGzuaSIb6mOIrZ7LgCI/XoIPnvJf3RsIJv7y1hkMvE+QnCq9zKA JMV8tbR5pot6iHL3EBKW2XXAqJM5+ApGwCvEnj7iWYw02WTqJjO0ci1TnCiThd9Xg445 pcSMonvfQBFpKb5hWyBaJtMySDLtJzDJSIYoXZXdot1LheibM6eHhYHQWrtYShBnp/K+ iwi8TcO5n5tk0ketawzGGBBDDj8oY+p4hunGEj1VW3/rokkCis1vkQfda195htV4ArRP EnQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6Y67UpGJgCeGI3YjkkCV3h1RWBz0EaSLMoBqw+YNaKM=; b=i4JhkczdiVAZxbJ8/hC6I8OSUtGal6kftEu+QieyBk9lIMir0JiKqkGmS47QamLxjL d1PTX72aJDrGjfcI2t7eqlliwGSEZP5ZBKdTYv8VGwOz4YJAg1fAe6kG+E3K2BjUhl34 HvuBuo/++8dU60Mlc8RxpN3f8AIJV7kyNL/NguW8+Sfx/zBkxDAgB6Qz1S+t+b7XcArI PkgYC629xqLOPEuJEUsw2+m7RMIO5lYciiX9GZN0mvvSmc5CVoK1Qx48/A7upEeQ/Sfp edzkxutQsYlzu0wezb1PmK7Iv/dKhrhhiV8MwhQvHRwxtp63JVrrp1Qp+En5wJk3mM5x LQqA== X-Gm-Message-State: AOAM532JgeIgVfGsW9BTN3PPcCuIhFrcrilQkQquuTcuz/r05gfQwh+h oE7qPyIX/Vj0h3ZHoCzHaIg= X-Google-Smtp-Source: ABdhPJxGVSXvOUZjhokqqNWOPu2slOcHKradSt7jDO2Wwih5XKmhc8jCE0q6lk4Znh/tsr/lxxzGbw== X-Received: by 2002:a17:90b:1b0e:: with SMTP id nu14mr9710263pjb.39.1642963197744; Sun, 23 Jan 2022 10:39:57 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id d8sm9389575pjz.32.2022.01.23.10.39.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:39:57 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, "Rafael J. Wysocki" , Daniel Lezcano , Amit Kucheria , Zhang Rui , Sebastian Andrzej Siewior , Christophe JAILLET , Rikard Falkeborn , linux-pm@vger.kernel.org Subject: [PATCH 03/54] thermal/intel: don't use bitmap_weight() in end_power_clamp() Date: Sun, 23 Jan 2022 10:38:34 -0800 Message-Id: <20220123183925.1052919-4-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Don't call bitmap_weight() if the following code can get by without it. Signed-off-by: Yury Norov --- drivers/thermal/intel/intel_powerclamp.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/thermal/intel/intel_powerclamp.c b/drivers/thermal/int= el/intel_powerclamp.c index 14256421d98c..c841ab37e7c6 100644 --- a/drivers/thermal/intel/intel_powerclamp.c +++ b/drivers/thermal/intel/intel_powerclamp.c @@ -556,12 +556,9 @@ static void end_power_clamp(void) * stop faster. */ clamping =3D false; - if (bitmap_weight(cpu_clamping_mask, num_possible_cpus())) { - for_each_set_bit(i, cpu_clamping_mask, num_possible_cpus()) { - pr_debug("clamping worker for cpu %d alive, destroy\n", - i); - stop_power_clamp_worker(i); - } + for_each_set_bit(i, cpu_clamping_mask, num_possible_cpus()) { + pr_debug("clamping worker for cpu %d alive, destroy\n", i); + stop_power_clamp_worker(i); } } =20 --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 933E3C433F5 for ; Sun, 23 Jan 2022 18:40:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233294AbiAWSkI (ORCPT ); Sun, 23 Jan 2022 13:40:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239622AbiAWSkC (ORCPT ); Sun, 23 Jan 2022 13:40:02 -0500 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5123AC061744; Sun, 23 Jan 2022 10:40:02 -0800 (PST) Received: by mail-pj1-x102d.google.com with SMTP id d15-20020a17090a110f00b001b4e7d27474so14267008pja.2; Sun, 23 Jan 2022 10:40:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=zfgimupqB4xhJIvLvGgrer31y9tj8J1RXghy7qnKugc=; b=gxMhHOGPzZikvHKNf5etkD8h5zwamCQvFvYm0T3TfrFpDLfs91aCsHtI+xqcPa8URu FFjowqDhhJ69tQF4OsI04OdzbE5H9ypOLCLw0BtlXsPReQihAHoMJCWdJw5zE4jVLwhO g1nviPaL/KLA6cJWfPzd19d6k4Ji+gex9ZTZO6W3Zaz3jY8H7L8ePhgHrqIqtcKI37r7 cowwVtPoBOznRQ1kol1AgbR+qWyIdu3IGSHuMqs4JxjKQY8qyAQLqRH8r0wbcItyWyPo E6MFahxwAjE0Bt/rxvJ7psK8eynqLBYQJQKjMtYYJccVf+NgvivqphIBCiCRJT/6TI3g RrSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zfgimupqB4xhJIvLvGgrer31y9tj8J1RXghy7qnKugc=; b=UejStlkhzuhx+lQNLhnf6qYMHBvkJ6yjLtghEAmZXMf+LBgRrInK7XpHi3KKXh4vOe jhpDWfbBGJiYYL0CDxmnSHIj0Mm2Jgz4snGLQQsIXLv+TdM622OhTaOMePNLhEfLRLXp 6ASkFtykNOeH994+XtTlx5dl5VPrhjkkgOTGN7jRhRismz40AVDEKNt4s+JxlYs3oNY/ EnrY4uFoE3qKKiMvA6BSsuSMlFtY0J9f3zB+o5F8V7MTwHLya+9XQFNIyd/B7/96dYqa el3yfkQMiUVncJOi0fHxA89d7nXXvDlKlvwGIY0azNZnj6mFCNRS42mpCxEBT9UipC7m DTnQ== X-Gm-Message-State: AOAM5317ks6D9UURsd+ougE+pSX77B017RQc+8qxuo8p8TIdlJe0wjpj R93f73LTPxm7JEWogSakeYs= X-Google-Smtp-Source: ABdhPJxLWQjXfOWkcABvAW38WG6KUSqa6hXvCSlwZOr+ADYOSoQ4eSLrZHymWaTH90oODMTjxHWQng== X-Received: by 2002:a17:902:ea0d:b0:14b:4c26:f43d with SMTP id s13-20020a170902ea0d00b0014b4c26f43dmr2267545plg.135.1642963201797; Sun, 23 Jan 2022 10:40:01 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id pj7sm1940960pjb.50.2022.01.23.10.40.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:40:01 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Tariq Toukan , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, linux-rdma@vger.kernel.org Subject: [PATCH 04/54] net: mellanox: fix open-coded for_each_set_bit() Date: Sun, 23 Jan 2022 10:38:35 -0800 Message-Id: <20220123183925.1052919-5-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Mellanox driver has an open-coded for_each_set_bit(). Fix it. Signed-off-by: Yury Norov Reviewed-by: Tariq Toukan --- drivers/net/ethernet/mellanox/mlx4/cmd.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/cmd.c b/drivers/net/etherne= t/mellanox/mlx4/cmd.c index e10b7b04b894..c56d2194cbfc 100644 --- a/drivers/net/ethernet/mellanox/mlx4/cmd.c +++ b/drivers/net/ethernet/mellanox/mlx4/cmd.c @@ -1994,21 +1994,16 @@ static void mlx4_allocate_port_vpps(struct mlx4_dev= *dev, int port) =20 static int mlx4_master_activate_admin_state(struct mlx4_priv *priv, int sl= ave) { - int port, err; + int p, port, err; struct mlx4_vport_state *vp_admin; struct mlx4_vport_oper_state *vp_oper; struct mlx4_slave_state *slave_state =3D &priv->mfunc.master.slave_state[slave]; struct mlx4_active_ports actv_ports =3D mlx4_get_active_ports( &priv->dev, slave); - int min_port =3D find_first_bit(actv_ports.ports, - priv->dev.caps.num_ports) + 1; - int max_port =3D min_port - 1 + - bitmap_weight(actv_ports.ports, priv->dev.caps.num_ports); =20 - for (port =3D min_port; port <=3D max_port; port++) { - if (!test_bit(port - 1, actv_ports.ports)) - continue; + for_each_set_bit(p, actv_ports.ports, priv->dev.caps.num_ports) { + port =3D p + 1; priv->mfunc.master.vf_oper[slave].smi_enabled[port] =3D priv->mfunc.master.vf_admin[slave].enable_smi[port]; vp_oper =3D &priv->mfunc.master.vf_oper[slave].vport[port]; @@ -2063,19 +2058,13 @@ static int mlx4_master_activate_admin_state(struct = mlx4_priv *priv, int slave) =20 static void mlx4_master_deactivate_admin_state(struct mlx4_priv *priv, int= slave) { - int port; + int p, port; struct mlx4_vport_oper_state *vp_oper; struct mlx4_active_ports actv_ports =3D mlx4_get_active_ports( &priv->dev, slave); - int min_port =3D find_first_bit(actv_ports.ports, - priv->dev.caps.num_ports) + 1; - int max_port =3D min_port - 1 + - bitmap_weight(actv_ports.ports, priv->dev.caps.num_ports); =20 - - for (port =3D min_port; port <=3D max_port; port++) { - if (!test_bit(port - 1, actv_ports.ports)) - continue; + for_each_set_bit(p, actv_ports.ports, priv->dev.caps.num_ports) { + port =3D p + 1; priv->mfunc.master.vf_oper[slave].smi_enabled[port] =3D MLX4_VF_SMI_DISABLED; vp_oper =3D &priv->mfunc.master.vf_oper[slave].vport[port]; --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7CDFCC433FE for ; Sun, 23 Jan 2022 18:40:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239651AbiAWSkO (ORCPT ); Sun, 23 Jan 2022 13:40:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239588AbiAWSkF (ORCPT ); Sun, 23 Jan 2022 13:40:05 -0500 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 441E5C061401; Sun, 23 Jan 2022 10:40:05 -0800 (PST) Received: by mail-pf1-x42f.google.com with SMTP id n32so4678122pfv.11; Sun, 23 Jan 2022 10:40:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=CMyb+uatsmk9qk9XVLHK9qLtTawikXiv3prI/J8nsYM=; b=FEb+34HTho0mKP3DvocyY5vmMMIY0jI+I0rv7W6aUWsRjGVGKae9x0632mvuE0VukX zea1g8JwnWdhuggaBW8Y/WdgbU1N97zxV/0lc6CVl6kbSLEu1CjejIFbnLW9WV32C1kU FEkKIt5A0hJfgPODT6AEm0bK2BqHK75ha9fyOYv/j+Ck8z034STtFPkqMtYK4YAyK09y B5tPcb3PlT/dgTM3UlBOIsFXEQ9fL4+wKUAhRQZHjGkf7umylX7mr7nvGMt8Cfb0SjUH m+xIEdg2rox44nz7G2yru3pMJuVJZnJeffn9C9FJnbibfqOZnCaDstrg3EG1S4ajlJf2 y5TQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CMyb+uatsmk9qk9XVLHK9qLtTawikXiv3prI/J8nsYM=; b=ufjsuJ4ls1F6hi8WyIyfzbjo8FtAyp+LJyBCSnXuj41DDsc9bfdY1v2PCCi6n238zc /NOeyVc2TEeATQCpeB+m13D+XyONmKkfBEW8ck+7Z3/Kfo8vt3xti39Kj6JwZ77OxtPA wZp7DsEWCEo6gvwF0i/XizAFhzs0oZaHPcklZ+M0pko6sazUHGCFSeClNSzVoz9E1BIZ 8jev3mMlZ1hPG8eBZneDMBiozxzSLsYyoR6Lsri7GOTiLB1scG5Nzs1fmgMpqiWNEnxc np/DmN6Jxk9MY1EYqZTTKiGtuG6InA80pr3col9Mb7b64i+i7DAM4w7FROgdeU+H5Myc H7nQ== X-Gm-Message-State: AOAM530Mxt3ikBG+imDDgBQyMGxyRG2yGnfmd+HivjwHsgOLBjSXgCMn +HgJHMz+GbuMEAAbF0TGBEE= X-Google-Smtp-Source: ABdhPJwf5QI0SPNdOnucozcNruZiu59ZtsANYNvXFoEq6uEFbg5cEgIjFW+kxBeTM2iWtFnYw5haWw== X-Received: by 2002:a63:6f87:: with SMTP id k129mr9529438pgc.248.1642963204752; Sun, 23 Jan 2022 10:40:04 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id a1sm9996929pgg.18.2022.01.23.10.40.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:40:04 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Nick Hu , Greentime Hu , Vincent Chen , linux-perf-users@vger.kernel.org Subject: [PATCH 05/54] nds32: perf: replace bitmap_weight with bitmap_empty where appropriate Date: Sun, 23 Jan 2022 10:38:36 -0800 Message-Id: <20220123183925.1052919-6-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" nds32_pmu_enable calls bitmap_weight() to check if any bit of a given bitmap is set. It's better to use bitmap_empty() in that case because bitmap_empty() stops traversing the bitmap as soon as it finds first set bit, while bitmap_weight() counts all bits unconditionally. Signed-off-by: Yury Norov --- arch/nds32/kernel/perf_event_cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/nds32/kernel/perf_event_cpu.c b/arch/nds32/kernel/perf_ev= ent_cpu.c index a78a879e7ef1..ea44e9ecb5c7 100644 --- a/arch/nds32/kernel/perf_event_cpu.c +++ b/arch/nds32/kernel/perf_event_cpu.c @@ -695,7 +695,7 @@ static void nds32_pmu_enable(struct pmu *pmu) { struct nds32_pmu *nds32_pmu =3D to_nds32_pmu(pmu); struct pmu_hw_events *hw_events =3D nds32_pmu->get_hw_events(); - int enabled =3D bitmap_weight(hw_events->used_mask, + bool enabled =3D !bitmap_empty(hw_events->used_mask, nds32_pmu->num_events); =20 if (enabled) --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 39CE2C433F5 for ; Sun, 23 Jan 2022 18:40:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239680AbiAWSkQ (ORCPT ); Sun, 23 Jan 2022 13:40:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239653AbiAWSkK (ORCPT ); Sun, 23 Jan 2022 13:40:10 -0500 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EDADC06174E; Sun, 23 Jan 2022 10:40:08 -0800 (PST) Received: by mail-pl1-x631.google.com with SMTP id d1so13469511plh.10; Sun, 23 Jan 2022 10:40:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=fXTatFQVxk5Bi3xsp9CFfQ0rYZTcQkLIFRbBZJuCKTo=; b=KYb54rPHkbyc69CRDBpNpVXaOnbgnehqVIcw6Q5nYZrUJqD8fYG2PdedR79iLsupu1 0gdBCwGbPIeYyZXmni9s7ZZpmKmo/Qkt6ciMlPncE4deOuznLGJzZl1K94T185JjDU1/ 0BM4tN7Pc3cUFGARdyGOI4WjOia7CvHbWBmFiJQomUMYAPygd6mJY/DqSogM2u5pn9Al mLIiLcJHMr9gmdThRmWN027YvK50UezK0LFgIFkLjtOSJtI19b+k2G8Scgm6vJnRW1yL NAcnbU0VWi26fHR+siKm19tyEpaeiFoGlNWzQNa+ac8t06cAXMt05iN57RqKTVDHGZd7 reYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fXTatFQVxk5Bi3xsp9CFfQ0rYZTcQkLIFRbBZJuCKTo=; b=gY2zTaPAOGGcOun3NSiwPOGJJ71sZn0VRWIwu4ehkfUYSLlm9lX6hzhRmXopTkHBSV qAsRnBOZ9cGxvlZKTur/+fnlQsthSgp0296bMII2f86EZzmLQMQHe3sf1ntRzx3CAjSH aTcknjGC6qF+x1j5+uPQIgVQKGUbA3Hdf6CNvJvcQP79WRYLXWbjcfNegz7n8wnnQG8D QP/M7fdwCdfrNS7+CGO2VnGBT9+yYmY791KTkiOL4QFoLmi3/Sjal3YGD+XiK1XJHQYZ iQLrfZDXsUT7oQHYWGCgN7Ki+SXoX4xaRHRqyzV6Jawghnk7NXk8JzgKycd5w3UvyNzw E6/Q== X-Gm-Message-State: AOAM532QpD+NZ2y4UuKCqTBZ7ylfKMylbzsETBYsinYE4V8QnB31PXEJ IV1OYbB1nxkKQOw7cmtcqNU= X-Google-Smtp-Source: ABdhPJxGmwUYVMRzODasTSE+4WExw7bWOf9Gl61W4KWfE3KrsgTh2yrUpg0D0gJG15OcPQdnUHlrww== X-Received: by 2002:a17:902:7844:b0:14a:9cff:66c7 with SMTP id e4-20020a170902784400b0014a9cff66c7mr11824524pln.14.1642963207648; Sun, 23 Jan 2022 10:40:07 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id m13sm10828821pjl.39.2022.01.23.10.40.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:40:07 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , x86@kernel.org, kvm@vger.kernel.org Subject: [PATCH 06/54] x86/kvm: replace bitmap_weight with bitmap_empty where appropriate Date: Sun, 23 Jan 2022 10:38:37 -0800 Message-Id: <20220123183925.1052919-7-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" In some places kvm/hyperv.c code calls bitmap_weight() to check if any bit of a given bitmap is set. It's better to use bitmap_empty() in that case because bitmap_empty() stops traversing the bitmap as soon as it finds first set bit, while bitmap_weight() counts all bits unconditionally. Signed-off-by: Yury Norov --- arch/x86/kvm/hyperv.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c index 6e38a7d22e97..2c3400dea4b3 100644 --- a/arch/x86/kvm/hyperv.c +++ b/arch/x86/kvm/hyperv.c @@ -90,7 +90,7 @@ static void synic_update_vector(struct kvm_vcpu_hv_synic = *synic, { struct kvm_vcpu *vcpu =3D hv_synic_to_vcpu(synic); struct kvm_hv *hv =3D to_kvm_hv(vcpu->kvm); - int auto_eoi_old, auto_eoi_new; + bool auto_eoi_old, auto_eoi_new; =20 if (vector < HV_SYNIC_FIRST_VALID_VECTOR) return; @@ -100,16 +100,16 @@ static void synic_update_vector(struct kvm_vcpu_hv_sy= nic *synic, else __clear_bit(vector, synic->vec_bitmap); =20 - auto_eoi_old =3D bitmap_weight(synic->auto_eoi_bitmap, 256); + auto_eoi_old =3D bitmap_empty(synic->auto_eoi_bitmap, 256); =20 if (synic_has_vector_auto_eoi(synic, vector)) __set_bit(vector, synic->auto_eoi_bitmap); else __clear_bit(vector, synic->auto_eoi_bitmap); =20 - auto_eoi_new =3D bitmap_weight(synic->auto_eoi_bitmap, 256); + auto_eoi_new =3D bitmap_empty(synic->auto_eoi_bitmap, 256); =20 - if (!!auto_eoi_old =3D=3D !!auto_eoi_new) + if (auto_eoi_old =3D=3D auto_eoi_new) return; =20 down_write(&vcpu->kvm->arch.apicv_update_lock); --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 37237C433EF for ; Sun, 23 Jan 2022 18:40:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239753AbiAWSkb (ORCPT ); Sun, 23 Jan 2022 13:40:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239638AbiAWSkM (ORCPT ); Sun, 23 Jan 2022 13:40:12 -0500 Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F200C06173B; Sun, 23 Jan 2022 10:40:11 -0800 (PST) Received: by mail-pg1-x52b.google.com with SMTP id h23so13121408pgk.11; Sun, 23 Jan 2022 10:40:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=5dgQylvVki0nkzDnS/+Po4tisaRNHjVIflYn4fyQ95A=; b=NPOFz183ei2daEpofKHSZlIolbNFGvjJd0bvuAgxnQXa1mbuzsB8hvhkTyioW5ltoS y5sMMuWjyvc6kDKU9Jy9RUasJPQQydggdGhHkwIb35VXWo1CaSQ0zCd9mdEPpwTnH9lE TQqSWzrtUY0GJOlgUr5T7TRU7USi2tfNg0iPTHfbRBNkqvnNmL37z4Z3nE/duk/GdyQ5 cmvTi8PRmdLMbpY5nfSMCDbv/xdK/q2iKEIs8W5TKJvzZ6qlATNv/wm7uCbiAn1dPBU1 +aM82cX+6IPqeayXYKuA7LfBX8rP3SzfEyhASY6EF68X1T6Es8PNFrBgcehKUkL4wkcD DEnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5dgQylvVki0nkzDnS/+Po4tisaRNHjVIflYn4fyQ95A=; b=C1XnGtuLZ+5b+jIpOZs8MkATAvPQ8EfJaC9z5s2FLWazeDtrPzD6gsXUmVACzVD5iD wOlJTT0C24+OwJPhf+xdAXqmVtWgi2ZKhVbt0mphnHRb5D0LaO8Me9g9wrDp5KX+nxPF 8QQwkas0RbsxMUINecOQJUediEutlqfByXCscoFJCF2rt3Qjj5ywrDNpTlclv8ZavaFP BrkNxGXCIQ1KqYH5ffVB4A1jDiyhWiKgfzzn0yQeB3/yRR1KJcYu3sz3y4Latirfu9Rt sg69Cb+5i0APwX31C5aQ6+SdXepuT9r+RJDeSBXhOADiiRW4bLuJ2bQti2+jH9zwC3B/ J1yg== X-Gm-Message-State: AOAM531AGLPoGrgMg+bghXOb31wb/ViO1NGjg5EbTC0EAUllEVJUoJJg l8RRJPpQjWR+kBuaDu2hwz0= X-Google-Smtp-Source: ABdhPJzsBbCwcI8UQ9QtXW6uxvo0U0RHWhtm06Iz8OLFP8vkslwU6MYNdswa+/Z1sC5DBYGMC9d39A== X-Received: by 2002:a05:6a00:23cc:b0:4c6:d3b8:29ea with SMTP id g12-20020a056a0023cc00b004c6d3b829eamr11191897pfc.78.1642963211024; Sun, 23 Jan 2022 10:40:11 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id a3sm10460879pfk.73.2022.01.23.10.40.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:40:10 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Rob Clark , Sean Paul , Abhinav Kumar , David Airlie , Daniel Vetter , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org Subject: [PATCH 07/54] gpu: drm: replace bitmap_weight with bitmap_empty where appropriate Date: Sun, 23 Jan 2022 10:38:38 -0800 Message-Id: <20220123183925.1052919-8-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" smp_request_block() in drivers/gpu/drm/msm/disp/mdp5/mdp5_smp.c calls bitmap_weight() to check if any bit of a given bitmap is set. It's better to use bitmap_empty() in that case because bitmap_empty() stops traversing the bitmap as soon as it finds first set bit, while bitmap_weight() counts all bits unconditionally. Signed-off-by: Yury Norov --- drivers/gpu/drm/msm/disp/mdp5/mdp5_smp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_smp.c b/drivers/gpu/drm/msm= /disp/mdp5/mdp5_smp.c index d7fa2c49e741..56a3063545ec 100644 --- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_smp.c +++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_smp.c @@ -68,7 +68,7 @@ static int smp_request_block(struct mdp5_smp *smp, uint8_t reserved; =20 /* we shouldn't be requesting blocks for an in-use client: */ - WARN_ON(bitmap_weight(cs, cnt) > 0); + WARN_ON(!bitmap_empty(cs, cnt)); =20 reserved =3D smp->reserved[cid]; =20 --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 875F4C433EF for ; Sun, 23 Jan 2022 18:40:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239712AbiAWSk0 (ORCPT ); Sun, 23 Jan 2022 13:40:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239650AbiAWSkO (ORCPT ); Sun, 23 Jan 2022 13:40:14 -0500 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36D4CC061744; Sun, 23 Jan 2022 10:40:14 -0800 (PST) Received: by mail-pl1-x635.google.com with SMTP id y17so3130394plg.7; Sun, 23 Jan 2022 10:40:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=wuCEC1DNMMa7rD1lJm/KbzT4QoZBEAK+Wq0lZsijL0E=; b=adBm5C46WHa+SqaVcfg/e7fBkpNQqkpVo+XFem4Slx6gw952BGG6XbNnKPU+0j7a1z CV9pkYrmO/yS2n03l5PKu9DuG7U8o+2dLXjMRbayjl4y7ovc6A14u23xvv++vlL2RwZb QBOnNfjUAXDNvJ0ils0KPIaveiqyrImHkBU5YO8vJeuD+wXqT7Vd/npI4VLDyp2sIUEh 9TpvMAiivxyIJvIAKnoVKMnfIRBi+0uh53dq6uCARjaZqdpPQgtBg0+xE8okK8qJUw5x GkFNj1C6hy7fktEJHJ4RaFYXgSegQ1d9X2bTja4WR/1sp9o36n4hN/tS1Y2dfuUXihBK KLUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wuCEC1DNMMa7rD1lJm/KbzT4QoZBEAK+Wq0lZsijL0E=; b=PvBCyqFrXaxokdRwLpkokMr7JOSbDvna2M2wj6PmvX2TPCJxnGuYpU6w0ehERWp+d+ 8LMBiQD6/w3ukOJ9Ceord6VvnBY5P7YSLJYYqbkXuRLEYAKCYzBNVXTsCNIy/y+4zjFt 24s9uOID5oMuc9q9KpzayB3yQOJ+Qll+QgBRq+5GBHK1z/d2Ot3+rFSDmfZEH+iEGv5i bO5vHtc8FouKcMjh4lwlgT25NzJQ2oDCpEsNkiry2x7XmmgBJIMmH/7iuXb4Gy6dOLvE XKIUipJX6UhCs5CYO6TPLhBTG3sTRCcCuCQuIlGuoIXb8TPAKQCQelJsGFEpGk0vdHfs GFIA== X-Gm-Message-State: AOAM531INligb4Xonb5ylcepuLd4QKg1QXjM3ex4iiKfNVYYj/d0nqh0 28fA987bx1SUGJxM13A67SVbMXo/LuM= X-Google-Smtp-Source: ABdhPJzACqIpOshcLMvZufgVtTCkTi5/v/UXrPKbyjQvs/zo09oEZyQLbdgvh5reWb2CzD5QERIA/A== X-Received: by 2002:a17:903:1c5:b0:14b:f87:bf3b with SMTP id e5-20020a17090301c500b0014b0f87bf3bmr11650785plh.130.1642963213640; Sun, 23 Jan 2022 10:40:13 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id om12sm5089855pjb.48.2022.01.23.10.40.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:40:13 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Jesse Brandeburg , Tony Nguyen , "David S. Miller" , Jakub Kicinski , intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org Subject: [PATCH 08/54] net: ethernet: replace bitmap_weight with bitmap_empty for intel Date: Sun, 23 Jan 2022 10:38:39 -0800 Message-Id: <20220123183925.1052919-9-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The ice_vf_has_no_qs_ena() calls bitmap_weight() to check if any bit of a given bitmap is set. It's better to use bitmap_empty() in that case because bitmap_empty() stops traversing the bitmap as soon as it finds first set bit, while bitmap_weight() counts all bits unconditionally. Signed-off-by: Yury Norov --- drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c b/drivers/net= /ethernet/intel/ice/ice_virtchnl_pf.c index 39b80124d282..9dd52aab68cc 100644 --- a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +++ b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c @@ -267,8 +267,8 @@ ice_set_pfe_link(struct ice_vf *vf, struct virtchnl_pf_= event *pfe, */ static bool ice_vf_has_no_qs_ena(struct ice_vf *vf) { - return (!bitmap_weight(vf->rxq_ena, ICE_MAX_RSS_QS_PER_VF) && - !bitmap_weight(vf->txq_ena, ICE_MAX_RSS_QS_PER_VF)); + return (bitmap_empty(vf->rxq_ena, ICE_MAX_RSS_QS_PER_VF) && + bitmap_empty(vf->txq_ena, ICE_MAX_RSS_QS_PER_VF)); } =20 /** --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F220C433EF for ; Sun, 23 Jan 2022 18:40:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239647AbiAWSkX (ORCPT ); Sun, 23 Jan 2022 13:40:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239692AbiAWSkR (ORCPT ); Sun, 23 Jan 2022 13:40:17 -0500 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28765C06173B; Sun, 23 Jan 2022 10:40:17 -0800 (PST) Received: by mail-pf1-x432.google.com with SMTP id a8so8429996pfa.6; Sun, 23 Jan 2022 10:40:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=p8QTRt3d7sePwL1Za7J+vXKVGF1Vcf9Dz8ECUX4YRaU=; b=kSGsBEjEhAy4ULYE8qToeMFrZ5GiZfr/HXBxXdnWrnJkuneYffzb9IfBYrjnabzgmu bQWPkMXab2fQ9EaV1nt5r+U8sE7GzTGBRdbOtiVhKrZ5XSK3W8jCWLhKf4M3tPPenrQd f4qF3ZUi/P6ID4y0yDSX8V35SSSCglIvWzd+uyYOcyv6zuzWmX6lnFpmfHASEgBqUQXd 1TUUPspx0Zbc1LlTY26uxgvmldx+2g/XNHHVQvBYvM+BDv3yt/SpDeOES8VpXQTsh1jW SHrKxQd+6ZQ0sDVq0B2fdCtaUfTjmagsqen6Tg/u4mKxbGYE411kjF8umErW0yq0NpVM 6YYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=p8QTRt3d7sePwL1Za7J+vXKVGF1Vcf9Dz8ECUX4YRaU=; b=AbybGlsdA+Pxtuk5v5cqR3vcMUlXQjxLD6ShnS54+uZ5kD8Khu8u63llbljz88azmg W94u6+sKBnF/K/gjZWMXCMM9/ex2j7XT7qL4WdXvcMTjU9dtfykvzExyYeYiWvvrtZ5w JpEySH+v8q4IOTYV2OF6Fk6cLWlZkrg2PFXbfRzeD51YMUfzJhwmoYWoD1v8rT6YEN3i oELCrnV8MuEBMDxH8IrtplxN43B4ls9JPp/IsWP+1tS4+rZGf6PXU4mAXVQ+Rbh19maU +4GanVa+17U++1ZkN/IG7HwRwDxXyTVCGOBqMrp2j0n6EAK3yaYD01z8B22xsEdJVovv +6WA== X-Gm-Message-State: AOAM530d+Qohfnxie3fpmO1VIAk/X1PGJ/KwFXZtPmarfu3wrVNys5N1 nuvv6N7SB8dnaqAMTQ/Gxn8= X-Google-Smtp-Source: ABdhPJxPEJs66727LmyAS5olRhoXIbWw8yvPTo3V487TVxqjG3bhda6a1xhG1HMlracKriT/z0m5AQ== X-Received: by 2002:a63:7251:: with SMTP id c17mr7591981pgn.579.1642963216638; Sun, 23 Jan 2022 10:40:16 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id mh11sm11502854pjb.3.2022.01.23.10.40.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:40:16 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Sunil Goutham , Geetha sowjanya , Subbaraya Sundeep , hariprasad , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org Subject: [PATCH 09/54] net: ethernet: replace bitmap_weight with bitmap_empty for Marvell Date: Sun, 23 Jan 2022 10:38:40 -0800 Message-Id: <20220123183925.1052919-10-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" In some places, octeontx2 code calls bitmap_weight() to check if any bit of a given bitmap is set. It's better to use bitmap_empty() in that case because bitmap_empty() stops traversing the bitmap as soon as it finds first set bit, while bitmap_weight() counts all bits unconditionally. Signed-off-by: Yury Norov --- drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c | 4 ++-- drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c b/driv= ers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c index 77a13fb555fb..80b2d64b4136 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c @@ -353,7 +353,7 @@ int otx2_add_macfilter(struct net_device *netdev, const= u8 *mac) { struct otx2_nic *pf =3D netdev_priv(netdev); =20 - if (bitmap_weight(&pf->flow_cfg->dmacflt_bmap, + if (!bitmap_empty(&pf->flow_cfg->dmacflt_bmap, pf->flow_cfg->dmacflt_max_flows)) netdev_warn(netdev, "Add %pM to CGX/RPM DMAC filters list as well\n", @@ -436,7 +436,7 @@ int otx2_get_maxflows(struct otx2_flow_config *flow_cfg) return 0; =20 if (flow_cfg->nr_flows =3D=3D flow_cfg->max_flows || - bitmap_weight(&flow_cfg->dmacflt_bmap, + !bitmap_empty(&flow_cfg->dmacflt_bmap, flow_cfg->dmacflt_max_flows)) return flow_cfg->max_flows + flow_cfg->dmacflt_max_flows; else diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c b/drivers= /net/ethernet/marvell/octeontx2/nic/otx2_pf.c index 6080ebd9bd94..3d369ccc7ab9 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c @@ -1115,7 +1115,7 @@ static int otx2_cgx_config_loopback(struct otx2_nic *= pf, bool enable) struct msg_req *msg; int err; =20 - if (enable && bitmap_weight(&pf->flow_cfg->dmacflt_bmap, + if (enable && !bitmap_empty(&pf->flow_cfg->dmacflt_bmap, pf->flow_cfg->dmacflt_max_flows)) netdev_warn(pf->netdev, "CGX/RPM internal loopback might not work as DMAC filters are activ= e\n"); --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0EB5C433EF for ; Sun, 23 Jan 2022 18:40:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239507AbiAWSki (ORCPT ); Sun, 23 Jan 2022 13:40:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239622AbiAWSkU (ORCPT ); Sun, 23 Jan 2022 13:40:20 -0500 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8451BC06173D; Sun, 23 Jan 2022 10:40:20 -0800 (PST) Received: by mail-pl1-x62e.google.com with SMTP id y17so3130522plg.7; Sun, 23 Jan 2022 10:40:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=QqjEcwh/Vt3ob/xyYzKK4XDGLqNzTDbmtmru+0FTCuE=; b=QirWg+lweofM9kFw4lQkoYZAFuKzZxOxrfW4krFfMwzWQOQc828Kg4wUFu/CnyQyYo jXMbk78JyjVnL00jc+K6b7IKZaGBiJkUZRjZhvTWLZjdoGe7Rmc5Ld5gBMmQE4h8CBwc 2nZWoOHGLABDxeInZgxPd1zaaerdmwx1uw/CoJ2KNxMrjYLyYAlHX6xP1WQspeALHNbo sOmk6CFE7AWiAd2Uop6Jh9ZUqhP1IiO6WNhmYk8AGo4PvVqdXR12F00sDQVaFHhrZT3G cr4x4N9BbO3MSVwZxJWjB2Lb76qglUp3ZalrE3oh0Bi001lr9e34A5qeWoVSN8j9CeP2 22Zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QqjEcwh/Vt3ob/xyYzKK4XDGLqNzTDbmtmru+0FTCuE=; b=p47GPAYHS8CCalQoJs3WgeqGZhSSgzX6BHuCUYwcJIX062oZaFkdnkEevSvive1aRX TIO0DoJj4Q3VnUAnSERJYGxixGb6Ut3uj/22NChLlmbSFy2ZqSzvHQ/fZ6aqC2lnJu5t 8EMNpuyZJzvQd6m4JfHiEkKeq4C/1r5YbuXdi2MyjK7atWZVqf3Bu8Zn/nXImGRhgX4S poeM4iQ3xAFDZ+bnDwzd8ipZzB3PrsH/dt8bLDgEkTd6JXvDVYk5frjixffgIbH+DCv8 D+mgOM3/r0pqh35hBkIgetXZLswdf+8Q9mW7NRCI9PBFXBrIuVjCXRd2HHY65JobQ7sO dxJw== X-Gm-Message-State: AOAM533Ge3zwx7u9AMz4ij+jhXICuBvGvwJe6FNTixrs/hRhV5X3SF6Z vEcCK7QG9p9S9EkHFJZ86rs= X-Google-Smtp-Source: ABdhPJwbVELe7QC7MMVE53A+dZrALuLWXks3kDspFFg5RnGQ+U6L1gKvdNAVlETCFY4gN45eIP7tHg== X-Received: by 2002:a17:902:b185:b0:149:fccf:1cf3 with SMTP id s5-20020a170902b18500b00149fccf1cf3mr11659042plr.77.1642963220019; Sun, 23 Jan 2022 10:40:20 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id r19sm10615026pjz.6.2022.01.23.10.40.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:40:19 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Ariel Elior , Manish Chopra , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org Subject: [PATCH 10/54] net: ethernet: replace bitmap_weight with bitmap_empty for qlogic Date: Sun, 23 Jan 2022 10:38:41 -0800 Message-Id: <20220123183925.1052919-11-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" qlogic/qed code calls bitmap_weight() to check if any bit of a given bitmap is set. It's better to use bitmap_empty() in that case because bitmap_empty() stops traversing the bitmap as soon as it finds first set bit, while bitmap_weight() counts all bits unconditionally. Signed-off-by: Yury Norov --- drivers/net/ethernet/qlogic/qed/qed_rdma.c | 4 ++-- drivers/net/ethernet/qlogic/qed/qed_roce.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/qlogic/qed/qed_rdma.c b/drivers/net/ether= net/qlogic/qed/qed_rdma.c index 23b668de4640..b6e2e17bac04 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_rdma.c +++ b/drivers/net/ethernet/qlogic/qed/qed_rdma.c @@ -336,7 +336,7 @@ void qed_rdma_bmap_free(struct qed_hwfn *p_hwfn, =20 /* print aligned non-zero lines, if any */ for (item =3D 0, line =3D 0; line < last_line; line++, item +=3D 8) - if (bitmap_weight((unsigned long *)&pmap[item], 64 * 8)) + if (!bitmap_empty((unsigned long *)&pmap[item], 64 * 8)) DP_NOTICE(p_hwfn, "line 0x%04x: 0x%016llx 0x%016llx 0x%016llx 0x%016llx 0x%016llx 0x%0= 16llx 0x%016llx 0x%016llx\n", line, @@ -350,7 +350,7 @@ void qed_rdma_bmap_free(struct qed_hwfn *p_hwfn, =20 /* print last unaligned non-zero line, if any */ if ((bmap->max_count % (64 * 8)) && - (bitmap_weight((unsigned long *)&pmap[item], + (!bitmap_empty((unsigned long *)&pmap[item], bmap->max_count - item * 64))) { offset =3D sprintf(str_last_line, "line 0x%04x: ", line); for (; item < last_item; item++) diff --git a/drivers/net/ethernet/qlogic/qed/qed_roce.c b/drivers/net/ether= net/qlogic/qed/qed_roce.c index 071b4aeaddf2..134ecfca96a3 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_roce.c +++ b/drivers/net/ethernet/qlogic/qed/qed_roce.c @@ -76,7 +76,7 @@ void qed_roce_stop(struct qed_hwfn *p_hwfn) * We delay for a short while if an async destroy QP is still expected. * Beyond the added delay we clear the bitmap anyway. */ - while (bitmap_weight(rcid_map->bitmap, rcid_map->max_count)) { + while (!bitmap_empty(rcid_map->bitmap, rcid_map->max_count)) { /* If the HW device is during recovery, all resources are * immediately reset without receiving a per-cid indication * from HW. In this case we don't expect the cid bitmap to be --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CE684C433F5 for ; Sun, 23 Jan 2022 18:40:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239670AbiAWSko (ORCPT ); Sun, 23 Jan 2022 13:40:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239764AbiAWSkf (ORCPT ); Sun, 23 Jan 2022 13:40:35 -0500 Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAFBDC06174E for ; Sun, 23 Jan 2022 10:40:23 -0800 (PST) Received: by mail-pg1-x532.google.com with SMTP id i8so13106807pgt.13 for ; Sun, 23 Jan 2022 10:40:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=QmvdvRYrU0pccxZjPQvOPFahs5Q0IVqksGfZERujS/w=; b=fEMWqJ0non1/1G7N6hoyBkFO73hoqLatan184u4QZ+CXOWfIxa+mKWmDZWQ330NtrL 79a4csmu1WrP8S5N3nNrCuH8lsqH8E0i37IaLhihnfxVCBlGpZ2fIrpdpj0Sf/sxDVCm SD1AIe7Vg0kK9S/RYVeb5lJ1TkJynGTztkTNtNc6fjgN8wXC13OCBbb3Yjz2/2uYMPif zlhj6Q8IPowwVu8vMseCCqQVQa4umcM/Hzid4RgLiZfxYjowX4xiAAPFyMkcjLChRCh+ JugaXNORXRbfPA4WwAdsVX5PX3vxTJsaiYITdOJiuCO+CTZSTYJLrDCdMCbCYWgff9A+ TYkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QmvdvRYrU0pccxZjPQvOPFahs5Q0IVqksGfZERujS/w=; b=2nrsf2sKcCkKcOY0Im7NwEqJDSFT2sOpFLkNEuqaJ571c8fA0qA4p937yZItu8Sb+w hSDtIBKzyahzIcawcqro1B8GSj3VA9wPZfGOytdWEsCFbw9Zt4yppyWCnRQCpPvl+Llm a2L2BdxG5/IQcRoyA6KqNsQ2QRzouKl2ipRucaKKjmTfOCHCfUtHa/4ycLxEIkB3Ag35 rfqTN8FDrTXbPtcdZ4VukPymzRCDYa7J9z+7jLAMoAWovE6ocFbnGVRXE0hjUBPYRzUi QmP9cP4I2XeO1Oeaxayj0izVKJD8+dybpy5o4KyC/+pYmDYXemalJV65tI/B27aLaN3c JUhQ== X-Gm-Message-State: AOAM533aFoOjJCpKAkdwI2QvNZ0tmG/b/QBk4FLcqc0aG3gdDIxPcAoH Cnfub98SLGEExZ1e8KqHBZs= X-Google-Smtp-Source: ABdhPJxe9Mdrm++g1fWsFijEPfG65qpS18BjZ5G1v3x54Dtr9GF+uWdZkbmUM6P3YG36cjhhM695Fg== X-Received: by 2002:a63:7543:: with SMTP id f3mr9431653pgn.360.1642963223187; Sun, 23 Jan 2022 10:40:23 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id y42sm5575467pfw.157.2022.01.23.10.40.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:40:22 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Will Deacon , Mark Rutland , Shaokun Zhang , Qi Liu , Khuong Dinh , linux-arm-kernel@lists.infradead.org Subject: [PATCH 11/54] perf: replace bitmap_weight with bitmap_empty where appropriate Date: Sun, 23 Jan 2022 10:38:42 -0800 Message-Id: <20220123183925.1052919-12-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" In some places, drivers/perf code calls bitmap_weight() to check if any bit of a given bitmap is set. It's better to use bitmap_empty() in that case because bitmap_empty() stops traversing the bitmap as soon as it finds first set bit, while bitmap_weight() counts all bits unconditionally. Signed-off-by: Yury Norov --- drivers/perf/arm-cci.c | 2 +- drivers/perf/arm_pmu.c | 4 ++-- drivers/perf/hisilicon/hisi_uncore_pmu.c | 2 +- drivers/perf/xgene_pmu.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/perf/arm-cci.c b/drivers/perf/arm-cci.c index 54aca3a62814..96e09fa40909 100644 --- a/drivers/perf/arm-cci.c +++ b/drivers/perf/arm-cci.c @@ -1096,7 +1096,7 @@ static void cci_pmu_enable(struct pmu *pmu) { struct cci_pmu *cci_pmu =3D to_cci_pmu(pmu); struct cci_pmu_hw_events *hw_events =3D &cci_pmu->hw_events; - int enabled =3D bitmap_weight(hw_events->used_mask, cci_pmu->num_cntrs); + bool enabled =3D !bitmap_empty(hw_events->used_mask, cci_pmu->num_cntrs); unsigned long flags; =20 if (!enabled) diff --git a/drivers/perf/arm_pmu.c b/drivers/perf/arm_pmu.c index 295cc7952d0e..a31b302b0ade 100644 --- a/drivers/perf/arm_pmu.c +++ b/drivers/perf/arm_pmu.c @@ -524,7 +524,7 @@ static void armpmu_enable(struct pmu *pmu) { struct arm_pmu *armpmu =3D to_arm_pmu(pmu); struct pmu_hw_events *hw_events =3D this_cpu_ptr(armpmu->hw_events); - int enabled =3D bitmap_weight(hw_events->used_mask, armpmu->num_events); + bool enabled =3D !bitmap_empty(hw_events->used_mask, armpmu->num_events); =20 /* For task-bound events we may be called on other CPUs */ if (!cpumask_test_cpu(smp_processor_id(), &armpmu->supported_cpus)) @@ -785,7 +785,7 @@ static int cpu_pm_pmu_notify(struct notifier_block *b, = unsigned long cmd, { struct arm_pmu *armpmu =3D container_of(b, struct arm_pmu, cpu_pm_nb); struct pmu_hw_events *hw_events =3D this_cpu_ptr(armpmu->hw_events); - int enabled =3D bitmap_weight(hw_events->used_mask, armpmu->num_events); + bool enabled =3D !bitmap_empty(hw_events->used_mask, armpmu->num_events); =20 if (!cpumask_test_cpu(smp_processor_id(), &armpmu->supported_cpus)) return NOTIFY_DONE; diff --git a/drivers/perf/hisilicon/hisi_uncore_pmu.c b/drivers/perf/hisili= con/hisi_uncore_pmu.c index a738aeab5c04..358e4e284a62 100644 --- a/drivers/perf/hisilicon/hisi_uncore_pmu.c +++ b/drivers/perf/hisilicon/hisi_uncore_pmu.c @@ -393,7 +393,7 @@ EXPORT_SYMBOL_GPL(hisi_uncore_pmu_read); void hisi_uncore_pmu_enable(struct pmu *pmu) { struct hisi_pmu *hisi_pmu =3D to_hisi_pmu(pmu); - int enabled =3D bitmap_weight(hisi_pmu->pmu_events.used_mask, + bool enabled =3D !bitmap_empty(hisi_pmu->pmu_events.used_mask, hisi_pmu->num_counters); =20 if (!enabled) diff --git a/drivers/perf/xgene_pmu.c b/drivers/perf/xgene_pmu.c index 2b6d476bd213..88bd100a9633 100644 --- a/drivers/perf/xgene_pmu.c +++ b/drivers/perf/xgene_pmu.c @@ -867,7 +867,7 @@ static void xgene_perf_pmu_enable(struct pmu *pmu) { struct xgene_pmu_dev *pmu_dev =3D to_pmu_dev(pmu); struct xgene_pmu *xgene_pmu =3D pmu_dev->parent; - int enabled =3D bitmap_weight(pmu_dev->cntr_assign_mask, + bool enabled =3D !bitmap_empty(pmu_dev->cntr_assign_mask, pmu_dev->max_counters); =20 if (!enabled) --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5043BC433EF for ; Sun, 23 Jan 2022 18:40:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239762AbiAWSks (ORCPT ); Sun, 23 Jan 2022 13:40:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239774AbiAWSkg (ORCPT ); Sun, 23 Jan 2022 13:40:36 -0500 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2AEDC061755; Sun, 23 Jan 2022 10:40:26 -0800 (PST) Received: by mail-pj1-x1036.google.com with SMTP id l16so14125208pjl.4; Sun, 23 Jan 2022 10:40:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Py1zW0ltpfyG7bmubSMBgFb3G+l3kBPmKZQHawk6878=; b=CSMBNJKY7dSpNlaAbMhxTV+T2YjWtTQxwONPqJ5KEFjCKKirqqwS/89tqsFoGH32ii sEZ1vNlsMZDixP+/ayAqyxiMC0i3u6z782a+Bo3DVmTaJnex3SXZYysIB8m+Wo4zOH3Z V6AmmUD+GrHiRD0/5XduLjLKdkrvqoN+cVkHe6GviOXtOT6ZWinK+V8y+XCROtaacI42 ZyUIuJu9taT5JU8l0oCznzFzit73pFBAmuv4ctUPVPPyN6bBCMMFFNYnqZfOflbYW8em pGMq4L1CIsiqfN/H0fvW8a4LgeBwbfJ7dYIn6rD0cLuyv6NDFlXm2PDjtu35I8dlUSE7 yUkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Py1zW0ltpfyG7bmubSMBgFb3G+l3kBPmKZQHawk6878=; b=IXtKXQ/j9Uo6CPmK/nbCml1Bbq2whYfII6Io9U4jhztFG9+4P0rTmrWPecmOOwdL+k YAtevm5oAObjBdiNuJ1AI2H6JhOg2Ns/RSxzbnuIOgegBpeSYp23IYzyntY5iMLMmMUW Ymu6Luv+swR6B8MBavpwBWCgrR7nC4iAaCpvWFz34dXWRVcx3shuHNosA+uJX13k7qZW N5IImWGWPcauHBEBCR+oFgPKQMlHBFYUckxSYoH4Ln0BwhZu1ctN4lVEJ6OnXxhk2nm+ Q5CmMoFIJuhIoS6yYV/zdUrJIjaD43WKyq89Yv4Rs4iMUJnu/5pP3JS9JbpA8MySg0wU S5cQ== X-Gm-Message-State: AOAM533oiyf43Qt3b4/lgCghbQL9rvbi6b1SNA12NDkOb0urQOZWXfNj 8SP6RwHs0tYPZpJteitTGWg= X-Google-Smtp-Source: ABdhPJw5u6/fkWBS7kc1sVnKC3utz4uerUZu9lGVkpSGNbzYVEKRH8JYJRwOLnk66EHUmGBuzA7QSg== X-Received: by 2002:a17:902:a417:b0:14b:1f32:e926 with SMTP id p23-20020a170902a41700b0014b1f32e926mr10664339plq.170.1642963226087; Sun, 23 Jan 2022 10:40:26 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id om12sm5090050pjb.48.2022.01.23.10.40.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:40:25 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-perf-users@vger.kernel.org Subject: [PATCH 12/54] tools/perf: replace bitmap_weight with bitmap_empty where appropriate Date: Sun, 23 Jan 2022 10:38:43 -0800 Message-Id: <20220123183925.1052919-13-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Some code in builtin-c2c.c calls bitmap_weight() to check if any bit of a given bitmap is set. It's better to use bitmap_empty() in that case because bitmap_empty() stops traversing the bitmap as soon as it finds first set bit, while bitmap_weight() counts all bits unconditionally. Signed-off-by: Yury Norov --- tools/perf/builtin-c2c.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c index 77dd4afacca4..14f787c67140 100644 --- a/tools/perf/builtin-c2c.c +++ b/tools/perf/builtin-c2c.c @@ -1080,7 +1080,7 @@ node_entry(struct perf_hpp_fmt *fmt __maybe_unused, s= truct perf_hpp *hpp, bitmap_zero(set, c2c.cpus_cnt); bitmap_and(set, c2c_he->cpuset, c2c.nodes[node], c2c.cpus_cnt); =20 - if (!bitmap_weight(set, c2c.cpus_cnt)) { + if (bitmap_empty(set, c2c.cpus_cnt)) { if (c2c.node_info =3D=3D 1) { ret =3D scnprintf(hpp->buf, hpp->size, "%21s", " "); advance_hpp(hpp, ret); @@ -1944,7 +1944,7 @@ static int set_nodestr(struct c2c_hist_entry *c2c_he) if (c2c_he->nodestr) return 0; =20 - if (bitmap_weight(c2c_he->nodeset, c2c.nodes_cnt)) { + if (!bitmap_empty(c2c_he->nodeset, c2c.nodes_cnt)) { len =3D bitmap_scnprintf(c2c_he->nodeset, c2c.nodes_cnt, buf, sizeof(buf)); } else { --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C7D3C433F5 for ; Sun, 23 Jan 2022 18:40:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239794AbiAWSkv (ORCPT ); Sun, 23 Jan 2022 13:40:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239780AbiAWSkg (ORCPT ); Sun, 23 Jan 2022 13:40:36 -0500 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BBFEEC06173B; Sun, 23 Jan 2022 10:40:29 -0800 (PST) Received: by mail-pg1-x534.google.com with SMTP id f8so13142887pgf.8; Sun, 23 Jan 2022 10:40:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=EaZo6YWz+PE4Amu8QukF1Cw8oSIakZDIQiKoGR/62wY=; b=V2jPEDWq3IwIGuJgkDE35gcjcxe2X2oRT+W5/8zZD364JRtYsD/NetC+jPipdlP248 VCZINxrgU8tohaAr/uOO2w7qtXxaF4tnonr9b/tMDnGy8/JWEsbHewV6ABBhs9UVYadY ZRHqPkouoaRfLkfknvSgvJd3V0Cre7vIvYAmqjqhx7RQhsyXW3ho+RqXj9q9WBKZaFnw 0zGgSRnEyOR8m11UhivzNB8lHiu2vzn+ZubLLiEtRJUlCjBZqg4O7WmF/YhdMkw1DmSN owVHE4zq1o6nHuVmcX62AylgLcK1BDygi77X2PO2ga9uCd6LKSXnMX8BIaj6I1/fkfLo NAtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EaZo6YWz+PE4Amu8QukF1Cw8oSIakZDIQiKoGR/62wY=; b=uBCUNFEZwWUKpj/628Wq+7kN8o08g5iVLv9Kd737PSnl4SsN7tbNasARBXl+usdZnE 8Jo3et3ffhU1GlAyWejJ5VUG4RT4e3EblfLPTZNLYjPSAqrQswAw1A/eHOWgUSGehUEZ AzjkPYflubawOk8p35zyzZ1lRULyoDc7fXQkqCE1tUrK51qMpwj7vMKzKbOHMF9RQ67J 7i+eclm8WWL1MuvY6VUG5AU9K8vckAq38B2pa7O8A9z7/pgF3wAHxKJN2PLCcLsNXTqa 30bO1sdRfP2Z2LWvuTOt1uWWu9C9+v3vLg2xs9xbXRgvQ5aNBYypNJPeMoGrcufV+oWE q7Tg== X-Gm-Message-State: AOAM532WQs9YN6rKVqNAEMWx9rUZMPOV8qZgrEH6zFSflRd61buWe0Yt WlGr3Thb8dhwqDR2m0dfTiE= X-Google-Smtp-Source: ABdhPJzeWapOdx/1eEYuO99kEzZ9xJia7gM6ZniR9//pywure5qlypDffs4P/Vm6jWZrQqOitmIbkg== X-Received: by 2002:a63:fe10:: with SMTP id p16mr9366634pgh.546.1642963229253; Sun, 23 Jan 2022 10:40:29 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id c8sm14350494pfl.122.2022.01.23.10.40.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:40:28 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Richard Henderson , Ivan Kokshaysky , Matt Turner , Geert Uytterhoeven , Davidlohr Bueso , "Russell King (Oracle)" , Kees Cook , Zheng Yongjun , Jens Axboe , linux-alpha@vger.kernel.org Subject: [PATCH 13/54] arch/alpha: replace cpumask_weight with cpumask_empty where appropriate Date: Sun, 23 Jan 2022 10:38:44 -0800 Message-Id: <20220123183925.1052919-14-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" common_shutdown_1() calls cpumask_weight() to check if any bit of a given cpumask is set. We can do it more efficiently with cpumask_empty() because cpumask_empty() stops traversing the cpumask as soon as it finds first set bit, while cpumask_weight() counts all bits unconditionally. Signed-off-by: Yury Norov --- arch/alpha/kernel/process.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/alpha/kernel/process.c b/arch/alpha/kernel/process.c index 5f8527081da9..0d4bc60828bf 100644 --- a/arch/alpha/kernel/process.c +++ b/arch/alpha/kernel/process.c @@ -125,7 +125,7 @@ common_shutdown_1(void *generic_ptr) /* Wait for the secondaries to halt. */ set_cpu_present(boot_cpuid, false); set_cpu_possible(boot_cpuid, false); - while (cpumask_weight(cpu_present_mask)) + while (!cpumask_empty(cpu_present_mask)) barrier(); #endif =20 --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D231FC433FE for ; Sun, 23 Jan 2022 18:41:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239825AbiAWSk6 (ORCPT ); Sun, 23 Jan 2022 13:40:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239652AbiAWSkm (ORCPT ); Sun, 23 Jan 2022 13:40:42 -0500 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C318BC06175F; Sun, 23 Jan 2022 10:40:32 -0800 (PST) Received: by mail-pg1-x535.google.com with SMTP id v3so7872549pgc.1; Sun, 23 Jan 2022 10:40:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=KWn9RMzA0EUrBxcMa6INAn/WVMY8I9S/vbZ+cvBsro8=; b=FEY4hkDCe+Bsb7dfhGhUPLZa3Mw0PtBQkOfweZG+4g+/AQd4KD6MMYPm2IDe5hdOX+ dkS3dA+wGDjARWWN5zO+u2yDzeYbGG5IN02WiGuELJoafSGPci3NnnLTdh9I8IhX7fti IpZ5jdcKQ0bOMVbXM9UFM6PgySOQy8PN/gr/8ncHmWzSzsjnyDIxkh9Zl6kXWPt+9/JC EfexkcP1u+e9NGbS8fqX0N1v0PcG40IfxWO1qSi6HVNUzwqETgbERn2BGZG4SW3pKOSA LnMk3qdAMIJw9tW9NvT+99rYqWeMvl91UnjK3COqKpRkCgyEYPdAn318dKt59hcjMA5Y Oj+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KWn9RMzA0EUrBxcMa6INAn/WVMY8I9S/vbZ+cvBsro8=; b=sPOPwlZishlFtZKSSIkea6+dos7H9o88E6jperQcZg8nv4sm9ou8fTgspNg5bWBqEx FWO/KVoQSBA1JPII5qHBh+xufOWa15+mh6nRpaHFRk2a1t+XVltkJz+fNRxRx71ucs0e kTbk3tfKeXJhOYVifCIm3hSq80cxnt/h43p969ztzcNYDxbCzumWNxfNVAM9K8KmT7Eh oIr92xPu38rppGv5fGka05S5FuH+9BIFCxqS5nd+6djpM3XpePFqYRluVejFATc8wydN S2EY6apwUsaVWahcQpXf6khTV3mGruSpI/h2gU6jtsT4oJ86jdnuUlkx9KeNnqziMVii zlPw== X-Gm-Message-State: AOAM53031B3Ivz7/kcJqZbIlfGqcBbBJ9kk9/4fRf1wG1FNnJALNKk3z Gj4X017ekgk7bskuKazRFvY= X-Google-Smtp-Source: ABdhPJwjqrtFluXvvrz63pW7odh2ArGWcrHPjVu1LB3+cE21kXqVjNBk4w7GSgYFMwwe6AGVJYJ/Ag== X-Received: by 2002:a63:2d6:: with SMTP id 205mr3524267pgc.64.1642963231993; Sun, 23 Jan 2022 10:40:31 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id f9sm9845631pgf.94.2022.01.23.10.40.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:40:31 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Geert Uytterhoeven , Yang Guang , linux-ia64@vger.kernel.org Subject: [PATCH 14/54] arch/ia64: replace cpumask_weight with cpumask_empty where appropriate Date: Sun, 23 Jan 2022 10:38:45 -0800 Message-Id: <20220123183925.1052919-15-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" setup_arch() calls cpumask_weight() to check if any bit of a given cpumask is set. We can do it more efficiently with cpumask_empty() because cpumask_empty() stops traversing the cpumask as soon as it finds first set bit, while cpumask_weight() counts all bits unconditionally. Signed-off-by: Yury Norov --- arch/ia64/kernel/setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/ia64/kernel/setup.c b/arch/ia64/kernel/setup.c index 5010348fa21b..fd6301eafa9d 100644 --- a/arch/ia64/kernel/setup.c +++ b/arch/ia64/kernel/setup.c @@ -572,7 +572,7 @@ setup_arch (char **cmdline_p) #ifdef CONFIG_ACPI_HOTPLUG_CPU prefill_possible_map(); #endif - per_cpu_scan_finalize((cpumask_weight(&early_cpu_possible_map) =3D=3D 0 ? + per_cpu_scan_finalize((cpumask_empty(&early_cpu_possible_map) ? 32 : cpumask_weight(&early_cpu_possible_map)), additional_cpus > 0 ? additional_cpus : 0); #endif /* CONFIG_ACPI_NUMA */ --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21303C433FE for ; Sun, 23 Jan 2022 18:41:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239848AbiAWSlA (ORCPT ); Sun, 23 Jan 2022 13:41:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239673AbiAWSkn (ORCPT ); Sun, 23 Jan 2022 13:40:43 -0500 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1427DC06173D; Sun, 23 Jan 2022 10:40:36 -0800 (PST) Received: by mail-pj1-x102b.google.com with SMTP id pf13so14152333pjb.0; Sun, 23 Jan 2022 10:40:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=QGbXvpGX2v4Ey2LzEKSSlIal0vlI7iYMGBrpPZxtbCI=; b=WDp7M2gjbxgNLuGpYm8aNkWuCH3uLDBFVX5FbgY+MiojtTvY8hzIZDZaDHvjikmt2W Iq6iXMvmCiKcT9KRr6bh0cz3x1yye0VWg64m7jFtFzX8DBqzKmf59SCJq5nT3uBXanWW N8X/Gnlq6wA3k1Jbo9hVJKnwZRGdnZfOvRVAubkwSPjFbGuqi6s2bSwqOSbAVB3HCFQO +GLitOBWcHfwg5XWigt/EC0FrOocZLnZNM99jzmQ3NFBxnY1b58cKstaTpkVSMQyLjLA q+k26qTBO1IzuK5NIYv4DYVJ8L3HgHD2KsaRkb7Rwpi42Dl3INgZa68SrvKvGO1nKF8m 1Drg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QGbXvpGX2v4Ey2LzEKSSlIal0vlI7iYMGBrpPZxtbCI=; b=cpLhqgpb/uFMUzsQhd4gPpFDRxlDy9PlxsTBAUqevMpBhhFzgB/zccuoT2scOkY/Lx bIZZBhM0vqciJrdvRE+TSNGuLubnMZXkz1hkEJ677GfzPZx/Al0fHCq8q3+EGGAzNROt lHPeDaUmOc/2zVdwCKTyENMkeOZ8YnZbOHFc9zRMUb1XFaMSiJoyuGCp3UVOpk1Jf4NU szyeE15ksesC1mrVTAjyut4FDyuhBYntO8cnRwjebf03vonJl5QnHYEAmQUDrIkpaF90 EfUyVH/6cH1hSXNeI8m6FgViuZVNz7rRlR2KSGlnbJgvsOdHBgwlkoKkcE7M8URQ5vB5 zb1g== X-Gm-Message-State: AOAM531TeMdaPtO2hK0HBavdPKgP6mXLHbpoNVYcB8Eh24pa2nYLsN2b GqeauFAZXt28NffOt2woDME= X-Google-Smtp-Source: ABdhPJzroRDuKrvAjwFE0ux2Z+D6OhNX3syUYDOc6D4LzgGjMVdFddeEIpydTA07jIYbaPfmlVZLhw== X-Received: by 2002:a17:90b:1b0e:: with SMTP id nu14mr9711815pjb.39.1642963235490; Sun, 23 Jan 2022 10:40:35 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id c8sm14350579pfl.122.2022.01.23.10.40.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:40:35 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Fenghua Yu , Reinette Chatre , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Steven Rostedt , Karol Herbst , Pekka Paalanen , Andy Lutomirski , Steve Wahl , Mike Travis , Dimitri Sivanich , Russ Anderson , Darren Hart , Andy Shevchenko , x86@kernel.org, nouveau@lists.freedesktop.org, platform-driver-x86@vger.kernel.org Subject: [PATCH 15/54] arch/x86: replace cpumask_weight with cpumask_empty where appropriate Date: Sun, 23 Jan 2022 10:38:46 -0800 Message-Id: <20220123183925.1052919-16-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" In some cases, arch/x86 code calls cpumask_weight() to check if any bit of a given cpumask is set. We can do it more efficiently with cpumask_empty() because cpumask_empty() stops traversing the cpumask as soon as it finds first set bit, while cpumask_weight() counts all bits unconditionally. Signed-off-by: Yury Norov --- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 14 +++++++------- arch/x86/mm/mmio-mod.c | 2 +- arch/x86/platform/uv/uv_nmi.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index b57b3db9a6a7..e23ff03290b8 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -341,14 +341,14 @@ static int cpus_mon_write(struct rdtgroup *rdtgrp, cp= umask_var_t newmask, =20 /* Check whether cpus belong to parent ctrl group */ cpumask_andnot(tmpmask, newmask, &prgrp->cpu_mask); - if (cpumask_weight(tmpmask)) { + if (!cpumask_empty(tmpmask)) { rdt_last_cmd_puts("Can only add CPUs to mongroup that belong to parent\n= "); return -EINVAL; } =20 /* Check whether cpus are dropped from this group */ cpumask_andnot(tmpmask, &rdtgrp->cpu_mask, newmask); - if (cpumask_weight(tmpmask)) { + if (!cpumask_empty(tmpmask)) { /* Give any dropped cpus to parent rdtgroup */ cpumask_or(&prgrp->cpu_mask, &prgrp->cpu_mask, tmpmask); update_closid_rmid(tmpmask, prgrp); @@ -359,7 +359,7 @@ static int cpus_mon_write(struct rdtgroup *rdtgrp, cpum= ask_var_t newmask, * and update per-cpu rmid */ cpumask_andnot(tmpmask, newmask, &rdtgrp->cpu_mask); - if (cpumask_weight(tmpmask)) { + if (!cpumask_empty(tmpmask)) { head =3D &prgrp->mon.crdtgrp_list; list_for_each_entry(crgrp, head, mon.crdtgrp_list) { if (crgrp =3D=3D rdtgrp) @@ -394,7 +394,7 @@ static int cpus_ctrl_write(struct rdtgroup *rdtgrp, cpu= mask_var_t newmask, =20 /* Check whether cpus are dropped from this group */ cpumask_andnot(tmpmask, &rdtgrp->cpu_mask, newmask); - if (cpumask_weight(tmpmask)) { + if (!cpumask_empty(tmpmask)) { /* Can't drop from default group */ if (rdtgrp =3D=3D &rdtgroup_default) { rdt_last_cmd_puts("Can't drop CPUs from default group\n"); @@ -413,12 +413,12 @@ static int cpus_ctrl_write(struct rdtgroup *rdtgrp, c= pumask_var_t newmask, * and update per-cpu closid/rmid. */ cpumask_andnot(tmpmask, newmask, &rdtgrp->cpu_mask); - if (cpumask_weight(tmpmask)) { + if (!cpumask_empty(tmpmask)) { list_for_each_entry(r, &rdt_all_groups, rdtgroup_list) { if (r =3D=3D rdtgrp) continue; cpumask_and(tmpmask1, &r->cpu_mask, tmpmask); - if (cpumask_weight(tmpmask1)) + if (!cpumask_empty(tmpmask1)) cpumask_rdtgrp_clear(r, tmpmask1); } update_closid_rmid(tmpmask, rdtgrp); @@ -488,7 +488,7 @@ static ssize_t rdtgroup_cpus_write(struct kernfs_open_f= ile *of, =20 /* check that user didn't specify any offline cpus */ cpumask_andnot(tmpmask, newmask, cpu_online_mask); - if (cpumask_weight(tmpmask)) { + if (!cpumask_empty(tmpmask)) { ret =3D -EINVAL; rdt_last_cmd_puts("Can only assign online CPUs\n"); goto unlock; diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c index 933a2ebad471..c3317f0650d8 100644 --- a/arch/x86/mm/mmio-mod.c +++ b/arch/x86/mm/mmio-mod.c @@ -400,7 +400,7 @@ static void leave_uniprocessor(void) int cpu; int err; =20 - if (!cpumask_available(downed_cpus) || cpumask_weight(downed_cpus) =3D=3D= 0) + if (!cpumask_available(downed_cpus) || cpumask_empty(downed_cpus)) return; pr_notice("Re-enabling CPUs...\n"); for_each_cpu(cpu, downed_cpus) { diff --git a/arch/x86/platform/uv/uv_nmi.c b/arch/x86/platform/uv/uv_nmi.c index 1e9ff28bc2e0..ea277fc08357 100644 --- a/arch/x86/platform/uv/uv_nmi.c +++ b/arch/x86/platform/uv/uv_nmi.c @@ -985,7 +985,7 @@ static int uv_handle_nmi(unsigned int reason, struct pt= _regs *regs) =20 /* Clear global flags */ if (master) { - if (cpumask_weight(uv_nmi_cpu_mask)) + if (!cpumask_empty(uv_nmi_cpu_mask)) uv_nmi_cleanup_mask(); atomic_set(&uv_nmi_cpus_in_nmi, -1); atomic_set(&uv_nmi_cpu, -1); --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6EA3FC433F5 for ; Sun, 23 Jan 2022 18:41:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239693AbiAWSlN (ORCPT ); Sun, 23 Jan 2022 13:41:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239683AbiAWSkn (ORCPT ); Sun, 23 Jan 2022 13:40:43 -0500 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12BCBC061765; Sun, 23 Jan 2022 10:40:39 -0800 (PST) Received: by mail-pg1-x536.google.com with SMTP id 187so12949541pga.10; Sun, 23 Jan 2022 10:40:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=eBCqVqROfO1n2GtvmaN8kb1rlmDqWZOnUSJDskEB5Oo=; b=mJpgWld2B5wbHhAvTMo/0gMGWx3ZGMwlFDlFyfSZigS6cUmCqMZhCmhhnpUtMwHQvy U7vEWX2yv0mK4/592AvEUhGR8Bcq1qSOtPDaE68Fcx0iEHXFXSw+JfHNJwvdbsEQU8Nk Tzi0/XyxcEtaa0BR1NACnnrVqmbASiYnUX6wAv39ETD9AwBjexOS8Dq6D28L55v1DIeA z8LGQVXZcM/fQX5tf8gJB52u4N9LngjlLpLvLwTz9zLbczSKPpNuB1og0VOis8OQopte HszK8h97b+7fUeV0fxI+/kNFpek6zXMX2TbaxxRH0Jpoxd5rkk3XDT7S9kduvAKZlNGN xX/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eBCqVqROfO1n2GtvmaN8kb1rlmDqWZOnUSJDskEB5Oo=; b=IRZxEoCn+McUkhmywm3VzhKsR0s2yfCfPa7cI8dcmn5LgWwy/ZiGAdJj6LpHLrRONb tjcaFMpBPVxk7hduAfYsYcUAARDqtwLzl5Kwvy5V8Yl7S4a7frEkZ3XEEKGHrdJ0kewQ Ai3xCpHzyodY3A0IlNiWWoEWd3xGNpFJqsJozKpdrbkf3aXaxvCphy/pkXE/3mtY7mob 9ufx3FdXt9lzcv1CVIyEjtCr6cozWAeh6IcFSmxaGk45FwdisVzwso1AXIkHDg2AV8p0 4YtyyxDhWcTtf0cFZk8z8Yt49dP3oV5dUey/vm+/JNbxzNeBe0w3PyePkQ0pWWmZmoQ4 WwZw== X-Gm-Message-State: AOAM533OKRVq4kq+drMIlfKCwt1g+Gyh2FR6GI1RmWsWIMIAWp6mpKgB KlRBZNFkqyIJKvQlMaVGX1QOK5DX42U= X-Google-Smtp-Source: ABdhPJwRbsW8Pwf2wNB+Tms82WHgGwFZKC0sf8JW2mhyRDN3TsdWwUbRPyPzecSyKFotLcUKv7t4fA== X-Received: by 2002:a62:4c3:0:b0:4c2:7817:7360 with SMTP id 186-20020a6204c3000000b004c278177360mr11429381pfe.24.1642963238546; Sun, 23 Jan 2022 10:40:38 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id h5sm13043609pfi.111.2022.01.23.10.40.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:40:38 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Andy Gross , Bjorn Andersson , "Rafael J. Wysocki" , Viresh Kumar , Sudeep Holla , Cristian Marussi , linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 16/54] cpufreq: replace cpumask_weight with cpumask_empty where appropriate Date: Sun, 23 Jan 2022 10:38:47 -0800 Message-Id: <20220123183925.1052919-17-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" drivers/cpufreq calls cpumask_weight() to check if any bit of a given cpumask is set. We can do it more efficiently with cpumask_empty() because cpumask_empty() stops traversing the cpumask as soon as it finds first set bit, while cpumask_weight() counts all bits unconditionally. Signed-off-by: Yury Norov --- drivers/cpufreq/qcom-cpufreq-hw.c | 2 +- drivers/cpufreq/scmi-cpufreq.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufr= eq-hw.c index 05f3d7876e44..95a0c57ab5bb 100644 --- a/drivers/cpufreq/qcom-cpufreq-hw.c +++ b/drivers/cpufreq/qcom-cpufreq-hw.c @@ -482,7 +482,7 @@ static int qcom_cpufreq_hw_cpu_init(struct cpufreq_poli= cy *policy) } =20 qcom_get_related_cpus(index, policy->cpus); - if (!cpumask_weight(policy->cpus)) { + if (cpumask_empty(policy->cpus)) { dev_err(dev, "Domain-%d failed to get related CPUs\n", index); ret =3D -ENOENT; goto error; diff --git a/drivers/cpufreq/scmi-cpufreq.c b/drivers/cpufreq/scmi-cpufreq.c index 1e0cd4d165f0..919fa6e3f462 100644 --- a/drivers/cpufreq/scmi-cpufreq.c +++ b/drivers/cpufreq/scmi-cpufreq.c @@ -154,7 +154,7 @@ static int scmi_cpufreq_init(struct cpufreq_policy *pol= icy) * table and opp-shared. */ ret =3D dev_pm_opp_of_get_sharing_cpus(cpu_dev, priv->opp_shared_cpus); - if (ret || !cpumask_weight(priv->opp_shared_cpus)) { + if (ret || cpumask_empty(priv->opp_shared_cpus)) { /* * Either opp-table is not set or no opp-shared was found. * Use the CPU mask from SCMI to designate CPUs sharing an OPP --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 350CFC433F5 for ; Sun, 23 Jan 2022 18:41:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239930AbiAWSlQ (ORCPT ); Sun, 23 Jan 2022 13:41:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239629AbiAWSko (ORCPT ); Sun, 23 Jan 2022 13:40:44 -0500 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2414AC061748 for ; Sun, 23 Jan 2022 10:40:42 -0800 (PST) Received: by mail-pl1-x633.google.com with SMTP id e8so13479916plh.8 for ; Sun, 23 Jan 2022 10:40:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=475Re6o4qrxmTY2+dJD1szR+aZ9ztNBAVJwVf2XomiQ=; b=jmVObv+DHvV/nfgWMGm7G0AiVWxWK811CYrpCGiHV6xY0cRphRK/F1bxcyarhazE7G QO3y6iESjwSCWQV4XxfbN0VGrGzLnz+MQAZouCPpYGATGaaGpx/xFlQQHIUbUBuvRRw5 0P/sPgZ/Zob1yCiUwsGdNVWUVVlgMqpf+xC55wv1WQFaeiZGDLCbtdTLECSRwzD1BwDr 5hJchQzstXRUP379uF+B/2jyU8zwFVQtEt3XnUASMZLgJzQPBHWzsJ7NMd9Pe5Hmto0M h6UFu1fpTLkx6o30OssQidiED5LGIyGRgU4+4B2Dhf6WKpYvcVZFv0Kk+WkaLBOUlnoc 3Wyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=475Re6o4qrxmTY2+dJD1szR+aZ9ztNBAVJwVf2XomiQ=; b=IgPEElMhsrwOZyqBIF6X1X3A2GiUz8JltvaSiye4L5nlMNr7f9as3XlpC5ufxV/1W0 FaHotqvrScV3VtyXf1BbeCL7VhpYjP1TF3TyFaYV+A+5earT0aRfy9uxOiRcebjbVxOS 4n9DKpTzSoX0Li/UtMurY/LN3VAItmXF8CBmA7qBTO+xmwtRFbYGdBZiSg8SAWicPiY6 1OpVGbf1r2fE3d3+LIMeRckJgDgLEMOgEQD9sDXRC/PFHzM1E6Qw6kILVWo/eXmH7fp6 mYI0uZg9R8D6aCDvxsLu+9K7uAEpUhTV4OyXCEevBLydmmFfdnR5VJEdb2gDFBvOhV5w VUYg== X-Gm-Message-State: AOAM533ML7IKXq8PPDxPeMFDiW+R0NPf0EQg+JY6HIe0qGkAADQEp7Ic +l3xuEaGLYnB8J7mCxLv/xE= X-Google-Smtp-Source: ABdhPJyghkxvVhznkwLCfy/A1+7acBwkBZ1BlnfDfQwJqPCZvzndSaF4vpp9USN1uOTwz9n3zy27xQ== X-Received: by 2002:a17:90a:460f:: with SMTP id w15mr9814786pjg.123.1642963241641; Sun, 23 Jan 2022 10:40:41 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id q9sm13712586pfk.137.2022.01.23.10.40.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:40:41 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Daniel Vetter , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH 17/54] gpu: drm: replace cpumask_weight with cpumask_empty where appropriate Date: Sun, 23 Jan 2022 10:38:48 -0800 Message-Id: <20220123183925.1052919-18-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" i915_pmu_cpu_online() calls cpumask_weight() to check if any bit of a given cpumask is set. We can do it more efficiently with cpumask_empty() because cpumask_empty() stops traversing the cpumask as soon as it finds first set bit, while cpumask_weight() counts all bits unconditionally. Signed-off-by: Yury Norov --- drivers/gpu/drm/i915/i915_pmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_pmu.c b/drivers/gpu/drm/i915/i915_pm= u.c index ea655161793e..1894c876b31d 100644 --- a/drivers/gpu/drm/i915/i915_pmu.c +++ b/drivers/gpu/drm/i915/i915_pmu.c @@ -1048,7 +1048,7 @@ static int i915_pmu_cpu_online(unsigned int cpu, stru= ct hlist_node *node) GEM_BUG_ON(!pmu->base.event_init); =20 /* Select the first online CPU as a designated reader. */ - if (!cpumask_weight(&i915_pmu_cpumask)) + if (cpumask_empty(&i915_pmu_cpumask)) cpumask_set_cpu(cpu, &i915_pmu_cpumask); =20 return 0; --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84B04C433FE for ; Sun, 23 Jan 2022 18:41:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239947AbiAWSlS (ORCPT ); Sun, 23 Jan 2022 13:41:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239801AbiAWSkw (ORCPT ); Sun, 23 Jan 2022 13:40:52 -0500 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65E54C061756; Sun, 23 Jan 2022 10:40:45 -0800 (PST) Received: by mail-pj1-x1036.google.com with SMTP id d15-20020a17090a110f00b001b4e7d27474so14268037pja.2; Sun, 23 Jan 2022 10:40:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=geJcDF7eG8EOHs97ZbucxlWSNBb9ica7os3IO5WyQsk=; b=HZ5wFq5vKklf9YkTPPXH/lZMPEpCXNyoVqeQMYs5eSx898mpi8WLmcz/f0KpKVFBeW csCQYfbmltl4T3oVDVfzDu4v5mpUC6d+uWCx1BKMIrwjNVXkvy/oBKMa98kAw6vNd+BZ RVKXg0LetIuDEYO2OW3Zzx9ar3qZzetE1p3RxXMGVGXPU+PsDMqz8DRwZ2tm9YMbZWAw TH//sNAOe6+1oHsRcVNo4paHLUKJNoRfSdoRzqdFGgQdIrkpmbhkoc0NqiMsDUwRRfIN 9iVDq8wrBejuUjKzUcXbb6RDNssoqskWFcbdbeYQfLdz3jJqRtd/vRp/SMnfQdvMBYi2 BWWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=geJcDF7eG8EOHs97ZbucxlWSNBb9ica7os3IO5WyQsk=; b=IcQ5DbsQJojZ9y2Bi/8zowQtHIoYnv9ZvokUd4Cn0jvHFJrqAkkwMAycXH1mZP9+b8 NzclidjnMtKCepNLrTHHkXIEP0Df8iJJ+qoB0/LVusltKDmyn4Cj1KdXxSSmdeG1o2nF RoXxzvOpDKapslS/X+8YB+E1O5MuvSvXcbbumJOlfP3N3TkYhrlqdS9w57xaPYypKBer 2Nl2u+cUODwPM+uPCQhpN2CKeFVzqs24Wnsu/NpuJFsJgmio43U7/Gd986FYSJZvZYKl KIZqWEr2VHxljqBwSK4BIy9pp9B3jo/2ueIEmiskyw0jB4Lvzf3HQn5WlpVmttf2SlMP FLIA== X-Gm-Message-State: AOAM533FhfnZQwrzitdu0JQ8tIfYZ72egRBoiqr3KO0zQll278SIQGPy YuZNrti5rkNG8qiEpzIT06Q= X-Google-Smtp-Source: ABdhPJymK27TH5kGJL/EoV+91cYg2zsWinqPXBG6oJtzEAWeUpTPZAAzN7lPEF4QI4wEaGLrxdCnkQ== X-Received: by 2002:a17:90b:4ad1:: with SMTP id mh17mr9873766pjb.160.1642963244937; Sun, 23 Jan 2022 10:40:44 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id rj9sm11344424pjb.49.2022.01.23.10.40.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:40:44 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Mike Marciniszyn , Dennis Dalessandro , Jason Gunthorpe , linux-rdma@vger.kernel.org Subject: [PATCH 18/54] drivers/infiniband: replace cpumask_weight with cpumask_empty where appropriate Date: Sun, 23 Jan 2022 10:38:49 -0800 Message-Id: <20220123183925.1052919-19-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" drivers/infiniband/hw/hfi1/affinity.c code calls cpumask_weight() to check if any bit of a given cpumask is set. We can do it more efficiently with cpumask_empty() because cpumask_empty() stops traversing the cpumask as soon as it finds first set bit, while cpumask_weight() counts all bits unconditionally. Signed-off-by: Yury Norov --- drivers/infiniband/hw/hfi1/affinity.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/hw/hfi1/affinity.c b/drivers/infiniband/hw/= hfi1/affinity.c index 98c813ba4304..38eee675369a 100644 --- a/drivers/infiniband/hw/hfi1/affinity.c +++ b/drivers/infiniband/hw/hfi1/affinity.c @@ -667,7 +667,7 @@ int hfi1_dev_affinity_init(struct hfi1_devdata *dd) * engines, use the same CPU cores as general/control * context. */ - if (cpumask_weight(&entry->def_intr.mask) =3D=3D 0) + if (cpumask_empty(&entry->def_intr.mask)) cpumask_copy(&entry->def_intr.mask, &entry->general_intr_mask); } @@ -687,7 +687,7 @@ int hfi1_dev_affinity_init(struct hfi1_devdata *dd) * vectors, use the same CPU core as the general/control * context. */ - if (cpumask_weight(&entry->comp_vect_mask) =3D=3D 0) + if (cpumask_empty(&entry->comp_vect_mask)) cpumask_copy(&entry->comp_vect_mask, &entry->general_intr_mask); } --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8BB74C433EF for ; Sun, 23 Jan 2022 18:41:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239981AbiAWSlW (ORCPT ); Sun, 23 Jan 2022 13:41:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239780AbiAWSkw (ORCPT ); Sun, 23 Jan 2022 13:40:52 -0500 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7DE56C061759; Sun, 23 Jan 2022 10:40:48 -0800 (PST) Received: by mail-pl1-x62c.google.com with SMTP id n8so13502444plc.3; Sun, 23 Jan 2022 10:40:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=cO0Z3PvJvrtBIn6aCGpasZToGZcZBgiQnRAFqmRKoUA=; b=VTMY+YdRuNkseAuKEB0sacTZvHBgfmV4zPDgBlUHO02zbXakt4ftdzjgYgBnhNFYrJ Gq/uz/GbVuYEBJ11Si9b0Vn28HMi/mKcmODrHWStsvvykUL1wKNDqrObs/faG5tjJnMP OFcvcKedlRAfcJ0JntIkaDRTuDhuOwUp6/XHLbkcuMjlet0EBexHnDi/ng57aRf/xLdn 1R/z7KVKOdfOw/cNFfqJCxm+KwLQZH3lH+oCNAjmxn67gPX35JUauw2ASaBtUHJW84ui 7X7hf94iixk6ny58oeNC4S0XBdNtjpDuPJIvRp+WVBgHJCoL0Ieo81r93udRPOdgTwY0 3e3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cO0Z3PvJvrtBIn6aCGpasZToGZcZBgiQnRAFqmRKoUA=; b=G9OX+MsPW8hB9aTVfrhDYWPI/3f6yU6LtHjJq+HMEgedto9yeYfnXcbcrdHqwmwuLj r9j36Xn/Qu09sW9CL9RRMfbA3VlfDHuVUilmdqHojmBqsqgrV8BZJ/SVdHEq+aVM2hm8 oNWzOZ206W9iEv4EwqirKTUkihIDoMA8EqG/bbhai/lJuD243z9BJs+o6L4834YXIrc6 aH+3aLDckl+ou5mr2KBEa2SRFprBz+mPrGR4Bs2HMnNQ+WJj+EXsIu8rTpXFlkC+sywC AQ5ko7/iIgBT+EVXAWoFoeK5d5s8pCtaB9RL5B9iNZzNTPfZhEspfmcNy7NQFvpHD2ic cOqQ== X-Gm-Message-State: AOAM532CSSVdJpNxlb3Tcr2DoCQqz8o/AiuecbJo/GcnNePMIGFJLDX1 BsdXpupwTvnC9E6XhnartrI= X-Google-Smtp-Source: ABdhPJwrgZ6tKrcQ8FvcUHvDuVXP9x3ixqRStUB6a92ecxEbeN5yZXa/hXjzJafBTJp3VTMlXUGOfA== X-Received: by 2002:a17:902:ec82:b0:14a:6b35:903 with SMTP id x2-20020a170902ec8200b0014a6b350903mr11826986plg.78.1642963248015; Sun, 23 Jan 2022 10:40:48 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id q21sm13893599pfj.94.2022.01.23.10.40.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:40:47 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Florian Fainelli , Thomas Gleixner , Marc Zyngier , bcm-kernel-feedback-list@broadcom.com, linux-mips@vger.kernel.org Subject: [PATCH 19/54] drivers/irqchip: replace cpumask_weight with cpumask_empty where appropriate Date: Sun, 23 Jan 2022 10:38:50 -0800 Message-Id: <20220123183925.1052919-20-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" bcm6345_l1_of_init() calls cpumask_weight() to check if any bit of a given cpumask is set. We can do it more efficiently with cpumask_empty() because cpumask_empty() stops traversing the cpumask as soon as it finds first set bit, while cpumask_weight() counts all bits unconditionally. Signed-off-by: Yury Norov --- drivers/irqchip/irq-bcm6345-l1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/irqchip/irq-bcm6345-l1.c b/drivers/irqchip/irq-bcm6345= -l1.c index fd079215c17f..142a7431745f 100644 --- a/drivers/irqchip/irq-bcm6345-l1.c +++ b/drivers/irqchip/irq-bcm6345-l1.c @@ -315,7 +315,7 @@ static int __init bcm6345_l1_of_init(struct device_node= *dn, cpumask_set_cpu(idx, &intc->cpumask); } =20 - if (!cpumask_weight(&intc->cpumask)) { + if (cpumask_empty(&intc->cpumask)) { ret =3D -ENODEV; goto out_free; } --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E357EC433F5 for ; Sun, 23 Jan 2022 18:41:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234678AbiAWSlZ (ORCPT ); Sun, 23 Jan 2022 13:41:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239818AbiAWSk5 (ORCPT ); Sun, 23 Jan 2022 13:40:57 -0500 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BE35C06175A for ; Sun, 23 Jan 2022 10:40:52 -0800 (PST) Received: by mail-pj1-x1030.google.com with SMTP id d12-20020a17090a628c00b001b4f47e2f51so15465787pjj.3 for ; Sun, 23 Jan 2022 10:40:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=LzUduzolyZ+4xt2vAObi0ehcZor8t7e5g8GsVVH/1TU=; b=I3KQk9RairbI2xGbFTQyBvOz1r8XmtL+1VMHv+8xfIG0laBeuSNtG38Ni3Hyl9YL4M tYU9Sf/7ekYcztKvrRATglZw1d8PZGncVS4Rp3bAFA2DenPxej7qVnw70zkXgcXrFx5g 1vGrqTWhPoydoQcCLlQ4Siqv/nNxaW+AzbY4JPfOB+R72HGbj3qay8HOiyb/wLh7WkqO aW4XGpT8J9XHyJ01oBonS/Jw0jZaJCUrqSsxVdnynxHPs3WM4X2INHUWlpNtWYRAPW5i OZ3hY/KwVxyiFP0uFF9M47OdXE73OymBsIpsxT0h9LbsC+hN1SbPHe93ikxnWjJ8foVq ZdAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LzUduzolyZ+4xt2vAObi0ehcZor8t7e5g8GsVVH/1TU=; b=NLJZMZybQAOwPlvjmHTCPxXiwj/ClgSpXwCn5rISpFC/KKFO2cgcrNrfOtb/jYIUKv MdYFvy9tX1qatH1ST2g4qMPV2Eu8UmLGLwOGp4Mm0WWPE0el5v8v9KTwNfrHG/k0rvxr r52oWwfyZsJIojhGq89Er0NXEj/L+hUuFeCOuoPPA4CkL0OzCY1KUQs/Z/jpcrsRD5zO AYOW0YTPvZP1OX4MQ8dMxWyqv62TduiywTnLExZafZckhSB9lo3jI4Pq8IvEXq+gdZcu Ceu8InWGS+WKJZgG15cdZNAKbeKVz6kMzSsQRMeXX16ZP7CwlOpcGuoWx7NTflsuZ0a6 hvag== X-Gm-Message-State: AOAM5310iTePJFO/sLUNucfaGejgZj3NOSXYFd/LDHOKvikSbdr2Futf lwiS1hu6acocQX59NMDDnV8= X-Google-Smtp-Source: ABdhPJxJh2Q2GUvN1TLZh6ILSvNRlzZ4CZKgjgsTzypxj1R8sL8XUzs0nMFTl1sFjrsuWNMxUZJjjw== X-Received: by 2002:a17:90a:6c05:: with SMTP id x5mr8005739pjj.172.1642963251555; Sun, 23 Jan 2022 10:40:51 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id d18sm13942816pfv.173.2022.01.23.10.40.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:40:51 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Thomas Gleixner Subject: [PATCH 20/54] kernel/irq: replace cpumask_weight with cpumask_empty where appropriate Date: Sun, 23 Jan 2022 10:38:51 -0800 Message-Id: <20220123183925.1052919-21-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" __irq_build_affinity_masks() calls cpumask_weight() to check if any bit of a given cpumask is set. We can do it more efficiently with cpumask_empty() because cpumask_empty() stops traversing the cpumask as soon as it finds first set bit, while cpumask_weight() counts all bits unconditionally. Signed-off-by: Yury Norov --- kernel/irq/affinity.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/irq/affinity.c b/kernel/irq/affinity.c index f7ff8919dc9b..18740faf0eb1 100644 --- a/kernel/irq/affinity.c +++ b/kernel/irq/affinity.c @@ -258,7 +258,7 @@ static int __irq_build_affinity_masks(unsigned int star= tvec, nodemask_t nodemsk =3D NODE_MASK_NONE; struct node_vectors *node_vectors; =20 - if (!cpumask_weight(cpu_mask)) + if (cpumask_empty(cpu_mask)) return 0; =20 nodes =3D get_nodes_in_cpumask(node_to_cpumask, cpu_mask, &nodemsk); --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 37840C433EF for ; Sun, 23 Jan 2022 18:41:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239863AbiAWSlc (ORCPT ); Sun, 23 Jan 2022 13:41:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239694AbiAWSk5 (ORCPT ); Sun, 23 Jan 2022 13:40:57 -0500 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EEA7C061771; Sun, 23 Jan 2022 10:40:55 -0800 (PST) Received: by mail-pl1-x632.google.com with SMTP id i1so3819214pla.0; Sun, 23 Jan 2022 10:40:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=mN17EzppG4ynDyxtSQ4OI8cPa8nEXu8EGM7JWhlGQJ0=; b=DPUMC+f8vFIQ4C+keKENcS1CZWerPnD3IRPXyE6h/2QcbBF/Wu0tlG5aDajxt2jKzz R77TXcmefxVIyjDUH0SbTh1R81w3+ZjleGO8L8GbGqNycuZPsi9R1xIoeZU6CxcA52bW kuMsn6KUX3+efxJQKY9q9xe25lwJeLNjJYypvJ4iwlen2xiBcr8fBQRpJT57a1zbmNqq ZEolRzFj16zWoBqUTbH6ftmKyfB4GX6z+03CiemxUY6JVGCfhyyq0eIzS6jeVIzyBiVs 6CiqnsuFmHULvTE5lW9PsqmKJNLema9/DCoXl7ozQltvAJZFoFsPhbte6bb5pEylNiMp kfAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mN17EzppG4ynDyxtSQ4OI8cPa8nEXu8EGM7JWhlGQJ0=; b=O0Eq5RmckDujcjRofgLWxeDiwuLp+jNJ969g40g8wfYPf1N1sSIVIgtMlAqFHCIE4a Pv43TIm8jo0bUmhGZwCPglf8xdH9JbZDuYS+NB7GcHCLcooa6kgkZ/uGrXnIMPeXrH14 lIWPCiaqlpIlkEjLSA8d/PjPYoXTN05DtzJ3RTCNWh67imefvcm03yka0oLTfRiO0YWY xEDoJX5Fhh20HvQuzYhZIrtx24fh0efjjoRKB/PfBGxhVp1RKv8f/DGSvHAraLICqaPO 0wwUcbyn1WCLx44rcQSJdxUk04tDAcK2LelSkXtvAp1MEQDSQn7EjGAf3J4N7Jk/1DDD 78oA== X-Gm-Message-State: AOAM532hBgbZr9t7jtGSkjGgvQEDDjIzaBuR0UARZKwhlaq4pw7mBLON cjLLKysHsSUSYE2msrM6HGg= X-Google-Smtp-Source: ABdhPJz6lZ1os7HUxApPqwpmn5620+izBGVNFDoMgaNBOkggq3kvy803tDVOr4KKVQpxK2I/EoWfqA== X-Received: by 2002:a17:902:ed82:b0:14a:9ad8:a146 with SMTP id e2-20020a170902ed8200b0014a9ad8a146mr11639698plj.55.1642963254650; Sun, 23 Jan 2022 10:40:54 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id t2sm9752456pgt.12.2022.01.23.10.40.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:40:54 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Steffen Klassert , Daniel Jordan , linux-crypto@vger.kernel.org Subject: [PATCH 21/54] kernel: replace cpumask_weight with cpumask_empty in padata.c Date: Sun, 23 Jan 2022 10:38:52 -0800 Message-Id: <20220123183925.1052919-22-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" padata_do_parallel() calls cpumask_weight() to check if any bit of a given cpumask is set. We can do it more efficiently with cpumask_empty() because cpumask_empty() stops traversing the cpumask as soon as it finds first set bit, while cpumask_weight() counts all bits unconditionally. Signed-off-by: Yury Norov --- kernel/padata.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/padata.c b/kernel/padata.c index 18d3a5c699d8..e5819bb8bd1d 100644 --- a/kernel/padata.c +++ b/kernel/padata.c @@ -181,7 +181,7 @@ int padata_do_parallel(struct padata_shell *ps, goto out; =20 if (!cpumask_test_cpu(*cb_cpu, pd->cpumask.cbcpu)) { - if (!cpumask_weight(pd->cpumask.cbcpu)) + if (cpumask_empty(pd->cpumask.cbcpu)) goto out; =20 /* Select an alternate fallback CPU and notify the caller. */ --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7EFD5C433EF for ; Sun, 23 Jan 2022 18:41:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240053AbiAWSlk (ORCPT ); Sun, 23 Jan 2022 13:41:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239715AbiAWSk6 (ORCPT ); Sun, 23 Jan 2022 13:40:58 -0500 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9CD8C06173D; Sun, 23 Jan 2022 10:40:57 -0800 (PST) Received: by mail-pg1-x533.google.com with SMTP id v3so7873287pgc.1; Sun, 23 Jan 2022 10:40:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=UUKJUI5LEQZKArKXE5kTNrLEuODfkVdvxUFHk4GiAXc=; b=B8p8tHIZv+dHEfVHl/No8uGC1d6rBNR6KHiGIhB03BC1EQYyDbAFs0hZR8USDjt7YJ 3BoLtDJ5s3uk+CrF8kCmGokKb4I5AxPFFEYJNS2upRFlOrifOivmrVCyvvbSblPt+8QR STKpfwVdgogy51f2LObUIq3MF8dfBcNvricle3FbVfD/Lvk9zeg90qAhFoz9FJ7BxJn/ GM/zJCtI9FWyBo11QplwdknQKRo4mmbbO9dcmA2AMQ2r6h4D/R+C/6Z5Upz2H+6FwawR McHv69WPqBt6COW7wuNPvTYLatkej8o2lExGiIEITYQDhZ07nISE4qjY1T0p/V3fyJXa +iXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UUKJUI5LEQZKArKXE5kTNrLEuODfkVdvxUFHk4GiAXc=; b=jY6QJ0zklMjv6hqzQGgfMJMWOCj1OigQws7E2DIA7QIF+ywjUYshnSxbkppqTHE3qz ScCBrRuokyUfDZMjMN5T7I0g+KONAI80+lxu8dAaJhGRzqCo5NhXwXc1VLAbWwmhgG/P r4Dtkj41jH/eVcDFBllI9CQwipw8lSGLyowygGsCzeoIe1jT3LNJRfBmHfNORmvxwh9c a1BFTwexAsZB3PV19KuKua5yMLMI8I8UggvxwdE4/YVNnko5FtjlBKoa4DKik8nRd16c VvsvL1ftk162yIXQJs5cLIT6pultr5ev6P2cI+7pm/78TKZLKybboKJdbfRI+rA827kE amgA== X-Gm-Message-State: AOAM532F9vb8toge0AiG3g2TZ0YM8o98ji3alqL8g5kVrTlUWNEshQDb VNuIJ1rPp1Wnk1bBwKfzWuQOPpfls9U= X-Google-Smtp-Source: ABdhPJx6P1H1G7heLbutA+icIyViqrkaWle0teU4GGguSdO0pA8FIAznKJQS2GmROqlo2H6iYL8uJg== X-Received: by 2002:a62:dd56:0:b0:4c7:8603:3ffe with SMTP id w83-20020a62dd56000000b004c786033ffemr8567637pff.15.1642963257316; Sun, 23 Jan 2022 10:40:57 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id v8sm3258809pfu.186.2022.01.23.10.40.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:40:57 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, "Paul E. McKenney" , Josh Triplett , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Joel Fernandes , rcu@vger.kernel.org Subject: [PATCH 22/54] rcu: replace cpumask_weight with cpumask_empty where appropriate Date: Sun, 23 Jan 2022 10:38:53 -0800 Message-Id: <20220123183925.1052919-23-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" In some places, RCU code calls cpumask_weight() to check if any bit of a given cpumask is set. We can do it more efficiently with cpumask_empty() because cpumask_empty() stops traversing the cpumask as soon as it finds first set bit, while cpumask_weight() counts all bits unconditionally. Signed-off-by: Yury Norov --- kernel/rcu/tree_nocb.h | 4 ++-- kernel/rcu/tree_plugin.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/rcu/tree_nocb.h b/kernel/rcu/tree_nocb.h index eeafb546a7a0..f83c7b1d6110 100644 --- a/kernel/rcu/tree_nocb.h +++ b/kernel/rcu/tree_nocb.h @@ -1169,7 +1169,7 @@ void __init rcu_init_nohz(void) struct rcu_data *rdp; =20 #if defined(CONFIG_NO_HZ_FULL) - if (tick_nohz_full_running && cpumask_weight(tick_nohz_full_mask)) + if (tick_nohz_full_running && !cpumask_empty(tick_nohz_full_mask)) need_rcu_nocb_mask =3D true; #endif /* #if defined(CONFIG_NO_HZ_FULL) */ =20 @@ -1348,7 +1348,7 @@ static void __init rcu_organize_nocb_kthreads(void) */ void rcu_bind_current_to_nocb(void) { - if (cpumask_available(rcu_nocb_mask) && cpumask_weight(rcu_nocb_mask)) + if (cpumask_available(rcu_nocb_mask) && !cpumask_empty(rcu_nocb_mask)) WARN_ON(sched_setaffinity(current->pid, rcu_nocb_mask)); } EXPORT_SYMBOL_GPL(rcu_bind_current_to_nocb); diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h index c5b45c2f68a1..0dc0c8d6717c 100644 --- a/kernel/rcu/tree_plugin.h +++ b/kernel/rcu/tree_plugin.h @@ -1215,7 +1215,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_= node *rnp, int outgoingcpu) cpu !=3D outgoingcpu) cpumask_set_cpu(cpu, cm); cpumask_and(cm, cm, housekeeping_cpumask(HK_FLAG_RCU)); - if (cpumask_weight(cm) =3D=3D 0) + if (cpumask_empty(cm)) cpumask_copy(cm, housekeeping_cpumask(HK_FLAG_RCU)); set_cpus_allowed_ptr(t, cm); free_cpumask_var(cm); --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E861CC433EF for ; Sun, 23 Jan 2022 18:41:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239870AbiAWSlp (ORCPT ); Sun, 23 Jan 2022 13:41:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239852AbiAWSlA (ORCPT ); Sun, 23 Jan 2022 13:41:00 -0500 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1590C061744 for ; Sun, 23 Jan 2022 10:41:00 -0800 (PST) Received: by mail-pj1-x1033.google.com with SMTP id nn16-20020a17090b38d000b001b56b2bce31so3335296pjb.3 for ; Sun, 23 Jan 2022 10:41:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Y1tPM2x+LdwD18VwjZck6YxRe2obac2jjzlUu/mgFiM=; b=fVijBHEL3gp13HONCJnA7ih2LQ9ToB3knn2X89I+BbqwX9+Qmqrs8TpNzVK2ulM7lB eLtmJFXke0X5Cm1JiG8QIg3CDGBuG4rwyTm9xaCmjC2IO6ehozsunIo9HkdfcgRQw6F/ K2LTk+yI+tlvBlD6Dd1A8kiJO7MdlREWIQ9FiK1a9WmXnMxEUCAe06jNHuBSYqKyHEzv XF8onjg6Gt/lrMZVErLMtWr9qNdX1CCpARXqcoL3ueiYM4PQ9UspcRzS+SYvNvTLCBG7 FnH0GItcXoFe8VRupuNvpvRgHrjh4oc+FeHPjx8JP2nguGysLsxxq6BziCv2BoI5uyBd leGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Y1tPM2x+LdwD18VwjZck6YxRe2obac2jjzlUu/mgFiM=; b=ycNwjHqqjoa4FgC6U6a4FB8Mz2wYh/RWa+nmc4r1uNf4wpeVoBrGjBVra/nCTsgNQS 3C5hmsFLa5mtyJAMYA38nP9BDe7BiVeuLP2JFCkq2uoIKW78aOM3woeJ5pMYF3tO6Nl6 KMjl1tu4Z6nLBs8YrLK+7dErYItaG1A+4E4Le2QBnEDeXqVM5T8+1/bd6WYDwP5xhK40 585vlRGivXu++v/JRccP3KkzII2Qw9YkpTyaqfyyWEfp5JZ/2F8w9x4w66VG8wQzDiHi Dwk+CbzGqw5A2vwLMEUiPlNzbFZb6XAatM68drxyvp5wR0saWAi1NyMPSkmFk4IVJRGW b3gg== X-Gm-Message-State: AOAM5331eJt5fIrZI1mRUxXHVbwplEy6ICfuyMNKA0rFk/ocKGzVf2JG TE5cdS/tRsriy22ZtwMWga8= X-Google-Smtp-Source: ABdhPJyssPaXQP2/ydapTk0xPZ7dpr7K04kh5u49fDFdhy50p0xc+q9sLR6vNLCbmjW+yBSzz7pdEQ== X-Received: by 2002:a17:903:124f:b0:149:a740:d8bc with SMTP id u15-20020a170903124f00b00149a740d8bcmr12002122plh.79.1642963260184; Sun, 23 Jan 2022 10:41:00 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id v17sm13674760pfu.220.2022.01.23.10.40.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:40:59 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Ingo Molnar , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira Subject: [PATCH 23/54] sched: replace cpumask_weight with cpumask_empty where appropriate Date: Sun, 23 Jan 2022 10:38:54 -0800 Message-Id: <20220123183925.1052919-24-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" In some places, kernel/sched code calls cpumask_weight() to check if any bit of a given cpumask is set. We can do it more efficiently with cpumask_empty() because cpumask_empty() stops traversing the cpumask as soon as it finds first set bit, while cpumask_weight() counts all bits unconditionally. Signed-off-by: Yury Norov --- kernel/sched/core.c | 2 +- kernel/sched/topology.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 2e4ae00e52d1..918d0bdc2ea8 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -8707,7 +8707,7 @@ int cpuset_cpumask_can_shrink(const struct cpumask *c= ur, { int ret =3D 1; =20 - if (!cpumask_weight(cur)) + if (cpumask_empty(cur)) return ret; =20 ret =3D dl_cpuset_cpumask_can_shrink(cur, trial); diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c index d201a7052a29..8478e2a8cd65 100644 --- a/kernel/sched/topology.c +++ b/kernel/sched/topology.c @@ -74,7 +74,7 @@ static int sched_domain_debug_one(struct sched_domain *sd= , int cpu, int level, break; } =20 - if (!cpumask_weight(sched_group_span(group))) { + if (cpumask_empty(sched_group_span(group))) { printk(KERN_CONT "\n"); printk(KERN_ERR "ERROR: empty group\n"); break; --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A866FC433F5 for ; Sun, 23 Jan 2022 18:41:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239885AbiAWSlv (ORCPT ); Sun, 23 Jan 2022 13:41:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239880AbiAWSlE (ORCPT ); Sun, 23 Jan 2022 13:41:04 -0500 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B9B0C061762 for ; Sun, 23 Jan 2022 10:41:04 -0800 (PST) Received: by mail-pf1-x435.google.com with SMTP id 128so13765689pfe.12 for ; Sun, 23 Jan 2022 10:41:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=QPKVddXMwyPUGJHCiBL7SqymTrzOfaCYlNdg2PQJoYo=; b=Iuh+2DtxuSEMkkUDpbhNS7s4A4Ryp5/2axsi17WCpZOdLQexzRWGG94IclzD4noeoE m7xu9iXKYySVHL8p04V+gv0xr+CPfTI6cdzYMcx9GRpoKbAgk3QFV7SaqeijUQUhL/f0 z/rGeX05aH+UT1FOD/rswO/+tOuwXagALyijgDkxJpRjDrcl6VxZXY8Mh3x3IQWLEAM1 TeLWq5rkQRmlZOkzw/Xut+RSfu10I5+m/ascmhUvfod6cLzfSCuIO+uY5F9RrHD9j8XF x7e2zB/H0SmJXM4XoVwvO6XSbNtXaLUff0UBYfTH1/hqb/lF8+SDeujHTLbfILlN8FMz y5vA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QPKVddXMwyPUGJHCiBL7SqymTrzOfaCYlNdg2PQJoYo=; b=mwDeq1xJTaSeaNVVtFOIU2NGVB6miFU9Y2SGTTCPzRBC4/Cj9uYbCULIkvivL9rd9t RSfrdZzCTGWSNLDYFhOUo6mkE/i8dbhav2q1wBClz+uTu9mFwcRaqKXFa4yhDJhF9jgn z1BalPF1Xe5didGsR015YeW7C5mKsLQD4+FJr9RcXj6rbnAl97M4ORqHRS+qnBptRx09 AkaYegliJ76p900eia+u+yZBUviYmLpDoEhydec2nRh8xWpNInX12rz3AmDP3bdgbVpC kjEhMFHibUD4YtFfSgnaoVOprd41eZ/fVKhrA9ISbhY+phqCBwADWQ0N9oihB9lQLwNl hseg== X-Gm-Message-State: AOAM530mNNbZf/yr6q7cqP56R8XCiSDFDVvQDUQt04AguZGJ5spw/A7v vlccIqnkN+TbcQ+69VlMDPA= X-Google-Smtp-Source: ABdhPJx9AGtXz/yHsvgR0AHxLbrVhd0CcN+ep2bKkeqRhK1BogRrK4KUaLaPLfv0O2CgN/UDdfoMAw== X-Received: by 2002:a62:4c3:0:b0:4c2:7817:7360 with SMTP id 186-20020a6204c3000000b004c278177360mr11430170pfe.24.1642963263649; Sun, 23 Jan 2022 10:41:03 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id ns21sm4951068pjb.43.2022.01.23.10.41.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:41:03 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, John Stultz , Thomas Gleixner , Stephen Boyd Subject: [PATCH 24/54] time: replace cpumask_weight with cpumask_empty in clocksource.c Date: Sun, 23 Jan 2022 10:38:55 -0800 Message-Id: <20220123183925.1052919-25-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" clocksource_verify_percpu() calls cpumask_weight() to check if any bit of a given cpumask is set. We can do it more efficiently with cpumask_empty() because cpumask_empty() stops traversing the cpumask as soon as it finds first set bit, while cpumask_weight() counts all bits unconditionally. Signed-off-by: Yury Norov --- kernel/time/clocksource.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c index 1cf73807b450..a2fecb4d8c0e 100644 --- a/kernel/time/clocksource.c +++ b/kernel/time/clocksource.c @@ -337,7 +337,7 @@ void clocksource_verify_percpu(struct clocksource *cs) cpus_read_lock(); preempt_disable(); clocksource_verify_choose_cpus(); - if (cpumask_weight(&cpus_chosen) =3D=3D 0) { + if (cpumask_empty(&cpus_chosen)) { preempt_enable(); cpus_read_unlock(); pr_warn("Not enough CPUs to check clocksource '%s'.\n", cs->name); --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5DE1CC433EF for ; Sun, 23 Jan 2022 18:41:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239920AbiAWSly (ORCPT ); Sun, 23 Jan 2022 13:41:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239902AbiAWSlI (ORCPT ); Sun, 23 Jan 2022 13:41:08 -0500 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 012D4C061765 for ; Sun, 23 Jan 2022 10:41:08 -0800 (PST) Received: by mail-pj1-x1030.google.com with SMTP id s2-20020a17090ad48200b001b501977b23so13568216pju.2 for ; Sun, 23 Jan 2022 10:41:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=/VgvGoSrjM7RHhvz4oz6UhP4t05IzW+FafmG/hxmK+g=; b=LtksDaUoKFgi6fsMPm0LDpUgQbJ1garCGl3knzuF4lCLaZ3c+Yrsn7OJJn4xT3yZMz qsEjgH5T23Sp6vKj0Xf98AkY37c6l52KvNWIc9u+gUXjEquq5MdjBegeB3QhUjG9VeoK kHMzkjDe3KwpVy01jvSDVT4RTAFNuKoRpg9WQ+bXRSqKI7x3EREi1itGAmmnmMX9zyAb OgfvbBkheON1V3OLU/a7FTndsUWqMzFAPMeI5mkD9gnX41YSkLDgoF6gMv8ptI1H9ksB gq+VEGbDrkrXDa2G0Fs0rQSEvAOsF2abSE0i4tOqxQTeF+nuNpz4uuApyqxnnvsc2ctR mUFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/VgvGoSrjM7RHhvz4oz6UhP4t05IzW+FafmG/hxmK+g=; b=ZrxLW4dY87+plWGg5teMhR+hj2Y4dR1xeuxNvv7fd4MpmO28zgahhxxMms9P7L+W4I HHz7WvIfkMM695j2+fmmKBPNHDEYlJdbaCdQHO3wV22tgPkhQkCqQxC3GwziGt6z7UHe LVhLAvtsCHhpoI/PJigAt3bdLrBumoHbr9jrwOcarFaTps4t6YEsKuOFn4LVr0AQdJvM G8CyHBo5UMedSvpnD8FvN9DPtPZo2XsmaLT7vi+/a6QRPP6bLchTQRMx+PjTky5V1+sx Y6q/r8WFPC9CCsPsp3couLf35zQtRiLgSGwGT3ZRLss9YVtpGplEsK/DkiRjcuxNSC+x hvQw== X-Gm-Message-State: AOAM533nogohVX8ybw0z9EAsqfn6D4XLTKmUUrRomjJV0FbWO5ijAGtn UkVfNEzHIbIrUdM05wGubkE= X-Google-Smtp-Source: ABdhPJxM5+OvTM7zV5jkK8eH28BzzoNvH/Nv9KCuB2FTZ9Fcl9QZ0o8NEWTqi1guXckSoVXq6LTshg== X-Received: by 2002:a17:902:b489:b0:14a:4747:9917 with SMTP id y9-20020a170902b48900b0014a47479917mr11450174plr.26.1642963267529; Sun, 23 Jan 2022 10:41:07 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id l13sm10214049pgs.16.2022.01.23.10.41.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:41:07 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 25/54] mm/vmstat: replace cpumask_weight with cpumask_empty where appropriate Date: Sun, 23 Jan 2022 10:38:56 -0800 Message-Id: <20220123183925.1052919-26-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" mm/vmstat.c code calls cpumask_weight() to check if any bit of a given cpumask is set. We can do it more efficiently with cpumask_empty() because cpumask_empty() stops traversing the cpumask as soon as it finds first set bit, while cpumask_weight() counts all bits unconditionally. Signed-off-by: Yury Norov --- mm/vmstat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/vmstat.c b/mm/vmstat.c index 4057372745d0..f56f11e3eef5 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -2035,7 +2035,7 @@ static void __init init_cpu_node_state(void) int node; =20 for_each_online_node(node) { - if (cpumask_weight(cpumask_of_node(node)) > 0) + if (!cpumask_empty(cpumask_of_node(node))) node_set_state(node, N_CPU); } } @@ -2062,7 +2062,7 @@ static int vmstat_cpu_dead(unsigned int cpu) =20 refresh_zone_stat_thresholds(); node_cpus =3D cpumask_of_node(node); - if (cpumask_weight(node_cpus) > 0) + if (!cpumask_empty(node_cpus)) return 0; =20 node_clear_state(node, N_CPU); --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24257C433F5 for ; Sun, 23 Jan 2022 18:41:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239912AbiAWSlz (ORCPT ); Sun, 23 Jan 2022 13:41:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239923AbiAWSlL (ORCPT ); Sun, 23 Jan 2022 13:41:11 -0500 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED325C06176A for ; Sun, 23 Jan 2022 10:41:10 -0800 (PST) Received: by mail-pl1-x62d.google.com with SMTP id n8so13503017plc.3 for ; Sun, 23 Jan 2022 10:41:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Va/u2iX1YVOINaxIuJLKJ3LTGOLOqvsNjPRhFp+Rqeo=; b=eagkQ6Q6MYIyUa2gGTCr0XP5Aj+BdjWz9lZgHECpuGLi3hniUg1vL04exTfY56Hd1E UQYcD0Az1f9gMpbExHH7+zle8nBUUcfkZnNB1N4d7yIalhSNXjF7FSmEJjs4Bo0exVu/ YCP495oGvt7PpQvBlyvD+w0qqqR7r/LG0ES5OU2Ogjc+uci4x3heIZYQMjeVZ4FrQ5FV 1W2RBQfKY1WNoTa6PY8XqJk7Lc3XawRe+hoQeiDVpxs8buZgdFT9jX1YsYXTbCfAQ6br vBCq01+NLc+plLrUmN/sZDmpb91ldk9OK1uKeec/eXNC3RqATlokAapxKDgOge4P9Aat X3Ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Va/u2iX1YVOINaxIuJLKJ3LTGOLOqvsNjPRhFp+Rqeo=; b=PdRLn2Bn+P4bZCI4VgP2+EBlRH+xTr+tSh1W8QIRXmfZ4OYZv/GmoCT2yi9uQg6q9l Dj9ZTI8FpFGXEqZVNqodheTgJnVWK77L9flxFCTToOTVDfzhqOcKFBoWTXdz2QY1erUm OSs1LETZq9iIt9xBcBMPRK5jKHBweceMWs3sLWYllYbnmY7lPeOg7T6/VNXJPGd0jM11 nR1K+npjbgilKxZenigqeL4BQTEZncS77YQCZ3rYKO+C1SB+9w81y0ejxeJkM+XncKBL MgMfZVWSJIM3urHbovqBAcMIgsoS43sHZixVyzG5Pv3+s6HatFoRQSubFkFjQ/Y+uICe Q1dQ== X-Gm-Message-State: AOAM531VtPKLmNtwNfk77u4iaSpJYjz2uE2xLQQxwEhNLgB6ABcxKZCa txLYfNjGF26Z5xiSe48Wm04= X-Google-Smtp-Source: ABdhPJxvxbe+z7NuSUkqm9rEuKdHdlkqT/vD80MI3bNETHPdwJquHkS8H8ObhnEdYy/07LJ3AxKonQ== X-Received: by 2002:a17:90a:4601:: with SMTP id w1mr10006540pjg.113.1642963270445; Sun, 23 Jan 2022 10:41:10 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id l17sm216332pfu.61.2022.01.23.10.41.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:41:10 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Dave Hansen , Andy Lutomirski , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , x86@kernel.org Subject: [PATCH 26/54] arch/x86: replace nodes_weight with nodes_empty where appropriate Date: Sun, 23 Jan 2022 10:38:57 -0800 Message-Id: <20220123183925.1052919-27-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" mm code calls nodes_weight() to check if any bit of a given nodemask is set. We can do it more efficiently with nodes_empty() because nodes_empty() stops traversing the nodemask as soon as it finds first set bit, while nodes_weight() counts all bits unconditionally. Signed-off-by: Yury Norov --- arch/x86/mm/amdtopology.c | 2 +- arch/x86/mm/numa_emulation.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/x86/mm/amdtopology.c b/arch/x86/mm/amdtopology.c index 058b2f36b3a6..b3ca7d23e4b0 100644 --- a/arch/x86/mm/amdtopology.c +++ b/arch/x86/mm/amdtopology.c @@ -154,7 +154,7 @@ int __init amd_numa_init(void) node_set(nodeid, numa_nodes_parsed); } =20 - if (!nodes_weight(numa_nodes_parsed)) + if (nodes_empty(numa_nodes_parsed)) return -ENOENT; =20 /* diff --git a/arch/x86/mm/numa_emulation.c b/arch/x86/mm/numa_emulation.c index 1a02b791d273..9a9305367fdd 100644 --- a/arch/x86/mm/numa_emulation.c +++ b/arch/x86/mm/numa_emulation.c @@ -123,7 +123,7 @@ static int __init split_nodes_interleave(struct numa_me= minfo *ei, * Continue to fill physical nodes with fake nodes until there is no * memory left on any of them. */ - while (nodes_weight(physnode_mask)) { + while (!nodes_empty(physnode_mask)) { for_each_node_mask(i, physnode_mask) { u64 dma32_end =3D PFN_PHYS(MAX_DMA32_PFN); u64 start, limit, end; @@ -270,7 +270,7 @@ static int __init split_nodes_size_interleave_uniform(s= truct numa_meminfo *ei, * Fill physical nodes with fake nodes of size until there is no memory * left on any of them. */ - while (nodes_weight(physnode_mask)) { + while (!nodes_empty(physnode_mask)) { for_each_node_mask(i, physnode_mask) { u64 dma32_end =3D PFN_PHYS(MAX_DMA32_PFN); u64 start, limit, end; --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20441C433F5 for ; Sun, 23 Jan 2022 18:42:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239739AbiAWSl7 (ORCPT ); Sun, 23 Jan 2022 13:41:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239728AbiAWSlO (ORCPT ); Sun, 23 Jan 2022 13:41:14 -0500 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD3DAC061775 for ; Sun, 23 Jan 2022 10:41:13 -0800 (PST) Received: by mail-pj1-x102d.google.com with SMTP id s61-20020a17090a69c300b001b4d0427ea2so18254996pjj.4 for ; Sun, 23 Jan 2022 10:41:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Y8ExfgOcgrA4CHmSecZvjPn/xavwnyrvtMRh3tqxxrw=; b=l53CvIarxDvrY/yoGsTqTp5a0/SfJI+CVqIBS/RZYOF/qD3Ntc15R0IX4/lby6qtWI jGZa8A9L0I8+vAoOofqFnB5LaPUDcxF64aMCojsV+iFSNF4362teiDOo6tIAT0Rvjnow t7sB0r9MqGQs0HvbUzP0MbNsZgpBmifd+HOFVn8vKQSsRfhivO9XfdSlFSR/IPfiNVjB 2Yf8wYUQMHYKkb+shQFMEl/YFTDS34zm8JwJbsaqX0s+LTs5ubgc66hFcRAXhzGdaGf1 eGRoXaxS8D2LBVkMeNuoO97VtU07aOv3KJHWFG29eBjbxZ88z53HCatKTmbUa7BFnMG4 OnYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Y8ExfgOcgrA4CHmSecZvjPn/xavwnyrvtMRh3tqxxrw=; b=eGA6kSj7m94hZn1B/PkytgnjwEN5j+je56DAbzV2TueGnJitQbh/iaV6UOpYy4wGqL 5gYVihziV8gESfbr/n6K+8bV4+iZN32RSzpkq2QGL9fM4G7HvI6Xq6GbSP4LR69z+49/ 2J/j2D26QMADe94z9igA9UitjR6am2mzbIb3ypUixLQF9/sH/fqRcQNXV3SNYORjcj68 Awx2wezqEBEOhU0VzpJ5a4e0pt5O9QnKvK2VbjoPiPPm8nTH1kga5gvD4zTvP6B75iII ysqMgBJm2jBtQNMRHSU+Zu/22XU+TrHklbIYUfTP/jvijxByCHW3kQzpxEMIqCUO7D+e wq3w== X-Gm-Message-State: AOAM530D9hSDsTbFhOFQ6n3OmOoOf1TO5Pc742JSBOc1EQ1ERIyM+5rI PsTEaffc+TPkMtg7ZxXOkss= X-Google-Smtp-Source: ABdhPJz9SuBXgihhtCBKqzwQSz+uocSqzMEBrT3ksigclxhUAX3fZgY+2I3/rO0dTsOO9uFovRNhFQ== X-Received: by 2002:a17:903:1250:b0:149:907d:afdc with SMTP id u16-20020a170903125000b00149907dafdcmr11769772plh.59.1642963273387; Sun, 23 Jan 2022 10:41:13 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id p18sm14538141pfh.98.2022.01.23.10.41.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:41:13 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org Subject: [PATCH 27/54] lib/bitmap: add bitmap_weight_{cmp, eq, gt, ge, lt, le} functions Date: Sun, 23 Jan 2022 10:38:58 -0800 Message-Id: <20220123183925.1052919-28-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Many kernel users use bitmap_weight() to compare the result against some number or expression: if (bitmap_weight(...) > 1) do_something(); It works OK, but may be significantly improved for large bitmaps: if first few words count set bits to a number greater than given, we can stop counting and immediately return. The same idea would work in other direction: if we know that the number of set bits that we counted so far is small enough, so that it would be smaller than required number even if all bits of the rest of the bitmap are set, we can stop counting earlier. This patch adds new bitmap_weight_cmp() as suggested by Micha=C5=82 Miros= =C5=82aw and a family of eq, gt, ge, lt and le wrappers to allow this optimization. The following patches apply new functions where appropriate. Suggested-by: "Micha=C5=82 Miros=C5=82aw" (for bi= tmap_weight_cmp) Signed-off-by: Yury Norov --- include/linux/bitmap.h | 80 ++++++++++++++++++++++++++++++++++++++++++ lib/bitmap.c | 21 +++++++++++ 2 files changed, 101 insertions(+) diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h index 7dba0847510c..708e57b32362 100644 --- a/include/linux/bitmap.h +++ b/include/linux/bitmap.h @@ -51,6 +51,12 @@ struct device; * bitmap_empty(src, nbits) Are all bits zero in *src? * bitmap_full(src, nbits) Are all bits set in *src? * bitmap_weight(src, nbits) Hamming Weight: number set= bits + * bitmap_weight_cmp(src, nbits) compare Hamming Weight wit= h a number + * bitmap_weight_eq(src, nbits, num) Hamming Weight =3D=3D num + * bitmap_weight_gt(src, nbits, num) Hamming Weight > num + * bitmap_weight_ge(src, nbits, num) Hamming Weight >=3D num + * bitmap_weight_lt(src, nbits, num) Hamming Weight < num + * bitmap_weight_le(src, nbits, num) Hamming Weight <=3D num * bitmap_set(dst, pos, nbits) Set specified bit area * bitmap_clear(dst, pos, nbits) Clear specified bit area * bitmap_find_next_zero_area(buf, len, pos, n, mask) Find bit free area @@ -162,6 +168,7 @@ int __bitmap_intersects(const unsigned long *bitmap1, int __bitmap_subset(const unsigned long *bitmap1, const unsigned long *bitmap2, unsigned int nbits); int __bitmap_weight(const unsigned long *bitmap, unsigned int nbits); +int __bitmap_weight_cmp(const unsigned long *bitmap, unsigned int bits, in= t num); void __bitmap_set(unsigned long *map, unsigned int start, int len); void __bitmap_clear(unsigned long *map, unsigned int start, int len); =20 @@ -403,6 +410,79 @@ static __always_inline int bitmap_weight(const unsigne= d long *src, unsigned int return __bitmap_weight(src, nbits); } =20 +/** + * bitmap_weight_cmp - compares number of set bits in @src with @num. + * @src: source bitmap + * @nbits: length of bitmap in bits + * @num: number to compare with + * + * As opposite to bitmap_weight() this function doesn't necessarily + * traverse full bitmap and may return earlier. + * + * Returns zero if weight of @src is equal to @num; + * negative number if weight of @src is less than @num; + * positive number if weight of @src is greater than @num; + * + * NOTES + * + * Because number of set bits cannot decrease while counting, when user + * wants to know if the number of set bits in the bitmap is less than + * @num, calling + * bitmap_weight_cmp(..., @num) < 0 + * is potentially less effective than + * bitmap_weight_cmp(..., @num - 1) <=3D 0 + * + * Consider an example: + * bitmap_weight_cmp(1000 0000 0000 0000, 1) < 0 + * ^ + * stop here + * + * bitmap_weight_cmp(1000 0000 0000 0000, 0) <=3D 0 + * ^ + * stop here + */ +static __always_inline +int bitmap_weight_cmp(const unsigned long *src, unsigned int nbits, int nu= m) +{ + if (num > (int)nbits || num < 0) + return -num; + + if (small_const_nbits(nbits)) + return hweight_long(*src & BITMAP_LAST_WORD_MASK(nbits)) - num; + + return __bitmap_weight_cmp(src, nbits, num); +} + +static __always_inline +bool bitmap_weight_eq(const unsigned long *src, unsigned int nbits, int nu= m) +{ + return bitmap_weight_cmp(src, nbits, num) =3D=3D 0; +} + +static __always_inline +bool bitmap_weight_gt(const unsigned long *src, unsigned int nbits, int nu= m) +{ + return bitmap_weight_cmp(src, nbits, num) > 0; +} + +static __always_inline +bool bitmap_weight_ge(const unsigned long *src, unsigned int nbits, int nu= m) +{ + return bitmap_weight_cmp(src, nbits, num - 1) > 0; +} + +static __always_inline +bool bitmap_weight_lt(const unsigned long *src, unsigned int nbits, int nu= m) +{ + return bitmap_weight_cmp(src, nbits, num - 1) <=3D 0; +} + +static __always_inline +bool bitmap_weight_le(const unsigned long *src, unsigned int nbits, int nu= m) +{ + return bitmap_weight_cmp(src, nbits, num) <=3D 0; +} + static __always_inline void bitmap_set(unsigned long *map, unsigned int st= art, unsigned int nbits) { diff --git a/lib/bitmap.c b/lib/bitmap.c index 926408883456..fb84ca70c5d9 100644 --- a/lib/bitmap.c +++ b/lib/bitmap.c @@ -348,6 +348,27 @@ int __bitmap_weight(const unsigned long *bitmap, unsig= ned int bits) } EXPORT_SYMBOL(__bitmap_weight); =20 +int __bitmap_weight_cmp(const unsigned long *bitmap, unsigned int bits, in= t num) +{ + unsigned int k, w, lim =3D bits / BITS_PER_LONG; + + for (k =3D 0, w =3D 0; k < lim; k++) { + if (w + bits - k * BITS_PER_LONG < num) + goto out; + + w +=3D hweight_long(bitmap[k]); + + if (w > num) + goto out; + } + + if (bits % BITS_PER_LONG) + w +=3D hweight_long(bitmap[k] & BITMAP_LAST_WORD_MASK(bits)); +out: + return w - num; +} +EXPORT_SYMBOL(__bitmap_weight_cmp); + void __bitmap_set(unsigned long *map, unsigned int start, int len) { unsigned long *p =3D map + BIT_WORD(start); --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3E47C433F5 for ; Sun, 23 Jan 2022 18:42:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240120AbiAWSmC (ORCPT ); Sun, 23 Jan 2022 13:42:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239935AbiAWSlR (ORCPT ); Sun, 23 Jan 2022 13:41:17 -0500 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7966C061755 for ; Sun, 23 Jan 2022 10:41:16 -0800 (PST) Received: by mail-pf1-x42d.google.com with SMTP id i65so13769829pfc.9 for ; Sun, 23 Jan 2022 10:41:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=HHGGgmQVmFZBmg7DQxGJPvdjEjZRhNrQASscNGanVdc=; b=EH/6cSa9YHoSM91y5ppgiQJWPTpXdG2h1ASsA1/BQXv7gF9h/mYO8png7AQzQ0PAHf j4VJRE+ZUXzbDygTfHwyInQ8nSymy4SRByDkAF5PbljjJssj/ISvNZYH57UV09qGoPuw LZVsthHIjt3JVJ4eYc5AcRvOlwzJgZ/JCdXft3FvsB0+UX3xKG761HQk0DVzrwArnBsZ CVChd9PanY0ZkBcfFw2y26HoT7nigXGb3ncN2czDrLbJOwgV/eFW7y26qkcOB48q3EWg IAPNxN9I+AUoD038aGCuWKHyG9dl08IJUEoVfXbWuGJ1h2E+cb5cs91xPZVVz2Qq4IBu /Dog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HHGGgmQVmFZBmg7DQxGJPvdjEjZRhNrQASscNGanVdc=; b=Hu42dJwLJu1nN/t/ZKZkXJYkqI8AvG6k0gwGO8G+kJ106z8eGyMN3q1PWsG9GozugT kLx/WhJ0PB76SQFV5mxCCMs6y9VNQFjwzjflxXRShc9r1lXJvDJ9dOA4J3JlgduKb0pw F+6OBEMbMyq6LwGmnPeTyQbBlfXMquIhvTSVCjxnftQkVpnDYcoMZ7gUdU1Yem+AagR7 U9qSXtsHN9zaqK2q+wuoZPxzaxoRf/rPqvEMCkzY7XTvrfXn3jllN5ni7/uxg6BFhB8s TIbWTTkxXuhcCifkpe86pSP3kx4wg6AtRaacSP+aBAc6fFd1Qsat4LO31GHDEmTSRo6w HcYg== X-Gm-Message-State: AOAM531SI4pjG0YtSadLNCMS25iihL+WWHTHFclVso22x8u9s/Ce/VAa 173so8/vBJtm05oy/hVRHxk= X-Google-Smtp-Source: ABdhPJyY/FkXD5OW6boCRJO4lG8VZ8gHvKX7Ug3rqmHXPLFay/JetkbpKroBAMlbdm088ksQ2leZGA== X-Received: by 2002:a63:a00a:: with SMTP id r10mr9334290pge.553.1642963276432; Sun, 23 Jan 2022 10:41:16 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id nv13sm4817821pjb.18.2022.01.23.10.41.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:41:16 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Fenghua Yu , Reinette Chatre , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , x86@kernel.org Subject: [PATCH 28/54] arch/x86: replace bitmap_weight with bitmap_weight_{eq,gt,ge,lt,le} where appropriate Date: Sun, 23 Jan 2022 10:38:59 -0800 Message-Id: <20220123183925.1052919-29-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" __init_one_rdt_domain in rdtgroup.c code calls bitmap_weight() to compare the weight of bitmap with a given number. We can do it more efficiently with bitmap_weight_lt because conditional bitmap_weight() may stop traversing the bitmap earlier, as soon as condition is met. Signed-off-by: Yury Norov --- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index e23ff03290b8..9d42e592c1cf 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -2752,7 +2752,7 @@ static int __init_one_rdt_domain(struct rdt_domain *d= , struct resctrl_schema *s, * bitmap_weight() does not access out-of-bound memory. */ tmp_cbm =3D cfg->new_ctrl; - if (bitmap_weight(&tmp_cbm, r->cache.cbm_len) < r->cache.min_cbm_bits) { + if (bitmap_weight_lt(&tmp_cbm, r->cache.cbm_len, r->cache.min_cbm_bits)) { rdt_last_cmd_printf("No space on %s:%d\n", s->name, d->id); return -ENOSPC; } --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C86C1C433FE for ; Sun, 23 Jan 2022 18:42:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239713AbiAWSmL (ORCPT ); Sun, 23 Jan 2022 13:42:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234675AbiAWSlX (ORCPT ); Sun, 23 Jan 2022 13:41:23 -0500 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBD83C061779; Sun, 23 Jan 2022 10:41:19 -0800 (PST) Received: by mail-pj1-x102f.google.com with SMTP id s61-20020a17090a69c300b001b4d0427ea2so18255143pjj.4; Sun, 23 Jan 2022 10:41:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=O51JzqdRjTovyIC/ZyJHG8/DGtHil0Z7ck+jIlH6LkU=; b=fovWQNvb9HXl8jjaVsgHvHD91mAc6xXgJWZPlPm+IeVNkXKL7OujCls6E2KxGZPzWQ gMsjVWabAvOW7f2zUVm9nUmszPVm/LvNkenop4bl2wfbaHf92C4EhKaz8UJALNOa2CSQ 2QeC7jmZf712NfO55cbwanvP9qsc5s1UqgI31E6/XJO9s71Hom9rlzmGjTnZw7loP1BS JwcBfchxhi1vztDBwThbFwphp/l4Y6a7XbkVLFh1iNYq3Euk/Gwrtjs6P+FcPk5XTLIA wZFGa4mwlZEd6x7LY382e1B4eEWLbifGhQ4BklMMgjDQg/F5t/xaO1CreRGvIFwd34Tj JuvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=O51JzqdRjTovyIC/ZyJHG8/DGtHil0Z7ck+jIlH6LkU=; b=k23vRDOW4cW36P2H47L+4+qJ4s9wW09wr9vFi7bBnzQxp2MSf96+/pK17Qtk5RXEjb XHGlSZ6Gj76wNGgSnZzj+d2hoBwOgGzcprSB4CQuQwWPG0X7ErvTVJ6QCtQIfyl+sgo7 8EgKus13qqkeEYL6gwPoeXJpsg6gG0uS/LpwapwT9bTBtxCdDd7V2Bsvl+KSfkrPot0f rYJzmcYbOOx+cpeIRfpkiLZ95pVoY7V+g5TuGGp1F1/S+9PKJ0uZRgKTbvYkM0CP1G/s 3FDnQVK05TycR1SaB8tq1+UOe1okBuo9ZaimrLFrmMIhjp9Rsni6a/QVpOiJbKj45Mxv nUAw== X-Gm-Message-State: AOAM533nnMK+3G1UFrrtZGBroVg+oSvS2oOsrzsqhmkkpCsEtkfDbMVj 0FxlaF/6AHg8VLiUmzU3lR8= X-Google-Smtp-Source: ABdhPJx/Of5AQmP5l2CQIGIsuYMrAUDSiAD5BOfqc34X7jNjuGlU1nMl8OEpFrItLTK8Od/kqfWHJQ== X-Received: by 2002:a17:90b:3b48:: with SMTP id ot8mr9777673pjb.95.1642963279324; Sun, 23 Jan 2022 10:41:19 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id f9sm9846505pgf.94.2022.01.23.10.41.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:41:19 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Jonathan Cameron , Lars-Peter Clausen , Nathan Chancellor , Alexandru Ardelean , linux-iio@vger.kernel.org Subject: [PATCH 29/54] drivers/iio: replace bitmap_weight() with bitmap_weight_{eq,gt} where appropriate Date: Sun, 23 Jan 2022 10:39:00 -0800 Message-Id: <20220123183925.1052919-30-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" drivers/iio calls bitmap_weight() to compare the weight of bitmap with a given number. We can do it more efficiently with bitmap_weight_{eq, gt} because conditional bitmap_weight may stop traversing the bitmap earlier, as soon as condition is met. Signed-off-by: Yury Norov --- drivers/iio/dummy/iio_simple_dummy_buffer.c | 4 ++-- drivers/iio/industrialio-trigger.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iio/dummy/iio_simple_dummy_buffer.c b/drivers/iio/dumm= y/iio_simple_dummy_buffer.c index d81c2b2dad82..670997301e47 100644 --- a/drivers/iio/dummy/iio_simple_dummy_buffer.c +++ b/drivers/iio/dummy/iio_simple_dummy_buffer.c @@ -71,8 +71,8 @@ static irqreturn_t iio_simple_dummy_trigger_h(int irq, vo= id *p) int i, j; =20 for (i =3D 0, j =3D 0; - i < bitmap_weight(indio_dev->active_scan_mask, - indio_dev->masklength); + bitmap_weight_gt(indio_dev->active_scan_mask, + indio_dev->masklength, i); i++, j++) { j =3D find_next_bit(indio_dev->active_scan_mask, indio_dev->masklength, j); diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-= trigger.c index f504ed351b3e..98c54022fecf 100644 --- a/drivers/iio/industrialio-trigger.c +++ b/drivers/iio/industrialio-trigger.c @@ -331,7 +331,7 @@ int iio_trigger_detach_poll_func(struct iio_trigger *tr= ig, { struct iio_dev_opaque *iio_dev_opaque =3D to_iio_dev_opaque(pf->indio_dev= ); bool no_other_users =3D - bitmap_weight(trig->pool, CONFIG_IIO_CONSUMERS_PER_TRIGGER) =3D=3D 1; + bitmap_weight_eq(trig->pool, CONFIG_IIO_CONSUMERS_PER_TRIGGER, 1); int ret =3D 0; =20 if (trig->ops && trig->ops->set_trigger_state && no_other_users) { --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51F07C433F5 for ; Sun, 23 Jan 2022 18:42:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239992AbiAWSmS (ORCPT ); Sun, 23 Jan 2022 13:42:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239984AbiAWSlX (ORCPT ); Sun, 23 Jan 2022 13:41:23 -0500 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA93CC06177E; Sun, 23 Jan 2022 10:41:22 -0800 (PST) Received: by mail-pg1-x52f.google.com with SMTP id h23so13123433pgk.11; Sun, 23 Jan 2022 10:41:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=6Ui4qYj030cyXXLNoJCYbzVgN3GtE9ORNZ/WmrY4RZ0=; b=bvjD/rU6iqsebFa6UrcK3iewqd10jG4LVBWUGqLPKS6DQHmKsM0GlWrRcDkwm32wez K2Tav2t5udTw/hhvd4t8Ul9uRQspEUYlHM2i05GSTepFyaem1ef2UrxlUOykmr/yIVwQ /LBLWZgnweBxdfSFAOGfeJDVTH8CBqw5Z6Tjd4R8ePwhjhCFathcOrwavkUjnB6NU7re rNo7Wqa3tUpSJLsAu4J/S0oXA9AhDk6aKHUwEoolQiPPOZJnjRuSzrwbX89WRuubEGpG JV3SpEZBVcZaT1MRC3c+z3VssVlfm7kpONiwsTOcm5S+lWEWrx6Ow2eBzVXGhCJbZ0Kz 8Mtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6Ui4qYj030cyXXLNoJCYbzVgN3GtE9ORNZ/WmrY4RZ0=; b=gTmwqm+gEreKHs475whqEdd50qE1hR3TMs5xD1b8Qljvdnes5nZ2RBmXeI6wXnLG4h 9BDvkxMZZkQ/TNPXCsrI8q5l2emy+b5Z39IKRHuf0INfKo7lAuuVLbKGNAlcNW1iNlXa 6Z0jFklUqwAtfE87SwaGemWrH9cGymdVbKGdfQIQSPIK5LFdYZkHDlDBpbZXvFfd71Yy CctB6e+Vs9Cg0rCyWvANKt73CuiNHV7HZtyKl0ykgo3GuDd5YhDMIfCnDB/5qv5k76ai Pjgh0LFvPCKwelGA0cNl81GVvCvr8PY9QggEcAgGZqUXn0KE26QEnyWA9T6vo34EzzHX IATg== X-Gm-Message-State: AOAM532RjT3/yEf65t1DOGCNth+EBP/hVHcuVpRa1MCCBS7Cyrzx7s5A ORdYcZLmvxPygjNwgjocwlE= X-Google-Smtp-Source: ABdhPJyHxkBqoZNM3/a8yoh+/kvzF/9ryJCIZITMK5v7+MiHPMppX6GN7won1auHHokIPW78B5j2mA== X-Received: by 2002:a63:1f07:: with SMTP id f7mr9444383pgf.219.1642963282332; Sun, 23 Jan 2022 10:41:22 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id y42sm5576483pfw.157.2022.01.23.10.41.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:41:22 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Maxim Levitsky , Alex Dubov , Ulf Hansson , Jens Axboe , Luis Chamberlain , Colin Ian King , Arnd Bergmann , Shubhankar Kuranagatti , linux-mmc@vger.kernel.org Subject: [PATCH 30/54] drivers/memstick: replace bitmap_weight with bitmap_weight_eq where appropriate Date: Sun, 23 Jan 2022 10:39:01 -0800 Message-Id: <20220123183925.1052919-31-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" msb_validate_used_block_bitmap() calls bitmap_weight() to compare the weight of bitmap with a given number. We can do it more efficiently with bitmap_weight_eq because conditional bitmap_weight may stop traversing the bitmap earlier, as soon as condition is met. Signed-off-by: Yury Norov --- drivers/memstick/core/ms_block.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/memstick/core/ms_block.c b/drivers/memstick/core/ms_bl= ock.c index 0cda6c6baefc..5cdd987e78f7 100644 --- a/drivers/memstick/core/ms_block.c +++ b/drivers/memstick/core/ms_block.c @@ -155,8 +155,8 @@ static int msb_validate_used_block_bitmap(struct msb_da= ta *msb) for (i =3D 0; i < msb->zone_count; i++) total_free_blocks +=3D msb->free_block_count[i]; =20 - if (msb->block_count - bitmap_weight(msb->used_blocks_bitmap, - msb->block_count) =3D=3D total_free_blocks) + if (bitmap_weight_eq(msb->used_blocks_bitmap, msb->block_count, + msb->block_count - total_free_blocks)) return 0; =20 pr_err("BUG: free block counts don't match the bitmap"); --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0B58C433EF for ; Sun, 23 Jan 2022 18:42:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240148AbiAWSmX (ORCPT ); Sun, 23 Jan 2022 13:42:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239623AbiAWSl0 (ORCPT ); Sun, 23 Jan 2022 13:41:26 -0500 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A17F2C06173D; Sun, 23 Jan 2022 10:41:25 -0800 (PST) Received: by mail-pl1-x634.google.com with SMTP id x11so7707399plg.6; Sun, 23 Jan 2022 10:41:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=0F414qr4KcwROxp4P4//QuZXhV1PvM+EIvGUM77ZnYw=; b=qPUDOzVrFgRR0ZojdlGaeaiqiXmK1Fu7gnq6Kpjzn0e7w+PMTD2rzLEY8hZ14TTY23 4uLU94junvHCzOpoqV1nqyFTW7bW5WJ8MgQ3l0T7cIVcpjhLRMaQMwidSTAEeMc7wt5B mVdwcYCTxWItcClOk4Zb1ar8U1kfFa/IA6Lr/AXWP3N7L2IA2kJFPnunibOS9tsFcpmc MChfOb+HBpNfCcx0obaVEgTnIWGgoow/wT1sQcndztEU/Zs4BKOT2XPqAkVgErnwmNNG 5eSnp6wZHkDMC25WBNoSmDV9Yy0bcHKDPTZE5N2I/Wy5EjHfW+m/LVbYton0nC1MmJP6 rWwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0F414qr4KcwROxp4P4//QuZXhV1PvM+EIvGUM77ZnYw=; b=UcfbjXFrYEC5VJzBPi2LJeH7qTGq+16AIndxwXz/OkUtXdeBYD6h38tj0Dh3C1TjJi FbkpkfTVrRf4JFUyYG/IbbHTaQHV4UJ93K1Te0gY1MH6M6e1valCZCRZ+fVXwAGCzj/s EG3YTi+ZIxHk0QVOONVho0Cn8Xcfn6a7C7ZsPzB0Wltnp6Msh3XKbadPAX2Z8VHY2Avm q/990nUgjGAbsjjgzWoAY4HyhvVrr1BfqmvS91EEmEXo0B5Uzh8ePkYGvdH6MbgKmni4 uYgUIMgzGuVNWk1PtdUIveqvkNcpnS4uWgpMVMaRSwOtfXkuuVtSw8OjFf8+Yw0Xh1ex Q/kA== X-Gm-Message-State: AOAM531rRSaWpF1ln5BK5pEZL3HzA0AEzM5G40Bu5SgvAN5V9YpNxyHQ SSsxygJ8FUXfcX6+HxWxx9A= X-Google-Smtp-Source: ABdhPJxKtLbZ+fS2qLQ72Hx4NHY5QVMT/SLF2EGamemsOG+fTKuUk8ZzUBc47pVyDM8deb3IguBF+w== X-Received: by 2002:a17:90b:1b0d:: with SMTP id nu13mr7887564pjb.24.1642963285131; Sun, 23 Jan 2022 10:41:25 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id s13sm13234564pfu.0.2022.01.23.10.41.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:41:24 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Jesse Brandeburg , Tony Nguyen , "David S. Miller" , Jakub Kicinski , intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org Subject: [PATCH 31/54] net: ethernet: replace bitmap_weight with bitmap_weight_eq for intel Date: Sun, 23 Jan 2022 10:39:02 -0800 Message-Id: <20220123183925.1052919-32-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" ixgbe_disable_sriov calls bitmap_weight() to compare the weight of bitmap with a given number. We can do it more efficiently with bitmap_weight_eq because conditional bitmap_weight may stop traversing the bitmap earlier, as soon as condition is met. Signed-off-by: Yury Norov --- drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c b/drivers/net/e= thernet/intel/ixgbe/ixgbe_sriov.c index 214a38de3f41..35297d8a488b 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c @@ -246,7 +246,7 @@ int ixgbe_disable_sriov(struct ixgbe_adapter *adapter) #endif =20 /* Disable VMDq flag so device will be set in VM mode */ - if (bitmap_weight(adapter->fwd_bitmask, adapter->num_rx_pools) =3D=3D 1) { + if (bitmap_weight_eq(adapter->fwd_bitmask, adapter->num_rx_pools, 1)) { adapter->flags &=3D ~IXGBE_FLAG_VMDQ_ENABLED; adapter->flags &=3D ~IXGBE_FLAG_SRIOV_ENABLED; rss =3D min_t(int, ixgbe_max_rss_indices(adapter), --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B38D7C433EF for ; Sun, 23 Jan 2022 18:42:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240169AbiAWSmZ (ORCPT ); Sun, 23 Jan 2022 13:42:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240000AbiAWSl3 (ORCPT ); Sun, 23 Jan 2022 13:41:29 -0500 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD4D5C06175E; Sun, 23 Jan 2022 10:41:28 -0800 (PST) Received: by mail-pf1-x436.google.com with SMTP id i65so13770076pfc.9; Sun, 23 Jan 2022 10:41:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Tg3yHCkGPkAs3t0HGnkJ3DADYUey/EkpuaonLgL/k1o=; b=ZFcRyIgejcwmVsRn9uACTkHbRFP1Zze98Yat48GCTiBhpRFGqV+EhNdjoptDiSuBV/ dvj3ZuDs5x5zOqKJGz4dgUg/bpE7jIhKYWqsuGU8JohMUazDatArKO78k8OfS62hFbG7 br07lUuskKVknb0qnOkcuQVxKJYz1MBJd4cJVIM0s3WCFCfUeyiLOatWKIvsI6pfk5/T D2em8N9PllFscT+6kUGr5skgotgtYRkpFEWyJmcfc3e77qXEOa+gQQ7yVKK5Cl1RW8+x H0YkTgJ/FjQ9h7YkPpnNjVdec9Fku25OI8swrUzmnquB2L1IOslvsbuGo+AIYfCvzb6w SI3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Tg3yHCkGPkAs3t0HGnkJ3DADYUey/EkpuaonLgL/k1o=; b=eEk1sT4NPRyUc2MQjEJSq/uhR5hiEJya0+X/UWYDQTIJxgLvtWzVNjqH4X5VAy/1NW OA8X+KjCgnVYdzuUPe4NL9lMqV1yaX6Yhvh7TZMORLvtZSrEVPC25BIx936KdS5mUpKr 9jrhx51MeQQGn6r0KHknU+AZ2oDo2HObqS+7OjhCdl76es6cYGncFBl4oDuMLXng4DfP tP721J5jZiTE6/4eiQu0CB9ABf7ulu85XKQ8fFrmP+ITCMrx0l5a4ltGca+XJ/PuZMSo /lh2nCiQlvUUicbYgcavSD2HakUczRABl4D139pctLfwqpBz/ETwGRfiVgpQ9cj2fpZk IugA== X-Gm-Message-State: AOAM530h5gytmOc5mV4wd668shTbAemMjjoC3PvKASXSuhN96XKV36z4 p+bXl9PQt/c3IezO0y8ylKI= X-Google-Smtp-Source: ABdhPJwoTvblvEg2tP4VBIJgYaJdRCS2zp7p/0njGw/SToaljAppp3HKkW/FWj7H2WQKfitLPsuBKQ== X-Received: by 2002:a05:6a00:1795:b0:4c1:e2f6:d0c8 with SMTP id s21-20020a056a00179500b004c1e2f6d0c8mr10981596pfg.47.1642963288396; Sun, 23 Jan 2022 10:41:28 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id mg17sm11154423pjb.19.2022.01.23.10.41.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:41:28 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Sunil Goutham , Geetha sowjanya , Subbaraya Sundeep , hariprasad , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org Subject: [PATCH 32/54] net: ethernet: replace bitmap_weight with bitmap_weight_{eq,gt} for OcteonTX2 Date: Sun, 23 Jan 2022 10:39:03 -0800 Message-Id: <20220123183925.1052919-33-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" OcteonTX2 code calls bitmap_weight() to compare the weight of bitmap with a given number. We can do it more efficiently with bitmap_weight_{eq,gt} because conditional bitmap_weight may stop traversing the bitmap earlier, as soon as condition is met. Signed-off-by: Yury Norov --- drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c | 2 +- drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c b/dr= ivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c index d85db90632d6..a55fd1d0c653 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c @@ -287,7 +287,7 @@ static int otx2_set_channels(struct net_device *dev, if (!channel->rx_count || !channel->tx_count) return -EINVAL; =20 - if (bitmap_weight(&pfvf->rq_bmap, pfvf->hw.rx_queues) > 1) { + if (bitmap_weight_gt(&pfvf->rq_bmap, pfvf->hw.rx_queues, 1)) { netdev_err(dev, "Receive queues are in use by TC police action\n"); return -EINVAL; diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c b/driv= ers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c index 80b2d64b4136..55c899a6fcdd 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c @@ -1170,8 +1170,8 @@ int otx2_remove_flow(struct otx2_nic *pfvf, u32 locat= ion) * interface mac address and configure CGX/RPM block in * promiscuous mode */ - if (bitmap_weight(&flow_cfg->dmacflt_bmap, - flow_cfg->dmacflt_max_flows) =3D=3D 1) + if (bitmap_weight_eq(&flow_cfg->dmacflt_bmap, + flow_cfg->dmacflt_max_flows, 1)) otx2_update_rem_pfmac(pfvf, DMAC_ADDR_DEL); } else { err =3D otx2_remove_flow_msg(pfvf, flow->entry, false); --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8AF6DC433F5 for ; Sun, 23 Jan 2022 18:42:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234843AbiAWSmd (ORCPT ); Sun, 23 Jan 2022 13:42:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240022AbiAWSld (ORCPT ); Sun, 23 Jan 2022 13:41:33 -0500 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D636C06176F; Sun, 23 Jan 2022 10:41:32 -0800 (PST) Received: by mail-pl1-x634.google.com with SMTP id d1so13471773plh.10; Sun, 23 Jan 2022 10:41:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=C5MxD9/CL9NsuqJ/4TQY8GLvDJf1hYVoh5cAUlzqQTg=; b=T16FcQMzIxc211JT8TxZ/iueFxAKmECInlg3Y+mQrSHrf7jHbkKVJ3VC30/X8nmvhk m7C5wa+DA3mOvsxQnVyk/nzrmQ3zY3xxWoSRqAi7R9GvfSXNHyGRXg7bJrx5g3+VTx6p ywIh7sngyIjjK4wfy9uxfdQ8mYadaqT+M7hJfZv8UUK+RJ2IZt64YtQ4+mdmPCi/PTjx qrGczB53zqAMOaTeMj5pglxTBuE1/s52Gqr5cQ+KGlbt3ZdWTJTE+ROhEEnJrvvJRr1l 9n1lftGq5Hdt5dZsWyrP/qeoV7yKCwiB74yKaPlJsIUKx8M/vqJF04dwzpeGxm8JLwes thiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=C5MxD9/CL9NsuqJ/4TQY8GLvDJf1hYVoh5cAUlzqQTg=; b=2fsUQQ3ZAwqtyPNsdKqR6WzHF1C6Ewv3TsTtWFbEXscu14lYcquim5JACNUsSoZzLF xlwMsajoN2+SzMha3R7Roerbcnrpbw+NnAwCSS/ndz0xx+L8E8SxcJWlihAbW6u5Esof W2fYghXI5LtK/BlboMGsEfFsJBpsvXWKftVNZ9FUz6eKI+sX0beOoJ91GkbjDQxSRLV1 PTbEdcPoV+fedNjBRbE/LDY8tlCVPKQvUcOV/PkWDfbIP+pxuFuemq/tq0biH4XUyqXW Z1rg3q5VxBOvFJfHB82+p6uNtC/gb3zoAyio8UFdspiGLtzqxATRRcjplfZG0MPFNBia 94sw== X-Gm-Message-State: AOAM533s1r9n/WuaHa7m1VN0vk159tHsDZkhu6V6Z+bQfw24b4lSI4EY nWnSHG1ajoUfHmLq0dDnbzg= X-Google-Smtp-Source: ABdhPJw2IERdv9EjDfTFfQgHtN7IRDQvs7Jvm28asGSoFXUNkoy5rYrqcLKI+IMbX0TTAZ1cRWBWxQ== X-Received: by 2002:a17:90a:8b82:: with SMTP id z2mr9751869pjn.146.1642963291689; Sun, 23 Jan 2022 10:41:31 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id e2sm9947439pgl.91.2022.01.23.10.41.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:41:31 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Sunil Goutham , Geetha sowjanya , Subbaraya Sundeep , hariprasad , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org Subject: [PATCH 33/54] net: ethernet: replace bitmap_weight with bitmap_weight_{eq,gt,ge,lt,le} for mellanox Date: Sun, 23 Jan 2022 10:39:04 -0800 Message-Id: <20220123183925.1052919-34-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Mellanox code uses bitmap_weight() to compare the weight of bitmap with a given number. We can do it more efficiently with bitmap_weight_{eq, ...} because conditional bitmap_weight may stop traversing the bitmap earlier, as soon as condition is met. Signed-off-by: Yury Norov --- drivers/net/ethernet/mellanox/mlx4/cmd.c | 10 +++------- drivers/net/ethernet/mellanox/mlx4/eq.c | 4 ++-- drivers/net/ethernet/mellanox/mlx4/fw.c | 4 ++-- drivers/net/ethernet/mellanox/mlx4/main.c | 2 +- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/cmd.c b/drivers/net/etherne= t/mellanox/mlx4/cmd.c index c56d2194cbfc..5bca0c68f00a 100644 --- a/drivers/net/ethernet/mellanox/mlx4/cmd.c +++ b/drivers/net/ethernet/mellanox/mlx4/cmd.c @@ -2792,9 +2792,8 @@ int mlx4_slave_convert_port(struct mlx4_dev *dev, int= slave, int port) { unsigned n; struct mlx4_active_ports actv_ports =3D mlx4_get_active_ports(dev, slave); - unsigned m =3D bitmap_weight(actv_ports.ports, dev->caps.num_ports); =20 - if (port <=3D 0 || port > m) + if (port <=3D 0 || bitmap_weight_lt(actv_ports.ports, dev->caps.num_ports= , port)) return -EINVAL; =20 n =3D find_first_bit(actv_ports.ports, dev->caps.num_ports); @@ -3404,10 +3403,6 @@ int mlx4_vf_set_enable_smi_admin(struct mlx4_dev *de= v, int slave, int port, struct mlx4_priv *priv =3D mlx4_priv(dev); struct mlx4_active_ports actv_ports =3D mlx4_get_active_ports( &priv->dev, slave); - int min_port =3D find_first_bit(actv_ports.ports, - priv->dev.caps.num_ports) + 1; - int max_port =3D min_port - 1 + - bitmap_weight(actv_ports.ports, priv->dev.caps.num_ports); =20 if (slave =3D=3D mlx4_master_func_num(dev)) return 0; @@ -3417,7 +3412,8 @@ int mlx4_vf_set_enable_smi_admin(struct mlx4_dev *dev= , int slave, int port, enabled < 0 || enabled > 1) return -EINVAL; =20 - if (min_port =3D=3D max_port && dev->caps.num_ports > 1) { + if (dev->caps.num_ports > 1 && + bitmap_weight_eq(actv_ports.ports, priv->dev.caps.num_ports, 1)) { mlx4_info(dev, "SMI access disallowed for single ported VFs\n"); return -EPROTONOSUPPORT; } diff --git a/drivers/net/ethernet/mellanox/mlx4/eq.c b/drivers/net/ethernet= /mellanox/mlx4/eq.c index 414e390e6b48..0c09432ff389 100644 --- a/drivers/net/ethernet/mellanox/mlx4/eq.c +++ b/drivers/net/ethernet/mellanox/mlx4/eq.c @@ -1435,8 +1435,8 @@ int mlx4_is_eq_shared(struct mlx4_dev *dev, int vecto= r) if (vector <=3D 0 || (vector >=3D dev->caps.num_comp_vectors + 1)) return -EINVAL; =20 - return !!(bitmap_weight(priv->eq_table.eq[vector].actv_ports.ports, - dev->caps.num_ports) > 1); + return bitmap_weight_gt(priv->eq_table.eq[vector].actv_ports.ports, + dev->caps.num_ports, 1); } EXPORT_SYMBOL(mlx4_is_eq_shared); =20 diff --git a/drivers/net/ethernet/mellanox/mlx4/fw.c b/drivers/net/ethernet= /mellanox/mlx4/fw.c index 42c96c9d7fb1..855aae326ccb 100644 --- a/drivers/net/ethernet/mellanox/mlx4/fw.c +++ b/drivers/net/ethernet/mellanox/mlx4/fw.c @@ -1300,8 +1300,8 @@ int mlx4_QUERY_DEV_CAP_wrapper(struct mlx4_dev *dev, = int slave, actv_ports =3D mlx4_get_active_ports(dev, slave); first_port =3D find_first_bit(actv_ports.ports, dev->caps.num_ports); for (slave_port =3D 0, real_port =3D first_port; - real_port < first_port + - bitmap_weight(actv_ports.ports, dev->caps.num_ports); + bitmap_weight_gt(actv_ports.ports, dev->caps.num_ports, + real_port - first_port); ++real_port, ++slave_port) { if (flags & (MLX4_DEV_CAP_FLAG_WOL_PORT1 << real_port)) flags |=3D MLX4_DEV_CAP_FLAG_WOL_PORT1 << slave_port; diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethern= et/mellanox/mlx4/main.c index b187c210d4d6..cfbaa7ac712f 100644 --- a/drivers/net/ethernet/mellanox/mlx4/main.c +++ b/drivers/net/ethernet/mellanox/mlx4/main.c @@ -1383,7 +1383,7 @@ static int mlx4_mf_bond(struct mlx4_dev *dev) dev->persist->num_vfs + 1); =20 /* only single port vfs are allowed */ - if (bitmap_weight(slaves_port_1_2, dev->persist->num_vfs + 1) > 1) { + if (bitmap_weight_gt(slaves_port_1_2, dev->persist->num_vfs + 1, 1)) { mlx4_warn(dev, "HA mode unsupported for dual ported VFs\n"); return -EINVAL; } --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0CD38C433FE for ; Sun, 23 Jan 2022 18:42:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240027AbiAWSm3 (ORCPT ); Sun, 23 Jan 2022 13:42:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239866AbiAWSlf (ORCPT ); Sun, 23 Jan 2022 13:41:35 -0500 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0EDAEC061771 for ; Sun, 23 Jan 2022 10:41:35 -0800 (PST) Received: by mail-pf1-x42f.google.com with SMTP id e28so9333233pfj.5 for ; Sun, 23 Jan 2022 10:41:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=T5W4tcAlu9II6TGKyllSre1cwbBZX0+vG2XX1glXT5Y=; b=VC3JAELl4Bcc9x72apcbabSCxL7VtVtW52zOXinf9qQcKr8OiQhjNNZMIrMJHzF88t PBbjx7GVOfENmdJpobQoYLoM0+q14MmtfuHhOG+fjHB0cOXMjZCKVaz6bk6JD+LNKC5B 5NUZ3S71+7ggjbktRx126GlRhxpUMjYhaZ2jbXFyzl5Lj7tIXclBHF9agDV7w5Qy9DhE XHds+SdkFGGW/BxKpgXgtqSdEdTmoAGhhKG9P7xJgfG1bWErw0ZgZPmTOwklfWyoaD2b xRSYuTXb3JFgXIhYF7+jekASh+2hU6RWDE3TB0a2Q1knyPegNCjOVKr8ZN8q72lZ8YSV A6cQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=T5W4tcAlu9II6TGKyllSre1cwbBZX0+vG2XX1glXT5Y=; b=sIiLreyopLGfEKUTqYsfLuClBnDPWFoou3+NSN0RBmaNstzRCuoG0tRENQSaGLBNAl wN2wtmNU1MiQq7K+c9u4XE9OrjPBX1sDuJaI0JgNRUDGa9dtT1RWyrQAcunONg0J0dyy kncWGBIa10zCX1FVnUs85mMpyn5K653BX+F42p9HvUojFkpRqIr6sl8ZJdpLbTBYm0Nn 9g+CyK3H/TXLDVmsxDY0QuJUkOAADJeXzW/uJSXSfUYXQxTBGWVL8ZFHjTZK39Z30Mro z9HyEUMR2/0/tZ81V6C6fe7JE3PZ/2vPoGRwOfXZ8SKWKgrTtPOX5rEzWVz3Z2Q9DMrO Bo0A== X-Gm-Message-State: AOAM532/ybak/HB8qBJqUYc2aAAj5ocpslZOWlBbtE3h8TcFA/Wz2pIE V9uTRETfX0LF/DlOB4Pd/Kk= X-Google-Smtp-Source: ABdhPJxNACDhw+pefiza8oco2JDFigwtzNjUitC28s8922ZKmIrgEEtXSDugjM9DU6Y1rqgheHdTqQ== X-Received: by 2002:a63:9347:: with SMTP id w7mr9366776pgm.84.1642963294566; Sun, 23 Jan 2022 10:41:34 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id k12sm14285241pfc.107.2022.01.23.10.41.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:41:34 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Will Deacon , Mark Rutland , linux-arm-kernel@lists.infradead.org Subject: [PATCH 34/54] perf: replace bitmap_weight with bitmap_weight_eq for ThunderX2 Date: Sun, 23 Jan 2022 10:39:05 -0800 Message-Id: <20220123183925.1052919-35-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" tx2_uncore_event_start() calls bitmap_weight() to compare the weight of bitmap with a given number. We can do it more efficiently with bitmap_weight_eq because conditional bitmap_weight may stop traversing the bitmap earlier, as soon as condition is met. Signed-off-by: Yury Norov --- drivers/perf/thunderx2_pmu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/perf/thunderx2_pmu.c b/drivers/perf/thunderx2_pmu.c index 05378c0fd8f3..ebfa66b212c7 100644 --- a/drivers/perf/thunderx2_pmu.c +++ b/drivers/perf/thunderx2_pmu.c @@ -623,8 +623,8 @@ static void tx2_uncore_event_start(struct perf_event *e= vent, int flags) return; =20 /* Start timer for first event */ - if (bitmap_weight(tx2_pmu->active_counters, - tx2_pmu->max_counters) =3D=3D 1) { + if (bitmap_weight_eq(tx2_pmu->active_counters, + tx2_pmu->max_counters, 1)) { hrtimer_start(&tx2_pmu->hrtimer, ns_to_ktime(tx2_pmu->hrtimer_interval), HRTIMER_MODE_REL_PINNED); --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2C67C4332F for ; Sun, 23 Jan 2022 18:42:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240212AbiAWSmj (ORCPT ); Sun, 23 Jan 2022 13:42:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240074AbiAWSlo (ORCPT ); Sun, 23 Jan 2022 13:41:44 -0500 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A4EEC0613DE; Sun, 23 Jan 2022 10:41:38 -0800 (PST) Received: by mail-pl1-x634.google.com with SMTP id c3so13490602pls.5; Sun, 23 Jan 2022 10:41:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=IkNrFbXH9gY1KIOKy+h9o3LQcC7Su75w6LGwm4LKjaA=; b=EaNO/dASy+lPZWlcOtxF1hC9GdUeB2iS8umkWOWTX4v3h315YhPaRibVAi7vXbbHWe dZQi44B8tyxUoVsiF1ho0iJZOHCw92Invp1s1Jngv0T8L+0c7uqMPEEfpdlpf7wsR2hX def6pyngVUbofEtQ0onarODYce0lr6EcewlHKAkg7wW7/E/IkNjJ29EwgZ9JC95dqfwt HyYjjJh6C7hZd1XozPUerv73BbBwkDAQaBq4LR4A9muS5E19XN+FHJn+gDMMIIQ3OCVG BFULBqru13piNITxvIlEYH3XteGH1vToU8U0ADIfL8v4GWj0g5Y1FVAMkzSf8zEQusxa sUQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IkNrFbXH9gY1KIOKy+h9o3LQcC7Su75w6LGwm4LKjaA=; b=RY59NwHFm1GkcqcSz+WxYiTzOYYpKs+o8EVUByY0h5MJM5wYx/6NXMO0C3l/O7iM47 zy7TIyf6BD90C/Gx3RYoGJN0FF+ttqgIpLAEcTglK5xMG6p/r3Wld1zHt1UQTMdg9/B5 ZcdJQU7NqMYXzUInH6Hb0Okv6Ga2ZXrmewlIePNR+W8s7zKaeOe3Ac1pY8RtrjkHhzLW Wff7QzpHnVxJt2ZZnPsiAUh8Lllkj6mX9zoYQBY/u0yXlToUZKrY0KfgyceF6XowEoJB 0ZCZtc7Fl/encwiEBiwxmdzweEEETg5f72uKev0mWl8EvuiwKNNbeaZa8H9ICoRw4U7w TWHA== X-Gm-Message-State: AOAM533iw7yIgHU+dKabTx8o/cKkFQjbqjvwHdZ1mdw6MG7nYzRnwfOb tkutO2Rvl22V5fOZIfPOo2Y= X-Google-Smtp-Source: ABdhPJzWjGjT87hpyuJ8zxGhbFECmd1/Zcro15HLI2qS1pA/4gjZkUJUdMuLJwg9rhA75s0Tv2Dbgg== X-Received: by 2002:a17:902:c40d:b0:14a:96a4:1044 with SMTP id k13-20020a170902c40d00b0014a96a41044mr11869369plk.50.1642963297601; Sun, 23 Jan 2022 10:41:37 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id ms14sm11163509pjb.15.2022.01.23.10.41.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:41:37 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH 35/54] drivers/staging: replace bitmap_weight with bitmap_weight_le for tegra-video Date: Sun, 23 Jan 2022 10:39:06 -0800 Message-Id: <20220123183925.1052919-36-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" tegra_channel_enum_format() calls bitmap_weight() to compare the weight of bitmap with a given number. We can do it more efficiently with bitmap_weight_le() because conditional bitmap_weight may stop traversing the bitmap earlier, as soon as condition is met. Signed-off-by: Yury Norov --- drivers/staging/media/tegra-video/vi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media= /tegra-video/vi.c index d1f43f465c22..4e79a80e9307 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -436,7 +436,7 @@ static int tegra_channel_enum_format(struct file *file,= void *fh, if (!IS_ENABLED(CONFIG_VIDEO_TEGRA_TPG)) fmts_bitmap =3D chan->fmts_bitmap; =20 - if (f->index >=3D bitmap_weight(fmts_bitmap, MAX_FORMAT_NUM)) + if (bitmap_weight_le(fmts_bitmap, MAX_FORMAT_NUM, f->index)) return -EINVAL; =20 for (i =3D 0; i < f->index + 1; i++, index++) --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16BA4C433EF for ; Sun, 23 Jan 2022 18:42:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234957AbiAWSms (ORCPT ); Sun, 23 Jan 2022 13:42:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239887AbiAWSlw (ORCPT ); Sun, 23 Jan 2022 13:41:52 -0500 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD3D5C0613EC for ; Sun, 23 Jan 2022 10:41:41 -0800 (PST) Received: by mail-pf1-x42f.google.com with SMTP id v74so10524110pfc.1 for ; Sun, 23 Jan 2022 10:41:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=FpGkB1VQhnPPql1nIYBbXxejidNq19lPQtdnhOiEEDw=; b=XYd+pCzi4ZT+GjuWIA7KOpvcIA55kJ1GGwxi03S/32tAG3rkcZiB6MrLqmUrT7RkbE lx85QVKw/hzQx8cm441C9mDFEmr1tF/DCu+iMUyOHcf4tDdo/Sx183QfU3mCjyZ0V2oe nfNCIUq8w60/gcYRa0dScV70cJ3uIRN0tikaeTF21C1rJNdJPj/ATljgmjHMfpz9maBQ A/msWA6jpi+qqcrHKcXuLyGqy+ohgcCuwn551sxDj/UP0PDvOkaUbl7cJIQ1JGpUeMKQ HWzg2mcpuNVpexCE8PHN6NejQ+tZ7B87H9A5mVliwZ3ln09IhDFVTargeNi9UYHA14g+ Rjcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FpGkB1VQhnPPql1nIYBbXxejidNq19lPQtdnhOiEEDw=; b=jsEG/fy0KN3sCl/CgnW+bSMoSAMlnS/55c+/mxNacN5VmpSdgyrcPmA2l7KitcZUoq E8FWomu5bgR7v542Y0j0iKSGEAfElYTGDrN9UhQrbu+8BX82RtmDRRxE13ofzKn0uooJ qNE2NUQQBcDQjDs/Tvu90TbX9nzuA6F5eBwft55fFTxUm7aF5gjfjUrU5HpgfBtpIwCb +yQY4mQoJawmILfDG9VnH01q4nvV2hyBCnAq/UZTEyyTnjuakeKFXQojfEftw/olOEK4 LMsw9XjdZW/4frplJnPp2TB8lGZZLMh7o51fnV9tSr01AmMNMJyPW8K1YqWHRb9EBOCD sEZw== X-Gm-Message-State: AOAM532BZgFmLAVKP2lTWYn5ponjcFf3ygc0yNliyaICfDx1OIRXO2MJ e4q0M+wc/IlDljGVp+24bQk= X-Google-Smtp-Source: ABdhPJxDuWuravBMI+rpmbnMCNC8EfAtpHxg3yYmz60gSnxCSHRycBJIQK5jLyWBzwNUeovtznVXXg== X-Received: by 2002:a63:3fc5:: with SMTP id m188mr9367408pga.307.1642963301119; Sun, 23 Jan 2022 10:41:41 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id x1sm2314965pfh.167.2022.01.23.10.41.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:41:40 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org Subject: [PATCH 36/54] lib/cpumask: add cpumask_weight_{eq,gt,ge,lt,le} Date: Sun, 23 Jan 2022 10:39:07 -0800 Message-Id: <20220123183925.1052919-37-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" In many cases people use cpumask_weight() to compare the result against some number or expression: if (cpumask_weight(...) > 1) do_something(); It may be significantly improved for large cpumasks: if first few words count set bits to a number greater than given, we can stop counting and immediately return. The same idea would work in other direction: if we know that the number of set bits that we counted so far is small enough, so that it would be smaller than required number even if all bits of the rest of the cpumask are set, we can stop counting earlier. This patch adds cpumask_weight_{eq, gt, ge, lt, le} helpers based on corresponding bitmap functions. The following patches apply new functions where appropriate. Signed-off-by: Yury Norov --- include/linux/cpumask.h | 50 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h index 64dae70d31f5..1906e3225737 100644 --- a/include/linux/cpumask.h +++ b/include/linux/cpumask.h @@ -575,6 +575,56 @@ static inline unsigned int cpumask_weight(const struct= cpumask *srcp) return bitmap_weight(cpumask_bits(srcp), nr_cpumask_bits); } =20 +/** + * cpumask_weight_eq - Check if # of bits in *srcp is equal to a given num= ber + * @srcp: the cpumask to count bits (< nr_cpu_ids) in. + * @num: the number to check. + */ +static inline bool cpumask_weight_eq(const struct cpumask *srcp, unsigned = int num) +{ + return bitmap_weight_eq(cpumask_bits(srcp), nr_cpumask_bits, num); +} + +/** + * cpumask_weight_gt - Check if # of bits in *srcp is greater than a given= number + * @srcp: the cpumask to count bits (< nr_cpu_ids) in. + * @num: the number to check. + */ +static inline bool cpumask_weight_gt(const struct cpumask *srcp, int num) +{ + return bitmap_weight_gt(cpumask_bits(srcp), nr_cpumask_bits, num); +} + +/** + * cpumask_weight_ge - Check if # of bits in *srcp is greater than or equa= l to a given number + * @srcp: the cpumask to count bits (< nr_cpu_ids) in. + * @num: the number to check. + */ +static inline bool cpumask_weight_ge(const struct cpumask *srcp, int num) +{ + return bitmap_weight_ge(cpumask_bits(srcp), nr_cpumask_bits, num); +} + +/** + * cpumask_weight_lt - Check if # of bits in *srcp is less than a given nu= mber + * @srcp: the cpumask to count bits (< nr_cpu_ids) in. + * @num: the number to check. + */ +static inline bool cpumask_weight_lt(const struct cpumask *srcp, int num) +{ + return bitmap_weight_lt(cpumask_bits(srcp), nr_cpumask_bits, num); +} + +/** + * cpumask_weight_le - Check if # of bits in *srcp is less than or equal t= o a given number + * @srcp: the cpumask to count bits (< nr_cpu_ids) in. + * @num: the number to check. + */ +static inline bool cpumask_weight_le(const struct cpumask *srcp, int num) +{ + return bitmap_weight_le(cpumask_bits(srcp), nr_cpumask_bits, num); +} + /** * cpumask_shift_right - *dstp =3D *srcp >> n * @dstp: the cpumask result --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E63DC433EF for ; Sun, 23 Jan 2022 18:42:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239903AbiAWSmo (ORCPT ); Sun, 23 Jan 2022 13:42:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239894AbiAWSlx (ORCPT ); Sun, 23 Jan 2022 13:41:53 -0500 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7737C061748; Sun, 23 Jan 2022 10:41:44 -0800 (PST) Received: by mail-pf1-x42b.google.com with SMTP id x37so9813297pfh.8; Sun, 23 Jan 2022 10:41:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Azd/w2Pv4tWIAvkFg87uiwY2Tzr35b3ymris6XNGI+U=; b=IPyJfSxowKcB1S3Q1A4DTZa7XdI3e/XLnFC7naVawaaQ+1a+LtUNQ+e7L1/yh1uVnU tJKAhbiAtQmE7P3de0oCrhKBgD83mkQONZzr24n6xdYLMwpBMQ4wjv6rDLtRwAinUqWj t+lS9kohf4hERa3Dcc5YBZXqRN5C2wf9P7AyvM1DqjJJTmRX/0pwnajQC0iWSf/TaORQ Kb9Rr8lYSFcs5alkmVEFbtbaUleUoZ5hcxIjxRshgTwzvy2Tf4ynKKCEExSxgj3kyb5c tCb/HyztCPdSBTHTBayp1FVJQdkzrDqOD+6gkbn9ctA5mbUNZqpD9qsgH5p/3gicHVGE 6Efw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Azd/w2Pv4tWIAvkFg87uiwY2Tzr35b3ymris6XNGI+U=; b=41OZloVqGKlwUBz3536NGGdPlEZRQ932eSMZvCnE3jDwJj4pt/Qw7gTEDL4tccwLe/ ZaR+pI5rqxH8hucmmAz6ptwvGdtBtXnJXO5YyTw+VJ70wm7swauYLNmYApCN73+S6/IM Su+k9i0C2aNRkYsylaa2fTCD1iqIFniTHqGnyDCJWtOC/HzgL1qwTJkq4UIn/CwLqCKP VWMTo8kzOGTnYA0xX4xw9YioEH/++N0OOWXC6hBPisL4yY4rEVe6xzHltl1L9ZUm3FSf Kg2PHHOaq9B9nMnw8iwN+foRFk9LbO7OzpzQBQDcSnWdYwKoYU6Ws/x6Rerx/W5Si3jV hoVw== X-Gm-Message-State: AOAM530wun6cxDYGzTelbPwf6Eddbu1As3cILFbofHSmFl78C6trGqVQ EA7ndON38gxBD7CwMz6b6h8= X-Google-Smtp-Source: ABdhPJzM40DL0G0MWrnWXQaAocMzZ4JkN5vXEMfehpYSeKlSDkS1lKxTvQEApD4W0wyCbqB+jxF+cA== X-Received: by 2002:a65:494f:: with SMTP id q15mr9457430pgs.333.1642963304207; Sun, 23 Jan 2022 10:41:44 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id z29sm7442507pfk.38.2022.01.23.10.41.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:41:43 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, linux-ia64@vger.kernel.org Subject: [PATCH 37/54] arch/ia64: replace cpumask_weight with cpumask_weight_eq in mm/tlb.c Date: Sun, 23 Jan 2022 10:39:08 -0800 Message-Id: <20220123183925.1052919-38-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" __flush_tlb_range() code calls cpumask_weight() to compare the weight of cpumask with a given number. We can do it more efficiently with cpumask_weight_eq because conditional cpumask_weight may stop traversing the cpumask earlier, as soon as condition is met. Signed-off-by: Yury Norov --- arch/ia64/mm/tlb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/ia64/mm/tlb.c b/arch/ia64/mm/tlb.c index 135b5135cace..a5bce13ab047 100644 --- a/arch/ia64/mm/tlb.c +++ b/arch/ia64/mm/tlb.c @@ -332,7 +332,7 @@ __flush_tlb_range (struct vm_area_struct *vma, unsigned= long start, =20 preempt_disable(); #ifdef CONFIG_SMP - if (mm !=3D current->active_mm || cpumask_weight(mm_cpumask(mm)) !=3D 1) { + if (mm !=3D current->active_mm || !cpumask_weight_eq(mm_cpumask(mm), 1)) { ia64_global_tlb_purge(mm, start, end, nbits); preempt_enable(); return; --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A081C433EF for ; Sun, 23 Jan 2022 18:43:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239911AbiAWSm6 (ORCPT ); Sun, 23 Jan 2022 13:42:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239899AbiAWSlx (ORCPT ); Sun, 23 Jan 2022 13:41:53 -0500 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E724C0613EE; Sun, 23 Jan 2022 10:41:47 -0800 (PST) Received: by mail-pf1-x434.google.com with SMTP id u130so9498904pfc.2; Sun, 23 Jan 2022 10:41:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=fUD3By+Q+kq98PS9J46Zo9V/GV4St0mmKcFfwwO9Pb8=; b=K1iIT+1E2cEHkTf9YJEGufFMzj+1Eh7+cQ1FoYkqUeKs/xVJZ8bsBzPqbE+az5UcOF 3N8dLMXOE9d+QRCy7gbLXLdF0+I4cTggikREfhOztuJnumxxAHkt4rbDqPCOopgasrHg CifKAdMoNw1LqCWQI9py1vRrOdGwG43vlNKwIAPHLqcdjgI+EHDWFVHNzP5YykPOq44x 9QKl41c3DWud2s6j5qb22F4E30o25hALFnzf108ytQymFZ1W+tpflr656JLCzb7dZlaq 79StCTlGk+PiEDZ2KwRGMk+GircEjWTnb9bYlBtUG0HBcuVDzYqTHzylz2vMtMmszbQ1 F0oA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fUD3By+Q+kq98PS9J46Zo9V/GV4St0mmKcFfwwO9Pb8=; b=2W74cVVt6RL4kW+puBFgmctKrbpNfDzLAlgQTYjzDP/frJQFsiGZCmjClqFQxgKl5Y b1rzcfo87K1LBxmKuU2e1kZYeUA7sH1i0UezQJ8cjuHU8wIS+t+SEzoj5yEWNLBMI1Z3 u48jvDPDS8A/i+zkXuG+rnjDH/C+MqoTwd2czNcVJG290Al0d9QSZo8RO3X4IVkwqOx5 lT+N1lg7at8UM+uFmcC7NwwrIwmvUWR3vuH0MlfJgc0HGJdkWWd+Y1hOXOPsgXXepNYU e142jc7UL5VymSJc5m9w9au4wdRbK1NIIKfo7hqrheZO0cvRKh7IB6suJj/sKFiUgvjL Eelg== X-Gm-Message-State: AOAM533wAKPtJhBmFsCzCIApw+vpMwtaRzXpoxcBCUuFPjSxJsv2O+r9 5A9IuC2fChmNwMXrTWX3s6iMkx5LbLw= X-Google-Smtp-Source: ABdhPJzgui0t/epPuAWCm48+9aVBhNRSHTduGzhQc69xdNO0+dJyfJfNKcCZ70W6D4Q4vze3O9f0vA== X-Received: by 2002:a63:3710:: with SMTP id e16mr9494755pga.507.1642963306975; Sun, 23 Jan 2022 10:41:46 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id mm24sm11135471pjb.20.2022.01.23.10.41.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:41:46 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Thomas Bogendoerfer , Mark Rutland , Marc Zyngier , linux-mips@vger.kernel.org Subject: [PATCH 38/54] arch/mips: replace cpumask_weight with cpumask_weight_{eq, ...} where appropriate Date: Sun, 23 Jan 2022 10:39:09 -0800 Message-Id: <20220123183925.1052919-39-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Mips code uses calls cpumask_weight() to compare the weight of cpumask with a given number. We can do it more efficiently with cpumask_weight_{eq, ...} because conditional cpumask_weight may stop traversing the cpumask earlier, as soon as condition is met. Signed-off-by: Yury Norov --- arch/mips/cavium-octeon/octeon-irq.c | 4 ++-- arch/mips/kernel/crash.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/mips/cavium-octeon/octeon-irq.c b/arch/mips/cavium-octeon= /octeon-irq.c index 844f882096e6..914871f15fb7 100644 --- a/arch/mips/cavium-octeon/octeon-irq.c +++ b/arch/mips/cavium-octeon/octeon-irq.c @@ -763,7 +763,7 @@ static void octeon_irq_cpu_offline_ciu(struct irq_data = *data) if (!cpumask_test_cpu(cpu, mask)) return; =20 - if (cpumask_weight(mask) > 1) { + if (cpumask_weight_gt(mask, 1)) { /* * It has multi CPU affinity, just remove this CPU * from the affinity set. @@ -795,7 +795,7 @@ static int octeon_irq_ciu_set_affinity(struct irq_data = *data, * This removes the need to do locking in the .ack/.eoi * functions. */ - if (cpumask_weight(dest) !=3D 1) + if (!cpumask_weight_eq(dest, 1)) return -EINVAL; =20 if (!enable_one) diff --git a/arch/mips/kernel/crash.c b/arch/mips/kernel/crash.c index 81845ba04835..5b690d52491f 100644 --- a/arch/mips/kernel/crash.c +++ b/arch/mips/kernel/crash.c @@ -72,7 +72,7 @@ static void crash_kexec_prepare_cpus(void) */ pr_emerg("Sending IPI to other cpus...\n"); msecs =3D 10000; - while ((cpumask_weight(&cpus_in_crash) < ncpus) && (--msecs > 0)) { + while (cpumask_weight_lt(&cpus_in_crash, ncpus) && (--msecs > 0)) { cpu_relax(); mdelay(1); } --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2D0EC433EF for ; Sun, 23 Jan 2022 18:43:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240261AbiAWSnB (ORCPT ); Sun, 23 Jan 2022 13:43:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239900AbiAWSlx (ORCPT ); Sun, 23 Jan 2022 13:41:53 -0500 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CABC1C06175D for ; Sun, 23 Jan 2022 10:41:50 -0800 (PST) Received: by mail-pl1-x62c.google.com with SMTP id d1so13472186plh.10 for ; Sun, 23 Jan 2022 10:41:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=6C24rFRm4D9dQifkbAjpKYbgU7hbqSNfEMJXgU+U9KI=; b=gYPbDS3xW8Bof6/g8XIUI3VOyuWClFWj+Zb1KxH7n8eeylpaD7S+0cAQt0BGU2As3z duZ9/03UsRs07ChTiteduoXTEha9M3JOt6tS2tzofY+aoNv/yDnGgcW162IO7pfl0wRn ZdC0c7yMRUF0QVaQPTId/pywxUsN08BWrvHjR6PfR/383ALFfcq0bHBGeuYVyfzZTOTt y5IAqKFglXI7xWlG7X5EuweqyLRNOsqcKnZPCn+pO0ZCouINBgits28kN7Bj2Z0Eniua b/brsWqVckOYFra9U6GGgIJGIuiycyhOEhIHy1iVyx8K7y1oYTijPy9C6uKNewCLCHDK pV/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6C24rFRm4D9dQifkbAjpKYbgU7hbqSNfEMJXgU+U9KI=; b=YrP5QJJCuKhJ9q0wTofRcoAnOqnGLlN/4v6JywjfFuTtdxSU5QuJacq1QvU7nBxpWG 72+UpY/kzUhT3NymlDoGZm2Ml4ig2MLURNVJF6TXVsePY8TeW6t9gVAhpWkgVpZjuhzk YcqIr4VTfEC/l84FHczzIt7qTf4zN1qj41c63i/BM9LMq0X4SG9/Q+74hFnOHjtTJDx0 ufOt/cjlVXxbqDRPUR3LAbExdUjrpY8/2M+/MjtFUMy34QE18o47QPzjJ4R6vywBWwOc 7sWjtNRiOqpoZ5+3ArxtCu3bUDK1CEz7oROka+Sz6apdfnjxyLQq237+8ALO2JJVM2uy X82g== X-Gm-Message-State: AOAM531NLqIs8lSSIyiZagc4yGLGZwllaAlxXbv6idn02tC0DTJkbpYX Qapzgg9J4Td/RRo1+HKCCQQ= X-Google-Smtp-Source: ABdhPJwCUm5LGUQRIavV14WvbHJtSguBHM0RRlDYhBuujEK/erleabWJrnbTCB8LogwV7QJ8p8LuVA== X-Received: by 2002:a17:90b:4f87:: with SMTP id qe7mr7183731pjb.154.1642963310342; Sun, 23 Jan 2022 10:41:50 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id pj7sm1942706pjb.50.2022.01.23.10.41.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:41:50 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Srikar Dronamraju , "Gautham R. Shenoy" , Valentin Schneider , Parth Shah , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Hari Bathini , Rob Herring , Laurent Dufour , Petr Mladek , John Ogness , Sudeep Holla , Christophe Leroy , "Naveen N. Rao" , Xiongwei Song , Arnd Bergmann , linuxppc-dev@lists.ozlabs.org Subject: [PATCH 39/54] arch/powerpc: replace cpumask_weight with cpumask_weight_{eq, ...} where appropriate Date: Sun, 23 Jan 2022 10:39:10 -0800 Message-Id: <20220123183925.1052919-40-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" PowerPC code uses cpumask_weight() to compare the weight of cpumask with a given number. We can do it more efficiently with cpumask_weight_{eq, ...} because conditional cpumask_weight may stop traversing the cpumask earlier, as soon as condition is met. Signed-off-by: Yury Norov --- arch/powerpc/kernel/smp.c | 2 +- arch/powerpc/kernel/watchdog.c | 2 +- arch/powerpc/xmon/xmon.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c index b7fd6a72aa76..8bff748df402 100644 --- a/arch/powerpc/kernel/smp.c +++ b/arch/powerpc/kernel/smp.c @@ -1656,7 +1656,7 @@ void start_secondary(void *unused) if (has_big_cores) sibling_mask =3D cpu_smallcore_mask; =20 - if (cpumask_weight(mask) > cpumask_weight(sibling_mask(cpu))) + if (cpumask_weight_gt(mask, cpumask_weight(sibling_mask(cpu)))) shared_caches =3D true; } =20 diff --git a/arch/powerpc/kernel/watchdog.c b/arch/powerpc/kernel/watchdog.c index bfc27496fe7e..62937a077de7 100644 --- a/arch/powerpc/kernel/watchdog.c +++ b/arch/powerpc/kernel/watchdog.c @@ -483,7 +483,7 @@ static void start_watchdog(void *arg) =20 wd_smp_lock(&flags); cpumask_set_cpu(cpu, &wd_cpus_enabled); - if (cpumask_weight(&wd_cpus_enabled) =3D=3D 1) { + if (cpumask_weight_eq(&wd_cpus_enabled, 1)) { cpumask_set_cpu(cpu, &wd_smp_cpus_pending); wd_smp_last_reset_tb =3D get_tb(); } diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c index fd72753e8ad5..b423812e94e0 100644 --- a/arch/powerpc/xmon/xmon.c +++ b/arch/powerpc/xmon/xmon.c @@ -469,7 +469,7 @@ static bool wait_for_other_cpus(int ncpus) =20 /* We wait for 2s, which is a metric "little while" */ for (timeout =3D 20000; timeout !=3D 0; --timeout) { - if (cpumask_weight(&cpus_in_xmon) >=3D ncpus) + if (cpumask_weight_ge(&cpus_in_xmon, ncpus)) return true; udelay(100); barrier(); @@ -1338,7 +1338,7 @@ static int cpu_cmd(void) case 'S': case 't': cpumask_copy(&xmon_batch_cpus, &cpus_in_xmon); - if (cpumask_weight(&xmon_batch_cpus) <=3D 1) { + if (cpumask_weight_le(&xmon_batch_cpus, 1)) { printf("There are no other cpus in xmon\n"); break; } --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 802FCC433F5 for ; Sun, 23 Jan 2022 18:43:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239803AbiAWSnD (ORCPT ); Sun, 23 Jan 2022 13:43:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239906AbiAWSly (ORCPT ); Sun, 23 Jan 2022 13:41:54 -0500 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01BE0C061763; Sun, 23 Jan 2022 10:41:54 -0800 (PST) Received: by mail-pl1-x62f.google.com with SMTP id x11so7708017plg.6; Sun, 23 Jan 2022 10:41:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=O3KT5VKSFvO3GdRn4FJX6rtqnPjQLFUvXRpKrWgV0vk=; b=Kl5oq/zPHhzFnmY1AQ/X1WXwEJ/77u/DsV5WzawwBW5htJum8noY7sVHr104trMone 0luZQz2YmdZVgBfkBF7XUtbU9U5NNNE77xLkoQ6e44CE/RvA9plyW2k9hGC6yj4hcQuJ 3veVmDisG0BBCnjxVejMYJbzG51E1SUUiavOLrCnhpLmFLG2cjoWTdfbKr211UkALHeQ 2UQ9q6rFTw5kdo2WkXGDG4DycaPBW+FTwLqtIRIMJWOFHbQOJNBGAkvI2xkJd9ogpR0/ QJ92P/ea5Xg/x4A1RP8yiI6aL+2j8Go7YQU125GnF0jEpsfIT0Swhds7G6WuudRZkBgQ i7XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=O3KT5VKSFvO3GdRn4FJX6rtqnPjQLFUvXRpKrWgV0vk=; b=cPzUMJk09ubWBOfHQVyNaidwKQeXM9xI6A1XzbcTEhAak0AhuWUEqBFHPkCWj0KZSX j3oPNkNzRlAXFAp55HdQDLYjGIJei7qZmd8EnvVsIQIhX6O71OxSbdDUW7/01R4FdvZ2 bbzn83m4K+ltj3rs278T54MvHjYlzM+vLi8B7DT4M5vZRj52wyL8UEk23voWihuOsPDV sQKBAuCorZtUl6FLCfdnyno+Xx6FnRMyGjiJscBsFmQ7jC3WfoGCnl2KXRjymlVCLUUu lxvUdQ94uL2ovlu4dRa3v6nT6YQqq7gNSVFja9QRvrHGhNTOJ6J88hGAkeaE/G2SODPI T+9A== X-Gm-Message-State: AOAM531kY/DhehXPe8LpqVC6Fxa6HY7rUWi/3J8Ueg5doX5Lyc0lq2Wn dGGHYuMBwTpNvAQvo9+UCYE= X-Google-Smtp-Source: ABdhPJyA03nygberi3JeFhIpeLaKgTDTgDNIwOWLUJrakKCuQW5OTWU8/LphWZHA5drEVEeiqoOhkA== X-Received: by 2002:a17:902:6841:b0:149:6791:5a4f with SMTP id f1-20020a170902684100b0014967915a4fmr11869454pln.123.1642963313406; Sun, 23 Jan 2022 10:41:53 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id my11sm8413621pjb.35.2022.01.23.10.41.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:41:53 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Alexander Gordeev , Sven Schnelle , Thomas Richter , Sumanth Korikkar , Sebastian Andrzej Siewior , Jiapeng Chong , kernel test robot , linux-s390@vger.kernel.org Subject: [PATCH 40/54] arch/s390: replace cpumask_weight with cpumask_weight_eq where appropriate Date: Sun, 23 Jan 2022 10:39:11 -0800 Message-Id: <20220123183925.1052919-41-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" cfset_all_start() calls cpumask_weight() to compare the weight of cpumask with a given number. We can do it more efficiently with cpumask_weight_{eq, ...} because conditional cpumask_weight may stop traversing the cpumask earlier, as soon as condition is met. Signed-off-by: Yury Norov --- arch/s390/kernel/perf_cpum_cf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/s390/kernel/perf_cpum_cf.c b/arch/s390/kernel/perf_cpum_c= f.c index ee8707abdb6a..4d217f7f5ccf 100644 --- a/arch/s390/kernel/perf_cpum_cf.c +++ b/arch/s390/kernel/perf_cpum_cf.c @@ -975,7 +975,7 @@ static int cfset_all_start(struct cfset_request *req) return -ENOMEM; cpumask_and(mask, &req->mask, cpu_online_mask); on_each_cpu_mask(mask, cfset_ioctl_on, &p, 1); - if (atomic_read(&p.cpus_ack) !=3D cpumask_weight(mask)) { + if (!cpumask_weight_eq(mask, atomic_read(&p.cpus_ack))) { on_each_cpu_mask(mask, cfset_ioctl_off, &p, 1); rc =3D -EIO; debug_sprintf_event(cf_dbg, 4, "%s CPUs missing", __func__); --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88D02C433F5 for ; Sun, 23 Jan 2022 18:43:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234741AbiAWSnF (ORCPT ); Sun, 23 Jan 2022 13:43:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240094AbiAWSl5 (ORCPT ); Sun, 23 Jan 2022 13:41:57 -0500 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6ED7C06176A for ; Sun, 23 Jan 2022 10:41:56 -0800 (PST) Received: by mail-pj1-x1032.google.com with SMTP id o64so14143486pjo.2 for ; Sun, 23 Jan 2022 10:41:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=a9TYPmGPsvgwUeMF0miMOaL4P3BFvKAG7ZDEborhqcw=; b=eQqSkdKb/R0sdmnpZUtNk+VSO8leZXruRoP6mdzgnjc+ouKL+ERWx3kc4JV3KSIcaj eSiZXZgMTwjIj3nzNC4k+VdtedXL5cZQm34+Lp95+RC3OVMiiSxNaZVTAWc+/mr4jaQK N7n5p4X8aPBCbwCtXVqyejJ/GU7GOtsLQItb1fzji1JsiWi2X9be5jD08yNGADBhKpP6 9uGhHlVPV2JBdvVTmM/xVmt4DnAzfsy8AbzezIOxp4VL2azg9y5gjX1na+vR/dO0pumv IGb6zPvP5CX5BbGNKgZKsvq92ox1kQaQPSa/xPFNYwVJCQ6CUkkc9+2/234v3BpZSlrJ iSnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=a9TYPmGPsvgwUeMF0miMOaL4P3BFvKAG7ZDEborhqcw=; b=mURZEtLXzwpbVLoAeZ3bARliY0A/DLwQKyuIZmAGKKEMtGlitVOKCPSw44N3SemaRF yWo4IsGvd/hn6oFqsiucnoH4XtCq40LlHLIuu2vMXfrK4ADgr0/pXHuwVgMMWzAqwTm4 STxu0WPHIPX+g/aFq9N7bIuf1e6DDEB/vEDBRGSaiMqariHwmM/L6ikcIbs4+RnB7SiC HHxCFk9Nxe/+MY0uqMtRwQ2x6+tPuY4FRnEktcYpQ4fS+weHS2UVgc3f7IXz+pAI/8zT imB/m7sHCrC0v3PlcHtn1y7675Zs5Si+EcURa+iCEOrMAB4JekcKdQ03vhxdn7Zkenf8 AC8w== X-Gm-Message-State: AOAM531IZ2ViymrW8l2fFPtjWkVh7I4EuzS9zc73J0ZZFTjXFiKKNsGe +PASH0kkDwRViA20MgcS/Rw= X-Google-Smtp-Source: ABdhPJwJ4wSV5vrFBDblt9Iik5xdBLS1XzYEZG8To1B2j4sSumFwtdIheE1VJnzdPK6bALklB0q0Cw== X-Received: by 2002:a17:902:b10e:b0:14a:4a48:cac5 with SMTP id q14-20020a170902b10e00b0014a4a48cac5mr12003272plr.16.1642963316358; Sun, 23 Jan 2022 10:41:56 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id z14sm5257693pfq.3.2022.01.23.10.41.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:41:56 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , "Rafael J. Wysocki" , Vitaly Kuznetsov , Tim Chen , Alison Schofield , Boris Ostrovsky Subject: [PATCH 41/54] arch/x86: replace cpumask_weight with cpumask_weight_eq where appropriate Date: Sun, 23 Jan 2022 10:39:12 -0800 Message-Id: <20220123183925.1052919-42-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" smpboot code in somw places calls cpumask_weight() to compare the weight of cpumask with a given number. We can do it more efficiently with cpumask_weight_eq() because conditional cpumask_weight may stop traversing the cpumask earlier, as soon as condition is met. Signed-off-by: Yury Norov --- arch/x86/kernel/smpboot.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index 617012f4619f..e851e9945eb5 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -1608,7 +1608,7 @@ static void remove_siblinginfo(int cpu) /*/ * last thread sibling in this cpu core going down */ - if (cpumask_weight(topology_sibling_cpumask(cpu)) =3D=3D 1) + if (cpumask_weight_eq(topology_sibling_cpumask(cpu), 1)) cpu_data(sibling).booted_cores--; } =20 @@ -1617,7 +1617,7 @@ static void remove_siblinginfo(int cpu) =20 for_each_cpu(sibling, topology_sibling_cpumask(cpu)) { cpumask_clear_cpu(cpu, topology_sibling_cpumask(sibling)); - if (cpumask_weight(topology_sibling_cpumask(sibling)) =3D=3D 1) + if (cpumask_weight_eq(topology_sibling_cpumask(sibling), 1)) cpu_data(sibling).smt_active =3D false; } =20 --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2DB40C433EF for ; Sun, 23 Jan 2022 18:43:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234686AbiAWSnG (ORCPT ); Sun, 23 Jan 2022 13:43:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239775AbiAWSmA (ORCPT ); Sun, 23 Jan 2022 13:42:00 -0500 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37B0DC061755 for ; Sun, 23 Jan 2022 10:42:00 -0800 (PST) Received: by mail-pj1-x102b.google.com with SMTP id d5so11712781pjk.5 for ; Sun, 23 Jan 2022 10:42:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=SXSPpkBNjFI2449vR4ZOBpkrXqfQ1QSZDhxzDBOLdyY=; b=eiPAXI/WjLAblkhca2uJhe8/W1CRBsKo7ESuVXB0ckdjmDbHwcwgeLa2vXoJEA0fxt Lk59qbjVjcrnZW1unyX5auKxG1xSZWfPJLHePY7jbbfw6OU/1dAOiaW9oqdl3dEpJ3Xn sakgCeMBvaAp3NPshZro4hIL2pKSOLMTNpsTpVv9/0QG/GJwtcdeptM9Yq4T2QuU6dXK UTfY8b5LygRS843t6y5kmY8IYWkURJI+hhQfQcy71BSS5so3P9u58xxmG18sNMn9oYSq pafGE5mVfB/hgq0mIoQ+ZMVlM2mnFF+ic2R7UXat+e/IHhEQ+9l8LdM2qfjQ5lJdjt7W AaWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SXSPpkBNjFI2449vR4ZOBpkrXqfQ1QSZDhxzDBOLdyY=; b=us95joowT3/ZtECP6SY0PY4wZ/iwTQp403UNTlhLuPQ0d8z1qbpQ7jv4N5EeQlO6Ra dgYJqU39xUPAZtqV04A58V/se+jJXe6OjUmQIxknvU9n4O6fdU8LfqgLdd6nDHAPX8qo AoHsYKuSZWQ1PLqe6SNZjIhETUa6HEhgIN1LXG81Gv3sBOBhjxeszaM0K3OP6rlEH4No j1l2rNI/qoDVFn1WeTdzqK4eS/I4Bp6VCRuRpCgJ/HyAzTHABBqhhoejRhu0Xaild8U4 9NuBYyKc2YvJnFq+FeOgdPYkXJ4hSsne6kl3xP3HMjsQqOeFoVy79Xga6eZ/SgepxhPG o5Yg== X-Gm-Message-State: AOAM532rmazHEXhmTlJ/yLYJnd68R/T6r6eiGLpQsY5LaGUBHYGkZApH Zi7AyTAs7BkpDVLD2qfhm/Q= X-Google-Smtp-Source: ABdhPJyKnDsoQFq8L/+C1ePy3bLtIDZz3wYrVC6GemjQIHFlwG9Gr4xw7tsDXE/Qezv8iRphFZXolQ== X-Received: by 2002:a17:90a:8807:: with SMTP id s7mr9725127pjn.223.1642963319695; Sun, 23 Jan 2022 10:41:59 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id mi6sm12051532pjb.40.2022.01.23.10.41.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:41:59 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Mark Rutland , Lorenzo Pieralisi , linux-arm-kernel@lists.infradead.org Subject: [PATCH 42/54] firmware: pcsi: replace cpumask_weight with cpumask_weight_eq Date: Sun, 23 Jan 2022 10:39:13 -0800 Message-Id: <20220123183925.1052919-43-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" down_and_up_cpus() calls cpumask_weight() to compare the weight of cpumask with a given number. We can do it more efficiently with cpumask_weight_{eq, ...} because conditional cpumask_weight may stop traversing the cpumask earlier, as soon as condition is met. Signed-off-by: Yury Norov --- drivers/firmware/psci/psci_checker.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/firmware/psci/psci_checker.c b/drivers/firmware/psci/p= sci_checker.c index 116eb465cdb4..90c9473832a9 100644 --- a/drivers/firmware/psci/psci_checker.c +++ b/drivers/firmware/psci/psci_checker.c @@ -90,7 +90,7 @@ static unsigned int down_and_up_cpus(const struct cpumask= *cpus, * cpu_down() checks the number of online CPUs before the TOS * resident CPU. */ - if (cpumask_weight(offlined_cpus) + 1 =3D=3D nb_available_cpus) { + if (cpumask_weight_eq(offlined_cpus, nb_available_cpus - 1)) { if (ret !=3D -EBUSY) { pr_err("Unexpected return code %d while trying " "to power down last online CPU %d\n", --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C8EB9C433EF for ; Sun, 23 Jan 2022 18:43:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239631AbiAWSnI (ORCPT ); Sun, 23 Jan 2022 13:43:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239935AbiAWSmD (ORCPT ); Sun, 23 Jan 2022 13:42:03 -0500 Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4C36C061782; Sun, 23 Jan 2022 10:42:03 -0800 (PST) Received: by mail-pg1-x52c.google.com with SMTP id v3so7875037pgc.1; Sun, 23 Jan 2022 10:42:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=I0YT/VYh6ObjnXDB7ng030sn8u8S3AAW+xjtpU6qhC0=; b=kq3s29g6GZf8wi2NbTnwwMbHhy8TpKIQ4eWUy/tjlH1Vpe8OzRohSKbh0NJuBIbGKE AWefAIJHW1zxeanlvYSDuErwI7AbVCYWnyZSnLyC+yOjjk1falLUifpAOyQfzPGRxlUm NCgGGZw6YahfLJMTHbzfLum4x9VUdar9NvF4YR9uJAjsjgdICCc9bGMYTiw6dhVpIj2m 23T3yJQuFspBrGVljLlEbWLX8Hn44/lP19MFqTTsAIGZ+9GmI5K/C2rnUrTkmWn1r5Uj u7qZ1u+B53jjHd5jQ0n+p5ZGLFrBDziDkFTOYlcCINLApK7NL2aC6acKb3gscVOqbn1P UI2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=I0YT/VYh6ObjnXDB7ng030sn8u8S3AAW+xjtpU6qhC0=; b=KQcivrMrVE+hnVKq6JgrLyf0R2yo2tRKtKlOv+8RnMyCwrEtbwcz5K1rANwYnPw7/m 2m9CA/tmWLP/G20xdQlMLCsFb6EBjFf1JkhsmLiCfZmJ8NK5vxpdn9PqusIYHQ+skeCj r1NPCeNE67DVxPKCojmCjHS4okey9Ezz26YAx15Chwh4bRWV6Njz9mXXrY34QgmPtFZy 3F2Wg+Cm7ULySXflXNcrlcANhBdrGPxZY0qxtEqlZ2k9qPU9u55j2EiIAx4ilaMNVp5z tLn0O2ZFX4gkUNyln9cEGYU+L4ARjaaGF2mR/a5EOCXqvdppfOUQJWWvPveBc/TtPwy3 pQPA== X-Gm-Message-State: AOAM5332ttlwrbU/+MhPJxix/8L9FnmMWxP0t+dgs9p3gNrT1SHAd9TZ dT5vcoeiuO/Jq/IAsFieujc= X-Google-Smtp-Source: ABdhPJwmYpc9TEcV47PWOUUbisFcgskduL2L6nlnYlZH/hQG0qVGRL3+zTix+PrCha7mKeScBdPXNw== X-Received: by 2002:a05:6a00:1995:b0:4c5:eb10:c83d with SMTP id d21-20020a056a00199500b004c5eb10c83dmr11135520pfl.70.1642963323151; Sun, 23 Jan 2022 10:42:03 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id h14sm14431432pfh.95.2022.01.23.10.42.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:42:02 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Wei Liu , Dexuan Cui , linux-hyperv@vger.kernel.org Subject: [PATCH 43/54] drivers/hv: replace cpumask_weight with cpumask_weight_eq Date: Sun, 23 Jan 2022 10:39:14 -0800 Message-Id: <20220123183925.1052919-44-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" init_vp_index() calls cpumask_weight() to compare the weights of cpumasks We can do it more efficiently with cpumask_weight_eq because conditional cpumask_weight may stop traversing the cpumask earlier (at least one), as soon as condition is met. Signed-off-by: Yury Norov --- drivers/hv/channel_mgmt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c index 60375879612f..7420a5fd47b5 100644 --- a/drivers/hv/channel_mgmt.c +++ b/drivers/hv/channel_mgmt.c @@ -762,8 +762,8 @@ static void init_vp_index(struct vmbus_channel *channel) } alloced_mask =3D &hv_context.hv_numa_map[numa_node]; =20 - if (cpumask_weight(alloced_mask) =3D=3D - cpumask_weight(cpumask_of_node(numa_node))) { + if (cpumask_weight_eq(alloced_mask, + cpumask_weight(cpumask_of_node(numa_node)))) { /* * We have cycled through all the CPUs in the node; * reset the alloced map. --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 214FCC433F5 for ; Sun, 23 Jan 2022 18:43:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239696AbiAWSnQ (ORCPT ); Sun, 23 Jan 2022 13:43:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240141AbiAWSmH (ORCPT ); Sun, 23 Jan 2022 13:42:07 -0500 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C298C061788; Sun, 23 Jan 2022 10:42:07 -0800 (PST) Received: by mail-pl1-x630.google.com with SMTP id n8so13504407plc.3; Sun, 23 Jan 2022 10:42:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=1tLzjpnOADmNqLEv3y7RAP4vzyys1NFYghrGKziaABc=; b=khLdulZwVjToAAKsGPnVUTUcnSPw7gBK/gucAq2M+Jhnco/kZMbd3eY8aFWgX4ugKJ 7k+577Q/M58DQZd93gqoQYYcOYaxBVnkv5vFtyRh5jLDXRz4dHZ22XFzyvEzVigCqsfe KELEEKI+T+GTTCEDGx8gKeDamtVKHpIQ1xaCL6/PdkSahphjpKm9WIn49Og/34rufImJ hbjG0GfhOIvrGodBhGF98wMT4qBTUKamvsIMxxuN+3xpMeMpv8ToXjyI3NXBEEzJSmIP r5QQQNMMVWUxA35xSqj71hqMNWyUkUBFAjI9uGyb4qYvlskV5J++DcBZXbHJUMVaYtzp upKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1tLzjpnOADmNqLEv3y7RAP4vzyys1NFYghrGKziaABc=; b=XHyygYXuf0JfQ4PWT7N81cl7nfGypNcUQurFlg09zAlznNUGcY3Q59ucBos0uuj/lX AdsQVcyDOL+h8k/bfOICMckhJQ2ciuAPOyIKzMPpYUUETiUAeSUu3VL7k5wB1LLilsbB 4qLENV4Nafu7n6drOQ4MKNVYSL/GxntRelU0HagCSPxS336mt0nEKJKgCWyvrpVYaYJO SSL0dplUIfhtZ5CEQYddj5VIev2NVCEmxwhPJFG289UqTSHohifSFNKuoUaokq9OcWpH Tdteb46leda4hsNAuG/Aq0wpBUGtTS9zWyy9ax+UmiIhBS+c5wWmWVgLyaJh6Wk4o3/t 3UGg== X-Gm-Message-State: AOAM531/Dno9xEi59lHCy49aNifiLa2wtNJ4znYORISjKJQJP/Mub2tN 6qS1ff6Ha7oFoIx1+BpuTQE= X-Google-Smtp-Source: ABdhPJy02pmad9QwzHaMHfP8LQid/ly1qUr6qMXANtQBkQB6BCcJa3GDae9da0jqfsH81LIjOzFggg== X-Received: by 2002:a17:90b:3b46:: with SMTP id ot6mr9845312pjb.104.1642963326516; Sun, 23 Jan 2022 10:42:06 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id x12sm9977539pge.58.2022.01.23.10.42.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:42:06 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Mike Marciniszyn , Dennis Dalessandro , Jason Gunthorpe , linux-rdma@vger.kernel.org Subject: [PATCH 44/54] infiniband: replace cpumask_weight with cpumask_weight_{eq, ...} where appropriate Date: Sun, 23 Jan 2022 10:39:15 -0800 Message-Id: <20220123183925.1052919-45-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Infiniband code uses cpumask_weight() to compare the weight of cpumask with a given number. We can do it more efficiently with cpumask_weight_{eq, ...} because conditional cpumask_weight may stop traversing the cpumask earlier, as soon as condition is met. Signed-off-by: Yury Norov --- drivers/infiniband/hw/hfi1/affinity.c | 9 ++++----- drivers/infiniband/hw/qib/qib_file_ops.c | 2 +- drivers/infiniband/hw/qib/qib_iba7322.c | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/infiniband/hw/hfi1/affinity.c b/drivers/infiniband/hw/= hfi1/affinity.c index 38eee675369a..7c5ca5c5306a 100644 --- a/drivers/infiniband/hw/hfi1/affinity.c +++ b/drivers/infiniband/hw/hfi1/affinity.c @@ -507,7 +507,7 @@ static int _dev_comp_vect_cpu_mask_init(struct hfi1_dev= data *dd, * available CPUs divide it by the number of devices in the * local NUMA node. */ - if (cpumask_weight(&entry->comp_vect_mask) =3D=3D 1) { + if (cpumask_weight_eq(&entry->comp_vect_mask, 1)) { possible_cpus_comp_vect =3D 1; dd_dev_warn(dd, "Number of kernel receive queues is too large for completion vector= affinity to be effective\n"); @@ -593,7 +593,7 @@ int hfi1_dev_affinity_init(struct hfi1_devdata *dd) { struct hfi1_affinity_node *entry; const struct cpumask *local_mask; - int curr_cpu, possible, i, ret; + int curr_cpu, i, ret; bool new_entry =3D false; =20 local_mask =3D cpumask_of_node(dd->node); @@ -626,10 +626,9 @@ int hfi1_dev_affinity_init(struct hfi1_devdata *dd) local_mask); =20 /* fill in the receive list */ - possible =3D cpumask_weight(&entry->def_intr.mask); curr_cpu =3D cpumask_first(&entry->def_intr.mask); =20 - if (possible =3D=3D 1) { + if (cpumask_weight_eq(&entry->def_intr.mask, 1)) { /* only one CPU, everyone will use it */ cpumask_set_cpu(curr_cpu, &entry->rcv_intr.mask); cpumask_set_cpu(curr_cpu, &entry->general_intr_mask); @@ -1017,7 +1016,7 @@ int hfi1_get_proc_affinity(int node) cpu =3D cpumask_first(proc_mask); cpumask_set_cpu(cpu, &set->used); goto done; - } else if (current->nr_cpus_allowed < cpumask_weight(&set->mask)) { + } else if (cpumask_weight_gt(&set->mask, current->nr_cpus_allowed)) { hfi1_cdbg(PROC, "PID %u %s affinity set to CPU set(s) %*pbl", current->pid, current->comm, cpumask_pr_args(proc_mask)); diff --git a/drivers/infiniband/hw/qib/qib_file_ops.c b/drivers/infiniband/= hw/qib/qib_file_ops.c index aa290928cf96..add89bc21b0a 100644 --- a/drivers/infiniband/hw/qib/qib_file_ops.c +++ b/drivers/infiniband/hw/qib/qib_file_ops.c @@ -1151,7 +1151,7 @@ static void assign_ctxt_affinity(struct file *fp, str= uct qib_devdata *dd) * reserve a processor for it on the local NUMA node. */ if ((weight >=3D qib_cpulist_count) && - (cpumask_weight(local_mask) <=3D qib_cpulist_count)) { + (cpumask_weight_le(local_mask, qib_cpulist_count))) { for_each_cpu(local_cpu, local_mask) if (!test_and_set_bit(local_cpu, qib_cpulist)) { fd->rec_cpu_num =3D local_cpu; diff --git a/drivers/infiniband/hw/qib/qib_iba7322.c b/drivers/infiniband/h= w/qib/qib_iba7322.c index ceed302cf6a0..b17f96509d2c 100644 --- a/drivers/infiniband/hw/qib/qib_iba7322.c +++ b/drivers/infiniband/hw/qib/qib_iba7322.c @@ -3405,7 +3405,7 @@ static void qib_setup_7322_interrupt(struct qib_devda= ta *dd, int clearpend) local_mask =3D cpumask_of_pcibus(dd->pcidev->bus); firstcpu =3D cpumask_first(local_mask); if (firstcpu >=3D nr_cpu_ids || - cpumask_weight(local_mask) =3D=3D num_online_cpus()) { + cpumask_weight_eq(local_mask, num_online_cpus())) { local_mask =3D topology_core_cpumask(0); firstcpu =3D cpumask_first(local_mask); } --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C408C433EF for ; Sun, 23 Jan 2022 18:43:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240392AbiAWSnV (ORCPT ); Sun, 23 Jan 2022 13:43:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239954AbiAWSmK (ORCPT ); Sun, 23 Jan 2022 13:42:10 -0500 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22CDDC06173B; Sun, 23 Jan 2022 10:42:10 -0800 (PST) Received: by mail-pj1-x102c.google.com with SMTP id d15-20020a17090a110f00b001b4e7d27474so14270046pja.2; Sun, 23 Jan 2022 10:42:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=GndtSn11kZKp8gPiAnYtAF0D1ExNO7oxGiuzzMjH66E=; b=BCY8BFgQYJuoXKOVV9p7rADrcLbaR8XwOD2oDh49UsHvgwjsHzRqmVsA58kTvbMC52 8JK4BMrp4oZfp3fXguYb/3lGTDBa79/2a2dIP0EYqWSBlrHq6Q1+lWRisPqcd8kiwU0n NPAE97Kv0/tSwl1szc7CNNNEDeP3vnAGePfb1sRIXNHsvVq//ZdFKZvSrgBsOfnP584S XvRmz/4ORGJRhEHl2lHJCyNgfxlXqpkwXextNWwwAIASqn5NxAhQPNubJtagwZsHxm8g v/3WdP4q4IDpdGmg4yIOJm3LL/ymjzOiEu9TOP39Q8wNTbN+vnWyGAj8b/VaQE3Hwxm5 JWYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GndtSn11kZKp8gPiAnYtAF0D1ExNO7oxGiuzzMjH66E=; b=PAH95OcIOJauGinXVTdq3le7/k+ZaeU8AHRhsVmPawHQVJu3i1+K6VUZbi/hzXvqYM ZNpPYRN+ELCzqX7vNJ17I8G1NX3uODS8f0S713Q2wZMO5D9Jq+wWARwStJE0eL6XWOWO JnLb8wrynFEJlxdVBd/Khve57orDBpSR1ClrlSd2zACrUVdLwOXghoXCySLNMVLJ65oa Ye0LnD9vNHNs7GsIGKYWtlAHIcxKPxWD7RQkV2yKUSAAvOxIjviI+ABcSFST81W7DkhU dPddtS43vAA0MJV4m+lG2G7s/NREEnWpOsvPTlUPEiC/QRpDZpl7iuNzzDOIvYp5Y/6I VZig== X-Gm-Message-State: AOAM533Ey+Ojucb3IXUvOW0kP3ZyH+g5WRSmz8DLOVIooKVfIomYhhRk 7KwiTv5vXH3cs8aeenStDLk= X-Google-Smtp-Source: ABdhPJw+B3WUB7yJ66uYnzJyrxSdBb4KzZWDTZMEioY+/QPO87Cj291gr3eP/fRZPxVluYuKiQlMrA== X-Received: by 2002:a17:90a:7101:: with SMTP id h1mr9564886pjk.93.1642963329571; Sun, 23 Jan 2022 10:42:09 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id c8sm14352243pfl.122.2022.01.23.10.42.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:42:09 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, James Smart , Dick Kennedy , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org Subject: [PATCH 45/54] scsi: replace cpumask_weight with cpumask_weight_gt Date: Sun, 23 Jan 2022 10:39:16 -0800 Message-Id: <20220123183925.1052919-46-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" lpfc_cpuhp_get_eq() calls cpumask_weight() to compare the weight of cpumask with a given number. We can do it more efficiently with cpumask_weight_gt because conditional cpumask_weight may stop traversing the cpumask earlier, as soon as condition is met. Signed-off-by: Yury Norov --- drivers/scsi/lpfc/lpfc_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index a56f01f659f8..325e9004dacd 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -12643,7 +12643,7 @@ lpfc_cpuhp_get_eq(struct lpfc_hba *phba, unsigned i= nt cpu, * gone offline yet, we need >1. */ cpumask_and(tmp, maskp, cpu_online_mask); - if (cpumask_weight(tmp) > 1) + if (cpumask_weight_gt(tmp, 1)) continue; =20 /* Now that we have an irq to shutdown, get the eq --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 002BFC433F5 for ; Sun, 23 Jan 2022 18:43:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239996AbiAWSnZ (ORCPT ); Sun, 23 Jan 2022 13:43:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239814AbiAWSmN (ORCPT ); Sun, 23 Jan 2022 13:42:13 -0500 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E887C061744 for ; Sun, 23 Jan 2022 10:42:13 -0800 (PST) Received: by mail-pl1-x633.google.com with SMTP id c3so13491565pls.5 for ; Sun, 23 Jan 2022 10:42:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=VqjN8AVE4l1jGj4WKwwteMJXfvhHCp8LxE1b5uVHyhI=; b=C1SMT8g72QpJmf2bGBlHtrMJyAm02anZRdJPiD2hXPa8KnxyJmdZw8KHlGAX0+WQGc BZHWyBl2a5DTg8aenBofL3Pa+LSa4prxrtnLXqzJa+qJVVLWS9YDxbbC4POYvOHztAqw IyapelEZ/75WdLGC84xm+UEAL5Cev9xJG06mFRsDSpCKQLMoLxgo8eFVJQqILZ1wkvcj /C5aH5KAaWIXgqOmeQebx/JlfxVpZJzkpasVbNS7lD3Xygu7Dq/lNJpvZKtbbQBFVMYy bxtmSmEeLKDAfMNUeFJyK+ebz4bFvez0SDfycUa2ySgs5dFSDYB8Y/ANERmbRLt77Z2M N4zA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VqjN8AVE4l1jGj4WKwwteMJXfvhHCp8LxE1b5uVHyhI=; b=4uq1Ag+v3dGH+lR9nb8OAPfr+lcbzlMUyshvu+9vF26rkhVSBRTc7f7pH+qRT+XD3P eW7rTdiOB4GBBcXhHEEI/uvDSm45Q+hyebvc7b154bihpm71AZpHsoBQYoJPkQeyyuVt KY0uSobdB7BFSj/C+ti97M0px1cFuwjPQbH05vSINVTqwW2GK1KRmE/KNot/4OpfytK4 irRutd5RLT4ZC4NLGLOpZLYA0B+lDpQnK3dMjtYPdcmIlGl0QOmcEgIUjyZaaV/PJcQ9 Co/mZBdqgBO8Q2fGCYL0/iwgzb2uEUNbqfL5OAFeq2dwuQ2CQD+vLdBod5i6+e1OTcqg VewA== X-Gm-Message-State: AOAM530CC+y0P8quG1rNTlmcQziVWkGmkGo7HL0EJqU3wzB985Qt/5mK lzahlK0fa3ymtdM9rT+k+N8= X-Google-Smtp-Source: ABdhPJyR3LEGx3dQjXbO/uCCX9t/QjIgjrhqlzEDELiIFsGeBhAD2N532FLMhxMOd5s6FzXSuCmH2g== X-Received: by 2002:a17:902:d883:b0:14a:4ba5:6e72 with SMTP id b3-20020a170902d88300b0014a4ba56e72mr12062149plz.27.1642963332593; Sun, 23 Jan 2022 10:42:12 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id q140sm10315902pgq.7.2022.01.23.10.42.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:42:12 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Li Yang , linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 46/54] soc: replace cpumask_weight with cpumask_weight_lt Date: Sun, 23 Jan 2022 10:39:17 -0800 Message-Id: <20220123183925.1052919-47-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" qman_test_stash() calls cpumask_weight() to compare the weight of cpumask with a given number. We can do it more efficiently with cpumask_weight_lt because conditional cpumask_weight may stop traversing the cpumask earlier, as soon as condition is met. Signed-off-by: Yury Norov --- drivers/soc/fsl/qbman/qman_test_stash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/soc/fsl/qbman/qman_test_stash.c b/drivers/soc/fsl/qbma= n/qman_test_stash.c index b7e8e5ec884c..28b08568a349 100644 --- a/drivers/soc/fsl/qbman/qman_test_stash.c +++ b/drivers/soc/fsl/qbman/qman_test_stash.c @@ -561,7 +561,7 @@ int qman_test_stash(void) { int err; =20 - if (cpumask_weight(cpu_online_mask) < 2) { + if (cpumask_weight_lt(cpu_online_mask, 2)) { pr_info("%s(): skip - only 1 CPU\n", __func__); return 0; } --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0EAF2C4332F for ; Sun, 23 Jan 2022 18:43:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239980AbiAWSnY (ORCPT ); Sun, 23 Jan 2022 13:43:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234791AbiAWSmQ (ORCPT ); Sun, 23 Jan 2022 13:42:16 -0500 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17971C06175C for ; Sun, 23 Jan 2022 10:42:16 -0800 (PST) Received: by mail-pl1-x631.google.com with SMTP id j16so2930422plx.4 for ; Sun, 23 Jan 2022 10:42:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=yBVTc0LoZqur4BtqWgAdcYwOfT8OtJjDGCNTNKx2gqc=; b=BpTXbSran70GJvWk28mflzE3lOWqBzL9WlsOPmyujYXLky3/zviqDe6o9eB402S4S/ V3BnWpazygS/UkW7qo7GNtpMVydp5uYemx8V6egaZqakcdxd9l4GIk7VYR9ux5lLCsnF O83Uk7z0WfZlgm2+AXjRQVfmRoqihYzoD8ye2B29+Mfj6INENzwW3GybQLMLgDFxF5F2 +/MWhDu3yUulDDeraRVcOukdPtfeisksDDO+cbnLBpsHbyNxM9zDDn2lSf4iXd0/VCZ+ gFP9iGGvINdI4UKIyi0fywypj0BQCrPQfDN/23G3H+6xKIRZFpDr4RnVni5pEFL8FPo4 URug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yBVTc0LoZqur4BtqWgAdcYwOfT8OtJjDGCNTNKx2gqc=; b=cfxb9Ys1k4w3RiO5qqylazz5exKni3zh8eAuDssuExsDQAiwwF61oDQcrCRNL2GNZ7 Dr2X4tl2klYuSK+Wl2vaEVLkgw/bpW1RYGdI/nzvDEm4h7lZNRCU0QNlrC905JCv0Zvl cMbmKc5+sMFpHBmd3mVua2RTBBq7qA4ZwfdUZzJbmQ0SILrDYoR9AZ/HZLdQrBHTRLQv sbEVO3Z8IVybagsZKZFDmkxAQRHzQg2MznjPNGhkua5T6mSxdTKVoZ7k2xOmAbMUVnsK RpUulUS/ZORf7ivm+NczlEF4TN3NFQ/6Tzk0u1+S9Bj2j36OAN07W9k9VY8mVirAUNeL olGw== X-Gm-Message-State: AOAM533n3u6+4UsR5+W8gpD97xkDUEf7qWbyp5kmrC+5tuA+6C2e4i6+ QuisoIUFxtSQKmzgAKxjTjI= X-Google-Smtp-Source: ABdhPJywhYuhKLgnMzPTf9A7fvWBjv4S4zdCMWrco5pL1xBowXW5LN4ta8sRs0d4CAHiU3t6zZJvYw== X-Received: by 2002:a17:90a:5210:: with SMTP id v16mr9917205pjh.107.1642963335556; Sun, 23 Jan 2022 10:42:15 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id x7sm13943517pfh.178.2022.01.23.10.42.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:42:15 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Ingo Molnar , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira Subject: [PATCH 47/54] sched: replace cpumask_weight with cpumask_weight_eq where appropriate Date: Sun, 23 Jan 2022 10:39:18 -0800 Message-Id: <20220123183925.1052919-48-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" kernel/sched code uses cpumask_weight() to compare the weight of cpumask with a given number. We can do it more efficiently with cpumask_weight_eq because conditional cpumask_weight may stop traversing the cpumask earlier, as soon as condition is met. Signed-off-by: Yury Norov --- kernel/sched/core.c | 8 ++++---- kernel/sched/topology.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 918d0bdc2ea8..7494f51a3608 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -6006,7 +6006,7 @@ static void sched_core_cpu_starting(unsigned int cpu) WARN_ON_ONCE(rq->core !=3D rq); =20 /* if we're the first, we'll be our own leader */ - if (cpumask_weight(smt_mask) =3D=3D 1) + if (cpumask_weight_eq(smt_mask, 1)) goto unlock; =20 /* find the leader */ @@ -6047,7 +6047,7 @@ static void sched_core_cpu_deactivate(unsigned int cp= u) sched_core_lock(cpu, &flags); =20 /* if we're the last man standing, nothing to do */ - if (cpumask_weight(smt_mask) =3D=3D 1) { + if (cpumask_weight_eq(smt_mask, 1)) { WARN_ON_ONCE(rq->core !=3D rq); goto unlock; } @@ -9045,7 +9045,7 @@ int sched_cpu_activate(unsigned int cpu) /* * When going up, increment the number of cores with SMT present. */ - if (cpumask_weight(cpu_smt_mask(cpu)) =3D=3D 2) + if (cpumask_weight_eq(cpu_smt_mask(cpu), 2)) static_branch_inc_cpuslocked(&sched_smt_present); #endif set_cpu_active(cpu, true); @@ -9120,7 +9120,7 @@ int sched_cpu_deactivate(unsigned int cpu) /* * When going down, decrement the number of cores with SMT present. */ - if (cpumask_weight(cpu_smt_mask(cpu)) =3D=3D 2) + if (cpumask_weight_eq(cpu_smt_mask(cpu), 2)) static_branch_dec_cpuslocked(&sched_smt_present); =20 sched_core_cpu_deactivate(cpu); diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c index 8478e2a8cd65..79395571599f 100644 --- a/kernel/sched/topology.c +++ b/kernel/sched/topology.c @@ -169,7 +169,7 @@ static const unsigned int SD_DEGENERATE_GROUPS_MASK =3D =20 static int sd_degenerate(struct sched_domain *sd) { - if (cpumask_weight(sched_domain_span(sd)) =3D=3D 1) + if (cpumask_weight_eq(sched_domain_span(sd), 1)) return 1; =20 /* Following flags need at least 2 groups */ --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A57C6C433F5 for ; Sun, 23 Jan 2022 18:43:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229955AbiAWSnf (ORCPT ); Sun, 23 Jan 2022 13:43:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240003AbiAWSmT (ORCPT ); Sun, 23 Jan 2022 13:42:19 -0500 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CAB6C061778 for ; Sun, 23 Jan 2022 10:42:19 -0800 (PST) Received: by mail-pl1-x632.google.com with SMTP id e8so13482292plh.8 for ; Sun, 23 Jan 2022 10:42:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=JZIbGsK4fO2MmYeZQFtgL2Ya3fsLijV0bZeyyLWVcBo=; b=aUu0ISOJcNHam1D3Deq4AyVkQoVeIW2t7/+xoxukqRlijxKAKMOj78cgt43a/ei4O1 0qBwFjn+P6QLJr2+wKvS0EcKSrQg6mt4PFWodNwqKDPeWfCi7wYI9gfBVe+HOIF5Zemp NPKMnKGkp9WLy3q9OJBIgUBz1KG4/Z7f9evOvF/91Tn1lI8xKoTxnDJN/Z2rWXDXZUem IxaPj5p1F0DqYX3yqlJtl6mqNMsfUy+eDzlRKccIkzih5UbyroeukBtDgkxOfC53IOj/ EBud2UhpLrJCkoFjjwbO78ukwiewlbuiEN7ns5yFjwfeHMFIpRAS9HSkDzA9klQeap9d TqqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JZIbGsK4fO2MmYeZQFtgL2Ya3fsLijV0bZeyyLWVcBo=; b=2iOlMzA3a7PG/P3ub2yI/178aETmYaKxUAPGqiLdVIFNkc9dptabWW5GwQueP74lcb 1z4y+bvpDEnHGvAdgpkIZhKFcW3nHQNaHoVn97qeQi4GN5AN3KLe/raNdW+f0FHf3LlS 41hFeZlZD4zzngnCJ6cvnSFwTZlVJtWSkKto1PyVRh4Pocb5yGElPbymBbFbrFB3KqpD neWNej56RNXmFtYRaWjr8KFxPSJmRH/Us7uJFeyjhDf0qInlb+UfgGiT2dkA8S5IR8Jr tEaklXD3DQTQgwQnl1hlG4nQzyD8NIYjXB6GllkJLbFtsDUsXIoEEtKVrGLJLSKzaNwC HzVA== X-Gm-Message-State: AOAM530NWWBLAxfJFNnySgVmUA0M2aLvLPZhYM1uIZGaZCqEjO2yIDPu nGpwYvn56BJYcsfT5I4wqT4= X-Google-Smtp-Source: ABdhPJxZyVaSdm8qfd0Lxd4g15OkNroNLz6HGWoPVFx+Xofe/zxCaNgOOfWpiOJzDf8cAIJOPuRTJw== X-Received: by 2002:a17:902:f243:b0:14b:1f32:e923 with SMTP id j3-20020a170902f24300b0014b1f32e923mr6194383plc.121.1642963338768; Sun, 23 Jan 2022 10:42:18 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id s2sm170778pgq.38.2022.01.23.10.42.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:42:18 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Thomas Gleixner Subject: [PATCH 48/54] kernel/time: replace cpumask_weight with cpumask_weight_eq where appropriate Date: Sun, 23 Jan 2022 10:39:19 -0800 Message-Id: <20220123183925.1052919-49-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" tick_cleanup_dead_cpu() calls cpumask_weight() to compare the weight of cpumask with a given number. We can do it more efficiently with cpumask_weight_eq() because conditional cpumask_weight may stop traversing the cpumask earlier, as soon as condition is met. Signed-off-by: Yury Norov --- kernel/time/clockevents.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c index 003ccf338d20..32d6629a55b2 100644 --- a/kernel/time/clockevents.c +++ b/kernel/time/clockevents.c @@ -648,7 +648,7 @@ void tick_cleanup_dead_cpu(int cpu) */ list_for_each_entry_safe(dev, tmp, &clockevent_devices, list) { if (cpumask_test_cpu(cpu, dev->cpumask) && - cpumask_weight(dev->cpumask) =3D=3D 1 && + cpumask_weight_eq(dev->cpumask, 1) && !tick_is_broadcast_device(dev)) { BUG_ON(!clockevent_state_detached(dev)); list_del(&dev->list); --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 740C7C433F5 for ; Sun, 23 Jan 2022 18:43:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234819AbiAWSnk (ORCPT ); Sun, 23 Jan 2022 13:43:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240144AbiAWSmW (ORCPT ); Sun, 23 Jan 2022 13:42:22 -0500 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43E7EC06177D for ; Sun, 23 Jan 2022 10:42:22 -0800 (PST) Received: by mail-pg1-x52f.google.com with SMTP id f8so13146029pgf.8 for ; Sun, 23 Jan 2022 10:42:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=uDMwxBm35O7PZhXWiy5lbRAhZckr6GgPEF1IMYcAF1M=; b=AixtNyS6WzA9hFKoRzjQ/Nln9Z2IsXf6Y7NSR+XlTdqyMMHMuAB2etyp7oOq8QIS23 I5NqfG9LyPILw33K6lCPHGVtIDK4NaLmU8fQWqww30sYGKnx4PDt2aONbX5UMEU/mjhK E5zU6vYPgyNaxyMP8vXWHhTZDlaFuVqn8hGiPFJVtl9dQ0ESYF0VTL6Vxsn/otIIcGMK E7/QKttkC07gwR/Qm+a1n0sYX+y6sr6KITS56A52HAQbBPTaaKjVm1pCgLoux+lxSUVG 63OBKz1TY9QXGAeTU5Oc1lyh/nXKFNj9zmcsV3DXXO8Acedl7zi7fw1xhVcB0FNayCMQ C5KQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uDMwxBm35O7PZhXWiy5lbRAhZckr6GgPEF1IMYcAF1M=; b=AgxYpJbsrRJaEszSfi7aubXIVvoBCYFrzDTgOidKgQKF5NiOog/kJkIYMxCshDy/Gp nONoYjnT6ONOmeND/1+2FZ/TWNP2fmqKfsL56vLNjUZSs6gSoQgOpPLX2NPoLzOa+p3y ZfQU0oanT9B4ja1fZ2sX62e/XsRpWcmv3VYEDyKXcsXRZlt8KRtn4oMQTjAS6OF0J1+k xUxJocX6BBpVG3kfIWIgG97gT3UB2Lmif/vLgf/4q4vrOyfxV6Dp5ZRLMXA8hL3LlWIR YojhQU9tqZ1EEb0+BdhI8ZdL18ztW7mXz9I9ZNi+xSRasuW5jRPFvWLUxsZbk3RZcpye GwPA== X-Gm-Message-State: AOAM533/YIWOpehAlDRKoys2lQlY5L+g0mhuUWMAj+icD95VuV13x7jv 7frnozPf9Dw5vRaBfojEuHI= X-Google-Smtp-Source: ABdhPJwG05qeKKcQ0O7Z3UZL5849JmNqnV5VItZoESEHKIuMkhNSWZnyxQj1pjU7UR1Wcc2s8yUkKQ== X-Received: by 2002:aa7:804c:0:b0:4bc:6ca6:4bac with SMTP id y12-20020aa7804c000000b004bc6ca64bacmr11151360pfm.52.1642963341772; Sun, 23 Jan 2022 10:42:21 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id q9sm13269180pfj.113.2022.01.23.10.42.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:42:21 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org Subject: [PATCH 49/54] lib/nodemask: add nodemask_weight_{eq,gt,ge,lt,le} Date: Sun, 23 Jan 2022 10:39:20 -0800 Message-Id: <20220123183925.1052919-50-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" In many cases kernel code uses nodemask_weight() to compare the result against some number or expression: if (nodes_weight(...) > 1) do_something(); It may be significantly improved for large nodemasks: if first few words count set bits to a number greater than given, we can stop counting and immediately return. The same idea would work in other direction: if we know that the number of set bits that we counted so far is small enough, so that it would be smaller than required number even if all bits of the rest of the nodemask are set, we can stop counting earlier. This patch adds nodes_weight{eq, gt, ge, lt, le} helpers based on corresponding bitmap functions. The following patches apply new functions where appropriate. Signed-off-by: Yury Norov --- include/linux/nodemask.h | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/include/linux/nodemask.h b/include/linux/nodemask.h index 567c3ddba2c4..197598e075e9 100644 --- a/include/linux/nodemask.h +++ b/include/linux/nodemask.h @@ -38,6 +38,11 @@ * int nodes_empty(mask) Is mask empty (no bits sets)? * int nodes_full(mask) Is mask full (all bits sets)? * int nodes_weight(mask) Hamming weight - number of set bits + * bool nodes_weight_eq(src, nbits, num) Hamming Weight is equal to num + * bool nodes_weight_gt(src, nbits, num) Hamming Weight is greater than num + * bool nodes_weight_ge(src, nbits, num) Hamming Weight is greater than or= equal to num + * bool nodes_weight_lt(src, nbits, num) Hamming Weight is less than num + * bool nodes_weight_le(src, nbits, num) Hamming Weight is less than or eq= ual to num * * void nodes_shift_right(dst, src, n) Shift right * void nodes_shift_left(dst, src, n) Shift left @@ -240,6 +245,36 @@ static inline int __nodes_weight(const nodemask_t *src= p, unsigned int nbits) return bitmap_weight(srcp->bits, nbits); } =20 +#define nodes_weight_eq(nodemask, num) __nodes_weight_eq(&(nodemask), MAX_= NUMNODES, (num)) +static inline int __nodes_weight_eq(const nodemask_t *srcp, unsigned int n= bits, int num) +{ + return bitmap_weight_eq(srcp->bits, nbits, num); +} + +#define nodes_weight_gt(nodemask, num) __nodes_weight_gt(&(nodemask), MAX_= NUMNODES, (num)) +static inline int __nodes_weight_gt(const nodemask_t *srcp, unsigned int n= bits, int num) +{ + return bitmap_weight_gt(srcp->bits, nbits, num); +} + +#define nodes_weight_ge(nodemask, num) __nodes_weight_ge(&(nodemask), MAX_= NUMNODES, (num)) +static inline int __nodes_weight_ge(const nodemask_t *srcp, unsigned int n= bits, int num) +{ + return bitmap_weight_ge(srcp->bits, nbits, num); +} + +#define nodes_weight_lt(nodemask, num) __nodes_weight_lt(&(nodemask), MAX_= NUMNODES, (num)) +static inline int __nodes_weight_lt(const nodemask_t *srcp, unsigned int n= bits, int num) +{ + return bitmap_weight_lt(srcp->bits, nbits, num); +} + +#define nodes_weight_le(nodemask, num) __nodes_weight_le(&(nodemask), MAX_= NUMNODES, (num)) +static inline int __nodes_weight_le(const nodemask_t *srcp, unsigned int n= bits, int num) +{ + return bitmap_weight_le(srcp->bits, nbits, num); +} + #define nodes_shift_right(dst, src, n) \ __nodes_shift_right(&(dst), &(src), (n), MAX_NUMNODES) static inline void __nodes_shift_right(nodemask_t *dstp, --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7571C433F5 for ; Sun, 23 Jan 2022 18:43:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240005AbiAWSnm (ORCPT ); Sun, 23 Jan 2022 13:43:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240176AbiAWSm0 (ORCPT ); Sun, 23 Jan 2022 13:42:26 -0500 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB8A6C06178C; Sun, 23 Jan 2022 10:42:25 -0800 (PST) Received: by mail-pj1-x1032.google.com with SMTP id h12so14115127pjq.3; Sun, 23 Jan 2022 10:42:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Hn/0KEFQM0VohxFbDN7o+rKVell2I9YQDMnO10ziuwg=; b=RLWSVVHhK5sS0VJoSJh5qzr3kvxFKZMIuqha6nZABD5yiUFV891TsT6pr+BuRKkmau Jr3NQlJfn60hdMW9oRHukDxgvDsry86rj7D7fDQ8hAMfFCHdYoGZ3xOOJS3VxiMXiCQN WnJ2HgK8tLMAJO17kJRpJTZd8jvdJSm4IT9rLQFWHGLA0yOqUkzDIoW/kt5NFH+HADLb 2tR+oOK30YBZYNgEdS7t6hR2kTpNLr7opXgJIUR7uT0EagLXFCDKhdsJMzGULlhJQXBq ZXbfYZZn9gq9VNQqPhfrLOtLeJu+QgAk81hoKa+JbgquZkSqgiXO36WP2fNwoKI4MuU2 KYWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Hn/0KEFQM0VohxFbDN7o+rKVell2I9YQDMnO10ziuwg=; b=MSgXdiFbGidJlosx3rJr7JXboPggUaQHjtMgqcsl7i6senjOutUDPb9oBHxo+6JgIQ H11FbGozgpng2VkNraxPovYXwoYvNSkW7GdB3qghaBKp+seZu2QysfrlYOsnbN5gBD+Z uebO/kyX55F2cQFtAQQ/4MJgw8HjhN4DCv+DziRRfxSycp54DPOqM/a7u0bzYe2dsrsU leZ5ARobQchDk8y9nSc4u5kDwr+e1LxCH9UFx9AgppBzNXAOxrxBtrytfBg0p13gE1UO Fxh9EnloBvgd7BmsDqUjOZeFjXp7lj0W4OejHPyO3hmBG85JksGB/37WGlEl0Kfk1m/H VEWw== X-Gm-Message-State: AOAM531ZkzSLhilAQgoHg8Z6fs5zCzqzqZmrxFXqvN1oZDOvTynwNqw6 50MnPZN3wDXZauCRO7Bi1/T6LhPNV78= X-Google-Smtp-Source: ABdhPJyBszq+12k1TYVOUS+HW7O6m3uyaICRkRGYjMlRMdlMz+xzwmFYZQSU4jgwO4Co8mlvCOHd+Q== X-Received: by 2002:a17:902:9a83:b0:14a:a893:f7ff with SMTP id w3-20020a1709029a8300b0014aa893f7ffmr11718191plp.6.1642963345210; Sun, 23 Jan 2022 10:42:25 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id ck21sm10634905pjb.51.2022.01.23.10.42.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:42:24 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, "Rafael J. Wysocki" , Len Brown , Dan Williams , Huacai Chen , Vitaly Kuznetsov , Alison Schofield , linux-acpi@vger.kernel.org Subject: [PATCH 50/54] acpi: replace nodes__weight with nodes_weight_ge for numa Date: Sun, 23 Jan 2022 10:39:21 -0800 Message-Id: <20220123183925.1052919-51-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" acpi_map_pxm_to_node() calls nodes_weight() to compare the weight of nodemask with a given number. We can do it more efficiently with nodes_weight_eq() because conditional nodes_weight may stop traversing the nodemask earlier, as soon as condition is met. Signed-off-by: Yury Norov --- drivers/acpi/numa/srat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/acpi/numa/srat.c b/drivers/acpi/numa/srat.c index 3b818ab186be..fe7a7996f553 100644 --- a/drivers/acpi/numa/srat.c +++ b/drivers/acpi/numa/srat.c @@ -67,7 +67,7 @@ int acpi_map_pxm_to_node(int pxm) node =3D pxm_to_node_map[pxm]; =20 if (node =3D=3D NUMA_NO_NODE) { - if (nodes_weight(nodes_found_map) >=3D MAX_NUMNODES) + if (nodes_weight_ge(nodes_found_map, MAX_NUMNODES)) return NUMA_NO_NODE; node =3D first_unset_node(nodes_found_map); __acpi_map_pxm_to_node(pxm, node); --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AC6BAC433EF for ; Sun, 23 Jan 2022 18:43:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240490AbiAWSnp (ORCPT ); Sun, 23 Jan 2022 13:43:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239859AbiAWSm2 (ORCPT ); Sun, 23 Jan 2022 13:42:28 -0500 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4D86C06176F for ; Sun, 23 Jan 2022 10:42:28 -0800 (PST) Received: by mail-pg1-x533.google.com with SMTP id t32so13141428pgm.7 for ; Sun, 23 Jan 2022 10:42:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Ouatn2R2XSrlqBb/cl6QBZlhDkWXWZjR0T2HBFMF8GM=; b=Pg+6hPzMUrdJ2L0XacgOuQCKjl4jmD1DkA4Uft+PyFR3TG54sPD+Vgh5++LQcbqVcV ylxUcOCGkUe7IWVmwD2RuZYGjfzClUYynm95FBXzxuFGgIkfqk4jW7AKoYK9A5FUGhuJ sVukEpWtFRuWctbRULsmwXelbY2fsOOfcIhFUJjs+cBsQM+cs6jGbbA2cbh5zVnDfKsu k9dmhPbTZOq7mJM6vn095szshkPUxZNrubKcCMQxWn/W19NNa79wsYTpwCY8ol+XoPgt 7DPidvWsROJ378WbseEcbhSy28SO0NcPuyDD1CYAhMjsFte3s3JcqDUnJ8tRB7EuhjY0 8hWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ouatn2R2XSrlqBb/cl6QBZlhDkWXWZjR0T2HBFMF8GM=; b=dJf9cQKgKHEhxy1XkjJrcmb45OMUk1cdwFSfOwjg7B/vP2vAZz739zfpYYvGJBuQRO WhVW0SwHHBJMtgRAXVBep/M4CVr7C6x1CMJo8rtPsrugtX00QSzmQqO+ao8cWPt+dQnI QRG63a+GfITZnuZdQZt92uURV8bHG/X2baSZRtwRVN97Au8IoGy4YTtqeceCOs/uIiU3 Tccb2ATFZTHehPYEZA+dRmZR0sx9RS7weUF7/MGuqV+DxOCEluXQob6ZQItftQkODhIu E89P17KSxIQc9Xt+WlEUSstX+DOBVX73Uxk8wYFXg7QmNLGGBCH/MBGjb0WyLtQph8n1 6E0w== X-Gm-Message-State: AOAM5321czyqHUTX5IaHMfRarCq8fxPxfB+q7W9KRmfP7xguSUKGwfjh i8lYtIKcK2yZbxY59TZo6Kk= X-Google-Smtp-Source: ABdhPJy0WTtp3rHcuax4YIT+LcH4DXFc3zkfPiLxk2xJ70kkMzrkhq/X13/68EEM7x8rgLqZZjwFPg== X-Received: by 2002:a63:b34c:: with SMTP id x12mr9392573pgt.541.1642963348406; Sun, 23 Jan 2022 10:42:28 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id y20sm2328066pfi.78.2022.01.23.10.42.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:42:28 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 51/54] mm: replace nodes_weight with nodes_weight_eq in mempolicy Date: Sun, 23 Jan 2022 10:39:22 -0800 Message-Id: <20220123183925.1052919-52-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" do_migrate_pages() calls nodes_weight() to compare the weight of nodemask with a given number. We can do it more efficiently with nodes_weight_eq() because conditional nodes_weight() may stop traversing the nodemask earlier, as soon as condition is met. Signed-off-by: Yury Norov --- mm/mempolicy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index a86590b2507d..27817cf2f2a0 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -1157,7 +1157,7 @@ int do_migrate_pages(struct mm_struct *mm, const node= mask_t *from, * [0-7] - > [3,4,5] moves only 0,1,2,6,7. */ =20 - if ((nodes_weight(*from) !=3D nodes_weight(*to)) && + if (!nodes_weight_eq(*from, nodes_weight(*to)) && (node_isset(s, *to))) continue; =20 --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5B6EC433F5 for ; Sun, 23 Jan 2022 18:43:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240191AbiAWSnt (ORCPT ); Sun, 23 Jan 2022 13:43:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240047AbiAWSmc (ORCPT ); Sun, 23 Jan 2022 13:42:32 -0500 Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D508BC061794 for ; Sun, 23 Jan 2022 10:42:31 -0800 (PST) Received: by mail-pf1-x42e.google.com with SMTP id e28so9334233pfj.5 for ; Sun, 23 Jan 2022 10:42:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=85CEHLzivVSDPv5NoUUHMFbNwsVpSDhXVe4Dokl88jA=; b=UzLV4ACAW1Zy650aoKKKtti7eIYU39SU4smwBi6B3avNAIj+XR/PLCLBZK7l8VFZGd GOy2eGmfswc9be1FqLvOFJQ9k4AveCVBGC9efdwLQ/Ntp/+55BTmI5Wx6A1/VNWY4rKL f//7wEMw7b/7dWk9eXodLjfhTVgj7bWk//YBPIJptJPcK7+kqhioGoP0gZtSiBe9mT8Q FUrvSqGgkNljkIUpAVSAm6jqntWWFFJ8C7/aXlmsCAywzSh7xfUTuxF6RBVnzcyq6J8S bOkE/gKUxJf09SuXz0WQHQ6tjK3FC8HTY4bDHghjLZ6GOodD8DCQuZWaqY4aPyB0qjfg Zf3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=85CEHLzivVSDPv5NoUUHMFbNwsVpSDhXVe4Dokl88jA=; b=7iv2NlAonKsZJiw2KZI5EroDG4mx4fGxfwJZGEQDL5uX8o8C4iN4KaHU9YCBmfoktu p2MYfSyVhkCfJf2NizGVBtr5/rSYnS2aqYQZjFKobwg9puwuhooOZFSRGmLijqi3v7rZ cAn69EhxErqSgz42gQCXQyj2qoeIo1tlZDv2omdpTDdFHzTCv73DlWidJaYHj6RuCbDN gYsTA2zVnrnp7iCezlfroGkXm9FMDXC8mXNSqCLKOSEraZZC4N418uL/1OFUyRwzyLEn 1lhmChvBD216LBa2jZz5S7S4O7e4YbL34/pemearvf7uVPRKHCXjtvbFV5UNCFyHlFoy 3OBQ== X-Gm-Message-State: AOAM5333C+E1m6nCnV7v3Srt1iJwROWgDOZZmwgt16aP2z2X2Dka8lSY V6LiqXZo3omVgEHQrC6worI= X-Google-Smtp-Source: ABdhPJzbT2vRHTzHp9RDGT6tMM884pEgiTMl6MSvk/izz/msw8mIEJTAbh58Y/esUmn/X7IAMRDKxg== X-Received: by 2002:a05:6a00:1407:b0:4c3:3ab:1467 with SMTP id l7-20020a056a00140700b004c303ab1467mr11218233pfu.22.1642963351381; Sun, 23 Jan 2022 10:42:31 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id k13sm14218413pfc.176.2022.01.23.10.42.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:42:31 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 52/54] lib/nodemask: add num_node_state_eq() Date: Sun, 23 Jan 2022 10:39:23 -0800 Message-Id: <20220123183925.1052919-53-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Kernel code uses num_node_state() to compare number of nodes with a given number. The underlying code calls bitmap_weight(), and we can do it more efficiently with num_node_state_eq because conditional nodes_weight may stop traversing the nodemask earlier, as soon as condition is met. Signed-off-by: Yury Norov --- include/linux/nodemask.h | 5 +++++ mm/page_alloc.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/linux/nodemask.h b/include/linux/nodemask.h index 197598e075e9..c5014dbf3cce 100644 --- a/include/linux/nodemask.h +++ b/include/linux/nodemask.h @@ -466,6 +466,11 @@ static inline int num_node_state(enum node_states stat= e) return nodes_weight(node_states[state]); } =20 +static inline int num_node_state_eq(enum node_states state, int num) +{ + return nodes_weight_eq(node_states[state], num); +} + #define for_each_node_state(__node, __state) \ for_each_node_mask((__node), node_states[__state]) =20 diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 8dd6399bafb5..37496d764643 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -8328,7 +8328,7 @@ void __init page_alloc_init(void) int ret; =20 #ifdef CONFIG_NUMA - if (num_node_state(N_MEMORY) =3D=3D 1) + if (num_node_state_eq(N_MEMORY, 1)) hashdist =3D 0; #endif =20 --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94D04C433EF for ; Sun, 23 Jan 2022 18:43:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239888AbiAWSnw (ORCPT ); Sun, 23 Jan 2022 13:43:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240198AbiAWSmi (ORCPT ); Sun, 23 Jan 2022 13:42:38 -0500 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23EA7C0617A3; Sun, 23 Jan 2022 10:42:35 -0800 (PST) Received: by mail-pj1-x102a.google.com with SMTP id s2-20020a17090ad48200b001b501977b23so13570149pju.2; Sun, 23 Jan 2022 10:42:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=CXYULLi3PASNYDuyMVe1ZOcJwgtgVdN/yE5O/a0uB5k=; b=EBlwI85Bbp4dt/mAkId3TjlgUi1+WVSFLBzAsO6qdsN8OkWVycPY02ONEgCFCYtrPp 9jbRHmFFtKBqEEjSp2REFIp2gGt8TEbu7plsGMtxXUVV4SRs1bPYmhg5rdarJyC4wXJN O48VL6MBCdRj5GGLnF99bJTQrJ+Kawn/ILuPZJAoyt6GL/arqg/3zlZwBxXs95JKY1W7 Lbtw1M3Y+nph1ONbaomtxJgVBDMJzKL7wpXIBhykwVGCfEuYZmfcjswjIEu/L7++/KsT etT1Sa2eUvukmUwrooVJYG25UOejsWMPwDkQ0l3X/ZXgECdi/lDg7/nYtQ6fs/q9cR39 ILmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CXYULLi3PASNYDuyMVe1ZOcJwgtgVdN/yE5O/a0uB5k=; b=tNdBwuMUYFFCQjpySmZdl/3fNT0456rjTAFlaOIYnYo4tyCkL2AdhbjlOb367kXEIT gclsmNS41YwtmKaQEzu4eso3y5OjHes33aENq/iYIhb2lAI9rORTRJuowSLxsfU8SL0z rCC9bUFmO7zoP/kiBn7TJDq2AdxMV8XDWVM/QMK06rcfLuwODMwu4W2n+97a1srZV5Wo gGRDDXXvJRpsNSWa4YgA+BObrpWyjHhtayAgg+yMQ/vXkhEC1ODrjd5T9YxllCzC+LZc OXgRXxu9SJfbJwgjdyd96Rnb3BgzxjHZNErtMcE6e4RGQS0lRbzWxfeQz3hVaAqyuFsL F7cA== X-Gm-Message-State: AOAM531mutAlUktWjIbvlqlVrlkC7XgfRqFMXFjdBLt0SMu9hrmX34B/ HjxHGYhTNZmo1xT5wK6ul4E= X-Google-Smtp-Source: ABdhPJxe/Ur2GuzvwBNqJcV/GLr6+a9GVwBzRQRxs4BSKqFLKxjVBkWf1QQy0aITY9KZJJVXij7Tpw== X-Received: by 2002:a17:90b:3508:: with SMTP id ls8mr4353610pjb.214.1642963354651; Sun, 23 Jan 2022 10:42:34 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id d18sm13944708pfv.173.2022.01.23.10.42.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:42:34 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Jin Yao , John Garry , Ian Rogers , Kan Liang , linux-perf-users@vger.kernel.org Subject: [PATCH 53/54] tools/bitmap: sync bitmap_weight Date: Sun, 23 Jan 2022 10:39:24 -0800 Message-Id: <20220123183925.1052919-54-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Pull bitmap_weight_{cmp,eq,gt,ge,lt,le} from mother kernel and use where applicable. Signed-off-by: Yury Norov --- tools/include/linux/bitmap.h | 44 ++++++++++++++++++++++++++++++++++++ tools/lib/bitmap.c | 20 ++++++++++++++++ tools/perf/util/pmu.c | 2 +- 3 files changed, 65 insertions(+), 1 deletion(-) diff --git a/tools/include/linux/bitmap.h b/tools/include/linux/bitmap.h index ea97804d04d4..e8ae9a85d555 100644 --- a/tools/include/linux/bitmap.h +++ b/tools/include/linux/bitmap.h @@ -12,6 +12,8 @@ unsigned long name[BITS_TO_LONGS(bits)] =20 int __bitmap_weight(const unsigned long *bitmap, int bits); +int __bitmap_weight_cmp(const unsigned long *bitmap, unsigned int bits, + unsigned int num); void __bitmap_or(unsigned long *dst, const unsigned long *bitmap1, const unsigned long *bitmap2, int bits); int __bitmap_and(unsigned long *dst, const unsigned long *bitmap1, @@ -68,6 +70,48 @@ static inline int bitmap_weight(const unsigned long *src= , unsigned int nbits) return __bitmap_weight(src, nbits); } =20 +static __always_inline +int bitmap_weight_cmp(const unsigned long *src, unsigned int nbits, int nu= m) +{ + if (num > (int)nbits || num < 0) + return -num; + + if (small_const_nbits(nbits)) + return hweight_long(*src & BITMAP_LAST_WORD_MASK(nbits)) - num; + + return __bitmap_weight_cmp(src, nbits, num); +} + +static __always_inline +bool bitmap_weight_eq(const unsigned long *src, unsigned int nbits, int nu= m) +{ + return bitmap_weight_cmp(src, nbits, num) =3D=3D 0; +} + +static __always_inline +bool bitmap_weight_gt(const unsigned long *src, unsigned int nbits, int nu= m) +{ + return bitmap_weight_cmp(src, nbits, num) > 0; +} + +static __always_inline +bool bitmap_weight_ge(const unsigned long *src, unsigned int nbits, int nu= m) +{ + return bitmap_weight_cmp(src, nbits, num - 1) > 0; +} + +static __always_inline +bool bitmap_weight_lt(const unsigned long *src, unsigned int nbits, int nu= m) +{ + return bitmap_weight_cmp(src, nbits, num - 1) <=3D 0; +} + +static __always_inline +bool bitmap_weight_le(const unsigned long *src, unsigned int nbits, int nu= m) +{ + return bitmap_weight_cmp(src, nbits, num) <=3D 0; +} + static inline void bitmap_or(unsigned long *dst, const unsigned long *src1, const unsigned long *src2, unsigned int nbits) { diff --git a/tools/lib/bitmap.c b/tools/lib/bitmap.c index db466ef7be9d..06e58fee8523 100644 --- a/tools/lib/bitmap.c +++ b/tools/lib/bitmap.c @@ -18,6 +18,26 @@ int __bitmap_weight(const unsigned long *bitmap, int bit= s) return w; } =20 +int __bitmap_weight_cmp(const unsigned long *bitmap, unsigned int bits, in= t num) +{ + unsigned int k, w, lim =3D bits / BITS_PER_LONG; + + for (k =3D 0, w =3D 0; k < lim; k++) { + if (w + bits - k * BITS_PER_LONG < num) + goto out; + + w +=3D hweight_long(bitmap[k]); + + if (w > num) + goto out; + } + + if (bits % BITS_PER_LONG) + w +=3D hweight_long(bitmap[k] & BITMAP_LAST_WORD_MASK(bits)); +out: + return w - num; +} + void __bitmap_or(unsigned long *dst, const unsigned long *bitmap1, const unsigned long *bitmap2, int bits) { diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index 8dfbba15aeb8..2c26cdd7f9b0 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -1314,7 +1314,7 @@ static int pmu_config_term(const char *pmu_name, */ if (term->type_val =3D=3D PARSE_EVENTS__TERM_TYPE_NUM) { if (term->no_value && - bitmap_weight(format->bits, PERF_PMU_FORMAT_BITS) > 1) { + bitmap_weight_gt(format->bits, PERF_PMU_FORMAT_BITS, 1)) { if (err) { parse_events_error__handle(err, term->err_val, strdup("no value assigned for term"), --=20 2.30.2 From nobody Tue Jun 30 06:33:10 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1BC88C433EF for ; Sun, 23 Jan 2022 18:43:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240054AbiAWSn4 (ORCPT ); Sun, 23 Jan 2022 13:43:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240206AbiAWSmj (ORCPT ); Sun, 23 Jan 2022 13:42:39 -0500 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 955F0C0613DE for ; Sun, 23 Jan 2022 10:42:38 -0800 (PST) Received: by mail-pj1-x102b.google.com with SMTP id q63so9477391pja.1 for ; Sun, 23 Jan 2022 10:42:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=eurCTfqQPWvOuAgaV33nc0wGgUHFJYL01lWf+T5k2PY=; b=FFMT2f8tr34dAdw6qtWLyYPfB4JxqS9+3IX2kpUT3TpR8TAPWwSftQobhiNpybwI9a EiyLHk4tFUU5q5iqJ+glN5C5lddCZMB0OD2kYc2syyqq54rQ17CHadonX5bGub/FIJTp IECKqMlX01o+0SdqQs2yGwrqdHoTitmFEo34i5Bh8cDa9724NVJqUdgwSFIcJ5BNZ8gj ChoRMM6wgOtyJzqG3JoUYUh8u+GT6RSw6PrBcgAsCInNy/UuWQtvvW8mAikxyZ0Pe1ua ptvxnd66XB0Od3rvoUFylEiHd66+ccWXgvquEi+7+ZkI4gQpMOnPcTy+jSZMeCttgU15 NVCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eurCTfqQPWvOuAgaV33nc0wGgUHFJYL01lWf+T5k2PY=; b=BFinx2CpKC7i/iOGrSN+3YzITcuSQzG00iII/tnX/MR2bYNq06xlYsaDx8RqDVmgra XprB5bu0JEpoBG5pLi9+RtruLz2VjY9AFZPk8Z+X0jn4j5JG3aPA+Eb7U8OPrhSuGXkE ak5kIa8CkAHdCpSJl59SDiB3Dt16RaPzto71YWfO1weeolicU0zYtxkkDR5j6bGtCfrS keP4DnQ5L0Narx5M8Be49INS4CdV0xa/rptSFaJo4gNGb6FtbxwGztBeBWNL6Ovr0PGs xH3Njw8JaSvWa40Bz5ChE0trTCWzdb3dN5wtKQp15nT11Rq38/jOl6BLafUj8UvHjoY1 2mMw== X-Gm-Message-State: AOAM530D/V573RFhd6To9l3XTsM5y1DHKHCjl+Ru++6MnUyYZE7QA2SC FfU5dxws0sbiyYDAFDqWI/o= X-Google-Smtp-Source: ABdhPJzf3y0mSqzIQNCHu5M8urUCU9T6nbBKxdNMprAK5Xer13Pwyl+y6AEUQai5c7RvsuvJOXpPNQ== X-Received: by 2002:a17:902:8305:b0:14a:bd99:203b with SMTP id bd5-20020a170902830500b0014abd99203bmr11479566plb.74.1642963358028; Sun, 23 Jan 2022 10:42:38 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id z15sm9867945pgf.66.2022.01.23.10.42.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:42:37 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org Subject: [PATCH 54/54] MAINTAINERS: add cpumask and nodemask files to BITMAP_API Date: Sun, 23 Jan 2022 10:39:25 -0800 Message-Id: <20220123183925.1052919-55-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" cpumask and nodemask APIs are thin wrappers around basic bitmap API, and corresponding files are not formally maintained. This patch adds them to BITMAP_API section, so that bitmap folks would have closer look at it. Signed-off-by: Yury Norov --- MAINTAINERS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 27730a5a6345..7a3798de61c9 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3412,10 +3412,14 @@ R: Andy Shevchenko R: Rasmus Villemoes S: Maintained F: include/linux/bitmap.h +F: include/linux/cpumask.h F: include/linux/find.h +F: include/linux/nodemask.h F: lib/bitmap.c +F: lib/cpumask.c F: lib/find_bit.c F: lib/find_bit_benchmark.c +F: lib/nodemask.c F: lib/test_bitmap.c F: tools/include/linux/bitmap.h F: tools/include/linux/find.h --=20 2.30.2