From nobody Sun Dec 28 02:07:43 2025 Received: from mail-yw1-f179.google.com (mail-yw1-f179.google.com [209.85.128.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D67DE111A0 for ; Thu, 28 Dec 2023 20:09:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Eja/+ae/" Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-5e54d40cca2so40809207b3.3 for ; Thu, 28 Dec 2023 12:09:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703794187; x=1704398987; 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=oeRpHv3Rhilh+EuNYr3bORiW/nxnS2Awjr3v2Rkry9o=; b=Eja/+ae/XJcxuLTLIZmeaQ+OPV2QONh46htJCpY7l0ArQDois0UVMNqr2I/kpidJ0D l97e9PPfR45+RMCGsdBnxwFMxs6rpaPOKm08gy9c+xGzHYn+nMPEKkJd/AuuCQ2VQRk8 cxtLQMhoQD1djjBE7a017GIe7mU9CUC4LVT6g20w2Cl0HyMXWpz8BVi7EoyPxFKPL/bZ 3oO/9L47u6vqw9Ivcc9Cd/RIo8oujj3Ot1WnumMMAq7EvwqaTd561PvXlTvnJXhbNpUk bBaS28FpYo1CjkCadNhWqe0DaKZFZrJNE1skLypOw8wYIlDLW17y5QEZwscMX8fj1mIb OZGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703794187; x=1704398987; 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=oeRpHv3Rhilh+EuNYr3bORiW/nxnS2Awjr3v2Rkry9o=; b=CCC2VM7uEqnKL/vP/T+AyXFqVGSMj3ENpn87vDui0WxM8l+T+1y+LoR2TktJs7LI9I EYPJdw+P5GTsDLLO4St529/35PrvCdYXbStfWEP8nwS7fP0asdKYVOo016xEjBfngOrt XJfhgNMpZB6o92Ufa9FzOX+Jtj2cY0IUwdaGuz+5HZYHteJ9PcN1cvXETP2ocpbWUj5s nqhraYlD0meWI/dGfAVA/jL9RrK5XK0q16gMlAvNheWCHBuPPT+Ks+uk1omO1arwmLa8 4L7bDRxWQoaxtY4QHjQjTQUlpAo2a228a+CiHW4F2umlOFleRbV/UMZnTeI2xWw2s0hV 5T9w== X-Gm-Message-State: AOJu0YzdwWIX2p9vknAliY3rFln3P28+2ehUqjxVhO6Du4EatYBJvK3W cO3haqtlGlNReDEXwEB7DSo= X-Google-Smtp-Source: AGHT+IHcbFk05w6SJYqvEuo5VRQtvdXG7sZmGKgqL+yYU9vmUaxJMjyDmh/gtRJllpF5LyxL0d18VA== X-Received: by 2002:a81:c603:0:b0:5ee:f221:326f with SMTP id l3-20020a81c603000000b005eef221326fmr1132194ywi.58.1703794186968; Thu, 28 Dec 2023 12:09:46 -0800 (PST) Received: from localhost ([2601:344:8301:57f0:967c:a333:ae09:3f60]) by smtp.gmail.com with ESMTPSA id d13-20020a81ab4d000000b005e71fbbc661sm7657164ywk.143.2023.12.28.12.09.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 12:09:46 -0800 (PST) From: Yury Norov To: Andrew Morton , Thomas Gleixner , Ming Lei , linux-kernel@vger.kernel.org Cc: Yury Norov , Andy Shevchenko , Rasmus Villemoes Subject: [PATCH 6/9] lib/group_cpus: drop unneeded cpumask_empty() call in __group_cpus_evenly() Date: Thu, 28 Dec 2023 12:09:33 -0800 Message-Id: <20231228200936.2475595-7-yury.norov@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231228200936.2475595-1-yury.norov@gmail.com> References: <20231228200936.2475595-1-yury.norov@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 redundant cpumask_empty() call from the __group_cpus_evenly() and save few cycles. Signed-off-by: Yury Norov Reviewed-by: Ming Lei --- 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 72c308f8c322..b8c0c3ae2bbd 100644 --- a/lib/group_cpus.c +++ b/lib/group_cpus.c @@ -259,9 +259,6 @@ static int __group_cpus_evenly(unsigned int startgrp, u= nsigned int numgrps, nodemask_t nodemsk =3D NODE_MASK_NONE; struct node_groups *node_groups; =20 - if (cpumask_empty(cpu_mask)) - return 0; - nodes =3D get_nodes_in_cpumask(node_to_cpumask, cpu_mask, &nodemsk); =20 /* @@ -401,9 +398,14 @@ struct cpumask *group_cpus_evenly(unsigned int numgrps) curgrp =3D 0; else curgrp =3D nr_present; - cpumask_andnot(npresmsk, cpu_possible_mask, npresmsk); - ret =3D __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 =3D __group_cpus_evenly(curgrp, numgrps, node_to_cpumask, + npresmsk, nmsk, masks); + else + ret =3D 0; + if (ret >=3D 0) nr_others =3D ret; =20 --=20 2.40.1