From nobody Fri May 8 05:17:26 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 50D07C433F5 for ; Tue, 10 May 2022 15:58:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347087AbiEJQBP (ORCPT ); Tue, 10 May 2022 12:01:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347234AbiEJPwG (ORCPT ); Tue, 10 May 2022 11:52:06 -0400 Received: from mail-qt1-x82a.google.com (mail-qt1-x82a.google.com [IPv6:2607:f8b0:4864:20::82a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23C9C18E34 for ; Tue, 10 May 2022 08:47:56 -0700 (PDT) Received: by mail-qt1-x82a.google.com with SMTP id t16so13810793qtr.9 for ; Tue, 10 May 2022 08:47:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pU7kC1SMo4mlTP7fmR59ozkw+4jH/4NJrCGuFJdf6A4=; b=jeTHL+zkb3ae98nnxoN+7AqqNSKIUvIKbCWy+KKPO0Yy+e0/IyD3M34Wwav9VY1MqP qBtHfminh+20L3UJ7VVq6aII3BSzarzWFYYI7OVAvt/38fBzk2Sj1ujp/Gqfvf4NmXRy HlohiNCPcThYZxFcUkOF3g0Imw0+5WTe7k0AUNXstVavNcPvzbP1hoHfGqYsWW7MEt8W dDl/3v4Lqf0fmdzWHiAjG2zocG+y6zMvXRrjwN64xPnmf1YdjS2EwK4u++MG6hvtG8XA BmSmG3hQvIkRhuqg3H3SPE5VwjKil3ri3u6auyhPuo5T7/ZWE9oDA+/k3R+Va+ocz6aP VZTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pU7kC1SMo4mlTP7fmR59ozkw+4jH/4NJrCGuFJdf6A4=; b=rJ9ngJ7YveZCG19/bjz20JbBmqH6KWdLGbVX5DaMI1zpPcFFhwHbZ+PzdcA8Jk5VMV 00qt5Apc9YV3iFZKNrYuwrlLhcL32CpotJLQNLQFOF//1S2EjEu4mrwWhG0wyrA9Byem rIbtT1dhrWCGZ8utrbjDIFOdeZc7yGTCvfM0FdXw9hJPb6uY6XLBjHMsjO0fmbXXEiKI j7wSpsrWyH/Fa1tADDrJG719ajWKJRdmeNxWEsQdKi3EwmvVseW3BqwzSyOrwxetqbVm ybChyx7botsZIGz2sIzisVUmRvnGY9L5E1dmUpvEh8EJDcpPAe0XQCXVWNqxWS34Ldm2 NMSg== X-Gm-Message-State: AOAM530QO6vwpW4wRM5mNhkwj9DGPYi4hKbCESf3A7CZGQIu4zuqxcln LmxU1Z3uWvDvlQhSnYLIQcc= X-Google-Smtp-Source: ABdhPJy2pJ02ApIgBhzwy2wz2hCj3CKDavdxJ7zOVAt2upsy4uouBW6BbQL5+JNwjE1EnvY1ZSwPkQ== X-Received: by 2002:a05:622a:587:b0:2f3:ced4:60ba with SMTP id c7-20020a05622a058700b002f3ced460bamr15492635qtb.493.1652197675159; Tue, 10 May 2022 08:47:55 -0700 (PDT) Received: from localhost ([98.242.65.84]) by smtp.gmail.com with ESMTPSA id d16-20020ac851d0000000b002f39b99f6bbsm9527839qtn.85.2022.05.10.08.47.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 May 2022 08:47:54 -0700 (PDT) From: Yury Norov To: Andy Shevchenko , David Laight , Greg Kroah-Hartman , Joe Perches , Julia Lawall , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Nicholas Piggin , Nicolas Palix , Peter Zijlstra , Rasmus Villemoes , Matti Vaittinen , linux-kernel@vger.kernel.org Cc: Yury Norov , cocci@inria.fr Subject: [PATCH 01/22] introduce bitmap.cocci Date: Tue, 10 May 2022 08:47:29 -0700 Message-Id: <20220510154750.212913-2-yury.norov@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220510154750.212913-1-yury.norov@gmail.com> References: <20220510154750.212913-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" Using bitmap_weight() to compare weight of bitmap against a number or expression is common but wrong pattern. The more efficient way is to use bitmap_weight_{empty,full,gt,lt,ge,le,eq} as appropriate. This patch adds cocci script to test sources for this. Because for short bitmaps there's no performance adwantage of conditional bitmap_weight over regular one, and because readability of latter may be considered better, bitmap_weight_{gt,lt,ge,le,eq} cases are marked with WARNING. CC: Andy Shevchenko CC: Rasmus Villemoes CC: Julia Lawall CC: Nicolas Palix CC: linux-kernel@vger.kernel.org CC: cocci@inria.fr CC: Yury Norov Signed-off-by: Yury Norov --- MAINTAINERS | 1 + scripts/coccinelle/api/bitmap.cocci | 104 ++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+) create mode 100644 scripts/coccinelle/api/bitmap.cocci diff --git a/MAINTAINERS b/MAINTAINERS index f57e6d38a542..17fd10824636 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3523,6 +3523,7 @@ F: lib/find_bit.c F: lib/find_bit_benchmark.c F: lib/nodemask.c F: lib/test_bitmap.c +F: scripts/coccinelle/api/bitmap.cocci F: tools/include/linux/bitmap.h F: tools/include/linux/find.h F: tools/lib/bitmap.c diff --git a/scripts/coccinelle/api/bitmap.cocci b/scripts/coccinelle/api/b= itmap.cocci new file mode 100644 index 000000000000..24ff1809ba1f --- /dev/null +++ b/scripts/coccinelle/api/bitmap.cocci @@ -0,0 +1,104 @@ +// SPDX-License-Identifier: GPL-2.0-only +/// Use bitmap_empty rather than bitmap_weight() =3D=3D 0 etc +/// +// Confidence: High +// Copyright: (C) 2022 Yury Norov +// URL: http://coccinelle.lip6.fr/ +// Comments: +// Options: --no-includes --include-headers + +virtual org +virtual report +virtual context +virtual patch + +@rfull depends on !patch@ +position p; +expression E1, E2; +binary operator cmp =3D {=3D=3D, !=3D, <}; +@@ + + bitmap_weight(E1,E2) cmp@p E2 + +@script:python depends on report@ +p << rfull.p; +@@ + +coccilib.report.print_report(p[0], "ERROR: use bitmap_full()") + +@script:python depends on org@ +p << rfull.p; +@@ + +@rempty1 depends on !patch@ +position p; +statement S; +@@ + + if (bitmap_weight@p(...)) S + +@script:python depends on report@ +p << rempty1.p; +@@ + +for p0 in p: + coccilib.report.print_report(p0, "ERROR: use !bitmap_empty()") + +@script:python depends on org@ +p << rempty1.p; +@@ + +@rempty depends on !patch@ +position p; +@@ + + bitmap_weight@p(...) =3D=3D 0 + +@script:python depends on report@ +p << rempty.p; +@@ + +for p0 in p: + coccilib.report.print_report(p0, "ERROR: use bitmap_empty()") + +@script:python depends on org@ +p << rempty.p; +@@ + +@not_rempty depends on !patch@ +position p; +@@ + + bitmap_weight(...) @p> 0 + +@script:python depends on report@ +p << not_rempty.p; +@@ + +for p0 in p: + coccilib.report.print_report(p0, "ERROR: use \"!bitmap_empty()\"") + +@script:python depends on org@ +p << not_rempty.p; +@@ + + +@rcmp depends on !patch@ +expression exp; +binary operator cmp =3D {>, <, >=3D, <=3D, =3D=3D, !=3D}; +position p; +@@ + + bitmap_weight(...) cmp@p exp + +@script:python depends on report@ +p << rcmp.p; +@@ + +for p0 in p: + coccilib.report.print_report(p0, + "WARNING: use bitmap_weight_{gt,lt,ge,le,eq} as appropriate") + +@script:python depends on org@ +p << rcmp.p; +@@ --=20 2.32.0 From nobody Fri May 8 05:17:26 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 316F9C433FE for ; Tue, 10 May 2022 15:58:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347016AbiEJQBI (ORCPT ); Tue, 10 May 2022 12:01:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347235AbiEJPwG (ORCPT ); Tue, 10 May 2022 11:52:06 -0400 Received: from mail-qt1-x834.google.com (mail-qt1-x834.google.com [IPv6:2607:f8b0:4864:20::834]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C9EF192B7 for ; Tue, 10 May 2022 08:47:57 -0700 (PDT) Received: by mail-qt1-x834.google.com with SMTP id p4so13818002qtq.12 for ; Tue, 10 May 2022 08:47:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZBCHbbVfn2W7GCIwQZshDqoULkmiIrMZcuv1e33Ldn0=; b=dQ1GWa7V+6A4Ba0P/Loz6vdV8JkdlmKJOFYNtQyPpOLMo+TUFCoGk3C/oxbyjIEUR9 qF8YHJmazC8RFIO7AvVXR3xUfjNQprYyQiXRQ7saJ8W/DkT0ozzAasW7JG9L2ALUYFkp 1TQXGYSjQpdi8zpVvuxcZdxEJNTnzJv26oWSGrcJIyHWNod9AjDbXvzlay+wvTIF2anN lViq1b7ZCcsfVpRDVzOcNeOEVCXUbStQRloVX3eRJMtCSoFzL4Bs0SRTHObbsJITWZtZ +1NYpYaxGJfQv++ZyHlLTWtyWsO8HylA0GPqD6YiSYpwm79JUee4tVWS6sVbTTj2+oRb QF6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZBCHbbVfn2W7GCIwQZshDqoULkmiIrMZcuv1e33Ldn0=; b=U+M7+c8Oxh+WvJZ2ebk2G0Wnm2MlWMIq7suIMWpm9H3G0ZpRQ2s7OeZ+pZ/aElK+XE Ka2NVOXS91bymW8PyiFtvm/mnxpIqHT5I6gj1eepZdFGwhhlLMG0snuvVD0evgvEFnkW wuASZK3DJkvZP5LuRGRdskyLJ3Bxeej8IBDCacEfDe44oOXUG/waYPJRk5UGUXYOdDMI 3QAcqz3wR9Toz5PvXYvErSJkPTqPGNZiJU8KubJ+fFwEPFMOvYM46N2sQnNuY8ZW6Uns V8DwCk+c/nIprCKlcZGlHTBxh+AUT1hC4poYBpP/uSlMiW/naQo/Tn8MDJmrG2byLFYd 0IIA== X-Gm-Message-State: AOAM533KJiHjRKGMz2rkxmg1fDhu0TwdKQunhuapXtqUjNYc/jyZkSiB BtQxV8KmlWXt2hoxE4mY5cE= X-Google-Smtp-Source: ABdhPJyJdQoZPyN3OxTbCUAfBqM+mpRRLD8sKoA6zBSO0+BMr1gYl5dyLfJnD+oibRJ+xp3OG2oVWg== X-Received: by 2002:ac8:7d86:0:b0:2f3:c523:19a2 with SMTP id c6-20020ac87d86000000b002f3c52319a2mr20026391qtd.566.1652197676437; Tue, 10 May 2022 08:47:56 -0700 (PDT) Received: from localhost ([98.242.65.84]) by smtp.gmail.com with ESMTPSA id e13-20020a05620a014d00b0069fc13ce23esm8906393qkn.111.2022.05.10.08.47.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 May 2022 08:47:56 -0700 (PDT) From: Yury Norov To: Andy Shevchenko , David Laight , Greg Kroah-Hartman , Joe Perches , Julia Lawall , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Nicholas Piggin , Nicolas Palix , Peter Zijlstra , Rasmus Villemoes , Matti Vaittinen , linux-kernel@vger.kernel.org Cc: Yury Norov , cocci@inria.fr Subject: [PATCH 02/22] introduce cpumask.cocci Date: Tue, 10 May 2022 08:47:30 -0700 Message-Id: <20220510154750.212913-3-yury.norov@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220510154750.212913-1-yury.norov@gmail.com> References: <20220510154750.212913-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" Using cpumask_weight() to compare weight of cpumask against a number or expression is common but wrong pattern. The more efficient way is to use cpumask_weight_{empty,full,gt,lt,ge,le,eq} as appropriate. This patch adds cocci script to test sources for this. CC: Andy Shevchenko CC: Julia Lawall CC: Nicolas Palix CC: Rasmus Villemoes CC: linux-kernel@vger.kernel.org CC: cocci@inria.fr Signed-off-by: Yury Norov --- MAINTAINERS | 1 + scripts/coccinelle/api/cpumask.cocci | 51 ++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 scripts/coccinelle/api/cpumask.cocci diff --git a/MAINTAINERS b/MAINTAINERS index 17fd10824636..ecd97fdd5d67 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3524,6 +3524,7 @@ F: lib/find_bit_benchmark.c F: lib/nodemask.c F: lib/test_bitmap.c F: scripts/coccinelle/api/bitmap.cocci +F: scripts/coccinelle/api/cpumask.cocci F: tools/include/linux/bitmap.h F: tools/include/linux/find.h F: tools/lib/bitmap.c diff --git a/scripts/coccinelle/api/cpumask.cocci b/scripts/coccinelle/api/= cpumask.cocci new file mode 100644 index 000000000000..2eb930dbe9c4 --- /dev/null +++ b/scripts/coccinelle/api/cpumask.cocci @@ -0,0 +1,51 @@ +// SPDX-License-Identifier: GPL-2.0-only +/// Use cpumask_empty rather than cpumask_weight() =3D=3D 0 etc +/// +// Confidence: High +// Copyright: (C) 2022 Yury Norov +// URL: http://coccinelle.lip6.fr/ +// Comments: +// Options: --no-includes --include-headers + +virtual org +virtual report +virtual context +virtual patch + +@rempty1 depends on !patch@ +position p; +statement S; +@@ + +if (cpumask_weight@p(...)) S + +@script:python depends on report@ +p << rempty1.p; +@@ + +for p0 in p: + coccilib.report.print_report(p0, "ERROR: use !cpumask_empty()") + +@script:python depends on org@ +p << rempty1.p; +@@ + +@rcmp depends on !patch@ +expression exp; +binary operator cmp =3D {>, <, >=3D, <=3D, =3D=3D, !=3D}; +position p; +@@ + + cpumask_weight(...) cmp@p exp + +@script:python depends on report@ +p << rcmp.p; +@@ + +for p0 in p: + coccilib.report.print_report(p0, + "ERROR: use cpumask_weight_{empty,full,gt,lt,ge,le,eq} as appropriate") + +@script:python depends on org@ +p << rcmp.p; +@@ --=20 2.32.0 From nobody Fri May 8 05:17:26 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 414F0C433F5 for ; Tue, 10 May 2022 15:56:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346667AbiEJQAn (ORCPT ); Tue, 10 May 2022 12:00:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347241AbiEJPwI (ORCPT ); Tue, 10 May 2022 11:52:08 -0400 Received: from mail-qt1-x82c.google.com (mail-qt1-x82c.google.com [IPv6:2607:f8b0:4864:20::82c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E2CF1A39D for ; Tue, 10 May 2022 08:47:58 -0700 (PDT) Received: by mail-qt1-x82c.google.com with SMTP id h3so13813201qtn.4 for ; Tue, 10 May 2022 08:47:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=et/xiYs/rsa/96PjCIfZq4Lkirm6fP+CXISc9QiPIK0=; b=IsDOgG2uagbr6NRW6ovKobMGvzpUOdJua8IomfIiNU6kDenE1Fu0AzzB5huYoyIsvM GSl1FP99vh+9EOCA2jtut5n00UVVVi+nImR31WrNC8RBBH61gz4c4CrrzfOdrYRluMqO Jjv9iPDqhRMZOXgb4joUBT6ed7fr9EBDeoSj3T1JobV6kw0/gQLLicraQZEnMONYFWol zed+b0HzJuKZzDuwmhmcMPniQkqvUuAv5H3zt3vjooHfAwp2dL3NH/OUkKUgOKc+wDoS XGJYn+r/V6HohEOATqEKIb8OtAbowchcKwtrUr6SaRzzdJQYSnRqmdjNkBQEdqfhM1Gc PKLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=et/xiYs/rsa/96PjCIfZq4Lkirm6fP+CXISc9QiPIK0=; b=KCOkX03LOYDqgpQ27swjlOyEcK1RDb98DQmasD7OfMUYa3C6HHgWk3FpPrsnWCOpK3 08+G2wOb6u9apDl4byDtNfzFkB9FF3gifjPp/hSVAHvXEAGF980XUCBV0U1o8eqRYs73 2SVQnzQY5PW5RW11cq/V8T36Df6RlDumI1rxgAOuoiny7rPeXSwtm+DGWJzO4T+LHX81 l2vXsxnLQHv9R/ews/Ue74Kll8ViHCgpbCT3c30sX1sa/Qc/VrwyXuvgbsrU+4jErVZa PNB5fQfqExh6HX819CBIOTWu0TUHCICHCN15VwdAFCxBqEvG7nOGuFO0x9mXO/gcP/cH /4wQ== X-Gm-Message-State: AOAM533Zohp3YI4mRRzyh8qSj+h5nUf/wBYtcc7OY8ZfjsFlmE5DyWCL EjmBziPF6AMJL2zc2teMLlg= X-Google-Smtp-Source: ABdhPJy4QPoN+Z2RE2YbnC2pYatWTGT1l1v59rnUGl7znoVFZudpny6dgHhL6zpVCHzzIASWFVjQxA== X-Received: by 2002:ac8:58ce:0:b0:2f3:a42d:ae28 with SMTP id u14-20020ac858ce000000b002f3a42dae28mr20031817qta.416.1652197677684; Tue, 10 May 2022 08:47:57 -0700 (PDT) Received: from localhost ([98.242.65.84]) by smtp.gmail.com with ESMTPSA id p5-20020ac84085000000b002f39b99f67esm9922487qtl.24.2022.05.10.08.47.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 May 2022 08:47:57 -0700 (PDT) From: Yury Norov To: Andy Shevchenko , David Laight , Greg Kroah-Hartman , Joe Perches , Julia Lawall , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Nicholas Piggin , Nicolas Palix , Peter Zijlstra , Rasmus Villemoes , Matti Vaittinen , linux-kernel@vger.kernel.org Cc: Yury Norov , cocci@inria.fr Subject: [PATCH 03/22] introduce nodemask.cocci Date: Tue, 10 May 2022 08:47:31 -0700 Message-Id: <20220510154750.212913-4-yury.norov@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220510154750.212913-1-yury.norov@gmail.com> References: <20220510154750.212913-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" Using nodemask_weight() to compare weight of nodemask against a number or expression is common but wrong pattern. The more efficient way is to use nodemask_weight_{empty,full,gt,lt,ge,le,eq} as appropriate. This patch adds cocci script to test sources for this. CC: Andy Shevchenko CC: Julia Lawall CC: Nicolas Palix CC: Rasmus Villemoes CC: linux-kernel@vger.kernel.org CC: cocci@inria.fr Signed-off-by: Yury Norov --- MAINTAINERS | 1 + scripts/coccinelle/api/nodemask.cocci | 51 +++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 scripts/coccinelle/api/nodemask.cocci diff --git a/MAINTAINERS b/MAINTAINERS index ecd97fdd5d67..69f95d79e5a3 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3525,6 +3525,7 @@ F: lib/nodemask.c F: lib/test_bitmap.c F: scripts/coccinelle/api/bitmap.cocci F: scripts/coccinelle/api/cpumask.cocci +F: scripts/coccinelle/api/nodemask.cocci F: tools/include/linux/bitmap.h F: tools/include/linux/find.h F: tools/lib/bitmap.c diff --git a/scripts/coccinelle/api/nodemask.cocci b/scripts/coccinelle/api= /nodemask.cocci new file mode 100644 index 000000000000..1d8578640d97 --- /dev/null +++ b/scripts/coccinelle/api/nodemask.cocci @@ -0,0 +1,51 @@ +// SPDX-License-Identifier: GPL-2.0-only +/// Use nodes_empty rather than nodes_weight() =3D=3D 0 etc +/// +// Confidence: High +// Copyright: (C) 2022 Yury Norov +// URL: http://coccinelle.lip6.fr/ +// Comments: +// Options: --no-includes --include-headers + +virtual org +virtual report +virtual context +virtual patch + +@rempty1 depends on !patch@ +position p; +statement S; +@@ + +if (nodes_weight@p(...)) S + +@script:python depends on report@ +p << rempty1.p; +@@ + +for p0 in p: + coccilib.report.print_report(p0, "ERROR: use !nodes_empty()") + +@script:python depends on org@ +p << rempty1.p; +@@ + +@rcmp depends on !patch@ +expression exp; +binary operator cmp =3D {>, <, >=3D, <=3D, =3D=3D, !=3D}; +position p; +@@ + + nodes_weight(...) cmp@p exp + +@script:python depends on report@ +p << rcmp.p; +@@ + +for p0 in p: + coccilib.report.print_report(p0, + "ERROR: use nodes_weight_{empty,full,gt,lt,ge,le,eq} as appropriate") + +@script:python depends on org@ +p << rcmp.p; +@@ --=20 2.32.0 From nobody Fri May 8 05:17:26 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 1E282C433EF for ; Tue, 10 May 2022 15:58:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346996AbiEJQBB (ORCPT ); Tue, 10 May 2022 12:01:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347238AbiEJPwI (ORCPT ); Tue, 10 May 2022 11:52:08 -0400 Received: from mail-qt1-x82e.google.com (mail-qt1-x82e.google.com [IPv6:2607:f8b0:4864:20::82e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE8501A81A; Tue, 10 May 2022 08:47:59 -0700 (PDT) Received: by mail-qt1-x82e.google.com with SMTP id hf18so13860148qtb.0; Tue, 10 May 2022 08:47:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8XwVIoqaEjrb3iMSCaJMjNScsN/uhpRfrQ8NarzetBA=; b=TRtRj0OV5KH470cMHDPWUxl3cSGx95ngPsN0DC93pj0q8lGKr6CIDI7KqIjvYte1Hq DqQZeHliFkhzx++RKygoPz5nE4Aqk2UIQzgMw/6D7YlBFtqCr1XJQeY0aXrD7Z3I7zL8 vdYXHH5j0T9lwr4UaICLcWXUHX0ik0X+sJnHHfGa8ofweq10xOcV5vZi7VReLlWYtqqn nHzBpLgUII9FKyjiNIqU9JJdGkKXpJ8qxoycCK70hC8aBK07eSXmnxo2CnbJXB+wPmRf eG+ftCF5WaKR0/SbaXZWXn93wkpkW1VusQ4Xh9LxdA3A1hrUIpyXsC+T7vM12H0qF72o ZkGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8XwVIoqaEjrb3iMSCaJMjNScsN/uhpRfrQ8NarzetBA=; b=YttMwB8O6ncQnx11oCNG/1q2sfqdNlXA9Dr7W8V5gnSwyoVwYv/UTG1qi5m1p2Jzry urcXOzFtut1WnmVPNCU+elgC2WlEFqSTaOcaiMjHxv6v/DVfTrOi8Mhkm4zUy4llY9T/ oGPg8zSoy2NsvpDmM3SbmjiyceAW9RIB43TdbmtbRR6hpdRp2LZ0Y/ZpACTgqGPZzDcX 1aVmCNyrigv2AvgpacenE/Vb9Xyp/6mui3BvUU5RuYDq6e+4AdtD41FqoEU8v/jo6VCb /ckD70zNhU0NUnhF/w9qgiuNf4ZHN+LDGrfxy+A9CIvSeTcrXfmv3ygmhs/8dGddmt05 CnAQ== X-Gm-Message-State: AOAM533FC8mRzanlHpvbT+ujwA1IDP90Oa6GMAnXlCPWUAq2Hp8Zqo+t Q3t+1X/EE57ZDQz0+44dqmA= X-Google-Smtp-Source: ABdhPJx1lvQ2cAFBLJUoEVeXgxIKrxcn5z7aIGeJaHLVOgtu8J7l1okT1ZHyyT7jgo7gM8c1D/jlvA== X-Received: by 2002:ac8:58ca:0:b0:2f3:da32:ab1 with SMTP id u10-20020ac858ca000000b002f3da320ab1mr10163209qta.308.1652197678887; Tue, 10 May 2022 08:47:58 -0700 (PDT) Received: from localhost ([98.242.65.84]) by smtp.gmail.com with ESMTPSA id a123-20020ae9e881000000b0069fc13ce227sm8659793qkg.88.2022.05.10.08.47.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 May 2022 08:47:58 -0700 (PDT) From: Yury Norov To: Andy Shevchenko , David Laight , Greg Kroah-Hartman , Joe Perches , Julia Lawall , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Nicholas Piggin , Nicolas Palix , Peter Zijlstra , Rasmus Villemoes , Matti Vaittinen , linux-kernel@vger.kernel.org Cc: Yury Norov , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Jesse Brandeburg , Paolo Abeni , Tony Nguyen , intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org Subject: [PATCH 04/22] ice: use bitmap_empty() in ice_vf_has_no_qs_ena() Date: Tue, 10 May 2022 08:47:32 -0700 Message-Id: <20220510154750.212913-5-yury.norov@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220510154750.212913-1-yury.norov@gmail.com> References: <20220510154750.212913-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" bitmap_empty() is better than bitmap_weight() because it may return earlier, and improves on readability. CC: David S. Miller CC: Eric Dumazet CC: Jakub Kicinski CC: Jesse Brandeburg CC: Paolo Abeni CC: Tony Nguyen CC: intel-wired-lan@lists.osuosl.org CC: netdev@vger.kernel.org CC: linux-kernel@vger.kernel.org Signed-off-by: Yury Norov --- drivers/net/ethernet/intel/ice/ice_vf_lib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_vf_lib.c b/drivers/net/ethe= rnet/intel/ice/ice_vf_lib.c index 6578059d9479..de67ac4075f0 100644 --- a/drivers/net/ethernet/intel/ice/ice_vf_lib.c +++ b/drivers/net/ethernet/intel/ice/ice_vf_lib.c @@ -740,8 +740,8 @@ bool ice_is_vf_trusted(struct ice_vf *vf) */ 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.32.0 From nobody Fri May 8 05:17:26 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 A700BC433EF for ; Tue, 10 May 2022 15:57:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231824AbiEJQAv (ORCPT ); Tue, 10 May 2022 12:00:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347239AbiEJPwI (ORCPT ); Tue, 10 May 2022 11:52:08 -0400 Received: from mail-qt1-x82a.google.com (mail-qt1-x82a.google.com [IPv6:2607:f8b0:4864:20::82a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E5751C110; Tue, 10 May 2022 08:48:00 -0700 (PDT) Received: by mail-qt1-x82a.google.com with SMTP id t16so13810793qtr.9; Tue, 10 May 2022 08:48:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JH6FCKgVvpyM/CUSOGxGawAHjQOzmxSo0FiMXcNNQR0=; b=FaBd2ixjBk7/GliZhXs0HDiV5kgLBYPB7SKr0q2FlW/0EvPvlEvKOWZnDOKhZyOrmb Km6tyPTpfkvzxIkyS9lhLZegj8B6LocfHY3XCNef442bwbaK9GkccfM51jH4gO0/0FTn 7x2rmGpqKpMkPW2U5V8jNMUE+JYx0Sp+SmSABDdGRgu0CmaVz2Xsf0KaNvrDFYeSvRMZ TSg7KF3ivDe20IOjxOYY4T03BAaRtNXvIVLH3FsvqVSFltmUGp56UFdEX81S/WynqvKt xa8w94DQY/mn6ieYorGxnmjk8aydlWEg/zGkVmESlpB6rl+FwFRFmMCoZ4Mmhgb9CDi5 dnjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JH6FCKgVvpyM/CUSOGxGawAHjQOzmxSo0FiMXcNNQR0=; b=fJXg28IhH7ekdBR/ob6+MLc5UGxv4R9JlCKEXXq0VpFDHVZNZOFSEHhu1O4awYSUMW rzqlml5y97Z1MU9S//LMS7g5i3j1qgER1sEjnveodOSiSrvSp3sdKRTHLrpF79qd78nM Vpjlepb8DAyt+MnU1i0WHjRdlyFujxqKDf/fcWKDIRz619l/gGerVTjvbwhCJDgsjbZU P4i/BpSUwg29/oz8p1UvSJZbA2N5Bdg1J0v+JvAef/IRBAxT2RgmvhJtWFSpPBFQF5Qi 3QHZb6sKRPjyaoOnj9vETQvSKzQ9hiT/npLrmIepIjKXE7R1HqJQsGwmxBUCTc94boxG TFIw== X-Gm-Message-State: AOAM533eSqls7b1aR/JqQUMrkCZjmLaPuD/4C/q4lB7XtyXXhwmwFQIY cmDoVWBhA2HWj716t75f284= X-Google-Smtp-Source: ABdhPJylp/SaGGGIPQEhhG+6lZJxx6dLQq6Bqk2BLgbTztZ5hgS4GTpLRbdUJuM9djFz5zjSjKbejw== X-Received: by 2002:ac8:598f:0:b0:2f3:be36:9be5 with SMTP id e15-20020ac8598f000000b002f3be369be5mr20627899qte.204.1652197680116; Tue, 10 May 2022 08:48:00 -0700 (PDT) Received: from localhost ([98.242.65.84]) by smtp.gmail.com with ESMTPSA id o2-20020ac841c2000000b002f39b99f691sm9288175qtm.43.2022.05.10.08.47.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 May 2022 08:47:59 -0700 (PDT) From: Yury Norov To: Andy Shevchenko , David Laight , Greg Kroah-Hartman , Joe Perches , Julia Lawall , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Nicholas Piggin , Nicolas Palix , Peter Zijlstra , Rasmus Villemoes , Matti Vaittinen , linux-kernel@vger.kernel.org Cc: Yury Norov , Jonathan Cameron , Lars-Peter Clausen , Michael Hennerich , linux-iio@vger.kernel.org Subject: [PATCH 05/22] iio: replace bitmap_weight with bitmap_weitght_{eq,le} where appropriate Date: Tue, 10 May 2022 08:47:33 -0700 Message-Id: <20220510154750.212913-6-yury.norov@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220510154750.212913-1-yury.norov@gmail.com> References: <20220510154750.212913-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" bitmap_weight_{eq,le} is better than bitmap_weight because it may return earlier. CC: Jonathan Cameron CC: Lars-Peter Clausen CC: Michael Hennerich CC: linux-iio@vger.kernel.org CC: linux-kernel@vger.kernel.org Signed-off-by: Yury Norov --- drivers/iio/adc/ad_sigma_delta.c | 2 +- drivers/iio/industrialio-buffer.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/adc/ad_sigma_delta.c b/drivers/iio/adc/ad_sigma_de= lta.c index 261a9a6b45e1..6445b591f071 100644 --- a/drivers/iio/adc/ad_sigma_delta.c +++ b/drivers/iio/adc/ad_sigma_delta.c @@ -525,7 +525,7 @@ static bool ad_sd_validate_scan_mask(struct iio_dev *in= dio_dev, const unsigned l { struct ad_sigma_delta *sigma_delta =3D iio_device_get_drvdata(indio_dev); =20 - return bitmap_weight(mask, indio_dev->masklength) <=3D sigma_delta->num_s= lots; + return bitmap_weight_le(mask, indio_dev->masklength, sigma_delta->num_slo= ts); } =20 static const struct iio_buffer_setup_ops ad_sd_buffer_setup_ops =3D { diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-b= uffer.c index 06141ca27e1f..18d3d756aee1 100644 --- a/drivers/iio/industrialio-buffer.c +++ b/drivers/iio/industrialio-buffer.c @@ -1824,7 +1824,7 @@ void iio_buffers_free_sysfs_and_mask(struct iio_dev *= indio_dev) bool iio_validate_scan_mask_onehot(struct iio_dev *indio_dev, const unsigned long *mask) { - return bitmap_weight(mask, indio_dev->masklength) =3D=3D 1; + return bitmap_weight_eq(mask, indio_dev->masklength, 1); } EXPORT_SYMBOL_GPL(iio_validate_scan_mask_onehot); =20 --=20 2.32.0 From nobody Fri May 8 05:17:26 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 D869BC433EF for ; Tue, 10 May 2022 15:56:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346701AbiEJQAW (ORCPT ); Tue, 10 May 2022 12:00:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347244AbiEJPwI (ORCPT ); Tue, 10 May 2022 11:52:08 -0400 Received: from mail-qt1-x82a.google.com (mail-qt1-x82a.google.com [IPv6:2607:f8b0:4864:20::82a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58F8F1C924; Tue, 10 May 2022 08:48:02 -0700 (PDT) Received: by mail-qt1-x82a.google.com with SMTP id x22so13822868qto.2; Tue, 10 May 2022 08:48:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4h/3sgiwZZAh9sVqTF8TpILnTbNrmnSNrow0mo4Rdcc=; b=nJkTTrZSgx/CxVZqlMx3R99vSMQL//nFGa0hZ07IqiBvDSeqXSh9woBb7OJS56Cgai 0Eczz7GiCbLotCzZ0RoAwk+04UmWVPqefXwHcWCtVHfsoYKir1gUkz5PcvJDzZPWYQ75 URMLPjFUroRtaY2wPU9e49KSkKK2clyA5OTfTPRmfC3LA7D5bBVwUwv6tWChLYpP5q4b YliYKg8zx9K6d2Adk173DWMSF7K6ESmJdunxWxXgdW2HhDVTAcgzgFAfINNDUzoIKXXd lGkUlRAVou6efYVNj35qLHlyuwca4XCM01AFtngv6grLtyX/iW52ydqcsC8bm+QKi7Sq 0urg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4h/3sgiwZZAh9sVqTF8TpILnTbNrmnSNrow0mo4Rdcc=; b=l83P71Whvn/JgaMEcnYfNYMxDEL50qE+Ys7rvvh6UwpxG2Y15Kb7h/avTwFhJCgK1F 9G1Ca7F9hx1UxAWw6h7donXrCuSDMkJVY4oTVWXMuS06jTQRTSiy9NDQ4KBS9Wpx+feU YouAqp2KnjF7UF4MUExJrkpHTPFI/Wc/RDuBBJmSj8STIfzvDfFtPjxv4ysPB3+F/dVZ Z1JfGC4eTTqtAqwZNfJUl9TL5y52LQ8Wyo/3ob8fQ/39r+mh7CIM1xgnPhD9kC6vi+lK 5WIyvzMLPavR1/Jz+qYbv+wsn3TnHSHw6BSuJLXZmtmK2WfxU/S+zgzA7z3/jkQX7a/Y ySPQ== X-Gm-Message-State: AOAM533UUWEg41uKTc9TDCnzHCEHzi4+u1tNgpa7cpEv8nx+OPsxHqj2 dmlZ+rsUCEupG206X8vIjvg= X-Google-Smtp-Source: ABdhPJyRxWRJRs5edGWoSur4H0QL70ANK42gtong6CQMuKkJqvRPmtDL3Ea8w/9GEy/oZ2btzNbyrw== X-Received: by 2002:ac8:5ad4:0:b0:2f3:e0fb:df1c with SMTP id d20-20020ac85ad4000000b002f3e0fbdf1cmr6254624qtd.267.1652197681464; Tue, 10 May 2022 08:48:01 -0700 (PDT) Received: from localhost ([98.242.65.84]) by smtp.gmail.com with ESMTPSA id o2-20020ac841c2000000b002f39b99f691sm9288209qtm.43.2022.05.10.08.48.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 May 2022 08:48:01 -0700 (PDT) From: Yury Norov To: Andy Shevchenko , David Laight , Greg Kroah-Hartman , Joe Perches , Julia Lawall , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Nicholas Piggin , Nicolas Palix , Peter Zijlstra , Rasmus Villemoes , Matti Vaittinen , linux-kernel@vger.kernel.org Cc: Yury Norov , "David S . Miller" , Eric Dumazet , Geetha sowjanya , Jakub Kicinski , Jerin Jacob , Linu Cherian , Paolo Abeni , Subbaraya Sundeep , Sunil Goutham , hariprasad , netdev@vger.kernel.org Subject: [PATCH 06/22] octeontx2: use bitmap_empty() instead of bitmap_weight() Date: Tue, 10 May 2022 08:47:34 -0700 Message-Id: <20220510154750.212913-7-yury.norov@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220510154750.212913-1-yury.norov@gmail.com> References: <20220510154750.212913-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" bitmap_empty() is better than bitmap_weight() because it may return earlier, and improves on readability. CC: David S. Miller CC: Eric Dumazet CC: Geetha sowjanya CC: Jakub Kicinski CC: Jerin Jacob CC: Linu Cherian CC: Paolo Abeni CC: Subbaraya Sundeep CC: Sunil Goutham CC: hariprasad CC: netdev@vger.kernel.org CC: linux-kernel@vger.kernel.org Signed-off-by: Yury Norov --- drivers/net/ethernet/marvell/octeontx2/af/cgx.c | 6 +++--- drivers/net/ethernet/marvell/octeontx2/af/rpm.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeontx2/af/cgx.c b/drivers/net/= ethernet/marvell/octeontx2/af/cgx.c index 25491edc35ce..921bf9cb707b 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/cgx.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/cgx.c @@ -615,7 +615,7 @@ void cgx_lmac_enadis_rx_pause_fwding(void *cgxd, int lm= ac_id, bool enable) return; =20 /* Pause frames are not enabled just return */ - if (!bitmap_weight(lmac->rx_fc_pfvf_bmap.bmap, lmac->rx_fc_pfvf_bmap.max)) + if (bitmap_empty(lmac->rx_fc_pfvf_bmap.bmap, lmac->rx_fc_pfvf_bmap.max)) return; =20 cgx_lmac_get_pause_frm_status(cgx, lmac_id, &rx_pause, &tx_pause); @@ -870,13 +870,13 @@ int verify_lmac_fc_cfg(void *cgxd, int lmac_id, u8 tx= _pause, u8 rx_pause, set_bit(pfvf_idx, lmac->tx_fc_pfvf_bmap.bmap); =20 /* check if other pfvfs are using flow control */ - if (!rx_pause && bitmap_weight(lmac->rx_fc_pfvf_bmap.bmap, lmac->rx_fc_pf= vf_bmap.max)) { + if (!rx_pause && !bitmap_empty(lmac->rx_fc_pfvf_bmap.bmap, lmac->rx_fc_pf= vf_bmap.max)) { dev_warn(&cgx->pdev->dev, "Receive Flow control disable not permitted as its used by other PFVFs= \n"); return -EPERM; } =20 - if (!tx_pause && bitmap_weight(lmac->tx_fc_pfvf_bmap.bmap, lmac->tx_fc_pf= vf_bmap.max)) { + if (!tx_pause && !bitmap_empty(lmac->tx_fc_pfvf_bmap.bmap, lmac->tx_fc_pf= vf_bmap.max)) { dev_warn(&cgx->pdev->dev, "Transmit Flow control disable not permitted as its used by other PFVF= s\n"); return -EPERM; diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rpm.c b/drivers/net/= ethernet/marvell/octeontx2/af/rpm.c index 47e83d7a5804..f2c866825c81 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rpm.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/rpm.c @@ -109,7 +109,7 @@ void rpm_lmac_enadis_rx_pause_fwding(void *rpmd, int lm= ac_id, bool enable) return; =20 /* Pause frames are not enabled just return */ - if (!bitmap_weight(lmac->rx_fc_pfvf_bmap.bmap, lmac->rx_fc_pfvf_bmap.max)) + if (bitmap_empty(lmac->rx_fc_pfvf_bmap.bmap, lmac->rx_fc_pfvf_bmap.max)) return; =20 if (enable) { --=20 2.32.0 From nobody Fri May 8 05:17:26 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 DC594C433F5 for ; Tue, 10 May 2022 15:55:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239369AbiEJP7t (ORCPT ); Tue, 10 May 2022 11:59:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347247AbiEJPwI (ORCPT ); Tue, 10 May 2022 11:52:08 -0400 Received: from mail-qt1-x831.google.com (mail-qt1-x831.google.com [IPv6:2607:f8b0:4864:20::831]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9058722BC7 for ; Tue, 10 May 2022 08:48:03 -0700 (PDT) Received: by mail-qt1-x831.google.com with SMTP id hh4so13812857qtb.10 for ; Tue, 10 May 2022 08:48:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aKum/y+r6etzQiDAncOGvinx4476e/+0uZXTw6pzwzs=; b=gW0t2QRbTyXmQvXyimlegclNnIEB2oz1Q2shjZ39XuWnPGlqj4KNZ0qpRhj0fKscpl cnjA8BtdGugJAErQ/HU8DJ/dsZkwoZ7BSSgTFS3o2Ra6snQf8kalMqJV7Z1E1ACwsSWo 5Sddgvu0qSXC+zgKYuWGwVBlY9JUUw+ncgV1uJ1F8HQOrhbwlvwHPwsjwlDyFYZiScfv mlP0EeM7Yygzq2Y6bpsLYjCliTNntkC+zkIjkyKrwaT0ca5n6C2Ay5KBcb9FBB4UlLug wc8H+vo20SJrhy118uJW+/eNG6vblqSGHG2s3aAf35TrzbH+YuT1vIuMRDY0jL/jEXiX T0rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aKum/y+r6etzQiDAncOGvinx4476e/+0uZXTw6pzwzs=; b=1IpSNfJLRehnkiGN7nFHiygJZcOos/XJNob9lr2xdy9NmG0bW8VEZrELOSLo8nceal /oSsuS3sHPzq1srgxPoqtt1EOiOaoI8c+Pbf9M/A1Gpr/uOQtPJ9WPnCw2l0IRA+2DkC ju3ZHMlB0dYEf2BSUYIHndwoK+vct83BjunVhUs0IH+xfmx9X4XyAv+T5HFHSVQnyjnt wYJJBDoYb/L8L0z/iI2OIKimHbBSStzppbU6SO/TbbUAHoTpV4m44PanuDSYqZ0JHcSJ dn0yBn8FahQLsnqZNfMU19kyZhhzCQZkKzu788+GY9XGxcO/ASl7toWLp8vFFZOlUZ2q I9Og== X-Gm-Message-State: AOAM533Z9dYYaJYLG+wRpIN00ya6eD4HJZONkQhWuFn9uhMHJeuXAgBs Q0GHs+tL1UOjHPkczZzKQmo= X-Google-Smtp-Source: ABdhPJz4ankS+cAqYT1bVrUsTcE2UHlB2KcHnUHYsVNYUl/deyqgn3ghukaHi8q8RzXf3c5GanpkYw== X-Received: by 2002:a05:622a:174b:b0:2f3:b473:13c6 with SMTP id l11-20020a05622a174b00b002f3b47313c6mr20251974qtk.198.1652197682702; Tue, 10 May 2022 08:48:02 -0700 (PDT) Received: from localhost ([98.242.65.84]) by smtp.gmail.com with ESMTPSA id b3-20020ac85403000000b002f39b99f6adsm9459897qtq.71.2022.05.10.08.48.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 May 2022 08:48:02 -0700 (PDT) From: Yury Norov To: Andy Shevchenko , David Laight , Greg Kroah-Hartman , Joe Perches , Julia Lawall , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Nicholas Piggin , Nicolas Palix , Peter Zijlstra , Rasmus Villemoes , Matti Vaittinen , linux-kernel@vger.kernel.org Cc: Yury Norov , Albert Ou , Anup Patel , Atish Patra , Jisheng Zhang , Palmer Dabbelt , Paul Walmsley , Tsukasa OI , linux-riscv@lists.infradead.org Subject: [PATCH 07/22] risc-v: replace bitmap_weight with bitmap_empty in riscv_fill_hwcap() Date: Tue, 10 May 2022 08:47:35 -0700 Message-Id: <20220510154750.212913-8-yury.norov@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220510154750.212913-1-yury.norov@gmail.com> References: <20220510154750.212913-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" bitmap_empty() is better than bitmap_weight() because it may return earlier, and improves on readability. CC: Albert Ou CC: Anup Patel CC: Atish Patra CC: Jisheng Zhang CC: Palmer Dabbelt CC: Paul Walmsley CC: Tsukasa OI CC: linux-riscv@lists.infradead.org CC: linux-kernel@vger.kernel.org Signed-off-by: Yury Norov Reviewed-by: Anup Patel --- arch/riscv/kernel/cpufeature.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c index 1b2d42d7f589..f0298d756f66 100644 --- a/arch/riscv/kernel/cpufeature.c +++ b/arch/riscv/kernel/cpufeature.c @@ -206,11 +206,10 @@ void __init riscv_fill_hwcap(void) else elf_hwcap =3D this_hwcap; =20 - if (bitmap_weight(riscv_isa, RISCV_ISA_EXT_MAX)) - bitmap_and(riscv_isa, riscv_isa, this_isa, RISCV_ISA_EXT_MAX); - else + if (bitmap_empty(riscv_isa, RISCV_ISA_EXT_MAX)) bitmap_copy(riscv_isa, this_isa, RISCV_ISA_EXT_MAX); - + else + bitmap_and(riscv_isa, riscv_isa, this_isa, RISCV_ISA_EXT_MAX); } =20 /* We don't support systems with F but without D, so mask those out --=20 2.32.0 From nobody Fri May 8 05:17:26 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 2F866C433EF for ; Tue, 10 May 2022 15:56:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346884AbiEJQA1 (ORCPT ); Tue, 10 May 2022 12:00:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347248AbiEJPwI (ORCPT ); Tue, 10 May 2022 11:52:08 -0400 Received: from mail-qv1-xf29.google.com (mail-qv1-xf29.google.com [IPv6:2607:f8b0:4864:20::f29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D78D022BD2 for ; Tue, 10 May 2022 08:48:04 -0700 (PDT) Received: by mail-qv1-xf29.google.com with SMTP id l1so10505527qvh.1 for ; Tue, 10 May 2022 08:48:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ORTCHnAqwd1LkHDszTdi37+rhpmYONfb9qJXBfSDiuE=; b=VDtJj557CbGsgXZsBMLxRRgOXF/lbKagIedVBBN0YtWpbB6czJI1IrMb5JZnoOoMEV 96iOstUXRGYkyl1xhR4EMVx7Zr7r47XBfXtPF4F/ZyJLVUHzRLa+oQg6l6R6LlryjySa pdHPvQc0iwk7GJcjgmjGDYCAIWGwuq6YBl5smqEla/pnpIeIXEwEaEuY8beHVu6hk33C 01X3PALm+xlI5IqjCND5OqedHUWaTJaFIddfQjjcwNTFowF5CFfHjv91aRZDJgmTB4qv QQ149aM2bfBzEmIP/ZD/ycouypZrrNENYWHDzYfDBZQizUuvOz5EYuMDvouepRw6KX5j feLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ORTCHnAqwd1LkHDszTdi37+rhpmYONfb9qJXBfSDiuE=; b=twG92nV93xWdWE2C5meXGCq5EAGygW1Zvld5xJHXGd8RxeIZ6OY0XxNf/6R7I6i4Ga 1KDDgliWQHVQQa/g5MTe5dFIVdYuSPkbmWrt9h1ztuff0dm34TKKpo/f+y3BpUFNtaov qAhYdCGgH/jIBfVB6ORCqowjbw3yqmkU4FnDjqW5z8KN7LKBDAuNZ3nGIdycV8uV08SA EMm3DVPDoP+sDTha2AmoE4TJq/H5OkmUuo1XzOYNFVcwkY9LCSZg816VKEd7sima/8D5 1jbt5krucxxXJbmS31ab2DGUeUruVvwRw70U/bys6Z7/UAwWmaFkOZ6Hq0V3gTbdvha7 Kl1g== X-Gm-Message-State: AOAM531MSTnxPI0A1+tLLp+8X95HID2hNdij3e8NNRpCKJyk0gpiSyw/ 9UZnvKjjGeuUxgshCttXFvs= X-Google-Smtp-Source: ABdhPJxGRjjQ+MXFnzoRE+rNBKwoGD3RJH05Q4YwDoHlhkbkt7OiNafsGZymV0A4ejSRRqqOTgNYew== X-Received: by 2002:a05:6214:d87:b0:45a:bb62:fa24 with SMTP id e7-20020a0562140d8700b0045abb62fa24mr18061167qve.71.1652197683948; Tue, 10 May 2022 08:48:03 -0700 (PDT) Received: from localhost ([98.242.65.84]) by smtp.gmail.com with ESMTPSA id c1-20020ac853c1000000b002f39b99f693sm9671775qtq.45.2022.05.10.08.48.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 May 2022 08:48:03 -0700 (PDT) From: Yury Norov To: Andy Shevchenko , David Laight , Greg Kroah-Hartman , Joe Perches , Julia Lawall , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Nicholas Piggin , Nicolas Palix , Peter Zijlstra , Rasmus Villemoes , Matti Vaittinen , linux-kernel@vger.kernel.org Cc: Yury Norov , Alexei Starovoitov , Andrew Morton , Chris Zankel , Christophe Leroy , "Eric W . Biederman" , Kumar Kartikeya Dwivedi , Max Filippov , =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= , linux-xtensa@linux-xtensa.org Subject: [PATCH 08/22] bitops: introduce MANY_BITS() macro Date: Tue, 10 May 2022 08:47:36 -0700 Message-Id: <20220510154750.212913-9-yury.norov@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220510154750.212913-1-yury.norov@gmail.com> References: <20220510154750.212913-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 arch/xtensa/kernel/traps.c and include/linux/log2.h define very similar functions with different behaviour. XTENSA defines IS_POW2(), and log2.h defines is_power_of_2(). The difference is that IS_POW2() considers 0 as power of 2, while is_power_of_2() - does not. This discrepancy may confuse reader. From mathematical point of view, 0 is not a power of 2. So let's introduce macro MANY_BITS(), which returns true if 2 or more bits are set in a number (which is what XTENSA actually needs), and use it in is_power_of_2(). CC: Alexei Starovoitov CC: Andrew Morton CC: Chris Zankel CC: Christophe Leroy CC: Eric W. Biederman CC: Kumar Kartikeya Dwivedi CC: Max Filippov CC: Toke H=C3=B8iland-J=C3=B8rgensen CC: linux-xtensa@linux-xtensa.org CC: linux-kernel@vger.kernel.org Signed-off-by: Yury Norov --- arch/xtensa/kernel/traps.c | 5 +---- include/linux/bitops.h | 3 +++ include/linux/log2.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/xtensa/kernel/traps.c b/arch/xtensa/kernel/traps.c index 138a86fbe9d7..040ec38bfce2 100644 --- a/arch/xtensa/kernel/traps.c +++ b/arch/xtensa/kernel/traps.c @@ -203,10 +203,7 @@ static void do_multihit(struct pt_regs *regs) =20 #if XTENSA_FAKE_NMI =20 -#define IS_POW2(v) (((v) & ((v) - 1)) =3D=3D 0) - -#if !(PROFILING_INTLEVEL =3D=3D XCHAL_EXCM_LEVEL && \ - IS_POW2(XTENSA_INTLEVEL_MASK(PROFILING_INTLEVEL))) +#if (MANY_BITS(XTENSA_INTLEVEL_MASK(PROFILING_INTLEVEL)) || PROFILING_INTL= EVEL !=3D XCHAL_EXCM_LEVEL) #warning "Fake NMI is requested for PMM, but there are other IRQs at or ab= ove its level." #warning "Fake NMI will be used, but there will be a bugcheck if one of th= ose IRQs fire." =20 diff --git a/include/linux/bitops.h b/include/linux/bitops.h index 7aaed501f768..96bc6a2552d6 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h @@ -21,6 +21,9 @@ #define BITS_TO_U32(nr) __KERNEL_DIV_ROUND_UP(nr, BITS_PER_TYPE(u32)) #define BITS_TO_BYTES(nr) __KERNEL_DIV_ROUND_UP(nr, BITS_PER_TYPE(char)) =20 +/* Return: nonzero if 2 or more bits are set */ +#define MANY_BITS(n) ((n) & ((n) - 1)) + extern unsigned int __sw_hweight8(unsigned int w); extern unsigned int __sw_hweight16(unsigned int w); extern unsigned int __sw_hweight32(unsigned int w); diff --git a/include/linux/log2.h b/include/linux/log2.h index 9f30d087a128..335b9dbd302d 100644 --- a/include/linux/log2.h +++ b/include/linux/log2.h @@ -44,7 +44,7 @@ int __ilog2_u64(u64 n) static inline __attribute__((const)) bool is_power_of_2(unsigned long n) { - return (n !=3D 0 && ((n & (n - 1)) =3D=3D 0)); + return n !=3D 0 && !MANY_BITS(n); } =20 /** --=20 2.32.0 From nobody Fri May 8 05:17:26 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 9AE4EC433EF for ; Tue, 10 May 2022 15:56:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346961AbiEJQAe (ORCPT ); Tue, 10 May 2022 12:00:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347246AbiEJPwI (ORCPT ); Tue, 10 May 2022 11:52:08 -0400 Received: from mail-qt1-x82a.google.com (mail-qt1-x82a.google.com [IPv6:2607:f8b0:4864:20::82a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9826023BC2; Tue, 10 May 2022 08:48:07 -0700 (PDT) Received: by mail-qt1-x82a.google.com with SMTP id t16so13810793qtr.9; Tue, 10 May 2022 08:48:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YUVX9pehnKFP2HbXOeJRXPON1pdMSinpND4hyUbpd7Y=; b=H7DHmga0YfNQOKRmyc5R1n9BtsfW36I+EeUo8Gn6tKIkX1sawCN5POYUm1ggf0QLIg y/zdQlOHPeAwSHVXraw2VC92qXm5io24/bWkUg1a+EOWnAFbhyWGy2MQNYq+voI38Af5 qZJGZMvd3wnnjh0CIvbujrGVLSjzEHi3dj/FKGGyEv7SNcwK08++bVPBiKSAfTxpILXC 10JenjZtFA2cuFkeXEq6/NVYLvBCGiFr8H5wwG5j8N/vk8f+kI2EV3ewRffC9eLq8o0I GfiUAU89D1PkvS/jYqGf1K163yTaUsGnqaXBK9LMC0TVultHBleCIej+qbQMbyD9ZLTL 8dXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YUVX9pehnKFP2HbXOeJRXPON1pdMSinpND4hyUbpd7Y=; b=Zn9ZO58XyJSLgt5sYc+kG8EU98WgEthfog6UBymmWTpVU2faebwW3aqZlNaW7MqQMr 6pcA0rMcAbjj5rcYGuI9KN+gHl5qJIPIG+m8gdx6D3Mn+p2RxTOA7bGCm8ZGXh3pBd1b VIwO3V0tSY140eeBt1mfk6aqYzxDvJGoQTXP+JKlGEYGINweLKmlUnHYTWGsyFwmhO8b Q1/XvmosCG2+5aDYPmSVR4VUUewxR7562AA9pqG00SGqo+1uC6tjUe5UI269HfP5CfxF GoFCuCjJ0hGnTAUZC2hDpXJGB5skLU33mQnZghBM9Rth7OLmx1d4Rz6nAJLCj5E8MXeR kr6g== X-Gm-Message-State: AOAM531FLpIT6bkKpy4xul547kLOB5vg5oG431ZKMKbHqApPCvet5q10 eCqcJ2Cq244Rt/9PX6Fu/RE= X-Google-Smtp-Source: ABdhPJxaFgINLYqbZDb9FJmk7RM9HPgCJquH2MWeHN9oyrPrIpTHIjpThvrKU8Y1hJ9jOgwtocfAUQ== X-Received: by 2002:a05:622a:141:b0:2f3:c7be:3f53 with SMTP id v1-20020a05622a014100b002f3c7be3f53mr19486120qtw.539.1652197685469; Tue, 10 May 2022 08:48:05 -0700 (PDT) Received: from localhost ([98.242.65.84]) by smtp.gmail.com with ESMTPSA id w2-20020a379402000000b0069fc13ce250sm9044681qkd.129.2022.05.10.08.48.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 May 2022 08:48:05 -0700 (PDT) From: Yury Norov To: Andy Shevchenko , David Laight , Greg Kroah-Hartman , Joe Perches , Julia Lawall , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Nicholas Piggin , Nicolas Palix , Peter Zijlstra , Rasmus Villemoes , Matti Vaittinen , linux-kernel@vger.kernel.org Cc: Yury Norov , Ariel Elior , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Manish Chopra , Paolo Abeni , netdev@vger.kernel.org Subject: [PATCH 09/22] qed: replace bitmap_weight() with MANY_BITS() Date: Tue, 10 May 2022 08:47:37 -0700 Message-Id: <20220510154750.212913-10-yury.norov@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220510154750.212913-1-yury.norov@gmail.com> References: <20220510154750.212913-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" qed_init_qm_get_idx_from_flags() uses bitmap_weight() to check if number of bits in pq_flags is greater than 1. It's a bad practice to use bitmap API for things like flags, because flags are not bitmaps (and it's bloating and potentially not safe - for example if flags are not declared as unsigned long). In this case, MANY_BITS() fits better than bitmap_weight(), and switching to MANY_BITS() silences scripts/coccinelle/api/bitmap.cocci. CC: Ariel Elior CC: David S. Miller CC: Eric Dumazet CC: Jakub Kicinski CC: Manish Chopra CC: Paolo Abeni CC: netdev@vger.kernel.org CC: linux-kernel@vger.kernel.org Signed-off-by: Yury Norov --- drivers/net/ethernet/qlogic/qed/qed_dev.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/ethernet/qlogic/qed/qed_dev.c b/drivers/net/ethern= et/qlogic/qed/qed_dev.c index 672480c9d195..fbe69e538f53 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_dev.c +++ b/drivers/net/ethernet/qlogic/qed/qed_dev.c @@ -1702,8 +1702,7 @@ static u16 *qed_init_qm_get_idx_from_flags(struct qed= _hwfn *p_hwfn, struct qed_qm_info *qm_info =3D &p_hwfn->qm_info; =20 /* Can't have multiple flags set here */ - if (bitmap_weight(&pq_flags, - sizeof(pq_flags) * BITS_PER_BYTE) > 1) { + if (MANY_BITS(pq_flags)) { DP_ERR(p_hwfn, "requested multiple pq flags 0x%lx\n", pq_flags); goto err; } --=20 2.32.0 From nobody Fri May 8 05:17:26 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 B49B2C433EF for ; Tue, 10 May 2022 15:56:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346899AbiEJQAP (ORCPT ); Tue, 10 May 2022 12:00:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347250AbiEJPwI (ORCPT ); Tue, 10 May 2022 11:52:08 -0400 Received: from mail-qt1-x830.google.com (mail-qt1-x830.google.com [IPv6:2607:f8b0:4864:20::830]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D6FE24595; Tue, 10 May 2022 08:48:09 -0700 (PDT) Received: by mail-qt1-x830.google.com with SMTP id y3so13831177qtn.8; Tue, 10 May 2022 08:48:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YR9pn4jX9oEu9ZPj21v5YqSNSABltP6KazwK0dihI+g=; b=b+d37BcnOOtc833JitSGOc7x3f2L3AE7Nf10xKLmhD4GjDgpUtUBGSvKNjCXlWoFqv 6YzrP02ahLFBG32O0Ws+15xbHp+dOeXdYG4mz3m054dW6mc4c722EwbQ9AzX+mLaIQv4 ESgLOi0yiR8EipW8HUqp/tAQoath61KrpL7EIRFe5NTmTAK+1Wzc8MkJakAmihyXNKk5 JQYymdcaGhZgnIVlvXS6OESpD7BDWVMQKKwcNHxjWTXNIQ5ryfnwS9lOEAZIo6T+A9Gz ivAvlL2bGWw2ECqmb0qWK6tD/Dbpw/VQMsOwfpB+0Bvitw4WH0kczgxf39JrhdgbNJbK YL4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YR9pn4jX9oEu9ZPj21v5YqSNSABltP6KazwK0dihI+g=; b=tzOHQMEfD0xji+InY5WoyEFQgqewNXy9B4MV+MjS8OeAgnry3O8zqzmSJHDWHReZx4 CUmsMWv8mlRc35E6zytTWh1LfizfgHSoJcUdFBVNQOx4t/YC0fqfZxVgmQwgrFOhlJ/F StD/ie14Rog2kDuvEMUzWuAZuRTu8O77VyDyGTeLxw/3mKyGjN81o4UXUTj/9RM2YECD iXejwkQNgy1O9q+1hKi9iV9w10OBbRgrfgh8mlKY1d2jHkrO+5QRVFN61h7O4bXEq0ef s6D3uHatuHHQAK5Rdn1z11GJF/1/GBpeDOXlnnMk2TLzjaA3mzELPjdxks1u3MxX1VHS 9jRg== X-Gm-Message-State: AOAM532CYAcfP/bkUWh99K6ZBcyGYSNM7PDr58Jf6ZizJhrRil6S6Ijl ZrESImBNpoNWybekJbpgw1s= X-Google-Smtp-Source: ABdhPJxFRmHP4o+KUAcl9Gzd3ONFTDwlKHVokPABxu3iBRg8vfeqO1O6Qd5Jeytf8QvM2mlUZTuU5Q== X-Received: by 2002:a05:622a:1213:b0:2f3:a79a:2ccc with SMTP id y19-20020a05622a121300b002f3a79a2cccmr20009701qtx.376.1652197688440; Tue, 10 May 2022 08:48:08 -0700 (PDT) Received: from localhost ([98.242.65.84]) by smtp.gmail.com with ESMTPSA id h191-20020a379ec8000000b0069fc347ef5dsm8578128qke.74.2022.05.10.08.48.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 May 2022 08:48:08 -0700 (PDT) From: Yury Norov To: Andy Shevchenko , David Laight , Greg Kroah-Hartman , Joe Perches , Julia Lawall , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Nicholas Piggin , Nicolas Palix , Peter Zijlstra , Rasmus Villemoes , Matti Vaittinen , linux-kernel@vger.kernel.org Cc: Yury Norov , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Leon Romanovsky , Paolo Abeni , Saeed Mahameed , netdev@vger.kernel.org, linux-rdma@vger.kernel.org Subject: [PATCH 10/22] net/mlx5e: simplify mlx5e_set_fecparam() Date: Tue, 10 May 2022 08:47:38 -0700 Message-Id: <20220510154750.212913-11-yury.norov@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220510154750.212913-1-yury.norov@gmail.com> References: <20220510154750.212913-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" mlx5e_set_fecparam() used bitmap API to handle fecparam->fec. This is a bad practice because ->fec is not a bitmap - it's an u32 mask. The code wants to prevent user from passing ->fec with many modes enables. For this purpose it's better to use MANY_BITS() macro, which allows to avoid converting u32 to bitmap. CC: David S. Miller CC: Eric Dumazet CC: Jakub Kicinski CC: Leon Romanovsky CC: Paolo Abeni CC: Saeed Mahameed CC: netdev@vger.kernel.org CC: linux-rdma@vger.kernel.org CC: linux-kernel@vger.kernel.org Signed-off-by: Yury Norov --- drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers= /net/ethernet/mellanox/mlx5/core/en_ethtool.c index 6e80585d731f..316cb72c4cc8 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c @@ -1664,13 +1664,11 @@ static int mlx5e_set_fecparam(struct net_device *ne= tdev, { struct mlx5e_priv *priv =3D netdev_priv(netdev); struct mlx5_core_dev *mdev =3D priv->mdev; - unsigned long fec_bitmap; u16 fec_policy =3D 0; int mode; int err; =20 - bitmap_from_arr32(&fec_bitmap, &fecparam->fec, sizeof(fecparam->fec) * BI= TS_PER_BYTE); - if (bitmap_weight(&fec_bitmap, ETHTOOL_FEC_LLRS_BIT + 1) > 1) + if (MANY_BITS(fecparam->fec)) return -EOPNOTSUPP; =20 for (mode =3D 0; mode < ARRAY_SIZE(pplm_fec_2_ethtool); mode++) { --=20 2.32.0 From nobody Fri May 8 05:17:26 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 84C34C433EF for ; Tue, 10 May 2022 15:56:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346883AbiEJQAH (ORCPT ); Tue, 10 May 2022 12:00:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347249AbiEJPwI (ORCPT ); Tue, 10 May 2022 11:52:08 -0400 Received: from mail-qt1-x82e.google.com (mail-qt1-x82e.google.com [IPv6:2607:f8b0:4864:20::82e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BEC225294; Tue, 10 May 2022 08:48:10 -0700 (PDT) Received: by mail-qt1-x82e.google.com with SMTP id hf18so13860148qtb.0; Tue, 10 May 2022 08:48:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=X3BNtoB4/F6niqoFfX4fx2Osn5fqWuTD5b1GlgfZFp8=; b=EabF1/L+wbkUd27VSF3/tF7Hgi1fgBopaHKNIvv3dj7doyy+kNYd+Am9ZenQfeE7MZ ez5LqgKnknGkr1X29oqKKeG5hO/HuqrPteNcfsqyla7aPBl8/XkUB4lOzZQPPxZ9ldyG mQP7YlICvUFB2oeF73toiOU/LxGQFPnJbQQckBNiTyWwxgz6DQ8o3cweqAQps+n5cG5I Nxy/HGqtH5Rk6LIj+b4gHe/FBUpavd3d0H2rir/Wgs1k+DoVD+5hBQ/c3R9wdySzZFHl egkJYRJqH2fWH+/EPULpjEqfOGIyjVTmZUZ7eBjLK5HvO4C3OnuWrT1+Q9W/Eq3pvkT0 czXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=X3BNtoB4/F6niqoFfX4fx2Osn5fqWuTD5b1GlgfZFp8=; b=Bzeqr8gqp6LUW5mMG0pxczxUPSvgD9Hm6tpsr/i++wpaSGRApvKGVEDdC7uzFSwNpU gziTdTjiXwX8THXjJPs/ENqwdiMaVRMUNNrypTsWoRKgwWzM4UVLR1/t+CtmpkgAyfyQ rIhhw36xFKXOC71NK55CbJCNKg929DR2Q+DQsSThqB/B96B1RiRVS+YWItsT/WWwxg0s YiQEOgmMMzVWJ60HQ6MuO0PxbhVar6ekygvdDCcIk6Bf0Q88qKRAzUeSpiAz3asHEiZ6 lcmAKatjWqtLwd/44sYlnOVpEyMYyl7ztMHR+jOZKSlPzjrHwqN+mcLnKComR1Blr1bC iKsA== X-Gm-Message-State: AOAM532zQv2Qh4UvwO+douzBu4wP5FI/Ti1wNLr+Shvqkdqv/YmFJ4pi qeFj9BVjMOq7Xn4v2jHNEZ4= X-Google-Smtp-Source: ABdhPJyRW2QB7yHYRodyUu35HiFlfKOXN/E+mTqJPQVZwWYac/HVRljaueGzRFfeuCppzBfOZdhAEA== X-Received: by 2002:a05:622a:64d:b0:2f3:e942:be29 with SMTP id a13-20020a05622a064d00b002f3e942be29mr2156043qtb.390.1652197689818; Tue, 10 May 2022 08:48:09 -0700 (PDT) Received: from localhost ([98.242.65.84]) by smtp.gmail.com with ESMTPSA id a36-20020a05620a43a400b0069fc13ce212sm8677904qkp.67.2022.05.10.08.48.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 May 2022 08:48:09 -0700 (PDT) From: Yury Norov To: Andy Shevchenko , David Laight , Greg Kroah-Hartman , Joe Perches , Julia Lawall , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Nicholas Piggin , Nicolas Palix , Peter Zijlstra , Rasmus Villemoes , Matti Vaittinen , linux-kernel@vger.kernel.org Cc: Yury Norov , Borislav Petkov , Dave Hansen , "H . Peter Anvin" , Ingo Molnar , Jim Mattson , Joerg Roedel , Paolo Bonzini , Sean Christopherson , Thomas Gleixner , Vitaly Kuznetsov , Wanpeng Li , kvm@vger.kernel.org, x86@kernel.org Subject: [PATCH 11/22] KVM: x86: hyper-v: replace bitmap_weight() with hweight64() Date: Tue, 10 May 2022 08:47:39 -0700 Message-Id: <20220510154750.212913-12-yury.norov@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220510154750.212913-1-yury.norov@gmail.com> References: <20220510154750.212913-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" kvm_hv_flush_tlb() applies bitmap API to a u64 variable valid_bank_mask. Since valid_bank_mask has a fixed size, we can use hweight64() and avoid excessive bloating. CC: Borislav Petkov CC: Dave Hansen CC: H. Peter Anvin CC: Ingo Molnar CC: Jim Mattson CC: Joerg Roedel CC: Paolo Bonzini CC: Sean Christopherson CC: Thomas Gleixner CC: Vitaly Kuznetsov CC: Wanpeng Li CC: kvm@vger.kernel.org CC: linux-kernel@vger.kernel.org CC: x86@kernel.org Signed-off-by: Yury Norov Acked-by: Vitaly Kuznetsov --- arch/x86/kvm/hyperv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c index 41585f0edf1e..b652b856df2b 100644 --- a/arch/x86/kvm/hyperv.c +++ b/arch/x86/kvm/hyperv.c @@ -1855,7 +1855,7 @@ static u64 kvm_hv_flush_tlb(struct kvm_vcpu *vcpu, st= ruct kvm_hv_hcall *hc) all_cpus =3D flush_ex.hv_vp_set.format !=3D HV_GENERIC_SET_SPARSE_4K; =20 - if (hc->var_cnt !=3D bitmap_weight((unsigned long *)&valid_bank_mask, 64= )) + if (hc->var_cnt !=3D hweight64(valid_bank_mask)) return HV_STATUS_INVALID_HYPERCALL_INPUT; =20 if (all_cpus) @@ -1956,7 +1956,7 @@ static u64 kvm_hv_send_ipi(struct kvm_vcpu *vcpu, str= uct kvm_hv_hcall *hc) valid_bank_mask =3D send_ipi_ex.vp_set.valid_bank_mask; all_cpus =3D send_ipi_ex.vp_set.format =3D=3D HV_GENERIC_SET_ALL; =20 - if (hc->var_cnt !=3D bitmap_weight(&valid_bank_mask, 64)) + if (hc->var_cnt !=3D hweight64(valid_bank_mask)) return HV_STATUS_INVALID_HYPERCALL_INPUT; =20 if (all_cpus) --=20 2.32.0 From nobody Fri May 8 05:17:26 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 7ABE8C35296 for ; Tue, 10 May 2022 15:58:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347635AbiEJQB4 (ORCPT ); Tue, 10 May 2022 12:01:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347256AbiEJPwK (ORCPT ); Tue, 10 May 2022 11:52:10 -0400 Received: from mail-qt1-x831.google.com (mail-qt1-x831.google.com [IPv6:2607:f8b0:4864:20::831]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0D192714B; Tue, 10 May 2022 08:48:11 -0700 (PDT) Received: by mail-qt1-x831.google.com with SMTP id t11so13819459qto.11; Tue, 10 May 2022 08:48:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CjDUHdg8cFM7kS83KS618TD4uElmyA10hO9dwUkMOD8=; b=kDJXbyhvj9QHNsY+CIMDYKuJitt2teWm52OsKOARN0n+1y8rud7V9QCrw+t5SilKMW GiOGonHD5UEWBztXu0e0Aq9uO8CwbFcQWvj3h+50zrc48Nk7ZmHaeUd02+YNlyyiAgHI 93xyHdhWG2wY+nmXl3uAODcwvjJBBwb2IPAeM20M5xl5n1KAOBxxjoZLAsHL4RlaFerN RBGK7Av2Mm5Bt/BhTlM/4IuOY/jXEa/geNIfM3VixAJ4FMZNKLxBP2ITXgEyFRk9kYH8 B1fdPa1WJe4S81tVdkaotLAL1V78RY57u9MPfPHbX0Y9Jxz8Z35PlhZFzcLXoBKmfIl6 VmCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CjDUHdg8cFM7kS83KS618TD4uElmyA10hO9dwUkMOD8=; b=ZwT0EYPb9LjnXtkXdFrA81/CKHeZAz8AMqUCo0f4KmOP3DN7oXIno6nXyS3TN39LSL Am0e5Q+ihXyAaDjsAEZFnqCTG1A2/Cn5LGG6UkoYqhbcUhqFXO8bOuy2ejhVPegz/YMP kkGyURe0X5LAGCYABIhfFYvK/gIRzo3pENAJWyPIW4y3ldS+f9cZkKNtJGM9T8O3AOMD Y3gjT5rOX85oKWonMSoMX8sN+JTwtaagFKzusP81bb7bQ7SwIXMXUTLPpkYSZl6ENdHi bPnPkswGxhskYmnnMEPKEsA7vbpdlTO2k5olaVqRB+zCIxLi+MLn183b/UPo4PT6LgZ9 4+zg== X-Gm-Message-State: AOAM533azuItoJHKhNZ/G0+THq3wlwoLp9ms6zvZeooNPsIH1vHPPPRj pKtj1JTsGYQ2DQgM38NO7bs= X-Google-Smtp-Source: ABdhPJwrojQGWx5ySvoO7WtsNRq8OASz8gqW8BN6clOG1VkXmIodWaR5f99J4mVoKuQ9QKI3tDi2rg== X-Received: by 2002:a05:622a:342:b0:2f3:dd79:2463 with SMTP id r2-20020a05622a034200b002f3dd792463mr7817047qtw.468.1652197691097; Tue, 10 May 2022 08:48:11 -0700 (PDT) Received: from localhost ([98.242.65.84]) by smtp.gmail.com with ESMTPSA id x11-20020a05620a01eb00b0069fc13ce230sm2735416qkn.97.2022.05.10.08.48.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 May 2022 08:48:10 -0700 (PDT) From: Yury Norov To: Andy Shevchenko , David Laight , Greg Kroah-Hartman , Joe Perches , Julia Lawall , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Nicholas Piggin , Nicolas Palix , Peter Zijlstra , Rasmus Villemoes , Matti Vaittinen , linux-kernel@vger.kernel.org Cc: Yury Norov , Ingo Molnar , Valentin Schneider , linux-ia64@vger.kernel.org Subject: [PATCH 12/22] ia64: cleanup remove_siblinginfo() Date: Tue, 10 May 2022 08:47:40 -0700 Message-Id: <20220510154750.212913-13-yury.norov@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220510154750.212913-1-yury.norov@gmail.com> References: <20220510154750.212913-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" remove_siblinginfo() initialises variable 'last', but never uses it. Drop unneeded code. CC: Ingo Molnar CC: Peter Zijlstra CC: Valentin Schneider CC: linux-ia64@vger.kernel.org CC: linux-kernel@vger.kernel.org Signed-off-by: Yury Norov --- arch/ia64/kernel/smpboot.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/arch/ia64/kernel/smpboot.c b/arch/ia64/kernel/smpboot.c index d10f780c13b9..d0e935cf2093 100644 --- a/arch/ia64/kernel/smpboot.c +++ b/arch/ia64/kernel/smpboot.c @@ -576,8 +576,6 @@ clear_cpu_sibling_map(int cpu) static void remove_siblinginfo(int cpu) { - int last =3D 0; - if (cpu_data(cpu)->threads_per_core =3D=3D 1 && cpu_data(cpu)->cores_per_socket =3D=3D 1) { cpumask_clear_cpu(cpu, &cpu_core_map[cpu]); @@ -585,8 +583,6 @@ remove_siblinginfo(int cpu) return; } =20 - last =3D (cpumask_weight(&cpu_core_map[cpu]) =3D=3D 1 ? 1 : 0); - /* remove it from all sibling map's */ clear_cpu_sibling_map(cpu); } --=20 2.32.0 From nobody Fri May 8 05:17:26 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 C5E09C43219 for ; Tue, 10 May 2022 15:58:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347196AbiEJQBY (ORCPT ); Tue, 10 May 2022 12:01:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347258AbiEJPwK (ORCPT ); Tue, 10 May 2022 11:52:10 -0400 Received: from mail-qk1-x72b.google.com (mail-qk1-x72b.google.com [IPv6:2607:f8b0:4864:20::72b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D80927CEB for ; Tue, 10 May 2022 08:48:13 -0700 (PDT) Received: by mail-qk1-x72b.google.com with SMTP id w3so13494728qkb.3 for ; Tue, 10 May 2022 08:48:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DzOa2Y6OHG3zOOzih/UHA/mPrL2daZ9U5xSUAySq5NU=; b=YVhCf3kv6LNcxdYGCaM/o5jNWq1DDbQfDYf/9LDqfd66iJk7/HfHCtJNlQiAQIKeZM 87oKMPsmHN93oL4KtTqgJFQbFKzHw0V6h2LmGBrwzWvzOprPZEgRZD+MBCHRem0ivFxV jHqIEiKw11O06Ak3pj601EFWZgX+rUr7z1sudH+YjBYe32I1ZukX8vw99o7YtpaChpda dVCXY2yMJ0cZ2Xo1/IwU0vU8N9j4Obm21gk6VAFr+fuwK+8y+8d2oE4kgp3RnLKvu6Am L6gFw7fABYZU42euETFajBlYYWce93rcd+txWWzkD+TrA2yTyRIZzfg/TBGphP5FGdso CSBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DzOa2Y6OHG3zOOzih/UHA/mPrL2daZ9U5xSUAySq5NU=; b=6LLLTdSG0NTGB6qrWpCOFPlTz6etya7zXIRZ6hy/EDtqd1s5vZ0E10Pv7etlMX+yGL PLLKAscbBa2R43zC7xHkFdKScBVIl0e5CWuIbiRkRPOKVQUEtZ9vnG43gOujiYlH3zqJ lUD4FYbQMD9y5E/1NPOsxGXpaIQw/zM2U0S/+zMpHvo9OUUzRhM3aGk4s6g1y1lwsV5u CoBwSGtELEpEzd/J1AEnfXAnVkVhwPaKcLosOBcso9jARJJy9F+Ic26QRyUAdbe7JEMu R0H8EZAHGtay96ZLh7P1if2fLguwCivoAHqpp1DApy0+g4gORgT2LORTo0WYZG5tdgwr qR+w== X-Gm-Message-State: AOAM533cHZA56K++nqhLln7EBp7zvH+qA0cCXuvlufEC02FSMAHh8Rf1 lD2HnVets6mp3v6PUmfCWT8= X-Google-Smtp-Source: ABdhPJx9CpLX7r2qnlTmMtmnvI9rvpGDbklOgnbqs5MleVgT3HRf2xKTGDSyanO7fV9Jdddep/WekA== X-Received: by 2002:a05:620a:9d2:b0:69f:c168:7a35 with SMTP id y18-20020a05620a09d200b0069fc1687a35mr15982489qky.575.1652197692368; Tue, 10 May 2022 08:48:12 -0700 (PDT) Received: from localhost ([98.242.65.84]) by smtp.gmail.com with ESMTPSA id g15-20020ac87d0f000000b002f3e127be41sm2487642qtb.20.2022.05.10.08.48.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 May 2022 08:48:12 -0700 (PDT) From: Yury Norov To: Andy Shevchenko , David Laight , Greg Kroah-Hartman , Joe Perches , Julia Lawall , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Nicholas Piggin , Nicolas Palix , Peter Zijlstra , Rasmus Villemoes , Matti Vaittinen , linux-kernel@vger.kernel.org Cc: Yury Norov , Balbir Singh , Boris Ostrovsky , Borislav Petkov , Dave Hansen , "H . Peter Anvin" , Huang Rui , Ingo Molnar , "Paul E . McKenney" , "Rafael J . Wysocki" , Sean Christopherson , Thomas Gleixner , Tim Chen , x86@kernel.org Subject: [PATCH 13/22] x86: smp: move cpumask_weight() out of for-loop in remove_siblinginfo Date: Tue, 10 May 2022 08:47:41 -0700 Message-Id: <20220510154750.212913-14-yury.norov@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220510154750.212913-1-yury.norov@gmail.com> References: <20220510154750.212913-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" Because argument of the function is constant inside for_each_cpu() loop, the cpumask_weight() does the same work O(NR_CPUS) times, while it may be calculated only once. This patch moves cpumask_weight() out of the loop and replaces it with cpumask_weight_eq(). While here, fix comment format. CC: Balbir Singh CC: Boris Ostrovsky CC: Borislav Petkov CC: Dave Hansen CC: H. Peter Anvin CC: Huang Rui CC: Ingo Molnar CC: Paul E. McKenney CC: Peter Zijlstra CC: Rafael J. Wysocki CC: Sean Christopherson CC: Thomas Gleixner CC: Tim Chen CC: x86@kernel.org CC: linux-kernel@vger.kernel.org Signed-off-by: Yury Norov --- arch/x86/kernel/smpboot.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index 5e7f9532a10d..7d948f79ef31 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -1605,13 +1605,14 @@ static void remove_siblinginfo(int cpu) { int sibling; struct cpuinfo_x86 *c =3D &cpu_data(cpu); + bool last_thread_sibling =3D cpumask_weight_eq(topology_sibling_cpumask(c= pu), 1); =20 for_each_cpu(sibling, topology_core_cpumask(cpu)) { cpumask_clear_cpu(cpu, topology_core_cpumask(sibling)); - /*/ + /* * last thread sibling in this cpu core going down */ - if (cpumask_weight(topology_sibling_cpumask(cpu)) =3D=3D 1) + if (last_thread_sibling) cpu_data(sibling).booted_cores--; } =20 --=20 2.32.0 From nobody Fri May 8 05:17:26 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 46997C4167D for ; Tue, 10 May 2022 15:58:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347514AbiEJQBq (ORCPT ); Tue, 10 May 2022 12:01:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347263AbiEJPwL (ORCPT ); Tue, 10 May 2022 11:52:11 -0400 Received: from mail-qt1-x82e.google.com (mail-qt1-x82e.google.com [IPv6:2607:f8b0:4864:20::82e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76B5527CF4 for ; Tue, 10 May 2022 08:48:14 -0700 (PDT) Received: by mail-qt1-x82e.google.com with SMTP id h3so13813820qtn.4 for ; Tue, 10 May 2022 08:48:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=T2IJO+Pa5M9voLAKUXr0ktIZBj7JUQbqvUsJEPx3GJM=; b=c3IN7lMAFbv4sEP6laSQRowTvSX+G5HVSYHppf0FixY2y1TOg935HHtOG7mdR4VDoe LQ69xKtAOxfnp4jdc3DXQEgPRlFnpm00mdslKhj6m28OSLFLu9jG5au941IQtcxYX9TQ LhiZpqUmNAvT00BdJohSd3u1bbdaE5Qh+pz80eMMUhg7p6IuxcdGsDdMY3jG2dRCpBRt up0C87zFbVNdmfiE5nx6LZJOpflQEsJdkh86x0JFWLqfBZTWAa3OYqW+AanRLvD2B0BC 5N6Hb4J4B1CLqpldSIQVLKJNnVaehyw4jy1VsGrSBIyXrUm1jSbs+db1MZSetK+1f9zS A30w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=T2IJO+Pa5M9voLAKUXr0ktIZBj7JUQbqvUsJEPx3GJM=; b=0QH68RvxuyjdFimXMyhWDT+efAXL1dTJRpXorKAWfNq8lIg1F4AosERw6qQv8kquqW NQVNn+7GVLvWoCYmJBSTLoGX1xHzlLT7vakSGxn62A6ATcDni6lIq7ffwMubwDFaMnRQ zsWn0XhCgqn58GcJhE6XIUOqCTh4S2qxOzbTCvSVHLSOU/Lh2tTQukKSUxdPLEj1K2TS T1lDiP+yKC0xs7FS7A6Iq+7ljVWviRfJzAT4B4juAHu8A8D4jFo2kCK4GNLyuCwNzTyB pIQnDm9v6v2t8d+LdTHquNaR4EMaYEScD2EEn21q57FyiTASBSY0NrpDC37FUgXha9rT pr0Q== X-Gm-Message-State: AOAM5338ixKM7DFcV7KSnICGae5eQnOnFHE/z7mdvPghksV5UvtkTky1 R/gG/43CpaXInadEpxgIcIaD05Oc09/K4g== X-Google-Smtp-Source: ABdhPJz52r13mAcgDBQf1ACM0hZ/J0vco7XnwEomdirN9ZWSxVJnzg675wnJR4aV7S74ZqzB7KnbjA== X-Received: by 2002:ac8:7fd1:0:b0:2f3:dddb:4206 with SMTP id b17-20020ac87fd1000000b002f3dddb4206mr7333570qtk.11.1652197693544; Tue, 10 May 2022 08:48:13 -0700 (PDT) Received: from localhost ([98.242.65.84]) by smtp.gmail.com with ESMTPSA id z7-20020ac875c7000000b002f39b99f6b5sm9242338qtq.79.2022.05.10.08.48.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 May 2022 08:48:13 -0700 (PDT) From: Yury Norov To: Andy Shevchenko , David Laight , Greg Kroah-Hartman , Joe Perches , Julia Lawall , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Nicholas Piggin , Nicolas Palix , Peter Zijlstra , Rasmus Villemoes , Matti Vaittinen , linux-kernel@vger.kernel.org Cc: Yury Norov , Balbir Singh , Boris Ostrovsky , Borislav Petkov , Dave Hansen , "H . Peter Anvin" , Huang Rui , Ingo Molnar , "Paul E . McKenney" , "Rafael J . Wysocki" , Sean Christopherson , Thomas Gleixner , Tim Chen , x86@kernel.org Subject: [PATCH 14/22] x86: smp: use cpumask_weight_eq() in remove_siblinginfo Date: Tue, 10 May 2022 08:47:42 -0700 Message-Id: <20220510154750.212913-15-yury.norov@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220510154750.212913-1-yury.norov@gmail.com> References: <20220510154750.212913-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_weight_eq() is more efficient because it may stop traversing cpumask depending on condition. CC: Balbir Singh CC: Boris Ostrovsky CC: Borislav Petkov CC: Dave Hansen CC: H. Peter Anvin CC: Huang Rui CC: Ingo Molnar CC: Paul E. McKenney CC: Peter Zijlstra CC: Rafael J. Wysocki CC: Sean Christopherson CC: Thomas Gleixner CC: Tim Chen CC: x86@kernel.org CC: linux-kernel@vger.kernel.org Signed-off-by: Yury Norov --- arch/x86/kernel/smpboot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index 7d948f79ef31..74ca98b3ab2a 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -1621,7 +1621,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.32.0 From nobody Fri May 8 05:17:26 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 56628C41535 for ; Tue, 10 May 2022 15:58:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347575AbiEJQBt (ORCPT ); Tue, 10 May 2022 12:01:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347267AbiEJPwN (ORCPT ); Tue, 10 May 2022 11:52:13 -0400 Received: from mail-qt1-x82b.google.com (mail-qt1-x82b.google.com [IPv6:2607:f8b0:4864:20::82b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3D8B27FE4; Tue, 10 May 2022 08:48:15 -0700 (PDT) Received: by mail-qt1-x82b.google.com with SMTP id fu47so13827619qtb.5; Tue, 10 May 2022 08:48:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Yb/F6YFHx8jMmT8NzFo+iYOEgGU08YViXeElbI3tjgc=; b=MMnXS3xA1tmydR2qCDMamehnHI5FTZPQnT0YdSBT4isID4m9dejiQqAVaASciKXh2t uNvjLP9M1SpNR4L9suFWs2GB3zj0kW6tIw+HGOGD0qgwx94I6AWsORwzqjwEJ0Yw8Lon SHAjLcmqVRiNW8qsl5AfmJNSQJxIMdeX/5OhcZCWobvLe1G4TOlSiS1f4gQUkC3AyewE s/5zKTm6e85HXpPxzZGWWHF7kuC8kNjOOFMOLzuI6valozkPvbjyLJR/echRLonbSXes Vef44tpvYg2wXOOhFuE8RU0X4TxNWG/udFq3Emz7Cl/FRJe4tXgux0zhuZj3kBgh3jZD 9N3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Yb/F6YFHx8jMmT8NzFo+iYOEgGU08YViXeElbI3tjgc=; b=76KRrIAfArRUp4oHOH+q8Q1eCGeF4C0taImlIGbukwMIGyjKwxuWpkklPgrT/kuhc5 yJPlwBiUUp3BfXD23HIutJPzok2gMTbXuAj4TuMCfatte54JKnaTs071rCvslAIwfiXs GjRWKXwZFo9LmnbeHU8EjetkITZw7XCvp42ZLbB3JLqyzZzL1+DB9cnrgumfFfx3XEFu 81YqUvKwGGgrNZyCzo6JE1EVaALx3h+bAiMXJl4CHM1eEt9COp5aKE8QD4F5RSCIpWXf x+OskF7rVUhA5bp/XIPd8YDkylrloaraa3kfMW70URozjbjLZN88Y0WDdn4hP1GoV2s2 ZjHQ== X-Gm-Message-State: AOAM530b7Dwz3XLIq9adoT9BAqCT1884OEYOjet/Y45Lk+w3lWs23hnH poNcC8IgoVBlCZE81XbzsAg= X-Google-Smtp-Source: ABdhPJwV70hoAcYnRzaFrPNRGD//htdKIyrvhMG9B5O5rgnhDgAUf7COuLmQzmUbet3XQOUvrJCg2A== X-Received: by 2002:a05:622a:93:b0:2f3:c4ef:6c71 with SMTP id o19-20020a05622a009300b002f3c4ef6c71mr19568082qtw.505.1652197694757; Tue, 10 May 2022 08:48:14 -0700 (PDT) Received: from localhost ([98.242.65.84]) by smtp.gmail.com with ESMTPSA id c2-20020ac80542000000b002f39b99f67bsm9312717qth.21.2022.05.10.08.48.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 May 2022 08:48:14 -0700 (PDT) From: Yury Norov To: Andy Shevchenko , David Laight , Greg Kroah-Hartman , Joe Perches , Julia Lawall , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Nicholas Piggin , Nicolas Palix , Peter Zijlstra , Rasmus Villemoes , Matti Vaittinen , linux-kernel@vger.kernel.org Cc: Yury Norov , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Leon Romanovsky , Paolo Abeni , Saeed Mahameed , netdev@vger.kernel.org, linux-rdma@vger.kernel.org Subject: [PATCH 15/22] net/mlx5: use cpumask_weight_gt() in irq_pool_request_irq() Date: Tue, 10 May 2022 08:47:43 -0700 Message-Id: <20220510154750.212913-16-yury.norov@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220510154750.212913-1-yury.norov@gmail.com> References: <20220510154750.212913-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_weight_gt() is more efficient because it may stop traversing cpumask depending on condition. CC: David S. Miller CC: Eric Dumazet CC: Jakub Kicinski CC: Leon Romanovsky CC: Paolo Abeni CC: Saeed Mahameed CC: netdev@vger.kernel.org CC: linux-rdma@vger.kernel.org CC: linux-kernel@vger.kernel.org Signed-off-by: Yury Norov --- drivers/net/ethernet/mellanox/mlx5/core/irq_affinity.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/irq_affinity.c b/drive= rs/net/ethernet/mellanox/mlx5/core/irq_affinity.c index 380a208ab137..d57f804ee934 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/irq_affinity.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/irq_affinity.c @@ -58,7 +58,7 @@ irq_pool_request_irq(struct mlx5_irq_pool *pool, const st= ruct cpumask *req_mask) if (err) return ERR_PTR(err); if (pool->irqs_per_cpu) { - if (cpumask_weight(req_mask) > 1) + if (cpumask_weight_gt(req_mask, 1)) /* if req_mask contain more then one CPU, set the least loadad CPU * of req_mask */ --=20 2.32.0 From nobody Fri May 8 05:17:26 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 24F6CC4321E for ; Tue, 10 May 2022 15:58:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347387AbiEJQBj (ORCPT ); Tue, 10 May 2022 12:01:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244548AbiEJPwP (ORCPT ); Tue, 10 May 2022 11:52:15 -0400 Received: from mail-qk1-x72b.google.com (mail-qk1-x72b.google.com [IPv6:2607:f8b0:4864:20::72b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F24E829C90 for ; Tue, 10 May 2022 08:48:16 -0700 (PDT) Received: by mail-qk1-x72b.google.com with SMTP id n8so13036701qke.11 for ; Tue, 10 May 2022 08:48:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9Up5mCRghdypCXqXuJXfOWXocHqkgAdBl0+nsIM6Ysk=; b=JrNKu8ky7+tpeG4ipUBQNtHzamSzZvYFj1Jd6PRPJedGnMmLC/UH9a8NiwkmteVTzu d/+hLjUfYQ1fZO2CZKwt/XZkYe+OEoggGwWT33OfPOWDldoSBohHekj0AgQIdS+iw6OY YhFlVKAE3EhotCYNBKwmA/GbOfAY0s9EkvEfB0a886iD+j550LL5VN5ELQBxg9nXbMyY +OG9Z9EcqaJedFV1SkQwScKv3AXmgaBv5M7b9o+Ej9qwE3kBiKWzxUmZqPhegRS20Qwt i3b6hDk2Tlgjkjfg/HiOt/+ncui0jqfeBgr2f+UTLGe0ssXiFMyC3OwvKUlswUQlTZc6 L+Wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9Up5mCRghdypCXqXuJXfOWXocHqkgAdBl0+nsIM6Ysk=; b=uvGaaGEsVrtgtHIEXB+J85+fdHWbihRoYE0kN7d2TEBe6Sn8dCSxxMcImVGD9w8ZH5 1s5pNphuiJbz2TLGMQAZzbyTGdHqFmhGm1yd7K3T+2gKhS/S3zJ3096uNi3JEO/FwqrR Glxhe+vnxr1f75tw0xXac6zpnop/RwkFDuYtipms68BWuRyULJUl5ekHY06l8BZ/rXRq NHTI2O7JSyMJatZjWoGm7jNO3GjK3Y36hV2JaIuLSA6KshNh0+ICVorAN39yV4AprxI9 nyJmkSmjRTrxR3a5pqoru4gH1//gawYjAwifLmSIqcU0EKFIe+TZp6apZW2DoViab43F rWdQ== X-Gm-Message-State: AOAM5300LV70sbn2vgr9JB7zgHf8P1a24Doi4/dkU8hc4YDDG61h8TUC XxhgZtnjukv1fGq9g9g1ta4= X-Google-Smtp-Source: ABdhPJxt6oOjgPrazsh7EG7WhxZdH/RZY9aRthrd5IIpfiwxm4IanfNY3MYjHZh2X3jzG1aDQuKJzA== X-Received: by 2002:a05:620a:270c:b0:6a0:92b9:8196 with SMTP id b12-20020a05620a270c00b006a092b98196mr7469614qkp.417.1652197696083; Tue, 10 May 2022 08:48:16 -0700 (PDT) Received: from localhost ([98.242.65.84]) by smtp.gmail.com with ESMTPSA id h3-20020ac85483000000b002f39b99f6c7sm9105610qtq.97.2022.05.10.08.48.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 May 2022 08:48:15 -0700 (PDT) From: Yury Norov To: Andy Shevchenko , David Laight , Greg Kroah-Hartman , Joe Perches , Julia Lawall , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Nicholas Piggin , Nicolas Palix , Peter Zijlstra , Rasmus Villemoes , Matti Vaittinen , linux-kernel@vger.kernel.org Cc: Yury Norov , Borislav Petkov , Dave Hansen , Feng Tang , "H . Peter Anvin" , Ingo Molnar , Thomas Gleixner , x86@kernel.org Subject: [PATCH 16/22] x86/tsc: use cpumask_weight_gt() in loop_timeout() Date: Tue, 10 May 2022 08:47:44 -0700 Message-Id: <20220510154750.212913-17-yury.norov@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220510154750.212913-1-yury.norov@gmail.com> References: <20220510154750.212913-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_weight_gt() is more efficient because it may stop traversing cpumask depending on condition. This piece is not performance-critical, but helps keeping consistency of cpumask_weight() usage. CC: Borislav Petkov CC: Dave Hansen CC: Feng Tang CC: H. Peter Anvin CC: Ingo Molnar CC: Thomas Gleixner CC: x86@kernel.org CC: linux-kernel@vger.kernel.org Signed-off-by: Yury Norov --- arch/x86/kernel/tsc_sync.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/tsc_sync.c b/arch/x86/kernel/tsc_sync.c index 9452dc9664b5..2dc80e6f0a4f 100644 --- a/arch/x86/kernel/tsc_sync.c +++ b/arch/x86/kernel/tsc_sync.c @@ -340,7 +340,7 @@ static cycles_t check_tsc_warp(unsigned int timeout) */ static inline unsigned int loop_timeout(int cpu) { - return (cpumask_weight(topology_core_cpumask(cpu)) > 1) ? 2 : 20; + return cpumask_weight_gt(topology_core_cpumask(cpu), 1) ? 2 : 20; } =20 /* --=20 2.32.0 From nobody Fri May 8 05:17:26 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 3461FC4167E for ; Tue, 10 May 2022 15:58:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347455AbiEJQBn (ORCPT ); Tue, 10 May 2022 12:01:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346208AbiEJPwQ (ORCPT ); Tue, 10 May 2022 11:52:16 -0400 Received: from mail-qk1-x72c.google.com (mail-qk1-x72c.google.com [IPv6:2607:f8b0:4864:20::72c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D1F42AE1B for ; Tue, 10 May 2022 08:48:18 -0700 (PDT) Received: by mail-qk1-x72c.google.com with SMTP id m1so6260426qkn.10 for ; Tue, 10 May 2022 08:48:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ya/vdwdChlS+tAL1BwfCVBl0QMpJDdlIuc7UFyY3mko=; b=TlCC1FHeS9Vp7sRgrVJU6EDQc+dQs1Lvm3qZXexX4iAcPaDkDWQ4a3FtR2FSWjCDIm 5YVZRmJaG/Nv41leZxxgqULfaZjhMneVrYRPDAkl2sQdsbEftNGM3AIaROuL5Wdafn4I WZ9o/4T5VzWixRbR4gMP2ZMrm82bLeKSpwEzYh5OZl3AqH1LBA9Ou/BSEu6wvNfNicV4 4AOy9kIJ0/chNSK9noA79+b8sn4qeKt9zB2fXS/yGVQbG5SwYaIGpIjhqL75kqKtCQmB nOt/qBhGRKoO7S+PwiR4VDign1xYc5MjlGOGQuYnyRdLFh1ReKHE+wcJbHEVRHZGAJod +YXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ya/vdwdChlS+tAL1BwfCVBl0QMpJDdlIuc7UFyY3mko=; b=KCtnbeOpSoFJYQXP3Ph/nkm+mU/kbhLPuGsXXHFk6ZMaerJ65nZHfXv+GQoTqi+RKj g8a88uXv5pSWbWlu5XydTkZPfrjEE8DGgrnfpTHL+N1PcX8YKnl65JhLx5GqCppoajQj Fbe0pkmhy7EgzAXcYS4hC/Ra+aVdxE6CECCGypMWe3ojzqeStKeUTxvQNhndnn4DIDtV +omGNF92SE23YZSmAxWv002mKvQ0qkCBYDckxblIpL05CeCCFzXsP3KiNs0y07ulagVS nlDovqMEjltToDRG7x2C05hOfe7c2P1OF818V2f9ai3XwPALv7ECMxhkjpiSXIcaXeIM oZ7g== X-Gm-Message-State: AOAM5323TMjoe7s5uKFOQoA/Oe32s+U4wrY8Vk2I3IFbvODboHKHMuVV ajBMS6fsLHxRX0Viely1qdk= X-Google-Smtp-Source: ABdhPJzj4In6E2K7mgcFdSROB32xJL8d3sEtetPOgoESLE4arPsqpmo93DwWFWTuroO0mHGo22+zOg== X-Received: by 2002:a05:620a:1036:b0:69f:d57d:8136 with SMTP id a22-20020a05620a103600b0069fd57d8136mr15808970qkk.671.1652197697353; Tue, 10 May 2022 08:48:17 -0700 (PDT) Received: from localhost ([98.242.65.84]) by smtp.gmail.com with ESMTPSA id f3-20020ac84643000000b002f39b99f671sm9418292qto.11.2022.05.10.08.48.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 May 2022 08:48:17 -0700 (PDT) From: Yury Norov To: Andy Shevchenko , David Laight , Greg Kroah-Hartman , Joe Perches , Julia Lawall , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Nicholas Piggin , Nicolas Palix , Peter Zijlstra , Rasmus Villemoes , Matti Vaittinen , linux-kernel@vger.kernel.org Cc: Yury Norov , Ben Segall , Daniel Bristot de Oliveira , Dietmar Eggemann , Ingo Molnar , Juri Lelli , Mel Gorman , Steven Rostedt , Valentin Schneider , Vincent Guittot Subject: [PATCH 17/22] sched/core: fix opencoded cpumask_any_but() Date: Tue, 10 May 2022 08:47:45 -0700 Message-Id: <20220510154750.212913-18-yury.norov@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220510154750.212913-1-yury.norov@gmail.com> References: <20220510154750.212913-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" sched_core_cpu_starting() and sched_core_cpu_deactivate() implement opencoded cpumask_any_but(). Fix it. CC: Ben Segall CC: Daniel Bristot de Oliveira CC: Dietmar Eggemann CC: Ingo Molnar CC: Juri Lelli CC: Mel Gorman CC: Peter Zijlstra CC: Steven Rostedt CC: Valentin Schneider CC: Vincent Guittot CC: linux-kernel@vger.kernel.org Signed-off-by: Yury Norov --- kernel/sched/core.c | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index f5ebc392493d..9700001948d0 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -6125,7 +6125,7 @@ static void queue_core_balance(struct rq *rq) static void sched_core_cpu_starting(unsigned int cpu) { const struct cpumask *smt_mask =3D cpu_smt_mask(cpu); - struct rq *rq =3D cpu_rq(cpu), *core_rq =3D NULL; + struct rq *rq =3D cpu_rq(cpu), *core_rq; unsigned long flags; int t; =20 @@ -6138,19 +6138,16 @@ static void sched_core_cpu_starting(unsigned int cp= u) goto unlock; =20 /* find the leader */ - for_each_cpu(t, smt_mask) { - if (t =3D=3D cpu) - continue; - rq =3D cpu_rq(t); - if (rq->core =3D=3D rq) { - core_rq =3D rq; - break; - } - } + t =3D cpumask_any_but(smt_mask, cpu); + if (t >=3D nr_cpu_ids) + goto unlock; =20 - if (WARN_ON_ONCE(!core_rq)) /* whoopsie */ + rq =3D cpu_rq(t); + if (WARN_ON_ONCE(rq->core !=3D rq)) /* whoopsie */ goto unlock; =20 + core_rq =3D rq; + /* install and validate core_rq */ for_each_cpu(t, smt_mask) { rq =3D cpu_rq(t); @@ -6168,7 +6165,7 @@ static void sched_core_cpu_starting(unsigned int cpu) static void sched_core_cpu_deactivate(unsigned int cpu) { const struct cpumask *smt_mask =3D cpu_smt_mask(cpu); - struct rq *rq =3D cpu_rq(cpu), *core_rq =3D NULL; + struct rq *rq =3D cpu_rq(cpu), *core_rq; unsigned long flags; int t; =20 @@ -6185,16 +6182,12 @@ static void sched_core_cpu_deactivate(unsigned int = cpu) goto unlock; =20 /* find a new leader */ - for_each_cpu(t, smt_mask) { - if (t =3D=3D cpu) - continue; - core_rq =3D cpu_rq(t); - break; - } - - if (WARN_ON_ONCE(!core_rq)) /* impossible */ + t =3D cpumask_any_but(smt_mask, cpu); + if (t >=3D nr_cpu_ids) goto unlock; =20 + core_rq =3D cpu_rq(t); + /* copy the shared state to the new leader */ core_rq->core_task_seq =3D rq->core_task_seq; core_rq->core_pick_seq =3D rq->core_pick_seq; --=20 2.32.0 From nobody Fri May 8 05:17:26 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 064D3C4167B for ; Tue, 10 May 2022 15:58:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347322AbiEJQBg (ORCPT ); Tue, 10 May 2022 12:01:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346250AbiEJPwR (ORCPT ); Tue, 10 May 2022 11:52:17 -0400 Received: from mail-qt1-x834.google.com (mail-qt1-x834.google.com [IPv6:2607:f8b0:4864:20::834]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 890252CC94 for ; Tue, 10 May 2022 08:48:19 -0700 (PDT) Received: by mail-qt1-x834.google.com with SMTP id p4so13818002qtq.12 for ; Tue, 10 May 2022 08:48:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bRZCptIM03juaQv67hbbg4JReeAbmT3D5f9cphqNW9A=; b=FEVX6hWuLn7gTdB8Ry8/1gWnCWSO+tOkXnA4I3M29xUL2FIgRHi1ILsobsRmN+EpZs aJH3WxU0uKmKDheSwl2lRSJE/3sDCZJ4nttB8pgAs/Jb0gVUKEMRWbmgN22YlLJyAhO/ MR3DDWLJLejOAErjVdhHpMLI0ZE2IfCrl0kvgfpceVOdesnEQR3haqdchVZb3vXFvGTi A9Eff4upsFZrO/ORpwjECQ15qnwpy5an9lFA0Dta3brrC0DNBcFh9UA8fiQoS/huVUpJ Xb3JDk0nFnbWoRKp4O8h//ZwQT3H7sVnUe6PHMYnDuzpCQoye+G+yIvGR28Qs81aHwLn vIsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bRZCptIM03juaQv67hbbg4JReeAbmT3D5f9cphqNW9A=; b=Jkut5vv5z6zX9te8Ow+/xdxxLL2FPfVysijKszlK4t5UPBkpwkPRA7iMZORRSslNYS M0DFD3KAQi1VSLe5/hBtqvBxjBjeQpsuXVUlhEgo+R6oPTGWNS4L2th6upTb3jY4duRg slE/Wfk5bxbpJaEeHbJQ8RK0Nb9UxX70QXBJ333w0/NwW1yiNJt7sRTfoitaj4QIrT7Q 1z2h2AAfUPXZXv4s7m7QnM8H3RjedGKkQHchWkTHBfoSEYXPP5Rg3D1LB9Pl3jGsFeOo bQ/hEM1z5cU8MuVsOWDLr8dgzLGwqc5XnlTFP5eCS4FSUo1pcWJqnBTTn3Y6SooK0qGt PSEA== X-Gm-Message-State: AOAM530SG65W3gOinoQjM2EuKJo+GQ53YS6HtA4QemWuhSvfEBOZDEhd kO4dKVH5DoHhwlF/a0sOZ1g= X-Google-Smtp-Source: ABdhPJxOyrqz39sJo5kShX2mHmWAGuRDJv6Z8jgBVfVRbzekEbV4JEux0WZeo9gXBj1oPecD4VRcuw== X-Received: by 2002:a05:622a:143:b0:2e0:b7c8:3057 with SMTP id v3-20020a05622a014300b002e0b7c83057mr20386773qtw.179.1652197698712; Tue, 10 May 2022 08:48:18 -0700 (PDT) Received: from localhost ([98.242.65.84]) by smtp.gmail.com with ESMTPSA id h4-20020ac87764000000b002f39b99f6a2sm9129878qtu.60.2022.05.10.08.48.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 May 2022 08:48:18 -0700 (PDT) From: Yury Norov To: Andy Shevchenko , David Laight , Greg Kroah-Hartman , Joe Perches , Julia Lawall , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Nicholas Piggin , Nicolas Palix , Peter Zijlstra , Rasmus Villemoes , Matti Vaittinen , linux-kernel@vger.kernel.org Cc: Yury Norov , Ben Segall , Daniel Bristot de Oliveira , Dietmar Eggemann , Ingo Molnar , Juri Lelli , Mel Gorman , Steven Rostedt , Valentin Schneider , Vincent Guittot Subject: [PATCH 18/22] sched/core: remove unneeded cpumask_weight() in sched_core_cpu_{starting,deactivate} Date: Tue, 10 May 2022 08:47:46 -0700 Message-Id: <20220510154750.212913-19-yury.norov@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220510154750.212913-1-yury.norov@gmail.com> References: <20220510154750.212913-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 following cpumask_any_but() implicitly calculates if number of smt cpus is equal to 1, therefore we can drop the code that does it explicitly. CC: Ben Segall CC: Daniel Bristot de Oliveira CC: Dietmar Eggemann CC: Ingo Molnar CC: Juri Lelli CC: Mel Gorman CC: Peter Zijlstra CC: Steven Rostedt CC: Valentin Schneider CC: Vincent Guittot CC: linux-kernel@vger.kernel.org Signed-off-by: Yury Norov --- This is RFC because it drops WARN_ON_ONCE(rq->core !=3D rq). If this warinig is important, I'll rework the patch. kernel/sched/core.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 9700001948d0..07b8f35cbe36 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -6133,12 +6133,10 @@ static void sched_core_cpu_starting(unsigned int cp= u) =20 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) - goto unlock; - /* find the leader */ t =3D cpumask_any_but(smt_mask, cpu); + + /* if we're the first, we'll be our own leader */ if (t >=3D nr_cpu_ids) goto unlock; =20 @@ -6171,18 +6169,14 @@ static void sched_core_cpu_deactivate(unsigned int = cpu) =20 sched_core_lock(cpu, &flags); =20 - /* if we're the last man standing, nothing to do */ - if (cpumask_weight(smt_mask) =3D=3D 1) { - WARN_ON_ONCE(rq->core !=3D rq); - goto unlock; - } - /* if we're not the leader, nothing to do */ if (rq->core !=3D rq) goto unlock; =20 /* find a new leader */ t =3D cpumask_any_but(smt_mask, cpu); + + /* if we're the last man standing, nothing to do */ if (t >=3D nr_cpu_ids) goto unlock; =20 --=20 2.32.0 From nobody Fri May 8 05:17:26 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 8775BC433F5 for ; Tue, 10 May 2022 15:58:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346886AbiEJQCh (ORCPT ); Tue, 10 May 2022 12:02:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346675AbiEJPxE (ORCPT ); Tue, 10 May 2022 11:53:04 -0400 Received: from mail-qv1-xf32.google.com (mail-qv1-xf32.google.com [IPv6:2607:f8b0:4864:20::f32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7458B532DA for ; Tue, 10 May 2022 08:48:33 -0700 (PDT) Received: by mail-qv1-xf32.google.com with SMTP id h13so12911960qvh.0 for ; Tue, 10 May 2022 08:48:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bur4fxX/BrvprtCkzJ/rZNHI8r/mAEcHC8jDO+mfnuQ=; b=e7ZZlkybHOWLJx+oXUj0vXRSFyZd8IYa9ACjNcnatMK/JMp+ySDRPjT8uYOTAK8/7w lqdT156i0/jzgVElyb+JwrSMtOu7v0GL3YWJ/fVSU5cW3QFxtamzQa9GVDD0UzcDykJY FIc14I3NO0kojfKSu1255m+u3SDIOzbm4qF54SSdjoTRnnHt3C6qwPArhu3xwKIqccDG XQa+XqwN+qG41jvzVVIwOo5+4AHBpRv6jNutI5YRL/nE25gadkwFtzGt8sn4oazHvIiW bplPPpKcV5366Bm++v20GW3o574omfVzA9MtlUOaq+E/lSmy9fxyNUvfA2K0bbH3mLIq 3/6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bur4fxX/BrvprtCkzJ/rZNHI8r/mAEcHC8jDO+mfnuQ=; b=PlxTk68XAEXlbvtv6hWiXsWwkQHcUJ4gV8HxZyGd14OQfxRs49C12Z/ISKn3qQ6pU9 1WslQQ/Y0XLjqzPVXSCi2hO11DtGk/uhJ3LRXxinqnkrslQN6aiD2dWC6caPTZlxYfwV 1dl3cynVrf7b0mP24vmqGxy/WdjRKMrk/tU5kFdtai0F6R9K1YjAp3pmeowgW/HnHSa6 +pYlp2qpZvFUgwmee72FKWH12cFlXtIlwcNE32Vd+vWgZizd2XVsF9pC9Q44iN+w8HyS vwAWX8nBIWWh5t9F4YJ+obm3lT8ZeuN6EmC/lximiaGNB6pnWu2XeWg2buhDde73nyUM /QMQ== X-Gm-Message-State: AOAM531EEfoAwCyBeEvrPb2t7k3PctYicoCi/QRh6E6AAX+YMoqNKWZC my2+g3FVY+NR2nNJ+508OFo= X-Google-Smtp-Source: ABdhPJwQdNePPFuFx14UNaElb8MMSTHODZBDKbBYDNtA5BGS6X1s0xUxFjgIKXYwJ3SqCHWVDWzl6g== X-Received: by 2002:a0c:8001:0:b0:45a:a28a:99ef with SMTP id 1-20020a0c8001000000b0045aa28a99efmr18155233qva.99.1652197699995; Tue, 10 May 2022 08:48:19 -0700 (PDT) Received: from localhost ([98.242.65.84]) by smtp.gmail.com with ESMTPSA id m19-20020ac84453000000b002f39b99f674sm9248352qtn.14.2022.05.10.08.48.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 May 2022 08:48:19 -0700 (PDT) From: Yury Norov To: Andy Shevchenko , David Laight , Greg Kroah-Hartman , Joe Perches , Julia Lawall , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Nicholas Piggin , Nicolas Palix , Peter Zijlstra , Rasmus Villemoes , Matti Vaittinen , linux-kernel@vger.kernel.org Cc: Yury Norov , Ben Segall , Daniel Bristot de Oliveira , Dietmar Eggemann , Ingo Molnar , Juri Lelli , Mel Gorman , Steven Rostedt , Valentin Schneider , Vincent Guittot Subject: [PATCH 19/22] sched/core: replace cpumask_weight() with cpumask_weight_eq() where appropriate Date: Tue, 10 May 2022 08:47:47 -0700 Message-Id: <20220510154750.212913-20-yury.norov@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220510154750.212913-1-yury.norov@gmail.com> References: <20220510154750.212913-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_weight_eq() is better than cpumask_weight() because it may return earlier depending on condition. CC: Ben Segall CC: Daniel Bristot de Oliveira CC: Dietmar Eggemann CC: Ingo Molnar CC: Juri Lelli CC: Mel Gorman CC: Peter Zijlstra CC: Steven Rostedt CC: Valentin Schneider CC: Vincent Guittot CC: linux-kernel@vger.kernel.org Signed-off-by: Yury Norov --- kernel/sched/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 07b8f35cbe36..6bbd5e880984 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -9234,7 +9234,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); @@ -9310,7 +9310,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); --=20 2.32.0 From nobody Fri May 8 05:17:26 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 B0CADC433F5 for ; Tue, 10 May 2022 15:58:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345774AbiEJQCm (ORCPT ); Tue, 10 May 2022 12:02:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346666AbiEJPxE (ORCPT ); Tue, 10 May 2022 11:53:04 -0400 Received: from mail-qk1-x736.google.com (mail-qk1-x736.google.com [IPv6:2607:f8b0:4864:20::736]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1845E22BF3 for ; Tue, 10 May 2022 08:48:35 -0700 (PDT) Received: by mail-qk1-x736.google.com with SMTP id bs17so3927567qkb.0 for ; Tue, 10 May 2022 08:48:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=D+Ob9aaMTI9Q+iaXKEuKQQeHui5qUx1+hsZMR4tLjS0=; b=m3JS2xWyHZGT8NFfxmxtIl4Kh3WtP3p6ktBysoXoKHQZfpMSS9mj954iRRts2BK+4x 5V7E5hhsNujN1HE8zQf3BHFx1jVQxVL+bxJuXYr+VOSXa6/Z7UImjZDP5QW4s4KLQSGK O7ntbMP8KnCG3UuHo9UfUeBGDeg2ZmRlt27poMwOoedmk9qHCjOAiyBFhNS+6u5OfNiB x8kBJJnNjkDuLTj3HJOhxJF0WYU/EflANRB7UiVs3ebeAqc3iROH9kbT7WxXa7cJSARi bfohBsS4MHhavuITe9Vnw034NHl85wD+fvOAN3sngzOFJ9q5K+SKxhlLW1RwJcdoNJWh MBoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=D+Ob9aaMTI9Q+iaXKEuKQQeHui5qUx1+hsZMR4tLjS0=; b=rv1DyD3ZvkLqjVqXfWnuZrFE12RkR97Ghgfhjcqare3woqIwrChOGQ5tELlzPVSS9i uLXsGNNtBl3aMNWhpui99aVtbS7ubreNu+kX2Lvzem8iDQDVpetn5r/0iyz510xstmmd etIRLIewxo/jvrsA35rFLSfTKS8NQv7m94+Nwc0VNHJ2Ad6u6YcV2ddR0THb/NUAcfZ/ 3Lb9w4DN/Y21t2GQmmqLqe3KRB05AESwjH2LJwuO4SDZAD4R3ZgumVq3yPeRkB6cWGdh /SJbzotk3KBmD689xOPbB2vQDbG47UCk1YXHnuAnDMrOg6Z5+7YpJ7q/kP8QfMUCYsO6 qOig== X-Gm-Message-State: AOAM53178kEBuoCGs+/29ZygyRm0NoXwO/CTXPIIRHx3YXTVUoHmcZXs 4PGDYu6o+T1sT09UmHicMck= X-Google-Smtp-Source: ABdhPJy7WcqEGMFnf1b1ICGoUibKPJ7NRXwYXnzdxR/WUgi4c3o3Cpj0wm14DTQWFGpYYDNwuZqdgA== X-Received: by 2002:a05:620a:4142:b0:6a0:4a07:2027 with SMTP id k2-20020a05620a414200b006a04a072027mr14025416qko.517.1652197713811; Tue, 10 May 2022 08:48:33 -0700 (PDT) Received: from localhost ([98.242.65.84]) by smtp.gmail.com with ESMTPSA id j133-20020a37a08b000000b0069fc13ce1ddsm8907813qke.14.2022.05.10.08.48.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 May 2022 08:48:33 -0700 (PDT) From: Yury Norov To: Andy Shevchenko , David Laight , Greg Kroah-Hartman , Joe Perches , Julia Lawall , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Nicholas Piggin , Nicolas Palix , Peter Zijlstra , Rasmus Villemoes , Matti Vaittinen , linux-kernel@vger.kernel.org Cc: Yury Norov , Ben Segall , Daniel Bristot de Oliveira , Dietmar Eggemann , Ingo Molnar , Juri Lelli , Mel Gorman , Steven Rostedt , Valentin Schneider , Vincent Guittot Subject: [PATCH 20/22] sched/topology: replace cpumask_weight() with cpumask_weight_eq() where appropriate Date: Tue, 10 May 2022 08:47:48 -0700 Message-Id: <20220510154750.212913-21-yury.norov@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220510154750.212913-1-yury.norov@gmail.com> References: <20220510154750.212913-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" Replace cpumask_weight() with cpumask_weight_eq(..., 1) because it may return earlier. CC: Ben Segall CC: Daniel Bristot de Oliveira CC: Dietmar Eggemann CC: Ingo Molnar CC: Juri Lelli CC: Mel Gorman CC: Peter Zijlstra CC: Steven Rostedt CC: Valentin Schneider CC: Vincent Guittot CC: linux-kernel@vger.kernel.org Signed-off-by: Yury Norov --- kernel/sched/topology.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c index 05b6c2ad90b9..860137913b18 100644 --- a/kernel/sched/topology.c +++ b/kernel/sched/topology.c @@ -168,7 +168,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 */ @@ -1999,7 +1999,7 @@ void sched_update_numa(int cpu, bool online) * Scheduler NUMA topology is updated when the first CPU of a * node is onlined or the last CPU of a node is offlined. */ - if (cpumask_weight(cpumask_of_node(node)) !=3D 1) + if (!cpumask_weight_eq(cpumask_of_node(node), 1)) return; =20 sched_reset_numa(); --=20 2.32.0 From nobody Fri May 8 05:17:26 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 C0721C433EF for ; Tue, 10 May 2022 16:00:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238406AbiEJQCb (ORCPT ); Tue, 10 May 2022 12:02:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346588AbiEJPxV (ORCPT ); Tue, 10 May 2022 11:53:21 -0400 Received: from mail-qt1-x830.google.com (mail-qt1-x830.google.com [IPv6:2607:f8b0:4864:20::830]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 163EE56C1D; Tue, 10 May 2022 08:48:35 -0700 (PDT) Received: by mail-qt1-x830.google.com with SMTP id t16so13812425qtr.9; Tue, 10 May 2022 08:48:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JaQCzndoIKElsDsvqhkhCl2RygfACvXHBtQpId5Vc1c=; b=i71gtagyKGiWXzRNxnk9QZMeUToM3U4cmBzQ6dtU9BxKztB+WIf2q/eJVMGYw31RtO /lvkG7Xj2fzKeg7tfEjHvb8mDOvF4wCbpGVUcGgfmpgS+CTjQG0oIvzto6d7BgdQyNwo 8CvMuz0CBBr7zWNnwCwhnlaD5nQ2YSeZ7DDJrrZOFzL/2yC7HgmATq1jPpK6Wc0zlkcI EgAocPHMnzFLYrWp4zGkL52i7DWwype3EbKydFGJ3N3wKMtRZ6bV8rDSy9nhdokf0VDB u4gJJXOFFKbA7fIncH6nCuLNFpvlvwAL7TP+HNqegef5vggAeAVZVtTqD0pHAwE+rKF1 wjTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JaQCzndoIKElsDsvqhkhCl2RygfACvXHBtQpId5Vc1c=; b=sez4mh09uZczc80EcUH823hn3jySeaka8EBU18ueCQqD8fPkZ9HwYsf5f9EqIDnoSS T82SImACg7pUEbUOWvPPSdWlBNYPzUr+Vigg8JVzZhgKhbLSOVX4s2DQYD+x8PUtiO0X G+5YnbUeAb/azpbQKKfmdf0sP7w71AuylIjl9fyhn7woRE2v5X/Q8zUM8yX3N7lNSAIw d0B8UDqwmNbDMink8MkmxwdFlhNPhTu9rkmsRiBjxnj/n9GF4QJ5zQpdOh+9xYXBBrBc /u8oLE0GyjWw0YnKOVYq2qabTxJscRWCl79h1/bjp4cUqevNwIxOJz50wSy/U1jzDmLE Zk/Q== X-Gm-Message-State: AOAM530cXxFdRf+s7R1KxztvKVfmfFwPJIxawjol6X26SpjL1k22F28H hKlDjBvOWhcg7g19lQQp+58= X-Google-Smtp-Source: ABdhPJxuPGmpsFsy5UzCltnN+iZxpIXNeP9GnzMmanpplRZXVgVBhEq1tu6pOlBma+K3eeXlFr3gAQ== X-Received: by 2002:a05:622a:cc:b0:2f1:fc74:c7a6 with SMTP id p12-20020a05622a00cc00b002f1fc74c7a6mr20139605qtw.387.1652197715031; Tue, 10 May 2022 08:48:35 -0700 (PDT) Received: from localhost ([98.242.65.84]) by smtp.gmail.com with ESMTPSA id g25-20020a05620a109900b0069fc13ce1e3sm8619248qkk.20.2022.05.10.08.48.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 May 2022 08:48:34 -0700 (PDT) From: Yury Norov To: Andy Shevchenko , David Laight , Greg Kroah-Hartman , Joe Perches , Julia Lawall , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Nicholas Piggin , Nicolas Palix , Peter Zijlstra , Rasmus Villemoes , Matti Vaittinen , linux-kernel@vger.kernel.org Cc: Yury Norov , "Rafael J . Wysocki" , Viresh Kumar , linux-pm@vger.kernel.org Subject: [PATCH 21/22] cpufreq: use cpumask_weight_gt() in policy_is_shared() Date: Tue, 10 May 2022 08:47:49 -0700 Message-Id: <20220510154750.212913-22-yury.norov@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220510154750.212913-1-yury.norov@gmail.com> References: <20220510154750.212913-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_weight_gt() is better than cpumask_weight() because it may return earlier depending on condition. CC: Rafael J. Wysocki CC: Viresh Kumar CC: linux-pm@vger.kernel.org CC: linux-kernel@vger.kernel.org Signed-off-by: Yury Norov Acked-by: Viresh Kumar --- include/linux/cpufreq.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index d5595d57f4e5..865cc9e23518 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -214,7 +214,7 @@ static inline bool policy_is_inactive(struct cpufreq_po= licy *policy) =20 static inline bool policy_is_shared(struct cpufreq_policy *policy) { - return cpumask_weight(policy->cpus) > 1; + return cpumask_weight_gt(policy->cpus, 1); } =20 #ifdef CONFIG_CPU_FREQ --=20 2.32.0 From nobody Fri May 8 05:17:26 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 0A420C433FE for ; Tue, 10 May 2022 15:58:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347051AbiEJQCW (ORCPT ); Tue, 10 May 2022 12:02:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346707AbiEJPxp (ORCPT ); Tue, 10 May 2022 11:53:45 -0400 Received: from mail-qv1-xf2c.google.com (mail-qv1-xf2c.google.com [IPv6:2607:f8b0:4864:20::f2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C487F972AA for ; Tue, 10 May 2022 08:48:37 -0700 (PDT) Received: by mail-qv1-xf2c.google.com with SMTP id n10so3453364qvi.5 for ; Tue, 10 May 2022 08:48:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5nIvN5jHmvL0M7rHAiydx+MWBBo1BQ8EVOcMzgPyHJc=; b=j+jYLe396oClyr5IHojQ3d3KU6CeFejzRlvRHDs9Ld9I/vVTSMS/OCJJ3NgIEdFwM4 qlzj1QWuhz3Htg3OAhvNBNTX+bUfe0zlzVmt5DPIOXzEl/0D4ZjxedPdj6XgnJtA4C3B UbjsIgCaJNia8fULd3Sp3pc6Kxe/xk36JvDQzR+DZVncMyp8aT9nFrZPOvkRr+sm2B1p /3u957lpabocPIUdjjWz2kFKSkxylMGytjRrUyhMStAst040927tIJNsghiGfYjkPZuE 7kDnn3cwlxqrT/G+cXepRjcT+H44svQFZtMX1ljteWIRgaYPTqnmYdw/h8zbuXMcL0lt RKrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5nIvN5jHmvL0M7rHAiydx+MWBBo1BQ8EVOcMzgPyHJc=; b=phGnTiaXjXIbpc+tRtEOaOhXCojI+4+9U/h383hCB8720iXHLLi1Z+Sk6em5hrhxJd IHzomvP4/sZMzFkI6Gh6dluOvBUUNC9nYUyBtggLLfctmi0uoSRbt9iI8nWa5fWAUT3V JRi1nrbe/e77bFxSPgLRHODGDXOisSi+/OIVI4J+o60v0BeRCH+5fEe0DizbXdts94zT B/W86XkAKqp1obqxNEIFVcnG9JNI/Fmp5t8SDpLwfXP3C3SG9HBUClzOzwXvWCwVqcMp +fFcXimk94NgR0UKG1SW310TCXTo60GgxzaqCFMIe3xrge/WJFQcyyZKS+BPb6wllgME UjoA== X-Gm-Message-State: AOAM5314zMLA75oNAdY03AwN+O99K4Qf5Rl3YfVVMr+u8KXJNRCcSEf3 0vJDUEd6skqgU3+x5LWwGgc= X-Google-Smtp-Source: ABdhPJw8iCNDbTjDVJIhcwYTc0zGu0KHeiFsS7FlFbhAt6h15Suwh8rvq3HB2CClhGBjxk0axAjAZQ== X-Received: by 2002:a05:6214:1844:b0:456:4f8f:7369 with SMTP id d4-20020a056214184400b004564f8f7369mr18301205qvy.107.1652197716406; Tue, 10 May 2022 08:48:36 -0700 (PDT) Received: from localhost ([98.242.65.84]) by smtp.gmail.com with ESMTPSA id n2-20020a05622a11c200b002f3dc9ebb4bsm3969501qtk.65.2022.05.10.08.48.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 May 2022 08:48:36 -0700 (PDT) From: Yury Norov To: Andy Shevchenko , David Laight , Greg Kroah-Hartman , Joe Perches , Julia Lawall , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Nicholas Piggin , Nicolas Palix , Peter Zijlstra , Rasmus Villemoes , Matti Vaittinen , linux-kernel@vger.kernel.org Cc: Yury Norov , Thomas Gleixner Subject: [PATCH 22/22] clockevents: use cpumask_weight_eq() in tick_cleanup_dead_cpu() Date: Tue, 10 May 2022 08:47:50 -0700 Message-Id: <20220510154750.212913-23-yury.norov@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220510154750.212913-1-yury.norov@gmail.com> References: <20220510154750.212913-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" Replace cpumask_weight() with cpumask_weight_eq(..., 1) because the it may return earlier. CC: Thomas Gleixner CC: linux-kernel@vger.kernel.org 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 5d85014d59b5..fa651263650f 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.32.0