From nobody Sun Feb 8 15:46:35 2026 Received: from CH1PR05CU001.outbound.protection.outlook.com (mail-northcentralusazon11010056.outbound.protection.outlook.com [52.101.193.56]) (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 26808329C6B; Wed, 21 Jan 2026 21:15:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.193.56 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769030107; cv=fail; b=uWNIpi+BIN582lj1mguYTO21BMfb10QBfg40heC9u2D9jtY1rvvd/pDAP86imyLoWjt5VazdDhvRxDN3fVMYs6nmodwOVQjOV6F1xryTxLeDReEUgQUgKhl4kVn+6w0x9Nr086zBBKvxiENyG+3kdbAkEdlFOTKiZ4XjKAXIW7s= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769030107; c=relaxed/simple; bh=oZ7xA6sc2cisryQ7y+JtO+Z5wZ9Xn8KqG892Zq7Pm1E=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iYn0iJn5BOx+1peHnzNkrfc+nfvJ3THjUi9rot6kVcULBqFuglDvxaAaeNuBI+7+5GUSrhAzwWRffVRikUOuFfK71Ai8VCXupQ4/KhV9MBSzhvFr0Bnw5O2cSJMA5RPqeF+qM1lEK706/BYRlfxzkmEbT38OJHan2+sFezG4UiQ= 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=OzJk1LfN; arc=fail smtp.client-ip=52.101.193.56 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="OzJk1LfN" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ebBJLFHbG85ZrugWL+TEiKFWHan1WCGSEHap2wVqXtMyHzgAsF+qcsxgmd6sSZ23QTTO5EPcYO0dsLqoPC3+bNnZtI3vK/UmtOzaTuvlSGksW/ZIG27WbmBoBVlBYep35v7dSo5zqljp0+Kldm1fKFWus+s66I30Cb2o0inDWOQqf6TAe+CwHaWJ28a2kBrHRX+vgKa/MtQI86WWaRDJAKvE/lageOCKnyxuZvYopfBqN/mkpihX/1kXZIaTiyFYK6PvhSdpBexUif3kMZvL92ltVj2H8OlPwhRl2zx6Ltg7E+txh3BwOZWFChLdAVrazI1z9HI6CEWtNRDEaAMFQg== 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=9PC7edQFe39USyvVGw3hUVGB69g3g2zI7YfRZB+iWxc=; b=Y5O0BTwRHZn20w4KsZt3KAJ7Z44Q/SdDGhJS7hgZoOuRvUgCa7iNu9c3Zb2yR1qSDQtJHsFol/NX132wBTq/92kzmdpMXbC9+MPQm3IrlY5e/TICkM2qJz7LMDuWA2k5dyKMylA68v9iYfisF1l9wLoVVCoTcUGqFL9TMOifXs+NfnjIS/IovG9Y0iWXWjMVlHEmI11adEQZmAn3ReMdU2MQzV2HpIMWLSHfF+R8TftL6PlzTOZwA4vncQb3IRVe9WDhr2jKlq0OF238Ci9OY9HPbxHstJai6FkgHZrzz+7N8uB0lrj7Q7m0Fud7GovCQU0QiHkTW/cZerbYlgPoFQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net 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=9PC7edQFe39USyvVGw3hUVGB69g3g2zI7YfRZB+iWxc=; b=OzJk1LfN/MkYnSwFkXWvg1gc2zDKPEkjlYK9nH3OH4BmTwjBon/8NeOtQlP64ii7lZSUzSg9N1J/0SzzZxfrvj4QkkC1dxKJ82qbA1boijmS4xVKY8c3eM465GGA1+EA3CX5MaPoAoSHtTFN62WkIWvxDYtvCvucpM8IIYpeqtg= Received: from BY1P220CA0007.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:59d::13) by BY5PR12MB4099.namprd12.prod.outlook.com (2603:10b6:a03:20f::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9542.9; Wed, 21 Jan 2026 21:14:55 +0000 Received: from SJ1PEPF00001CE6.namprd03.prod.outlook.com (2603:10b6:a03:59d:cafe::83) by BY1P220CA0007.outlook.office365.com (2603:10b6:a03:59d::13) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9542.10 via Frontend Transport; Wed, 21 Jan 2026 21:15:01 +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 SJ1PEPF00001CE6.mail.protection.outlook.com (10.167.242.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9542.4 via Frontend Transport; Wed, 21 Jan 2026 21:14:55 +0000 Received: from bmoger-ubuntu.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; Wed, 21 Jan 2026 15:14:47 -0600 From: Babu Moger To: , , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [RFC PATCH 13/19] x86/resctrl: Add PLZA state tracking and context switch handling Date: Wed, 21 Jan 2026 15:12:51 -0600 Message-ID: <17c9c0c252dcfe707dffe5986e7c98cd121f7cef.1769029977.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: 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 X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00001CE6:EE_|BY5PR12MB4099:EE_ X-MS-Office365-Filtering-Correlation-Id: e2d68424-17d0-4831-6bf0-08de59322030 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|7416014|376014|1800799024|36860700013|921020; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?BHkjhDef0RJSBHghdJHiVyi9gM/IvfP8xggq9zt6QfFD/2TESeyCjLJJawLw?= =?us-ascii?Q?YEQYtAURtNvW+JHDqsfOWPC64CFXH4dVQf3j3pCaU7IxY2GVC01y5vWgyTVE?= =?us-ascii?Q?MFgsNn0Md+659bUjD1/QZuA2LhJpfrxHL2FDJWVsWUS2BtP5nGbzZhwB3Iko?= =?us-ascii?Q?HlZKR1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mKA+anj7XBivIh?= =?us-ascii?Q?LM/wdMIx8N/uGN2cGDdU25JoXBy/cTvO17crfJNnOkZt/sEyXodbNsrsb9Pr?= =?us-ascii?Q?x20/9HLCTzHEaqo3eOJJjmDDsgsM8jG44L55uTYf0955u072jtr6qrT9aa+I?= =?us-ascii?Q?TSCi99QOFN5u7kJdLLJsP8SsJuAe4RgTIOOl1rJkLXujG+448l08ggoh1aDa?= =?us-ascii?Q?k3QoZ1Vd5mFX4DC8WxTDUAg3xORhazc5Z4Lu1Aylocf3cdi1tBPlu94j7rhw?= =?us-ascii?Q?hbG5dYTMWUE9knwaRV3r/lNuhduujF5kZhnXv1IzUINI3FyrzlS6NUiuGuhQ?= =?us-ascii?Q?OF0w08L85cKOrfMUtrb55xR+T5d9AGVpfian80Ewt1tWIL0neARF7aSzW/My?= =?us-ascii?Q?aBkKOuBd8nM7zyEwLgE5gCiX6o0kcUwfwh29cBrJEGouu0f5A9HSVYTdls1s?= =?us-ascii?Q?19l4IbPLaGoCLbq4ghyV3/aAqL9eYeeWB2egGTzJkRAgDoUsC/6KistYAslW?= =?us-ascii?Q?DsyahVWzTqF0RSTYshI8zIKjP0VyBHaZ7mYhEoQhjhzOZxMkwyKnhi61sDjq?= =?us-ascii?Q?3LLMqvwx0f2qSLBffl9f5Y1KxFOwmPlkbE6OjqSfmHFghDE4YblKi9pDi0MF?= =?us-ascii?Q?3/o+1yxQPxTXoj+LXZ5/u2FHA1g=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)(82310400026)(7416014)(376014)(1800799024)(36860700013)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jan 2026 21:14:55.5382 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e2d68424-17d0-4831-6bf0-08de59322030 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: SJ1PEPF00001CE6.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4099 Content-Type: text/plain; charset="utf-8" The resctrl subsystem writes the task's RMID/CLOSID to IA32_PQR_ASSOC in __resctrl_sched_in(). With PLZA support being introduced and guarded by rdt_plza_enable_key, the kernel needs a way to track and program the PLZA association independently of the regular RMID/CLOSID path. Extend the per-CPU resctrl_pqr_state to track PLZA-related state, including the current and default PLZA values along with the associated RMID and CLOSID. Update the resctrl scheduling-in path to program the PLZA MSR when PLZA support is enabled. During the context switch, the task-specific PLZA setting is applied if present; otherwise, the per-CPU default PLZA value is used. The MSR is only written when the PLZA state changes, avoiding unnecessary writes. PLZA programming is guarded by a static key to ensure there is no overhead when the feature is disabled. Signed-off-by: Babu Moger --- arch/x86/include/asm/resctrl.h | 19 +++++++++++++++++++ include/linux/sched.h | 1 + 2 files changed, 20 insertions(+) diff --git a/arch/x86/include/asm/resctrl.h b/arch/x86/include/asm/resctrl.h index fc0a7f64649e..76de7d6051b7 100644 --- a/arch/x86/include/asm/resctrl.h +++ b/arch/x86/include/asm/resctrl.h @@ -38,6 +38,10 @@ struct resctrl_pqr_state { u32 cur_closid; u32 default_rmid; u32 default_closid; + u32 cur_plza; + u32 default_plza; + u32 plza_rmid; + u32 plza_closid; }; =20 DECLARE_PER_CPU(struct resctrl_pqr_state, pqr_state); @@ -115,6 +119,7 @@ static inline void __resctrl_sched_in(struct task_struc= t *tsk) struct resctrl_pqr_state *state =3D this_cpu_ptr(&pqr_state); u32 closid =3D READ_ONCE(state->default_closid); u32 rmid =3D READ_ONCE(state->default_rmid); + u32 plza =3D READ_ONCE(state->default_plza); u32 tmp; =20 /* @@ -138,6 +143,20 @@ static inline void __resctrl_sched_in(struct task_stru= ct *tsk) state->cur_rmid =3D rmid; wrmsr(MSR_IA32_PQR_ASSOC, rmid, closid); } + + if (static_branch_likely(&rdt_plza_enable_key)) { + tmp =3D READ_ONCE(tsk->plza); + if (tmp) + plza =3D tmp; + + if (plza !=3D state->cur_plza) { + state->cur_plza =3D plza; + wrmsr(MSR_IA32_PQR_PLZA_ASSOC, + RMID_EN | state->plza_rmid, + (plza ? PLZA_EN : 0) | CLOSID_EN | state->plza_closid); + } + } + } =20 static inline unsigned int resctrl_arch_round_mon_val(unsigned int val) diff --git a/include/linux/sched.h b/include/linux/sched.h index 8f3a60f13393..d573163865ae 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -1326,6 +1326,7 @@ struct task_struct { #ifdef CONFIG_X86_CPU_RESCTRL u32 closid; u32 rmid; + u32 plza; #endif #ifdef CONFIG_FUTEX struct robust_list_head __user *robust_list; --=20 2.34.1