Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5453403rdb; Wed, 13 Dec 2023 09:03:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IG72LuuOcKw/mAUSIpgQAwCy7lN2Oe2cY9LIPRjajWpa/lsF+SW5w8M3ku9zEm6ARsnhl1J X-Received: by 2002:a05:6870:5147:b0:1fb:75a:de5f with SMTP id z7-20020a056870514700b001fb075ade5fmr11367105oak.77.1702487014856; Wed, 13 Dec 2023 09:03:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702487014; cv=none; d=google.com; s=arc-20160816; b=dlv2U9NHeh4VGOeYUMRA5TQk4monCctbL3CDX65f5vgSBiPA7tdkTCz8MjaMds56Wi FRjLFjd9xdp2dWTilqkLXmJIJlAN8CglhF6MltrleUtNM5HTzPsuHoN25eq7BwxjmSI5 oQFIFRlSt5f5bV7wEUitOzeUOnJJsTgupNuponr0YQL8t/FOTK4poghV2UbqzUPHAlye wtLeK0GoWSzEicH9UZ3qLPA1RYtg+i/ANT9dhLXOPaD7pshPgc//cjm6mcDTEsvB4iIZ Kd3njiD6EKc6QQmsYWzV6u2uMNZ3lVws6InXEmXkscn8NNWFfh9Mihxwbd5RbZB5NFUb IKHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=da2+Ei0XbvCEF/RIgh1CyB3A1CY6CaQf2SnXWjO6ruE=; fh=P8WKVbhiWBy10Q9giupoRy5TLybsQirmOwtBEYAPRCY=; b=Xo2/I43pD8EXFpM+bMRiHS34tfv7dHiSwEljoVWUjrAgA8ORxt9RwC9TTaxSXcZlZj hmeIpUp0sXqz+q+CjdBTBwF8IzFzhKVudG6RQb5r6QmoXw+rW938ww0mg0zp7IHeiRMP pFXoyh1dEDquoQicuw2jVVbScOM3fSTKN6BtjJNtFRcUWfKSQx3v5s0hhOolUh1F6l6F QFiAGXTzYPQDn5JOsEDGilDQr0Y7aPWP/qCcYVnmc636avUI4iO1VyFdSSdOiiqRNB1j pzwAdBHtho1EF91tBMrdDii67COinp6kWTEmKBwOKKNJ7Gi0OeG0iCHqW0zl+KSwML0w Sd8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=D1RPo9zN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id r77-20020a632b50000000b005c66b0c9dd7si9803063pgr.786.2023.12.13.09.03.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 09:03:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=D1RPo9zN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 2D27B80BFEF2; Wed, 13 Dec 2023 09:03:31 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232163AbjLMRDQ (ORCPT + 99 others); Wed, 13 Dec 2023 12:03:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229458AbjLMRDP (ORCPT ); Wed, 13 Dec 2023 12:03:15 -0500 Received: from mail-yw1-x112c.google.com (mail-yw1-x112c.google.com [IPv6:2607:f8b0:4864:20::112c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70089B3 for ; Wed, 13 Dec 2023 09:03:21 -0800 (PST) Received: by mail-yw1-x112c.google.com with SMTP id 00721157ae682-5d2d0661a8dso73086027b3.2 for ; Wed, 13 Dec 2023 09:03:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702487000; x=1703091800; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=da2+Ei0XbvCEF/RIgh1CyB3A1CY6CaQf2SnXWjO6ruE=; b=D1RPo9zNyp7f2fidI+j/fMwjcZFpymgwHBWzw1DSo538UPGCkMknNByZqFwnNzU2Vj h6waXRtipFiBfpD4JJ7hoVa38DgUygqVSkcWZv70aCz878FILH1vPGTdvtwY7+YjNIH6 lnscKaOtrSpVM8CDlgc3CMH8YaJXEQcLWheN3gdzNPItMbrppTeUPvhMNHiKeNp63nLk OMfJCGvqWcExdJbE83NGhuG9gVGZl+clDHQhtLx9kq7jPS/1SCEW+ftbwY0DekLXJOtP AKsJc0Iy1yPrNiYSkiirIoBHoKC2IYuhVKLICsaFNxv5n8ddNcNaIKUyaaiWyird0Dep J6AQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702487000; x=1703091800; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=da2+Ei0XbvCEF/RIgh1CyB3A1CY6CaQf2SnXWjO6ruE=; b=UDL9bFdd+jeOUEWkJGnIqsJroTBbKaUA9O0DV27DXjLvqabmNvD6nyfYNW4qnF572g xKXwKnkTLk3xh+exO0rLusBU0weVLv+esGi9fjmobMmkjd8EnRm4ywtqMwITRjQYFwlF r2UDqW2/TdBI6xkG7EKyDQg66WCZb2es/k16MfEoyNlbOJ5ktI4dhBsaH8vKoF3rL63M ZhScmo4TdZjljkpGveKE8dKLA96t1X2yXS4H9ceFABEk8wzhiH9BfllsWeSAYOJKIiON oRKzOg0T5+0vfhdtXonWvnTsfwJ36OarafxG7elFoO6Rwj/CLN1KT1XBRQzpd9VI4d4u YYCg== X-Gm-Message-State: AOJu0YywS2hb3o6Aa11Twj8Mt9/v45vZ+ob6idRli3QF7V3BPwv6OWEH LsztBxbuYprmIfoxz3cLxF0= X-Received: by 2002:a81:73c6:0:b0:5d7:1940:b395 with SMTP id o189-20020a8173c6000000b005d71940b395mr7074465ywc.97.1702487000412; Wed, 13 Dec 2023 09:03:20 -0800 (PST) Received: from localhost ([2601:344:8301:57f0:e69d:88a7:9ea:4f0b]) by smtp.gmail.com with ESMTPSA id ff9-20020a05690c320900b005e184771849sm1872201ywb.93.2023.12.13.09.03.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 09:03:18 -0800 (PST) Date: Wed, 13 Dec 2023 09:03:17 -0800 From: Yury Norov To: Ming Lei Cc: Andrew Morton , Thomas Gleixner , linux-kernel@vger.kernel.org, Andy Shevchenko , Rasmus Villemoes Subject: Re: [PATCH v3 3/7] lib/group_cpus: relax atomicity requirement in grp_spread_init_one() Message-ID: References: <20231212042108.682072-1-yury.norov@gmail.com> <20231212042108.682072-4-yury.norov@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 13 Dec 2023 09:03:31 -0800 (PST) On Wed, Dec 13, 2023 at 08:14:45AM +0800, Ming Lei wrote: > On Tue, Dec 12, 2023 at 08:52:14AM -0800, Yury Norov wrote: > > On Tue, Dec 12, 2023 at 05:50:04PM +0800, Ming Lei wrote: > > > On Mon, Dec 11, 2023 at 08:21:03PM -0800, Yury Norov wrote: > > > > Because nmsk and irqmsk are stable, extra atomicity is not required. > > > > > > > > Signed-off-by: Yury Norov > > > > --- > > > > lib/group_cpus.c | 8 ++++---- > > > > 1 file changed, 4 insertions(+), 4 deletions(-) > > > > > > > > diff --git a/lib/group_cpus.c b/lib/group_cpus.c > > > > index 10dead3ab0e0..7ac94664230f 100644 > > > > --- a/lib/group_cpus.c > > > > +++ b/lib/group_cpus.c > > > > @@ -24,8 +24,8 @@ static void grp_spread_init_one(struct cpumask *irqmsk, struct cpumask *nmsk, > > > > if (cpu >= nr_cpu_ids) > > > > return; > > > > > > > > - cpumask_clear_cpu(cpu, nmsk); > > > > - cpumask_set_cpu(cpu, irqmsk); > > > > + __cpumask_clear_cpu(cpu, nmsk); > > > > + __cpumask_set_cpu(cpu, irqmsk); > > > > cpus_per_grp--; > > > > > > > > /* If the cpu has siblings, use them first */ > > > > @@ -33,8 +33,8 @@ static void grp_spread_init_one(struct cpumask *irqmsk, struct cpumask *nmsk, > > > > sibl = cpu + 1; > > > > > > > > for_each_cpu_and_from(sibl, siblmsk, nmsk) { > > > > - cpumask_clear_cpu(sibl, nmsk); > > > > - cpumask_set_cpu(sibl, irqmsk); > > > > + __cpumask_clear_cpu(sibl, nmsk); > > > > + __cpumask_set_cpu(sibl, irqmsk); > > > > > > I think this kind of change should be avoided, here the code is > > > absolutely in slow path, and we care code cleanness and readability > > > much more than the saved cycle from non atomicity. > > > > Atomic ops have special meaning and special function. This 'atomic' way > > of moving a bit from one bitmap to another looks completely non-trivial > > and puzzling to me. > > > > A sequence of atomic ops is not atomic itself. Normally it's a sing of > > a bug. But in this case, both masks are stable, and we don't need > > atomicity at all. > > Here we don't care the atomicity. > > > > > It's not about performance, it's about readability. > > __cpumask_clear_cpu() and __cpumask_set_cpu() are more like private > helper, and more hard to follow. No that's not true. Non-atomic version of the function is not a private helper of course. > [@linux]$ git grep -n -w -E "cpumask_clear_cpu|cpumask_set_cpu" ./ | wc > 674 2055 53954 > [@linux]$ git grep -n -w -E "__cpumask_clear_cpu|__cpumask_set_cpu" ./ | wc > 21 74 1580 > > I don't object to comment the current usage, but NAK for this change. No problem, I'll add you NAK.