Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp2053249rdb; Thu, 7 Dec 2023 17:31:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IFG52W+W8IxZzBHIuYi2/63tLpUkLyff6qR2mdyRl3cYbUVqG+KhjSeDKGWRbmST2+GvZkX X-Received: by 2002:a17:902:bb8e:b0:1d0:796c:b06d with SMTP id m14-20020a170902bb8e00b001d0796cb06dmr2853736pls.7.1701999106413; Thu, 07 Dec 2023 17:31:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701999106; cv=none; d=google.com; s=arc-20160816; b=bdCP0OR/M1NOLO3K97SYvRzc/78DAmaHUfvX/kY0vrDYjVbm5jOFZwRcsqoU0xsgU9 ANfBOZk7bFWvuJ0AvxaLZO+ZPlIGEn5pC5iKtlxt6PcE9PsZefnivtM/RYoMwM+Gti/j CNU77p7al1dttBJnQ75Us0hD29VaHDTDmvfiQIjtLNVYL8TxQd1hnHFe4k77EIV0BsON PVlake1Dy+I2vN0shyF75rKJm15kESFrCvtJiaRNiuMrE+aYmb982atG4XnGsisYvepf cjUdb6cG/KjktrV7au5ry1wa/KlPl8FE8kdgjL0Y87uMedFSKNCSekxs9TAzV9Almlyt 1nZQ== 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=xyLK474iLRCVjM9/S7HxhA2tux3/UIG2K/rlVdDLtwA=; fh=BDL/a/ouV+t/CAyBcvNlMEmOkYdq8S2Mf5MVqbnjn8c=; b=G7k02LgZ2JUF8jqVZdOvoKZePhtJhwDCNErCbFkcMpXx+CScqIXVteq2RTUvX9xxgi lR4IoB2L7hZ4nkJGKBMHXCtZ6ySc7f3iwUpMQZRyfBV0svp4u2OwFixl+EVvc+ty+TJX G+mVXbnPKQBNeHYu0wfNykPN8Ndi9iazO29NtsHl41DY2mW3UFWoEWOvMFzeTls3jttP dEVg7m1u1g4d/647OZOiTT+ez808S2fQYzGtn0xZLJFOEaczdyKrmU0BzRpwaJvZQz2p UYH4jUzyi9qIDOes0zTLOdfOjH95RBjF4HjEGNBVZ1tJHnYHNKtUl5ynm3akP/bTrphg Ou1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bBL1qHaQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id t6-20020a170902b20600b001cfbd011ca2si647546plr.110.2023.12.07.17.31.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 17:31:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bBL1qHaQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id 75846801B305; Thu, 7 Dec 2023 17:31:45 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232763AbjLHBbe (ORCPT + 99 others); Thu, 7 Dec 2023 20:31:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231491AbjLHBbd (ORCPT ); Thu, 7 Dec 2023 20:31:33 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0ED21712 for ; Thu, 7 Dec 2023 17:31:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701999098; 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=xyLK474iLRCVjM9/S7HxhA2tux3/UIG2K/rlVdDLtwA=; b=bBL1qHaQmZpJc8tuBKISX8SLR4Ro32TRCxOawIyRmbRC69Ze4y4PS/yeVXxg5heeIDNv61 a21WN6jVOWYsGMX+DOjCGl4GdFrrJFYxnKAGJNVMU3aI7qsN0ETrH+/C8xnPIa/uhXwnx6 +nOpEtcooof7bMbigYl+9XvGCoMWFG0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-416-KfAOKfVyMEyFVsgb8DP7Yw-1; Thu, 07 Dec 2023 20:31:37 -0500 X-MC-Unique: KfAOKfVyMEyFVsgb8DP7Yw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (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 CFA8085A589; Fri, 8 Dec 2023 01:31:36 +0000 (UTC) Received: from fedora (unknown [10.72.120.10]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BA7E6C185A0; Fri, 8 Dec 2023 01:31:32 +0000 (UTC) Date: Fri, 8 Dec 2023 09:31:27 +0800 From: Ming Lei To: Yury Norov Cc: Andrew Morton , Thomas Gleixner , linux-kernel@vger.kernel.org, Andy Shevchenko , Rasmus Villemoes Subject: Re: [PATCH v2 2/6] lib/group_cpus: relax atomicity requirement in grp_spread_init_one() Message-ID: References: <20231207203900.859776-1-yury.norov@gmail.com> <20231207203900.859776-3-yury.norov@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231207203900.859776-3-yury.norov@gmail.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 07 Dec 2023 17:31:45 -0800 (PST) On Thu, Dec 07, 2023 at 12:38:56PM -0800, Yury Norov wrote: > Because nmsk and irqmsk are stable, extra atomicity is not required. > > Signed-off-by: Yury Norov > --- > lib/group_cpus.c | 9 ++++----- > 1 file changed, 4 insertions(+), 5 deletions(-) > > diff --git a/lib/group_cpus.c b/lib/group_cpus.c > index ee272c4cefcc..8eb18c6bbf3b 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 */ > @@ -34,9 +34,8 @@ static void grp_spread_init_one(struct cpumask *irqmsk, struct cpumask *nmsk, > sibl = cpumask_next(sibl, siblmsk); > if (sibl >= nr_cpu_ids) > break; > - if (!cpumask_test_and_clear_cpu(sibl, nmsk)) > - continue; > - cpumask_set_cpu(sibl, irqmsk); > + __cpumask_clear_cpu(sibl, nmsk); > + __cpumask_set_cpu(sibl, irqmsk); > cpus_per_grp--; Here the change isn't simply to remove atomicity, and the test part of cpumask_test_and_clear_cpu() is removed, so logic is changed, I feel the correct change should be: if (cpumask_test_cpu(sibl, nmsk)) { __cpumask_clear_cpu(sibl, nmsk); __cpumask_set_cpu(sibl, irqmsk); cpus_per_grp--; } Thanks, Ming