From nobody Fri Dec 19 17:18:32 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 6B8301FBE8A; Sat, 17 May 2025 10:02:58 +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=1747476180; cv=none; b=t4HVqQQ1jnybp+Q9rbDiNEiVfCQWEKZqAojYvEa2P0Me53NO/wgl7SbvxSMiKUwvV1YSfHe7J24HRowFiWJC0HPD/iERvhoLabiKASTsWhepHNDuhEq11kXP76DKeLHfNz0ukWk+sc/9CUAEhdSWwbi/dH45MWn8GuTF0yeJ7sk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747476180; c=relaxed/simple; bh=tsLlteKX17ky4XIJJiyOJtEQaLRnv2DJUT+D92ffloI=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=j1HVF30IG0WAIbD/CrW5hxbLDYOau7y1kPJn+qBF0j2M6npWfj4lwR2KvOiorG2sEquX4trXc34Tjb6HR8qYn6NVIekFJFwts3aA1opu2mioTkqTbypwCq4O4JQbHSIUc3fFM6+ooaB23Qz/p7OfUFs1OPpMondq3n4DRywbdQ0= 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=GS8WqF2D; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=QK/Qwi1T; 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="GS8WqF2D"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="QK/Qwi1T" Date: Sat, 17 May 2025 10:02:56 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1747476177; 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=gLcjQ5m/kDi9SEr3nKJRLrV2hTfx5OI2rRu4pzw8NJM=; b=GS8WqF2DgCpPVLXsG2/9lfLNUPZ7zY6OT6hxHTWcKpZDyXG3kfoS/zxEf2PHPeOez9y6Kj JbTSnn5Q4JZ8ItHTmVNuNPobcUVetuEe4rhVqbOs9JQBUZZ/0sHQni90GPCIh5bmm2bSqF hfrauIUjSmus9xxT/Nxv26spe2RMr0Yp6DxkLX70ft9BkBKmGZXGv/fW3IwmbqeADuUIjd t9HiGnHWlsMYp2U3aIJ+CDL2S1Iyh+pgtEvu0ZGzKzIH88HXVYxen+2BbGBErhFVObe4fX qgtNA7cqDuhZ+SPHFzWoHtxtEGpwuwxqnuooluIF1vpyIrumajbw+sOYZ3EeWQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1747476177; 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=gLcjQ5m/kDi9SEr3nKJRLrV2hTfx5OI2rRu4pzw8NJM=; b=QK/Qwi1TTOVXEh5ToWXn67yJua5Dh7raIyqC9XJLHp0miZISACk9ycLucpx11ZQMQvEgKh yewJotsXw8UWhRBw== 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] fs/resctrl: Add boiler plate for external resctrl code Cc: Dave Martin , James Morse , "Borislav Petkov (AMD)" , Shaopeng Tan , Tony Luck , Fenghua Yu , Reinette Chatre , Carl Worth , Peter Newman , Amit Singh Tomar , Shanker Donthineni , Babu Moger , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20250515165855.31452-16-james.morse@arm.com> References: <20250515165855.31452-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: <174747617608.406.11526762912747822153.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: bff70402d6d67843fe319338e4c56e1cba13fbd8 Gitweb: https://git.kernel.org/tip/bff70402d6d67843fe319338e4c56e1cb= a13fbd8 Author: James Morse AuthorDate: Thu, 15 May 2025 16:58:45=20 Committer: Borislav Petkov (AMD) CommitterDate: Fri, 16 May 2025 11:05:40 +02:00 fs/resctrl: Add boiler plate for external resctrl code Add Makefile and Kconfig for fs/resctrl. Add ARCH_HAS_CPU_RESCTRL for the common parts of the resctrl interface and make X86_CPU_RESCTRL select this. Adding an include of asm/resctrl.h to linux/resctrl.h allows the /fs/resctrl files to switch over to using this header instead. Co-developed-by: Dave Martin Signed-off-by: Dave Martin Signed-off-by: James Morse Signed-off-by: Borislav Petkov (AMD) Reviewed-by: Shaopeng Tan Reviewed-by: Tony Luck Reviewed-by: Fenghua Yu Reviewed-by: Reinette Chatre Tested-by: Fenghua Yu 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 Tested-by: Tony Luck Link: https://lore.kernel.org/20250515165855.31452-16-james.morse@arm.com --- MAINTAINERS | 1 +- arch/Kconfig | 8 +++++- arch/x86/Kconfig | 11 +----- arch/x86/kernel/cpu/resctrl/internal.h | 2 +- arch/x86/kernel/cpu/resctrl/monitor.c | 2 +- arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 2 +- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 2 +- fs/Kconfig | 1 +- fs/Makefile | 1 +- fs/resctrl/Kconfig | 39 ++++++++++++++++++++++- fs/resctrl/Makefile | 6 +++- fs/resctrl/ctrlmondata.c | 0 fs/resctrl/internal.h | 0 fs/resctrl/monitor.c | 0 fs/resctrl/monitor_trace.h | 0 fs/resctrl/pseudo_lock.c | 0 fs/resctrl/pseudo_lock_trace.h | 0 fs/resctrl/rdtgroup.c | 0 include/linux/resctrl.h | 4 ++- 19 files changed, 66 insertions(+), 13 deletions(-) create mode 100644 fs/resctrl/Kconfig create mode 100644 fs/resctrl/Makefile create mode 100644 fs/resctrl/ctrlmondata.c create mode 100644 fs/resctrl/internal.h create mode 100644 fs/resctrl/monitor.c create mode 100644 fs/resctrl/monitor_trace.h create mode 100644 fs/resctrl/pseudo_lock.c create mode 100644 fs/resctrl/pseudo_lock_trace.h create mode 100644 fs/resctrl/rdtgroup.c diff --git a/MAINTAINERS b/MAINTAINERS index f21f1da..ed96cc7 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -20427,6 +20427,7 @@ S: Supported F: Documentation/arch/x86/resctrl* F: arch/x86/include/asm/resctrl.h F: arch/x86/kernel/cpu/resctrl/ +F: fs/resctrl/ F: include/linux/resctrl*.h F: tools/testing/selftests/resctrl/ =20 diff --git a/arch/Kconfig b/arch/Kconfig index b0adb66..a3308a2 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -1518,6 +1518,14 @@ config STRICT_MODULE_RWX config ARCH_HAS_PHYS_TO_DMA bool =20 +config ARCH_HAS_CPU_RESCTRL + bool + help + An architecture selects this option to indicate that the necessary + hooks are provided to support the common memory system usage + monitoring and control interfaces provided by the 'resctrl' + filesystem (see RESCTRL_FS). + config HAVE_ARCH_COMPILER_H bool help diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 5873c9e..52cfb69 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -507,8 +507,9 @@ config X86_MPPARSE config X86_CPU_RESCTRL bool "x86 CPU resource control support" depends on X86 && (CPU_SUP_INTEL || CPU_SUP_AMD) - select KERNFS - select PROC_CPU_RESCTRL if PROC_FS + depends on MISC_FILESYSTEMS + select ARCH_HAS_CPU_RESCTRL + select RESCTRL_FS select RESCTRL_FS_PSEUDO_LOCK help Enable x86 CPU resource control support. @@ -526,12 +527,6 @@ config X86_CPU_RESCTRL =20 Say N if unsure. =20 -config RESCTRL_FS_PSEUDO_LOCK - bool - help - Software mechanism to pin data in a cache portion using - micro-architecture specific knowledge. - config X86_FRED bool "Flexible Return and Event Delivery" depends on X86_64 diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 01cb0ff..348895d 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -9,8 +9,6 @@ #include #include =20 -#include - #define L3_QOS_CDP_ENABLE 0x01ULL =20 #define L2_QOS_CDP_ENABLE 0x01ULL diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index ac1cec6..8847c23 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -19,11 +19,11 @@ =20 #include #include +#include #include #include =20 #include -#include =20 #include "internal.h" =20 diff --git a/arch/x86/kernel/cpu/resctrl/pseudo_lock.c b/arch/x86/kernel/cp= u/resctrl/pseudo_lock.c index f7bb586..db0b75b 100644 --- a/arch/x86/kernel/cpu/resctrl/pseudo_lock.c +++ b/arch/x86/kernel/cpu/resctrl/pseudo_lock.c @@ -18,12 +18,12 @@ #include #include #include +#include #include #include =20 #include #include -#include #include =20 #include "../../events/perf_event.h" /* For X86_CONFIG() */ diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index d480784..3a4a0bb 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -28,7 +29,6 @@ =20 #include =20 -#include #include "internal.h" =20 DEFINE_STATIC_KEY_FALSE(rdt_enable_key); diff --git a/fs/Kconfig b/fs/Kconfig index 5b4847b..44b6cdd 100644 --- a/fs/Kconfig +++ b/fs/Kconfig @@ -335,6 +335,7 @@ source "fs/omfs/Kconfig" source "fs/hpfs/Kconfig" source "fs/qnx4/Kconfig" source "fs/qnx6/Kconfig" +source "fs/resctrl/Kconfig" source "fs/romfs/Kconfig" source "fs/pstore/Kconfig" source "fs/ufs/Kconfig" diff --git a/fs/Makefile b/fs/Makefile index 77fd7f7..79c08b9 100644 --- a/fs/Makefile +++ b/fs/Makefile @@ -128,3 +128,4 @@ obj-$(CONFIG_EROFS_FS) +=3D erofs/ obj-$(CONFIG_VBOXSF_FS) +=3D vboxsf/ obj-$(CONFIG_ZONEFS_FS) +=3D zonefs/ obj-$(CONFIG_BPF_LSM) +=3D bpf_fs_kfuncs.o +obj-$(CONFIG_RESCTRL_FS) +=3D resctrl/ diff --git a/fs/resctrl/Kconfig b/fs/resctrl/Kconfig new file mode 100644 index 0000000..478a8e2 --- /dev/null +++ b/fs/resctrl/Kconfig @@ -0,0 +1,39 @@ +config RESCTRL_FS + bool "CPU Resource Control Filesystem (resctrl)" + depends on ARCH_HAS_CPU_RESCTRL + select KERNFS + select PROC_CPU_RESCTRL if PROC_FS + help + Some architectures provide hardware facilities to group tasks and + monitor and control their usage of memory system resources such as + caches and memory bandwidth. Examples of such facilities include + Intel's Resource Director Technology (Intel(R) RDT) and AMD's + Platform Quality of Service (AMD QoS). + + If your system has the necessary support and you want to be able to + assign tasks to groups and manipulate the associated resource + monitors and controls from userspace, say Y here to get a mountable + 'resctrl' filesystem that lets you do just that. + + If nothing mounts or prods the 'resctrl' filesystem, resource + controls and monitors are left in a quiescent, permissive state. + + On architectures where this can be disabled independently, it is + safe to say N. + + See for more information. + +config RESCTRL_FS_PSEUDO_LOCK + bool + depends on RESCTRL_FS + help + Software mechanism to pin data in a cache portion using + micro-architecture specific knowledge. + +config RESCTRL_RMID_DEPENDS_ON_CLOSID + bool + depends on RESCTRL_FS + help + Enabled by the architecture when the RMID values depend on the CLOSID. + This causes the CLOSID allocator to search for CLOSID with clean + RMID. diff --git a/fs/resctrl/Makefile b/fs/resctrl/Makefile new file mode 100644 index 0000000..e67f34d --- /dev/null +++ b/fs/resctrl/Makefile @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0 +obj-$(CONFIG_RESCTRL_FS) +=3D rdtgroup.o ctrlmondata.o monitor.o +obj-$(CONFIG_RESCTRL_FS_PSEUDO_LOCK) +=3D pseudo_lock.o + +# To allow define_trace.h's recursive include: +CFLAGS_monitor.o =3D -I$(src) diff --git a/fs/resctrl/ctrlmondata.c b/fs/resctrl/ctrlmondata.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/fs/resctrl/ctrlmondata.c diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/fs/resctrl/internal.h diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/fs/resctrl/monitor.c diff --git a/fs/resctrl/monitor_trace.h b/fs/resctrl/monitor_trace.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/fs/resctrl/monitor_trace.h diff --git a/fs/resctrl/pseudo_lock.c b/fs/resctrl/pseudo_lock.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/fs/resctrl/pseudo_lock.c diff --git a/fs/resctrl/pseudo_lock_trace.h b/fs/resctrl/pseudo_lock_trace.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/fs/resctrl/pseudo_lock_trace.h diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/fs/resctrl/rdtgroup.c diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index b8f8240..5c7c8bf 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -8,6 +8,10 @@ #include #include =20 +#ifdef CONFIG_ARCH_HAS_CPU_RESCTRL +#include +#endif + /* CLOSID, RMID value used by the default control group */ #define RESCTRL_RESERVED_CLOSID 0 #define RESCTRL_RESERVED_RMID 0