From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 81CF62673B0; Sat, 21 Mar 2026 14:14:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774102442; cv=none; b=kUhNI7ekevT09g/BbM7dpEmQOAgKQFQW5cbZMD5U4gbfpawhSyA0pM9yvzFIHImdP0CRO8s+rki4lS2isWtRpOj9xvpT/MUL4w+bKJFFcHkCqvfl/yQBXB7OgMxUJB0fDQGq+bQUR51C/of3vY71jSejip4xanlFy/BjqQYslaQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774102442; c=relaxed/simple; bh=sMK6mU3PFF1dDuHni83d3jJvhupAIcKvrDX8xn9lMeE=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=pnfz9xv86o6tabC7zr2VrASo6yM4m3wswQKghhyCfP5C9QHDEyHZM2VjCNZR/Wa0SrvgWW+iLGespEw6t8iyPgZML9IRSzL+SFaFcVXPs8nxZZy2RG25WvrmnbYPh7f6j1CHO9vrXscJYSzzfI6qKaZJ38YbEHYYSXXijzJSv+w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=iez9Xzza; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="iez9Xzza" Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62LB9uJI758326; Sat, 21 Mar 2026 14:13:45 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pp1; bh=h/QR4C umj3K8uINrPKXCNQzodJSBce9ZXk5jHXa3mqk=; b=iez9XzzaVX6UEfQUurJjby AtwgeSq9Uk8GMd0nHCvJ1zp1NBnYU6HItQjL6BAwr7WcvYDePvK03+dC2CSOmqw5 3otUeDsPh0fjrj3E0SERFMKeL0uTgir1JnAsmK9PkWS/e3ZwsI1KO2lEZbE6ja1J WEGDzEfzl4t0Esv7HY4sUfJrWDvim3rVaAPTVWy8UWeJIDyMDVNG9ERKJo2ghM4L 2YQsuQml3+OQigm5DriNkQhyD2sy/2cdKcmwYWX5G8mAORKdXKrwRk+Xk4g2yB5H K9TqbapkYQm+jqgb1BamQ4gwD9Ky3lxiUkzTTBmwqcyrBQJXNeB1fzonNBDZjxhQ == Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4d1kum91um-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 21 Mar 2026 14:13:45 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 62LA5jtK026460; Sat, 21 Mar 2026 14:13:45 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4cwjcykta2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 21 Mar 2026 14:13:44 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 62LEDg0v28967446 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 21 Mar 2026 14:13:43 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DD1892004B; Sat, 21 Mar 2026 14:13:42 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D854C20043; Sat, 21 Mar 2026 14:13:40 +0000 (GMT) Received: from [9.124.220.81] (unknown [9.124.220.81]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Sat, 21 Mar 2026 14:13:40 +0000 (GMT) Message-ID: Date: Sat, 21 Mar 2026 19:43:39 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [tip: sched/core] sched/topology: Compute sd_weight considering cpuset partitions To: K Prateek Nayak , Peter Zijlstra , "Chen, Yu C" Cc: linux-tip-commits@vger.kernel.org, linux-kernel@vger.kernel.org, Valentin Schneider , Dietmar Eggemann , x86@kernel.org, Nathan Chancellor References: <20260312044434.1974-2-kprateek.nayak@amd.com> <177382132440.1647592.1849180094328011054.tip-bot2@tip-bot2> <20260320235824.GA1176840@ax162> <60406550-d90e-4efa-a4d9-f901421887f8@intel.com> <470ce693-ee2e-414e-930b-d6581d649110@intel.com> <7fad91ea-e6cd-43c8-abe3-16d7843247ed@amd.com> <10204982-a007-4f44-ab12-bcddfe4140c8@amd.com> Content-Language: en-US From: Shrikanth Hegde In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: fLFfELZztWOogb1kdBP43liww6I2VQf6 X-Proofpoint-ORIG-GUID: fLFfELZztWOogb1kdBP43liww6I2VQf6 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzIxMDExNSBTYWx0ZWRfX4SEadwNszZY0 2poUHLcfEhTRTpdbxJuvMmWS+mI+Cng7rjcglBOlFVl+5KcC5nsQO5LryzNeyUMDsITGOhkiGo2 ZjWZ7RtoKT/dDWY9geCAmv+WoyB3WosLLHYoOD+E1AoIBJrBsdxWUb4e4Lzuft0qmhVNHaJGbky oQggNqqxEZhAcV4TWuX76r46Yzwju4EcUXNfKT8MvsR8915KRTr2AqsVka7WPYDigJViiuDc0kH LtrfVgqNBqLUb4gjO+99/Q6ZmoHb2lashZx8lH2aipc7BjsbFXvQG7MnTdl5RDLasqVoVFRbNIV MqLX1CZzBTVRY3XZW/a411nyk33Rkv8LP4UZ/WDkBzEWh8HA5+SJ+CJ+3DUg+YyyvCpIZa5ieLy AwU1Rv02Z0MsU5OYgVWoc2b8fFXa2VAHMxvLes17wvqa7/4Ur3EjdJk9zcojzqtppQagvw0dLdw aGOaGqD72xp2cvm88ww== X-Authority-Analysis: v=2.4 cv=KbXfcAYD c=1 sm=1 tr=0 ts=69bea799 cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=IkcTkHD0fZMA:10 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=RzCfie-kr_QcCd8fBx8p:22 a=RfROgwSC8_-vDYzAT7cA:9 a=QEXdDO2ut3YA:10 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-21_04,2026-03-20_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 impostorscore=0 malwarescore=0 adultscore=0 clxscore=1015 priorityscore=1501 bulkscore=0 lowpriorityscore=0 phishscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603210115 Hi Prateek. On 3/21/26 3:43 PM, K Prateek Nayak wrote: > On 3/21/2026 3:15 PM, K Prateek Nayak wrote: >> So this is what I've found: By default we have: >> >> cpumask_size: 4 >> struct sched_domain size: 296 >> >> If I do: >> >> diff --git a/include/linux/sched/topology.h b/include/linux/sched/topology.h >> index a1e1032426dc..f0bebce274f7 100644 >> --- a/include/linux/sched/topology.h >> +++ b/include/linux/sched/topology.h >> @@ -148,7 +148,7 @@ struct sched_domain { >> * by attaching extra space to the end of the structure, >> * depending on how many CPUs the kernel has booted up with) >> */ >> - unsigned long span[]; >> + unsigned long span[1]; >> }; >> >> static inline struct cpumask *sched_domain_span(struct sched_domain *sd) >> --- >> >> I still see: >> >> cpumask_size: 4 >> struct sched_domain size: 296 >> >> Which means we are overwriting the sd->span during *sd assignment even >> with the variable length array at the end :-( >> > > And more evidence - by default we have: > > sched_domain size: 296 > offset of sd_span: 292 > > sizeof() seems to account some sort of 4-byte padding for the struct which > pushes the offset of sd->span into the struct size. > > To resolve this, we can also do: > > diff --git a/include/linux/sched/topology.h b/include/linux/sched/topology.h > index a1e1032426dc..48bea2f7f750 100644 > --- a/include/linux/sched/topology.h > +++ b/include/linux/sched/topology.h > @@ -148,7 +148,7 @@ struct sched_domain { > * by attaching extra space to the end of the structure, > * depending on how many CPUs the kernel has booted up with) > */ > - unsigned long span[]; > + unsigned long span[] __aligned(2 * sizeof(int)); > }; Wouldn't that be susceptible to change in sched_domain somewhere in between? Right now, it maybe aligning to 296 since it is 8 byte aligned. But lets say someone adds a new int in between. Then size of sched_domain would be 300. but span would still be 296 since it 8 bit aligned? > > static inline struct cpumask *sched_domain_span(struct sched_domain *sd) > --- > > and the kernel boots fine with the sd_span offset aligned with > sched_domain struct size: > > sched_domain size: 296 > offset of sd_span: 296 > > > So Peter, which solution do you prefer? > > 1. Doing cpumask_and() after the *sd = { ... } initialization. (or) > > 2. Align sd->span to an 8-byte boundary. > Only update sd_weight and leave everything as it was earlier? sd_weight = cpumask_and_weight(cpu_map, tl->mask(tl, cpu));