Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4770524rdb; Tue, 12 Dec 2023 08:52:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IH9/NdC+hSLVlpjFLv885c4TMZmne/Z+yTWb3GulWQoPVf8MEZevfzQo5tO0/0njYSqiN1V X-Received: by 2002:a05:6a00:1808:b0:6ce:6837:4fcd with SMTP id y8-20020a056a00180800b006ce68374fcdmr3974943pfa.52.1702399954856; Tue, 12 Dec 2023 08:52:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702399954; cv=none; d=google.com; s=arc-20160816; b=QH2GOREQFS52/iC6bSvaQkw2Nx5rbIQIMEoECAlOvWNEdqhC8qatoDD6+Ch5LJDyNX +9+53xTneqeHz8npZMwv+Sa7v6Z2Ku3Oeg/YK2YZQsWqQ0VuZWt7p2nPi/hSQ0kOmaxg JUGoFFWRC2xC06x0VIyQUpkWuyCpOT8dApjw5l6ki+vWhNOB9MjM30i53Uc7RG/kgSJf 96/Q/EqJrqA9Uk6d5iTISw0LuTB6YTdFhnorODb64R8Crwok1TRxrvVuj9Neuo+ObnkO kTUzj+OCrVa59EtwsA+ERAXUbMXld9ZaLaNHGI+fvZ9tDyv2fN0c+khCAEkRcZZWDnk+ nFKw== 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=iB7faUxPOIljjBMh/VHLAZIKGCom3gnDztWcUHW1bf8=; fh=P8WKVbhiWBy10Q9giupoRy5TLybsQirmOwtBEYAPRCY=; b=uZhyxRd4nN1Nc8FuuvzcQrRslaDnW6Xq1a3E8pddVhN+kgK5Kt6HT2VhWYPpYbCe3F ouYI8j9bug708NUn9QneXzELmOonCaltsfsJghhO4OAL0mBGDkRBX1x0oOIi1dQCWXeJ y3ZJuHLP7kozNSBHl1+Z+QyStAe4FTrx0wdMd0Yqtm2rKYroRf/2r29LDDj1Nb67ChbQ +t0yANnsMncO7u4Ct+U0/lK64yMj53rEhtpy8y5+DaXTCxVJcqCW1YdcEi3dkJWOprdD hTUGxGgNlMCw7lyCBVU/Czt2T9FBLU/1oMuIvGtgCXF7hSJvn1NcpeBMynQ5YgokULEn wlmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=f9xhygkn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id u37-20020a631425000000b005c6ac5b5fd0si8052328pgl.248.2023.12.12.08.52.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 08:52:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=f9xhygkn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id 881FC802AB32; Tue, 12 Dec 2023 08:52:29 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232642AbjLLQwL (ORCPT + 99 others); Tue, 12 Dec 2023 11:52:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229702AbjLLQwJ (ORCPT ); Tue, 12 Dec 2023 11:52:09 -0500 Received: from mail-yb1-xb2b.google.com (mail-yb1-xb2b.google.com [IPv6:2607:f8b0:4864:20::b2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74BFBCF for ; Tue, 12 Dec 2023 08:52:16 -0800 (PST) Received: by mail-yb1-xb2b.google.com with SMTP id 3f1490d57ef6-dbcb66cdf87so1085033276.0 for ; Tue, 12 Dec 2023 08:52:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702399935; x=1703004735; 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=iB7faUxPOIljjBMh/VHLAZIKGCom3gnDztWcUHW1bf8=; b=f9xhygknzO0l3IDpH+LSa43pQGSRMrG8cQdW8HXUU1StWR9dl21+gTihdEmOYXmbFx HhgxlzSgXZ9tO3hdDiAvdI18IAYykLRDQRW/JASu6gn4DZ8pPEx9/vGECeOnUyQJaLDp wxxplygyF5LTacF7nK5C8teVPqyUlw6QDTFac1FPjF2KvJYAvxK8PFW0FoxluNHl2tjQ U8aGZNclIatONhGY8QSQ6LMOTX0zQJe5vwujNC5OlL265LZYnKJfyLVtDt5ZiKOL7TU4 eRp6/p1VPDGxPBvxpjRVASuXWkh/Pw7Bwba74czap7DOG+jl7zXB6a9qADUyJCENlIcL qKsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702399935; x=1703004735; 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=iB7faUxPOIljjBMh/VHLAZIKGCom3gnDztWcUHW1bf8=; b=PEiSHHEt0EhY03pvhaEFd9sJGU5BAzbnCMnqZi+nVHu6cOaELT9WczU6TG2aQTe98O DtIBi7QnYGmq/y8rPHHKqZAygSKhfHBcltPIFw9/4ww+eEgfXhJyFufQLhESFeOCbrCo 1BKAevcX3aEEaEYTfVvNFzHGeds8LM6/ImgOo3DsRJL6kAp3ZBCk/i24WnPPTWR9emIn ZwLB+NNRug+B4+ZsVeu8Fbz8S3jpszEWfv1RatYMtm2/hNAI2YQJxD5SeJUyUKQQHUtz t1Vk2OnE6YLWbsEcSz4p3iheFfAS0K1K8lcNp9WeEhAOE5K814hixvlqZv0Ml3WmX/Qa hiqQ== X-Gm-Message-State: AOJu0Yz5KBRX8r6KwxDXeQ5Sv7fNXHZZhxlRzrKIfWY1LHIAl8tVIDWj +xB22B8vO6e0bn3hQlgpO1g= X-Received: by 2002:a05:6902:e01:b0:db5:3a74:a9ac with SMTP id df1-20020a0569020e0100b00db53a74a9acmr4903408ybb.18.1702399935560; Tue, 12 Dec 2023 08:52:15 -0800 (PST) Received: from localhost ([2601:344:8301:57f0:38aa:1c88:df05:9b73]) by smtp.gmail.com with ESMTPSA id 67-20020a251546000000b00d9caecd5c86sm3352834ybv.62.2023.12.12.08.52.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 08:52:15 -0800 (PST) Date: Tue, 12 Dec 2023 08:52:14 -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 howler.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 (howler.vger.email [0.0.0.0]); Tue, 12 Dec 2023 08:52:29 -0800 (PST) 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. It's not about performance, it's about readability. Thanks, Yury