Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5682846rdb; Wed, 13 Dec 2023 16:44:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IGKg5ZQWVhk6VpM/glbb1zSlS4pVwhAeymhLHp4cjy0lOGPcL1SLzJaUifvOi5eb0EmaQ8d X-Received: by 2002:a9d:5c08:0:b0:6da:41f7:125d with SMTP id o8-20020a9d5c08000000b006da41f7125dmr88270otk.50.1702514666883; Wed, 13 Dec 2023 16:44:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702514666; cv=none; d=google.com; s=arc-20160816; b=Pvox7cGlI0mKeoRyDop0n8f0BxwgDTfg3BXbTZxa455OyEHhLltL5k0XzD4amV4Vjz XcP/qbrD77tQvezgWANffw0hucLkZLEIv31uabCk6phNsxAXpZw6FyAo3wHpkbz0Q+Jl 2KXTRC/SGB2ceEC5SktDpd2D4QulPCi2BS7nItSAjJkKgv0PSjIp+Xtvpdhk3NESQUFo nQC1nCdYMnkePfObWDxLp60IOAi5t7dWVhphO45l3EnfaF3RDQs6zcBljLBZ2EB+bAsv FJFToNJiUBMMC5uNxAKSOHUn/mCRVPOLOFaDkZDvi41sP8lHH07VsRNUv+DvF/WOiBy3 5TqQ== 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=00XBiI2/GjwYgdmGmgmI9vsz6zy2kiJraPjLIsuaPhU=; fh=BDL/a/ouV+t/CAyBcvNlMEmOkYdq8S2Mf5MVqbnjn8c=; b=KNpmYqGwwM8NVfQCui1qdZDHzFPs4Q83GR3+vlGsWnoXMDYzefwsRjG3B16z5pYUt5 PkDZUw/2p2lo0Rs5S/xUevxwlNxOaw7WMhG4Y/lRMHgmZFTOS8s27myaa/pvJv5l65ph JnVPMY6oFMCK7jt7k4uioruv3eBPzFoGpI6uFxUUW4gQ5FpMTftQ4LHbwDwDtQUZYaAb IAyP5zyy/Jpu+dkBv8JDhN6STpJoBckD1AhzLyCLI/2lPNC32lH7QiM4tDdl9C7+GNjJ jlsCbPlNAfjzaRoyB5WN1JRRn5TEcyqyP5unukaI94IUDwtg24F511Vf9aU/znL3HZOl Ay5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=eVGvXY1a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id u42-20020a056a0009aa00b006ce6f21565fsi10197275pfg.272.2023.12.13.16.44.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 16:44:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=eVGvXY1a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 56FE580275A5; Wed, 13 Dec 2023 16:44:24 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442887AbjLNAoF (ORCPT + 99 others); Wed, 13 Dec 2023 19:44:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234125AbjLNAoE (ORCPT ); Wed, 13 Dec 2023 19:44:04 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73657D0 for ; Wed, 13 Dec 2023 16:44:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1702514649; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=00XBiI2/GjwYgdmGmgmI9vsz6zy2kiJraPjLIsuaPhU=; b=eVGvXY1aLheqhml2TxwToPoCfIHQB99PnoQMsjs69DxRYqV7vreMfjr+MQc7sqzJdxejyT AkOaKj+Di4c9jiqa8IwSpelI686iYbXGqx1YoqVSNGvthNXJeSBhaOx5FvCLkTYIuZxKgU 6SIVWf8mQwkyljvOQxi4U6MEtmq5884= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-557-A8uzrfsRNs2QYDp84ekxSQ-1; Wed, 13 Dec 2023 19:44:06 -0500 X-MC-Unique: A8uzrfsRNs2QYDp84ekxSQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2DA2E1C0BA59; Thu, 14 Dec 2023 00:44:06 +0000 (UTC) Received: from fedora (unknown [10.72.116.126]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BEAD02026D66; Thu, 14 Dec 2023 00:44:02 +0000 (UTC) Date: Thu, 14 Dec 2023 08:43:58 +0800 From: Ming Lei To: Yury Norov 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-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 fry.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 (fry.vger.email [0.0.0.0]); Wed, 13 Dec 2023 16:44:24 -0800 (PST) On Wed, Dec 13, 2023 at 09:03:17AM -0800, Yury Norov wrote: > 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. You can add the following words meantime: __cpumask_clear_cpu() and __cpumask_set_cpu() are added in commit 6c8557bdb28d ("smp, cpumask: Use non-atomic cpumask_{set,clear}_cpu()") for fast code path( smp_call_function_many()). We have ~670 users of cpumask_clear_cpu & cpumask_set_cpu, lots of them fall into same category with group_cpus.c(doesn't care atomicity, not in fast code path), and needn't change to __cpumask_clear_cpu() and __cpumask_set_cpu(). Otherwise, this way may encourage to update others into the __cpumask_* version. Thanks, Ming