From nobody Fri Dec 19 17:19:35 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 DF167205AC1; Sat, 17 May 2025 10:03:04 +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=1747476186; cv=none; b=UzpI5eocf82N4caEjjbjorUUBQmDlxLEsnRrMobzARWjOCa4tuM5dM4FbYaYeY2oi4nHlvmlwfy7L5ZlQOq+CtfouLxcACLO4EVjDFGuHQa/mm0Hjrlf00jyUyGwKQoVRXqZ5KrtwJMQZ5lsKZIVo9TwWk7MQSYjXGhU/C4ss0U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747476186; c=relaxed/simple; bh=QQf1o9ifPefvEdQYHmV3eUANvfeMQPAFnbjn1kC20qI=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=Z3K3UGEu7a5RNbo8olQxsv8nc2RDKvl5O5kPCOyYDV3TUr0jbbPb1OY7QqnbnC/xBvnc8yEOLUdCuGVsjW3AmQjUWlL+hsk+lJiXNew6vtpBsgM5bkYQDP39y5SOW4LtUnNLPM7JDTuJwtsBV7cS7DQ5gVsQHj94zkUxANwsfzQ= 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=RJekmwA0; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=wYPU5NU1; 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="RJekmwA0"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="wYPU5NU1" Date: Sat, 17 May 2025 10:03:02 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1747476183; 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=pGuIzAJWeDZWSrlVnpD9xq9d1+D9VuqNGm4KIKObcio=; b=RJekmwA0zYSQMhaU4efe+PEHZJFtt0QMaxP469cXM8/LG+w8J8n85JiXk+WtDDchHvvVag tr9LLZfODD3pGB9zpYvvyUq4WgvGcxxsJo+f0vKaQCo+j7us4htMaNYJ4Kn7LINIE7VxUX o3g66NHjK/bynVot+TDvn0ZwIBwtWb0IoMQRwrWJvrQZEwiBHMJI30v/km3RpGY/afSWog /DzGcqjp8EonOEDOGM8YzjDBlb4urtFxpvfQUoEAWd0VYrL2T7b/t2MqoJ8C4G3oJu3Ria t0nSd3bv8tgyy86B2w816KP2fb1TsmgdzDSYiUXbr5hSA/gp742Cj11GS3HN+g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1747476183; 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=pGuIzAJWeDZWSrlVnpD9xq9d1+D9VuqNGm4KIKObcio=; b=wYPU5NU1UkJd1zWm8zNp+qIAbt2/FjBdZCd3uh2qlCBQxtWBa9rmyNC9Y+D39+zrOV5HeD 74Jj7v9msFiWnxCw== 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: Check all domains are offline in resctrl_exit() Cc: Reinette Chatre , James Morse , "Borislav Petkov (AMD)" , Fenghua Yu , Babu Moger , Shaopeng Tan , Tony Luck , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20250515165855.31452-8-james.morse@arm.com> References: <20250515165855.31452-8-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: <174747618259.406.16878539358798396377.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: 8eb7ad66badc71e0d8547cf6195a2a6190090152 Gitweb: https://git.kernel.org/tip/8eb7ad66badc71e0d8547cf6195a2a619= 0090152 Author: James Morse AuthorDate: Thu, 15 May 2025 16:58:37=20 Committer: Borislav Petkov (AMD) CommitterDate: Thu, 15 May 2025 21:02:21 +02:00 x86/resctrl: Check all domains are offline in resctrl_exit() resctrl_exit() removes things like the resctrl mount point directory and unregisters the filesystem prior to freeing data structures that were allocated during resctrl_init(). This assumes that there are no online domains when resctrl_exit() is called. If any domain were online, the limbo or overflow handler could be scheduled to run. Add a check for any online control or monitor domains, and document that the architecture code is required to offline all monitor and control domains before calling resctrl_exit(). Suggested-by: Reinette Chatre Signed-off-by: James Morse Signed-off-by: Borislav Petkov (AMD) Reviewed-by: Reinette Chatre Reviewed-by: Fenghua Yu Tested-by: Fenghua Yu Tested-by: Babu Moger Tested-by: Shaopeng Tan Tested-by: Tony Luck Link: https://lore.kernel.org/20250515165855.31452-8-james.morse@arm.com --- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 33 +++++++++++++++++++++++++- 1 file changed, 33 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 88197af..29f76ad 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -4420,8 +4420,41 @@ cleanup_mountpoint: return ret; } =20 +static bool __exit resctrl_online_domains_exist(void) +{ + struct rdt_resource *r; + + /* + * Only walk capable resources to allow resctrl_arch_get_resource() + * to return dummy 'not capable' resources. + */ + for_each_alloc_capable_rdt_resource(r) { + if (!list_empty(&r->ctrl_domains)) + return true; + } + + for_each_mon_capable_rdt_resource(r) { + if (!list_empty(&r->mon_domains)) + return true; + } + + return false; +} + +/* + * resctrl_exit() - Remove the resctrl filesystem and free resources. + * + * When called by the architecture code, all CPUs and resctrl domains must= be + * offline. This ensures the limbo and overflow handlers are not scheduled= to + * run, meaning the data structures they access can be freed by + * resctrl_mon_resource_exit(). + */ void __exit resctrl_exit(void) { + cpus_read_lock(); + WARN_ON_ONCE(resctrl_online_domains_exist()); + cpus_read_unlock(); + debugfs_remove_recursive(debugfs_resctrl); unregister_filesystem(&rdt_fs_type); sysfs_remove_mount_point(fs_kobj, "resctrl");