From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from BL2PR02CU003.outbound.protection.outlook.com (mail-eastusazon11011063.outbound.protection.outlook.com [52.101.52.63]) (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 B3166421F1D for ; Tue, 20 Jan 2026 11:33:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.52.63 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768908792; cv=fail; b=sRgn1hIlnleRv9EkKn1yzpTdx44ZH82SOLWJdeicJo/w/al3vvc6Fg0PPHwP9+8Z5WckvMozKM/L7Hv+9Cz3Qgo1i5op1PSqyGukWvD74Z646nsNegZBiiaR6qY6hP0vWWzolGzKLpOqtEwhLO+YF8wAU6P79CJdvufgQYkbe5c= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768908792; c=relaxed/simple; bh=/M4zFDmbSY/P+EkvPfuZ+zoaTLQ7kvaU9/URSBk9no4=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=jZt5d73SRi02130zFaVd+B3mu9mbCxC8EWbk6VFwbWl3ftfj+hDUtphGbJlMIBm6rCpeI0mkH60PNLYmtNiLEzXTbU8PBqRmoRrosZCxpPWfN1TW8j8aC2sNQ3H+iWq8ZWiN/UKt0E0gg8GSq6JwxVP1pt48tOhhfOJNqV1S8/U= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=q7wIqqoi; arc=fail smtp.client-ip=52.101.52.63 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="q7wIqqoi" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=zDkbTPgG8V12iF5H4W4mLoPsMo8D1uZWydY48HTcHOh+0CTN+mDPmfZfaCST243MblORZCtwxGuF5BwS6aZuB0UInzQ+ESPdgdMvoRKD3ouGRqYkchGRO9tfAIuCgnua2CXtqx13ojhA1CKXqSRvzXilvgdjTVpTbXxZY/g/TjvH5JefcP8kWcWTidkHaQ+VcMkOdVgBaA9K0wQKAJo7syZE821eZsciRvdUSaAqbJZqRyg5bQwDK4gZd6AeX2i5MzbA8yEAqY5tEirvabx6NF7K6uBXgNwh8e7IRVixdrgELugj4pmMGSScR12YSpddq0lIHVf0hVcaYAOTdFKXRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=HMzwzXI0BYlTd2MLIQTP35D01qaAUbvjFmQf8dL4wJs=; b=HsupqKesym+6/4AE3Bdmn453J5K/rud0Rvasq7DNSTVhilXuLSyMzlWpJ+MWAKRu0x7sOj8lwWGWxjTJkp74/uZw/npPLYPXcDqbgOi/FSucAhskXjTxwttL2qpIKFx9Jmftus2jgZ68bagHSm5R8YDmb2adbKZ/su3ZgErgIcA9K4unNfH4rDT/bGampek6XtuYgagrZObz3BhOyBgWdldL/bRgFK94xChCr2SHZ7Zpn3lTrGMgPk64Tf4V1OutCUw2FEbki5aP08oZMeEBRcXJMgfHWek8bhacVKaubpEDKe1vpQ6DoWyav3BorK6SbWj8eaAQ4Lfi7eTxoYuqFA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HMzwzXI0BYlTd2MLIQTP35D01qaAUbvjFmQf8dL4wJs=; b=q7wIqqoilMbyGMi/lYLIYEnlsFbj9Wk1om0T+CeSNjHL0fxEvmdHtVArz491kMPIkabpPaNAPELNwi0ClhL2meCwYhPLG4Kh+3yAJMYbxHCsYzeS5xhYojT59+RQQqTAPdziDphHd9VVbiTLT/YO3QSBkL1sOiHvs8fd6I4JrZ4= Received: from BL1PR13CA0274.namprd13.prod.outlook.com (2603:10b6:208:2bc::9) by MN0PR12MB6319.namprd12.prod.outlook.com (2603:10b6:208:3c0::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9520.12; Tue, 20 Jan 2026 11:33:05 +0000 Received: from BL02EPF00021F6F.namprd02.prod.outlook.com (2603:10b6:208:2bc:cafe::9) by BL1PR13CA0274.outlook.office365.com (2603:10b6:208:2bc::9) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9542.9 via Frontend Transport; Tue, 20 Jan 2026 11:33:09 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by BL02EPF00021F6F.mail.protection.outlook.com (10.167.249.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9542.4 via Frontend Transport; Tue, 20 Jan 2026 11:33:05 +0000 Received: from BLRKPRNAYAK.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Tue, 20 Jan 2026 05:33:00 -0600 From: K Prateek Nayak To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , CC: Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , Chen Yu , Shrikanth Hegde , "Gautham R. Shenoy" , K Prateek Nayak Subject: [PATCH v3 0/8] sched/topology: Optimize sd->shared allocation Date: Tue, 20 Jan 2026 11:32:38 +0000 Message-ID: <20260120113246.27987-1-kprateek.nayak@amd.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF00021F6F:EE_|MN0PR12MB6319:EE_ X-MS-Office365-Filtering-Correlation-Id: 3e585b52-83bc-44c9-c96a-08de5817adb8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|36860700013|82310400026|13003099007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?FBy12ACI8JEiZEHIHcvaFsT/dx0oFV5gy+DyhwarYpzWzNYDx9k2yULVHs9Y?= =?us-ascii?Q?Tu+2SjwkMGEda/AOkEjeKz4g6nQKY9pDeKvchhyy4ki4ac0Y8iSH63nZ9B5g?= =?us-ascii?Q?YpRy2ADxDr5sjNzls8kuuRGWbjApymV5/MRTuvKALuFi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7oFcyD5gyH1XkGix4KUnDkXQUbQtEjpxcXUFM/+03GR?= =?us-ascii?Q?CJhsYAMuoMC09EFGtwo2i9HZug2Tvob9PYYSiVZg/TuHA4I08ytdEWerK26K?= =?us-ascii?Q?IBsmTMjPwbh18wvSzGjPo36SJ/HsHDPD8MnSe3AMtXdNPbQ8LlSZwNF7qA3Y?= =?us-ascii?Q?5zWvrlMGhvid1cWO6KkqDO45uX/DKG2S/VomktLJzCWlF3KjHNDEj/Mkg8yy?= =?us-ascii?Q?t7jqM/FoDJBIoi5N8P09i5aaFA4u7KmVJUZmEN8jWhVCB8EMFYJzTEUk0wIY?= =?us-ascii?Q?AJe8yjepEJh3wFkldmZBijk7tjRrUYY2UAatVO5kjU6V1J+gtYUlAvD00QOw?= =?us-ascii?Q?STI9V59A8hxvctl7M362w04CPNzsFb37hPvsKIJ/S4m94iqqL6KybsPfalAV?= =?us-ascii?Q?WrgGd/udGDqUQOJghSZlDtMvQV0hdVFJ80attWMZkQFw6Q1szDDlAuBMFa+S?= =?us-ascii?Q?i0PJRwnppeamS4U9I6wxbAR1jtQhZ/gJEg341mZE4CItfTap2N6mWPflG0bS?= =?us-ascii?Q?HS+NnU1e1OFBxZue2KOwo47yLH0hK5zhFbqCnOyEDmyLgFcCP617hGdM2vFZ?= =?us-ascii?Q?zlp3uSsOPNzJnbOqVVdUV44=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(376014)(1800799024)(36860700013)(82310400026)(13003099007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2026 11:33:05.4808 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3e585b52-83bc-44c9-c96a-08de5817adb8 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF00021F6F.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6319 Discussed at LPC'25, the allocation of per-CPU "sched_domain_shared" objects for each topology level was found to be unnecessary since only "sd_llc_shared" is ever used by the scheduler and rest is either reclaimed during __sdt_free() or remain allocated without any purpose. Folks are already optimizing for unnecessary sched domain allocations with commit f79c9aa446d6 ("x86/smpboot: avoid SMT domain attach/destroy if SMT is not enabled") removing the SMT level entirely on the x86 side when it is know that the domain will be degenerated anyways by the scheduler. This goes one step ahead with the "sched_domain_shared" allocations by moving it out of "sd_data" which is allocated for every topology level and into "s_data" instead which is allocated once per partition. "sd->shared" is only allocated for the topmost SD_SHARE_LLC domain and the topology layer uses the sched domain degeneration path to pass the reference to the final "sd_llc" domain. Since degeneration of parent ensures 1:1 mapping between the span with the child, and the fact that SD_SHARE_LLC domains never overlap, degeneration of an SD_SAHRE_LLC domain either means its span is same as that of its child or that it only contains a single CPU making it redundant. Since the topology layer also checks for the existence of a valid "sd->shared" when "sd_llc" is present, the handling of "sd_llc_shared" can also be simplified when a reference to "sd_llc" is already present in the scope (Patch 7 and Patch 8). Patches are based on top of: git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git sched/core at commit 5d86d542f68f ("sched/fair: Remove nohz.nr_cpus and use weight of cpumask instead") --- Changelog rfc v2..v3: o Broke off the "sd->shared" assignment optimization into a separate series for easier review. o Spotted a case of incorrect calculation of load balancing periods in presence of cpuset partitions (Patch 1). o Broke off the single "sd->shared" assignment optimization patch into 3 parts for easier review (Patch 2 - Patch 4). The "Reviewed-by:" tag from Gautham was dropped as a result. o Building on recent effort from Peter to remove the superfluous usage of rcu_read_lock() in !preemptible() regions, Patch5 and Patch 6 cleans up the fair task's wakeup path before adding more cleanups in Patch 7 and Patch 8. o Dropped the RFC tag. v2: https://lore.kernel.org/lkml/20251208083602.31898-1-kprateek.nayak@amd.com/ --- K Prateek Nayak (8): sched/topology: Compute sd_weight considering cpuset partitions sched/topology: Allocate per-CPU sched_domain_shared in s_data sched/topology: Switch to assigning "sd->shared" from s_data sched/topology: Remove sched_domain_shared allocation with sd_data sched/core: Check for rcu_read_lock_any_held() in idle_get_state() sched/fair: Remove superfluous rcu_read_lock() in the wakeup path sched/fair: Simplify the entry condition for update_idle_cpu_scan() sched/fair: Simplify SIS_UTIL handling in select_idle_cpu() include/linux/sched/topology.h | 1 - kernel/sched/fair.c | 62 +++++++----------- kernel/sched/sched.h | 2 +- kernel/sched/topology.c | 111 ++++++++++++++++++++++----------- 4 files changed, 101 insertions(+), 75 deletions(-) base-commit: 5d86d542f68fda7ef6d543ac631b741db734101a -- 2.34.1