[tip: x86/cache] x86/resctrl: Move RFTYPE flags to be managed by resctrl

From: tip-bot2 for James Morse
Date: Wed Mar 12 2025 - 13:21:00 EST


The following commit has been merged into the x86/cache branch of tip:

Commit-ID: 373af4ecfdc922657be081b3feebbd0af8e7fa65
Gitweb: https://git.kernel.org/tip/373af4ecfdc922657be081b3feebbd0af8e7fa65
Author: James Morse <james.morse@xxxxxxx>
AuthorDate: Tue, 11 Mar 2025 18:37:12
Committer: Borislav Petkov (AMD) <bp@xxxxxxxxx>
CommitterDate: Wed, 12 Mar 2025 12:24:37 +01:00

x86/resctrl: Move RFTYPE flags to be managed by resctrl

resctrl_file_fflags_init() is called from the architecture specific code to
make the 'thread_throttle_mode' file visible. The architecture specific code
has already set the membw.throttle_mode in the rdt_resource.

This forces the RFTYPE flags used by resctrl to be exposed to the architecture
specific code.

This doesn't need to be specific to the architecture, the throttle_mode can be
used by resctrl to determine if the 'thread_throttle_mode' file should be
visible. This allows the RFTYPE flags to be private to resctrl.

Add thread_throttle_mode_init(), and use it to call resctrl_file_fflags_init()
from resctrl_init(). This avoids publishing an extra function between the
architecture and filesystem code.

Signed-off-by: James Morse <james.morse@xxxxxxx>
Signed-off-by: Borislav Petkov (AMD) <bp@xxxxxxxxx>
Reviewed-by: Reinette Chatre <reinette.chatre@xxxxxxxxx>
Reviewed-by: Fenghua Yu <fenghuay@xxxxxxxxxx>
Reviewed-by: Babu Moger <babu.moger@xxxxxxx>
Reviewed-by: Shaopeng Tan <tan.shaopeng@xxxxxxxxxxxxxx>
Tested-by: Peter Newman <peternewman@xxxxxxxxxx>
Tested-by: Shaopeng Tan <tan.shaopeng@xxxxxxxxxxxxxx>
Tested-by: Amit Singh Tomar <amitsinght@xxxxxxxxxxx> # arm64
Tested-by: Shanker Donthineni <sdonthineni@xxxxxxxxxx> # arm64
Tested-by: Babu Moger <babu.moger@xxxxxxx>
Link: https://lore.kernel.org/r/20250311183715.16445-28-james.morse@xxxxxxx
---
arch/x86/kernel/cpu/resctrl/core.c | 3 ---
arch/x86/kernel/cpu/resctrl/rdtgroup.c | 12 ++++++++++++
2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c
index b9b74f5..e590dd3 100644
--- a/arch/x86/kernel/cpu/resctrl/core.c
+++ b/arch/x86/kernel/cpu/resctrl/core.c
@@ -227,9 +227,6 @@ static __init bool __get_mem_config_intel(struct rdt_resource *r)
else
r->membw.throttle_mode = THREAD_THROTTLE_MAX;

- resctrl_file_fflags_init("thread_throttle_mode",
- RFTYPE_CTRL_INFO | RFTYPE_RES_MB);
-
r->alloc_capable = true;

return true;
diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
index e592715..58feba3 100644
--- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
+++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
@@ -2064,6 +2064,16 @@ static struct rftype *rdtgroup_get_rftype_by_name(const char *name)
return NULL;
}

+static void thread_throttle_mode_init(void)
+{
+ struct rdt_resource *r_mba;
+
+ r_mba = resctrl_arch_get_resource(RDT_RESOURCE_MBA);
+ if (r_mba->membw.throttle_mode != THREAD_THROTTLE_UNDEFINED)
+ resctrl_file_fflags_init("thread_throttle_mode",
+ RFTYPE_CTRL_INFO | RFTYPE_RES_MB);
+}
+
void resctrl_file_fflags_init(const char *config, unsigned long fflags)
{
struct rftype *rft;
@@ -4277,6 +4287,8 @@ int __init resctrl_init(void)

rdtgroup_setup_default();

+ thread_throttle_mode_init();
+
ret = resctrl_mon_resource_init();
if (ret)
return ret;