Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5016752rdb; Tue, 12 Dec 2023 17:00:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IGYmFZzelVW49tXyx6ZbjByDNgKQvBb9vxA2+bEYknpjfcm4p78nBZaV8ulh0D/s4SqWXVE X-Received: by 2002:a17:902:d512:b0:1d0:b32e:c808 with SMTP id b18-20020a170902d51200b001d0b32ec808mr9259063plg.26.1702429203615; Tue, 12 Dec 2023 17:00:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702429203; cv=none; d=google.com; s=arc-20160816; b=rBNo9fElvLOJTIEI2xT2T00WtDVLo6cAeNKkBlqHqNBjL6h3NW4JmE9rYYqw5wpL9C yKlO9+KSvSlnbCCspphDqdDmhS/QJ1ZEGdBt9rfVxF/K1AZ+fqossIDCXmzuKzMVVxuU fv3GaGAPY5iYegSVOdlzi2slAuDOniqDGabOWARQrLP2YvtsvRGyNZAnMtl7RGhbbHeN ZKufjbpdJv7rlYXz5E8qSbiXNm2cCHMoHf3eMkjDJ7BOgoblGdgWxzSSGghC7fpIgi17 uRfI6GY6F0Z1PWJt++BEbFYHYoQggl2wW17u+dbVhMekZB1YamL8G8qooZoUZT+7QdE7 T3fA== 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=MeC6gTSAnBVmjkuuefA5b1OJABX4rRMIDZ5Rl/0OcO8=; fh=BDL/a/ouV+t/CAyBcvNlMEmOkYdq8S2Mf5MVqbnjn8c=; b=EWJ0N1fomOPrEixKBMf8hXFUmQTb4QAvAHUNIGTavgyje/vmYZDi25TIPRiXoy15fx Z8MPzsNgp1TLBEMQxQK0GOzNpabiDcRarrJQxmR+xagqU6L8Rfd/Fz8ymYz6wVGxegOL ktayykxGkZSnl6Xl7ESWh1zlLtzEFEVejcvrUi2GRvE4TzGnb/TUioLCqyZzxCjD9Qoh OhF14UIQJoQHXyN55BI8pO8IsaSTrrO4gdUK1uZ9WYVaqyaJ46/M7F2FX4Rzi+9uDqmc opyPmxoA8I5LLAmUSvuCHHDQAJtL4gFFbHztG1ZXNcN8AQIVokV7576ZvgmIt7dfHkJA CDDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=A1SM3byh; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id e4-20020a170902744400b001d07c3e89fbsi8455187plt.468.2023.12.12.17.00.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 17:00:03 -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=@redhat.com header.s=mimecast20190719 header.b=A1SM3byh; 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=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id B45FC801B426; Tue, 12 Dec 2023 17:00:00 -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 S232724AbjLMA7r (ORCPT + 99 others); Tue, 12 Dec 2023 19:59:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232621AbjLMA7q (ORCPT ); Tue, 12 Dec 2023 19:59:46 -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 A43D9A0 for ; Tue, 12 Dec 2023 16:59:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1702429191; 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=MeC6gTSAnBVmjkuuefA5b1OJABX4rRMIDZ5Rl/0OcO8=; b=A1SM3byhXnb3zddKasVUPKbeLZP/D/oWlUgvi79wSZvhIcBBlwtXGAoAtdTkIvwtPgj1U0 OdA10u7fex+R8KcAYFztB9266XP5d3PeJksRNJvoKH81BkReB9vt7aRbb1SFRhOdVL8Rdh cz64j6qjsLQkwjF8O8e94U2cywK8EHQ= 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-213-NWjnGBwQPs-OtgRdSs-Akw-1; Tue, 12 Dec 2023 19:59:50 -0500 X-MC-Unique: NWjnGBwQPs-OtgRdSs-Akw-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (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 E4DDB380662C; Wed, 13 Dec 2023 00:59:49 +0000 (UTC) Received: from fedora (unknown [10.72.116.39]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BD165492BE6; Wed, 13 Dec 2023 00:59:46 +0000 (UTC) Date: Wed, 13 Dec 2023 08:59:42 +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 6/7] lib/group_cpus: drop unneeded cpumask_empty() call in __group_cpus_evenly() Message-ID: References: <20231212042108.682072-1-yury.norov@gmail.com> <20231212042108.682072-7-yury.norov@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231212042108.682072-7-yury.norov@gmail.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 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 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 17:00:01 -0800 (PST) On Mon, Dec 11, 2023 at 08:21:06PM -0800, Yury Norov wrote: > The function is called twice. First time it's called with > cpumask_present as a parameter, which can't be empty. Second time it's > called with a mask created with cpumask_andnot(), which returns false if > the result is an empty mask. > > We can safely drop redundand cpumask_empty() call from the > __group_cpus_evenly() and save few cycles. > > Signed-off-by: Yury Norov > --- > lib/group_cpus.c | 14 ++++++++------ > 1 file changed, 8 insertions(+), 6 deletions(-) > > diff --git a/lib/group_cpus.c b/lib/group_cpus.c > index c7fcd04c87bf..664a56171a1b 100644 > --- a/lib/group_cpus.c > +++ b/lib/group_cpus.c > @@ -252,9 +252,6 @@ static int __group_cpus_evenly(unsigned int startgrp, unsigned int numgrps, > nodemask_t nodemsk = NODE_MASK_NONE; > struct node_groups *node_groups; > > - if (cpumask_empty(cpu_mask)) > - return 0; > - > nodes = get_nodes_in_cpumask(node_to_cpumask, cpu_mask, &nodemsk); > > /* > @@ -394,9 +391,14 @@ struct cpumask *group_cpus_evenly(unsigned int numgrps) > curgrp = 0; > else > curgrp = nr_present; > - cpumask_andnot(npresmsk, cpu_possible_mask, npresmsk); > - ret = __group_cpus_evenly(curgrp, numgrps, node_to_cpumask, > - npresmsk, nmsk, masks); > + > + if (cpumask_andnot(npresmsk, cpu_possible_mask, npresmsk)) > + /* If npresmsk is not empty */ > + ret = __group_cpus_evenly(curgrp, numgrps, node_to_cpumask, > + npresmsk, nmsk, masks); > + else > + ret = 0; > + > if (ret >= 0) > nr_others = ret; Reviewed-by: Ming Lei Thanks, Ming