Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1925939rdb; Thu, 7 Dec 2023 12:39:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IGHXoawuDPx8pFJsz5ZH7o1+4exxihp7VVkmIrwuf9KBzcyq1HgPsxW6lKVBuB8U6+lgQBJ X-Received: by 2002:a92:c888:0:b0:35d:6c12:a6ee with SMTP id w8-20020a92c888000000b0035d6c12a6eemr3894620ilo.2.1701981589602; Thu, 07 Dec 2023 12:39:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701981589; cv=none; d=google.com; s=arc-20160816; b=z0uoMVcd1Ymw860bEZsQpopDpLAI0lVprk5aGpkpM7l68ySz3qVIBgQr+1YFfHP2z5 uO9PW8+kxXRyPP0gW8/5QJ1TJj+e3iivDUfI15gLT+vrDOPP9jnJswuCloOIZuHfF8hP Qx4cVSxvP6QIgeUG82MZUqqUsNP9+em6hurv3lWh6A5CPoLwe8HswwBoesKfIj9bcLh0 /HqN8GSZlEmZwdmuNxtz8yB7aW+JsG7iSzXGNAwoYv4um2l7GkxO2UdkIrf4mTYsNJQS HrKiy4Ua8syImQp4oqsRBbAAYUT7m+oXT05vCQyUTRp+WrxqTRx5vEsxpiwWwudaVz5m I+5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=AdhzPeT3AA9HptxSHcMzOSBTny61/xtguzzqnxzNv6M=; fh=1BoNDGd05aaAMfPxVJ9+hJFzTAErL73yhXGdigwpwQY=; b=ByqmEqCLaEZPDPK/b91mFY/fE5C9QYBYcMz4lEg8VAE1kApFxFWMGZQu9gwyfWhiJi Vnce2xrS+yqqLJzCv4f3g/BJGPMHeUZBox83pbQ0l0GBz0L0GXYurk/66S4UCN+CfRCT jTbHeIn+/ZpvcxI7Mh8cQLKSFF9NUHiypt9ScnyPhZwNNhfI6BDwoNmnPl/jEFGUBwW1 VQI8p6SCIJwIa4ACtfLtDcXClVVOAKFiRCe8pVINxbw12ZZyAR3M0dgSokBgEAZ07v+f RxdfvWnXIVLlZQXeH4XqdLNsHqkiJZb6tJ3tzDJX/xN7mJnzWd2ZiLXRU66xSFo/C+5P RBFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fbxVQMCB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id b13-20020a630c0d000000b005bd66bfc253si269365pgl.148.2023.12.07.12.39.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 12:39:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fbxVQMCB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id CCD3D8149717; Thu, 7 Dec 2023 12:39:46 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1443953AbjLGUjZ (ORCPT + 99 others); Thu, 7 Dec 2023 15:39:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1443936AbjLGUjG (ORCPT ); Thu, 7 Dec 2023 15:39:06 -0500 Received: from mail-yw1-x112b.google.com (mail-yw1-x112b.google.com [IPv6:2607:f8b0:4864:20::112b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E647E1725 for ; Thu, 7 Dec 2023 12:39:11 -0800 (PST) Received: by mail-yw1-x112b.google.com with SMTP id 00721157ae682-5d34f8f211fso12694467b3.0 for ; Thu, 07 Dec 2023 12:39:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701981551; x=1702586351; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AdhzPeT3AA9HptxSHcMzOSBTny61/xtguzzqnxzNv6M=; b=fbxVQMCBh6aSDW4fc5TmMHCIc+n8Se2z7D5ZprxNWPEcFxIM9uPVNQ+JS6oQjxJ31P 3t0k1sbxPjMGmgqqqn+KKnPwvTPrKAjGtYcEay8RvFEgFVr3dHb9QIOMbE5y/0xPJ5JW JR58N29bl4LAPZkajCme4vs5Ls8SCRwgWOQQzZCnxJPY8epMUXknvbOxEV9jaz9oxSNr kamv2vu/+Qnd80aYuBYkSbBjpZ1wpJQrNK3jfw/33SLFRnvMjuAeoeNb0KwpnrPxSmgl ww1BEZ/N85cewpFMR/VFwgGi/1pVsTf4DFtEEhiHfdWhn6j/7B9g99Uj7wRzDj4J/su8 m3fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701981551; x=1702586351; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AdhzPeT3AA9HptxSHcMzOSBTny61/xtguzzqnxzNv6M=; b=B2GJHTknxypwbdcXGNr+He1vTNiFJarPjFL9smNMZBIDDhmEzFXbtgUG+p0BYrX9BZ L3rfAq9yGbBxkkH4Y85TdlZwIZtyGPEVvP8BQTDCy4//hA5O7tEEnpGDfrtKqgI6y4lJ sDAV2S6Hgv4zt1t5p/xvnEa/Ztp0qoRa9UP2YsKUjeLMVxCClMJFEAA3FqsBSZ9XHIF8 1v7ZtGogh8w5bjfjBT/H8QqOg9aPrcpjqwDpGNPwlD/vHSeKkjtH2pQEYDzETaOvCjbS nUJ21WIwJSARtpkcP5qvrJesXzYZUZLnvt5CXqXIkXIQZwAbPK69hvBqcnSPyv3wtrUl MWNg== X-Gm-Message-State: AOJu0YwinTWVzjdoLp2JIQhoo1jLbDyFL1eyZSh7hmK1daA0xscd1bIb q5q/e+h8xcCrtU+bn7bWyJQ= X-Received: by 2002:a81:6cc3:0:b0:5d3:464d:18d9 with SMTP id h186-20020a816cc3000000b005d3464d18d9mr3060800ywc.21.1701981551006; Thu, 07 Dec 2023 12:39:11 -0800 (PST) Received: from localhost ([2601:344:8301:57f0:8f7f:efcd:5388:af4f]) by smtp.gmail.com with ESMTPSA id n186-20020a0dcbc3000000b005ca4acaf181sm145636ywd.32.2023.12.07.12.39.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 12:39:10 -0800 (PST) From: Yury Norov To: Andrew Morton , Thomas Gleixner , linux-kernel@vger.kernel.org Cc: Yury Norov , Ming Lei , Andy Shevchenko , Rasmus Villemoes Subject: [PATCH 6/6] lib/group_cpus.c: drop unneeded cpumask_empty() call in __group_cpus_evenly() Date: Thu, 7 Dec 2023 12:39:00 -0800 Message-Id: <20231207203900.859776-7-yury.norov@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231207203900.859776-1-yury.norov@gmail.com> References: <20231207203900.859776-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Thu, 07 Dec 2023 12:39:47 -0800 (PST) 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; -- 2.40.1