Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5020688rdb; Tue, 12 Dec 2023 17:06:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IFHBvLYIUqdK6LSx6m/IjdOwiqeRXDxubQsymsjtMt+i8FkxOjVwBXHYoYIiwizMHsVV6mq X-Received: by 2002:a05:6870:ec8b:b0:1fb:75c:400e with SMTP id eo11-20020a056870ec8b00b001fb075c400emr8362066oab.110.1702429597792; Tue, 12 Dec 2023 17:06:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702429597; cv=none; d=google.com; s=arc-20160816; b=Kx9iT3+Zria01raEm/P1xGF8LZc06/WPIeYoJZ8bOyWLFfjBU4MqA35F/V0qNmFfFu 6ksrckO2TyVKfjmlVmckVetQRFgF0qUNXqXEMItAsLOHBZsBO+wrDubrVHN/f9GQTF81 m1JcLTQ0XPA3NNIMeWWJ8BzYbP6Jc9Mc0l12SWeSTMi81Vq3C5T6FlqXLhf9Lw6WHsAq a81RQSUC90Z4LE7gDOoTGFbzjOs1fxAauJfgPkTfnqrrk7Mwzp0oQlqzv4dFG33/owtB M0BhhcCe61SX1lQ/YJg7UC/9QKLIlTVQoLNsK9b0+fsqU7CxG1etHwLxOsQbzzh0K1mB RGCQ== 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=D0SnZLCy81+dYJzS4wut67vLKnCWkGca6Y+iC19IrjA=; fh=BDL/a/ouV+t/CAyBcvNlMEmOkYdq8S2Mf5MVqbnjn8c=; b=syaK7DZwDeR5PYcRB50yQPzLG16mYw1thV0GsP5EugpRHpKujK99yadSSn36y2pgvU cwZfqdSBrNPAxYSv3c946oc/1KSQ7hTDsZNh3LVRSa9iktFO7ng7qWNwoeZ4Bs+oJ+dT b2GUg5TMLqSm6ezVPLc8KMJtS+pz7NWcxBrc2V2DCemCB42ZzHsJQXynjrWucEGkOUht ocT2T5s8E19uIC+YhKq4BHEL7lYPbyd3U2YPYl6FSZCnSK1owqtAZjU9osQmw32tqhDw nfCChFHHzilWciMI/O5b1yceCCsA7Hl6CNl9y/lzTbq+Ow4ZogAblSmsQlpQUC9RAiZc ZJeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DeH0wR79; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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. [23.128.96.37]) by mx.google.com with ESMTPS id g1-20020a056a000b8100b006cb906d800esi8817743pfj.107.2023.12.12.17.06.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 17:06:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DeH0wR79; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 2FBF78040E8C; Tue, 12 Dec 2023 17:06:33 -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 S1377653AbjLMBGU (ORCPT + 99 others); Tue, 12 Dec 2023 20:06:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235196AbjLMBGS (ORCPT ); Tue, 12 Dec 2023 20:06:18 -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 6D10ACE for ; Tue, 12 Dec 2023 17:06:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1702429584; 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=D0SnZLCy81+dYJzS4wut67vLKnCWkGca6Y+iC19IrjA=; b=DeH0wR79US59/2WBkbxR/aQNh08C3UzJ4YICFjcuMDuX+Q/uWoMn6nkCkAKjMozMoVqNWz Z7E2RUKVXiR5T9SRonvuCv+NiXgpMeoJg0nnO3Qv2fPX+YB/Jiwf6argBfviJ3rxosNkrh MGDGFKc1lmLm2oH/49B7vddIghL5C7s= 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-75--M6I3TC7ONq7bLk6cP72TQ-1; Tue, 12 Dec 2023 20:06:20 -0500 X-MC-Unique: -M6I3TC7ONq7bLk6cP72TQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (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 33A5E8489E4; Wed, 13 Dec 2023 01:06:20 +0000 (UTC) Received: from fedora (unknown [10.72.116.39]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D49583C25; Wed, 13 Dec 2023 01:06:16 +0000 (UTC) Date: Wed, 13 Dec 2023 09:06:12 +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 7/7] lib/group_cpus: simplify grp_spread_init_one() for more Message-ID: References: <20231212042108.682072-1-yury.norov@gmail.com> <20231212042108.682072-8-yury.norov@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231212042108.682072-8-yury.norov@gmail.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 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_H4,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]); Tue, 12 Dec 2023 17:06:33 -0800 (PST) On Mon, Dec 11, 2023 at 08:21:07PM -0800, Yury Norov wrote: > The outer and inner loops of grp_spread_init_one() do the same thing - > move a bit from nmsk to irqmsk. > > The inner loop iterates the sibling group, which includes the CPU picked > by outer loop. And it means that we can drop the part that moves the bit > in the outer loop. > > Signed-off-by: Yury Norov > --- > lib/group_cpus.c | 8 +------- > 1 file changed, 1 insertion(+), 7 deletions(-) > > diff --git a/lib/group_cpus.c b/lib/group_cpus.c > index 664a56171a1b..7aa7a6289355 100644 > --- a/lib/group_cpus.c > +++ b/lib/group_cpus.c > @@ -18,14 +18,8 @@ static void grp_spread_init_one(struct cpumask *irqmsk, struct cpumask *nmsk, > int cpu, sibl; > > for_each_cpu(cpu, nmsk) { > - __cpumask_clear_cpu(cpu, nmsk); > - __cpumask_set_cpu(cpu, irqmsk); > - if (cpus_per_grp-- == 0) > - return; > - > - /* If the cpu has siblings, use them first */ > siblmsk = topology_sibling_cpumask(cpu); > - sibl = cpu + 1; > + sibl = cpu; > > for_each_cpu_and_from(sibl, siblmsk, nmsk) { > __cpumask_clear_cpu(sibl, nmsk); Correctness of the above change requires that 'cpu' has to be included into topology_sibling_cpumask(cpu), however, not sure it is always true, see the following comment in Documentation/arch/x86/topology.rst ` - topology_sibling_cpumask(): The cpumask contains all online threads in the core to which a thread belongs. ` Thanks, Ming