Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp2421602rdb; Mon, 25 Dec 2023 10:03:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IF4Sg99GvGx8V8/WFl6ET3a0IJ9lJgOMzE3n0SyvNvYNmclr/rBQsweXsYxupPmSXrl5MT7 X-Received: by 2002:a05:6402:5bc4:b0:550:e014:5254 with SMTP id gy4-20020a0564025bc400b00550e0145254mr3621726edb.27.1703527403700; Mon, 25 Dec 2023 10:03:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703527403; cv=none; d=google.com; s=arc-20160816; b=yCDA5wN3pUeRNEOeWRwgNDefVQ1Vj5/PB2uphTgGAPve6OdM5o5lDv3NK0bGetPruP VgL6CjuK40dDGXkXlJXmpIPq8eiICcm4LSjZmNFNuUsFPHL87Q++VvgdKz3izawhgErt p3Pi2T9IDz/UWgD9q6ms0fT1B0iphVDietP1Ws2WVfj8zxJihLf/Bk4LMcrj8x8E7dMn W37SHOuaMA9i0KXL9uOiQ5PLhbpTNaTRwoOD4Dqk55VovPQELWWh3krecrn4v4q4RE/6 fGIrm3S8mrQtQzydson7Ydbg/Lmf85MiEdKssekRvZxZA9OfI/u6ehH0nrJXgIYC3SfK PLrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=TTwwJ8tmN6j1NykotOVTgc9yQ5nXK90UxGlg99Sewz8=; fh=P8WKVbhiWBy10Q9giupoRy5TLybsQirmOwtBEYAPRCY=; b=EdSB5rMCft+ENyG1gacqkbi61A/6icrCBNMxXras6L9+vDFrXf7kHD4FVihxTLitpK nyeEvkxETsKJ4Dm2gobrgH6ZHabGv7/1jP9YRGeUicYl4xymxX4D5jM30uYXg+WhowOd l4OuOEwkD1xRvrizGkAuOWmEWI/GhIFB5ZzL2GIDwq7Z1m/dbV/KBDqKuTlToyit/PcF jolEwcNohsaGynFJtfOxr8wr3ed/Qw6Y/FKuc0EF7KfBQVmI+tqXRjPxVMZ8d3sPWpOS sqNyyXsTpnw9uGA/FA06xpz8eXsFmsjydcwVvDEIYYb/bFyREyAguRCykRAIbgBEeinm D2YQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=LDHXyI6G; spf=pass (google.com: domain of linux-kernel+bounces-11137-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-11137-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id m13-20020a056402510d00b00553b47279b0si4503105edd.220.2023.12.25.10.03.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Dec 2023 10:03:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-11137-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=LDHXyI6G; spf=pass (google.com: domain of linux-kernel+bounces-11137-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-11137-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 774FF1F21E66 for ; Mon, 25 Dec 2023 18:03:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BD1B1537E4; Mon, 25 Dec 2023 18:03:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LDHXyI6G" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-oi1-f179.google.com (mail-oi1-f179.google.com [209.85.167.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 A774152F97 for ; Mon, 25 Dec 2023 18:03:14 +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 Received: by mail-oi1-f179.google.com with SMTP id 5614622812f47-3bb8f3d9f98so2622880b6e.3 for ; Mon, 25 Dec 2023 10:03:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703527393; x=1704132193; 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=TTwwJ8tmN6j1NykotOVTgc9yQ5nXK90UxGlg99Sewz8=; b=LDHXyI6GPng0zTfx1/B7I5H9lrotHm1v/Pdq6+2vpW44+ZCobC9R+zztw4v94jV6LQ sEh9gE7F/lCv1YWeUbd3XvVaAosoiWDh2inXjqjaj0tJdCTx5TDjlwgljGs5o/4NoqTs p2NE5M//rCNdD/lrFurZ3VTf2vz+/gMto277Zjheb1OD3t920HWXyHGmyve20KXrf7Ty qH85RH1PS8jAPqJ9Qtfq2V/H2rHG8kcdqQJ38LA6P5b4Bn2HnB+qaX15eFQ9M7g+wHPs fRaXIEuXgw4Jo2Htf56ACuwCbzfqTCQ5YpTEStgk1W1Pxn2tzPb/nkyJbOq7iFpmWR0u O7Tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703527393; x=1704132193; 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=TTwwJ8tmN6j1NykotOVTgc9yQ5nXK90UxGlg99Sewz8=; b=tOMKLUJ9IdZiXR8mToMfG80tk0HISwPdWNFpUByW92wLBI79fzW6oao9gpV4FrjTVa ZNuJzRLDpTmt7GSAdIYMDCsLRAU+JkkrJGHFFQkcVbW3B0DQnKHwMwYur3ZjWJyvEXNM Cm8ktJMHgWEWV6j1iXh6/Zq+IgPpcZvbuEij/Yg8XZ+oBNshAvsfVB/o9XLnLbK5CBjh dnGKQzkmWkPvpSBd33QOH0yU58ZPGTQelvlB/dVUfuLIkrf6eWZul/aYypQzmbBc4X1j 0KwC3PL9aojCZuFDnlNJCFq2mmoFJMNDLtthEr7kTGa41F3kqC0hWVzW2xaY7nxxb/cR 4Q3w== X-Gm-Message-State: AOJu0Yy50qCANnrgamJZA8D3Gt2+tw1WT8PNqM4cxM0bkPU8lNxtGu7H qSG/DY59rvVjAPfc89RSpQhC6oAFk7w= X-Received: by 2002:a05:6808:1285:b0:3b8:44e3:dfda with SMTP id a5-20020a056808128500b003b844e3dfdamr9520006oiw.3.1703527393462; Mon, 25 Dec 2023 10:03:13 -0800 (PST) Received: from localhost ([2601:344:8301:57f0:3e97:6886:45bb:11c4]) by smtp.gmail.com with ESMTPSA id g17-20020a25b111000000b00dbdbcb37e81sm3936465ybj.31.2023.12.25.10.03.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Dec 2023 10:03:12 -0800 (PST) Date: Mon, 25 Dec 2023 10:03:12 -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 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Wed, Dec 13, 2023 at 09:06:12AM +0800, Ming Lei wrote: > 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. > ` It's kind of nontrivial to spread IRQs on offline CPUs, but technically the above seems correct. I'll drop the patch then.