From nobody Thu Dec 18 18:04:17 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 93F6C25CC9F; Wed, 12 Mar 2025 17:20:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741800034; cv=none; b=n6VniEwnSvdJXSWO9DgVyTOF9lVWIH0XTGnv0SpqRcXItIp0GSSpWFs/3SNAw4rF6lJSQ3tQrkhDa48mEwCRgBl3zyg2ebt/U45ya14oKmZbdz/XsX/o5P/Wlz85ToUjw2McreXJf4GFb16t/asBGj7atJMH622QND0LG722VjU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741800034; c=relaxed/simple; bh=TXjY7L8ABk4dx025hAyDOsnJ+9mYyFuSUhmydrP53Po=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=NepBZ6hbgoXRj9YOe5Ftw9fIxBn9tAXIcPi2ScH++EVDlCy35ZrgoGtk9HcBvXKRW+TMkmkzzVvc4IIfR6wIJFvTgNAYyDxNw1N/SEXIUsCQISvyiSydE/ZT2XxdIDM7089ZwUIGXRkyPDe7bef7RFo741ZyAqjVcV6YPsnP5fo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=q5MpEBDF; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=lO6OXbDx; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="q5MpEBDF"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="lO6OXbDx" Date: Wed, 12 Mar 2025 17:20:29 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1741800030; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aAl+ZRT8UvHHdTpK70TGngKi/4TlYVEZdioC5BERGsU=; b=q5MpEBDFs43iWx0DkSh3fkT3MtTm9teWuOQOgEBRX6DxUfgE9YzHHsvqh5/7P2O5V401hW RtOdpyg/Bg9tBGdk/5GNdQrgWfwlEETU1RWmr8YXX0V+uTMf/ZXGmpBicaiYNJ6CfoD98u dJXWlas12en/WH/TlLWVf6Eh6v+844bz4FKc9avwxlemDSLST7yL5JbsKjy35fBlSrvhXq szbIgPt6b6kjF9xpuWW50futeugmTHk+eSetrVnipwIdCO1x0IhZS3D/lCu+1DVmygKYZD 37iyewpF0donZkzaz7VSgXDcOEBErdBhM1DleHo/WaT17R2CTPPGxjYT+xUBLA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1741800030; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aAl+ZRT8UvHHdTpK70TGngKi/4TlYVEZdioC5BERGsU=; b=lO6OXbDxsz+HLCuheA9CvzY0bSOOMF08X8V80acBc204UVG6lOPK3foo3DzcClmfM46H1u 5L35J9P8BRrOVqBw== From: "tip-bot2 for James Morse" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/cache] x86/resctrl: Move monitor exit work to a resctrl exit call Cc: James Morse , "Borislav Petkov (AMD)" , Shaopeng Tan , Tony Luck , Reinette Chatre , Fenghua Yu , Babu Moger , Carl Worth , Peter Newman , Amit Singh Tomar , Shanker Donthineni , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20250311183715.16445-16-james.morse@arm.com> References: <20250311183715.16445-16-james.morse@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <174180002923.14745.15958337522013936223.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the x86/cache branch of tip: Commit-ID: 011842727fa449f834c17b69d1273d88eb6e3309 Gitweb: https://git.kernel.org/tip/011842727fa449f834c17b69d1273d88e= b6e3309 Author: James Morse AuthorDate: Tue, 11 Mar 2025 18:37:00=20 Committer: Borislav Petkov (AMD) CommitterDate: Wed, 12 Mar 2025 12:23:13 +01:00 x86/resctrl: Move monitor exit work to a resctrl exit call rdt_put_mon_l3_config() is called via the architecture's resctrl_arch_exit() call, and appears to free the rmid_ptrs[] and closid_num_dirty_rmid[] array= s. In reality this code is marked __exit, and is removed by the linker as resc= trl can't be built as a module. To separate the filesystem and architecture parts of resctrl, this free()ing work needs to be triggered by the filesystem, as these structures belong to the filesystem code. Rename rdt_put_mon_l3_config() to resctrl_mon_resource_exit() and call it f= rom resctrl_exit(). The kfree() is currently dependent on r->mon_capable. Signed-off-by: James Morse Signed-off-by: Borislav Petkov (AMD) Reviewed-by: Shaopeng Tan Reviewed-by: Tony Luck Reviewed-by: Reinette Chatre Reviewed-by: Fenghua Yu Reviewed-by: Babu Moger Tested-by: Carl Worth # arm64 Tested-by: Shaopeng Tan Tested-by: Peter Newman Tested-by: Amit Singh Tomar # arm64 Tested-by: Shanker Donthineni # arm64 Tested-by: Babu Moger Link: https://lore.kernel.org/r/20250311183715.16445-16-james.morse@arm.com --- arch/x86/kernel/cpu/resctrl/core.c | 5 ----- arch/x86/kernel/cpu/resctrl/internal.h | 2 +- arch/x86/kernel/cpu/resctrl/monitor.c | 12 +++++++++--- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 2 ++ 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 850cb86..a1577bd 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -1074,14 +1074,9 @@ late_initcall(resctrl_arch_late_init); =20 static void __exit resctrl_arch_exit(void) { - struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; - cpuhp_remove_state(rdt_online); =20 resctrl_exit(); - - if (r->mon_capable) - rdt_put_mon_l3_config(); } =20 __exitcall(resctrl_arch_exit); diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 5f3713f..73005ca 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -586,7 +586,7 @@ void closid_free(int closid); int alloc_rmid(u32 closid); void free_rmid(u32 closid, u32 rmid); int rdt_get_mon_l3_config(struct rdt_resource *r); -void __exit rdt_put_mon_l3_config(void); +void __exit resctrl_mon_resource_exit(void); bool __init rdt_cpu_has(int flag); void mon_event_count(void *info); int rdtgroup_mondata_show(struct seq_file *m, void *arg); diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index e8388d1..15e8c01 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -1040,10 +1040,13 @@ out_unlock: return err; } =20 -static void __exit dom_data_exit(void) +static void __exit dom_data_exit(struct rdt_resource *r) { mutex_lock(&rdtgroup_mutex); =20 + if (!r->mon_capable) + goto out_unlock; + if (IS_ENABLED(CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID)) { kfree(closid_num_dirty_rmid); closid_num_dirty_rmid =3D NULL; @@ -1052,6 +1055,7 @@ static void __exit dom_data_exit(void) kfree(rmid_ptrs); rmid_ptrs =3D NULL; =20 +out_unlock: mutex_unlock(&rdtgroup_mutex); } =20 @@ -1237,9 +1241,11 @@ int __init rdt_get_mon_l3_config(struct rdt_resource= *r) return 0; } =20 -void __exit rdt_put_mon_l3_config(void) +void __exit resctrl_mon_resource_exit(void) { - dom_data_exit(); + struct rdt_resource *r =3D resctrl_arch_get_resource(RDT_RESOURCE_L3); + + dom_data_exit(r); } =20 void __init intel_rdt_mbm_apply_quirk(void) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 9eb57eb..42c48e7 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -4296,4 +4296,6 @@ void __exit resctrl_exit(void) debugfs_remove_recursive(debugfs_resctrl); unregister_filesystem(&rdt_fs_type); sysfs_remove_mount_point(fs_kobj, "resctrl"); + + resctrl_mon_resource_exit(); }