Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1573143rwb; Thu, 8 Dec 2022 12:23:25 -0800 (PST) X-Google-Smtp-Source: AA0mqf4AfHpgIkgoUFvy97N7+2VIm0YQYHnW8BxwZYorpX8JNl7Q80XyXYhgDyPEmdRheQI5uiad X-Received: by 2002:a17:90a:440b:b0:219:886b:9155 with SMTP id s11-20020a17090a440b00b00219886b9155mr32220349pjg.167.1670531005184; Thu, 08 Dec 2022 12:23:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670531005; cv=none; d=google.com; s=arc-20160816; b=HL5siAfLDKtaVPNOIvZ8bcPKlPSnXr6N9IIfeYZ2Fza6qWcKaFkPZ4bYDHrqnjFxbS HVMDT7Uh7F0JAot9/4LIvCivFdCzTLdpA0mf+x//Cj2D04woNfK2tutIM0GizbAdQFrq LdVFS3lMSJIKzOtdOgJ+NarOQDMniWqnurbx3P9yOs6xwwIjLPjzlGiggdN0MzoRb1MY qJrklLdLCnGUGtsKF/kATrS6Og2EMPjKqizdudRMzWekZVLJC0k85GfYX9QdXSBYKETS edf5fczmwBooW3sZVdcyzo9pW+1c8bapcqMQ+08E4HBoKtp2rksg14unXyU9ca9Lz4Zl yJZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :feedback-id:references:in-reply-to:message-id:subject:cc:from:to :dkim-signature:date; bh=XDr9OU9uLvDybQvM4E4TClVzCFExjZb/R4pcEYzFNcM=; b=eCIeiW0FYLrKvnSmej5otyFZ1/LJYXMZ/fMmznMJaFGzoT44QAzfY079DIxMVpByx9 yTTJ9tKhjkqMzjkC1zQyQa8y4fzVQwM2r7VInXWdPngVLAoisuiStHpPb/xys54zGFwP snptKH9ZE/FQ/an9qA0ZjpsBRrGEweK69umaidgpvCtzcL/fXSY/cUwk5JL/GMuZ7E94 DzvaZ5pXYyVyVpbL6WqwNktm6RPLTYIjdHTmiBll0YDvqF/z4TsIRNjb1TSG0wKkox9O WMKXxKfbICqKQ+r2aJUGHcpKbH6P1L2HrAFZNrGId03CPg2j+VigDJ9NoHE4dHZ/8L1+ j0vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@n8pjl.ca header.s=protonmail header.b=r7V12HGi; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=n8pjl.ca Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e67-20020a636946000000b0046ed15af9d1si16923265pgc.213.2022.12.08.12.22.58; Thu, 08 Dec 2022 12:23:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@n8pjl.ca header.s=protonmail header.b=r7V12HGi; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=n8pjl.ca Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229631AbiLHURk (ORCPT + 99 others); Thu, 8 Dec 2022 15:17:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229619AbiLHURj (ORCPT ); Thu, 8 Dec 2022 15:17:39 -0500 Received: from mail-4317.proton.ch (mail-4317.proton.ch [185.70.43.17]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B103C6159; Thu, 8 Dec 2022 12:17:35 -0800 (PST) Date: Thu, 08 Dec 2022 20:17:22 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=n8pjl.ca; s=protonmail; t=1670530652; x=1670789852; bh=XDr9OU9uLvDybQvM4E4TClVzCFExjZb/R4pcEYzFNcM=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=r7V12HGieDYlc1YW4cn7A2k7cTeu55Aw4HBD38EeiSyxRrLT5souB/WgEEimolI7q uS+Guulf83OZ8C3QthpVzKWbbEVD1aDJBerOqy4+YJ6uX9XHrPOre0Sq30OTQIQYMv pNuX2uuKxsZ6Wta8CkX0RoFolqo1Bd/M7Bcmjedr7tiqLGaWcUjqx5A2jtPN7oezQa y2CaVgnAXNwAsLbySDSD/ByopOW6H0/Fqk00AUEnJiTNYsVUmr6SlnpdnnneI4juHL 5I3AslsG/VPBmq1Ctwsu2TM8KF46USl4ktkeXljd8w94rIevfRBqflXJ3M4IzVpneB dWql3SZoyzqcg== To: Yury Norov From: Peter Lafreniere Cc: linux-kernel@vger.kernel.org, "David S. Miller" , Andy Shevchenko , Barry Song , Ben Segall , haniel Bristot de Oliveira , Dietmar Eggemann , Gal Pressman , Greg Kroah-Hartman , Heiko Carstens , Ingo Molnar , Jakub Kicinski , Jason Gunthorpe , Jesse Brandeburg , Jonathan Cameron , Juri Lelli , Leon Romanovsky , Mel Gorman , Peter Zijlstra , Rasmus Villemoes , Saeed Mahameed , Steven Rostedt , Tariq Toukan , Tariq Toukan , Tony Luck , Valentin Schneider , Vincent Guittot , linux-crypto@vger.kernel.org, netdev@vger.kernel.org, linux-rdma@vger.kernel.org Subject: Re: [PATCH v3 5/5] lib/cpumask: reorganize cpumask_local_spread() logic Message-ID: In-Reply-To: <20221208183101.1162006-6-yury.norov@gmail.com> References: <20221208183101.1162006-1-yury.norov@gmail.com> <20221208183101.1162006-6-yury.norov@gmail.com> Feedback-ID: 53133685:user:proton MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org > Now after moving all NUMA logic into sched_numa_find_nth_cpu(), > else-branch of cpumask_local_spread() is just a function call, and > we can simplify logic by using ternary operator. > > While here, replace BUG() with WARN(). Why make this change? It's still as bad to hit the WARN_ON as it was before= . > Signed-off-by: Yury Norov yury.norov@gmail.com > > --- > lib/cpumask.c | 16 ++++++---------- > 1 file changed, 6 insertions(+), 10 deletions(-) > > diff --git a/lib/cpumask.c b/lib/cpumask.c > index 255974cd6734..c7029fb3c372 100644 > --- a/lib/cpumask.c > +++ b/lib/cpumask.c > @@ -127,16 +127,12 @@ unsigned int cpumask_local_spread(unsigned int i, i= nt node) > /* Wrap: we always want a cpu. */ > i %=3D num_online_cpus(); > > - if (node =3D=3D NUMA_NO_NODE) { > - cpu =3D cpumask_nth(i, cpu_online_mask); > - if (cpu < nr_cpu_ids) > - return cpu; > - } else { > - cpu =3D sched_numa_find_nth_cpu(cpu_online_mask, i, node); > - if (cpu < nr_cpu_ids) > - return cpu; > - } > - BUG(); > + cpu =3D node =3D=3D NUMA_NO_NODE ? > + cpumask_nth(i, cpu_online_mask) : > + sched_numa_find_nth_cpu(cpu_online_mask, i, node); I find the if version clearer, and cleaner too if you drop the brackets. For the ternary version it would be nice to parenthesize the equality like you did in cmp() in 3/5. > + > + WARN_ON(cpu >=3D nr_cpu_ids); > > + return cpu; > } > EXPORT_SYMBOL(cpumask_local_spread); > > -- > 2.34.1 Minor nit: cmp() in 3/5 could use a longer name. The file's long, and cmp() doesn't explain _what_ it's comparing. How about cmp_cpumask() or something related to the function using it? Other than the above particularities, the whole series looks good to me. Reviewed-by: Peter Lafreniere