x86/resctrl: Move the resctrl filesystem code to /fs/resctrl
Subsystems (3)
Dave Martin
reviewerv2 cover x86/resctrl: Move the resctrl filesystem code to /fs/resctrl
Hi all,
This is a respin of the resctrl refactoring series described below, addressing review feedback. Many thanks to those to responded with feedback on the v1 series [2].
See Notes and FYIs in the individual patches for details on the changes and outstanding issues.
This series has not been rebased since the v1 posting, and remains based on the following upstream commit:
commit 23956900041d968f9ad0f30db6dede4daccd7aa9
Merge tag 'v6.9-rc-smb3-server-fixes' of git://git.samba.org/ksmbd
The actual code changes against v1 are few in number and rather spread around. For reviewer convenience, a diff against v1 is appended to this cover letter.
Due to the limited code changes, this series has *not* received any additional runtime testing over than done for v1 (other than build bisect testing).
Cheers
---Dave
[2] v1 series:
[PATCH v1 00/31] x86/resctrl: Move the resctrl filesystem code to /fs/resctrl
https://lore.kernel.org/all/[email protected]/
--8<-- Original blurb
This is the final series that allows other architectures to implement resctrl. The last patch just moves the code, and its a bit of a monster. I don't expect that to get merged as part of this series - we should wait for it to make less impact on other series. It's included here to show what gets moved, and that structures/function-prototypes have the right visibility.
Otherwise this series renames functions and moves code around. With the exception of invalid configurations for the configurable-events, there should be no changes in behaviour caused by this series.
The driving pattern is to make things like struct rdtgroup private to resctrl. Features like pseudo-lock aren't going to work on arm64, the ability to disable it at compile time is added.
After this, I can start posting the MPAM driver to make use of resctrl on arm64. (What's MPAM? See the cover letter of the first series. [1])
This series is based on Linus' commit 23956900041d and can be retrieved from:
https://git.kernel.org/pub/scm/linux/kernel/git/morse/linux.git
mpam/move_to_fs/v1
Sorry for the mid-merge window base, I'm away for a few weeks - this should rebase trivially onto rc1.
As ever - bugs welcome,
Thanks,
James
[1] https://lore.kernel.org/lkml/[email protected]/
-->8--
Dave Martin (4):
x86/resctrl: Squelch whitespace anomalies in resctrl core code x86/resctrl: Prefer alloc(sizeof(*foo)) idiom in rdt_init_fs_context() x86/resctrl: Relax some asm #includes
[SQUASHME] x86/resctrl: Move the resctrl filesystem code to
/fs/resctrl
James Morse (31):
x86/resctrl: Fix allocation of cleanest CLOSID on platforms with no
monitors
x86/resctrl: Add a helper to avoid reaching into the arch code
resource list
x86/resctrl: Move ctrlval string parsing policy away from the arch
code
x86/resctrl: Add helper for setting CPU default properties x86/resctrl: Remove rdtgroup from update_cpu_closid_rmid() x86/resctrl: Export resctrl fs's init function x86/resctrl: Wrap resctrl_arch_find_domain() around rdt_find_domain() x86/resctrl: Move resctrl types to a separate header x86/resctrl: Add a resctrl helper to reset all the resources x86/resctrl: Move monitor init work to a resctrl init call x86/resctrl: Move monitor exit work to a resctrl exit call x86/resctrl: Move max_{name,data}_width into resctrl code x86/resctrl: Stop using the for_each_*_rdt_resource() walkers x86/resctrl: Export the is_mbm_*_enabled() helpers to asm/resctrl.h x86/resctrl: Add resctrl_arch_is_evt_configurable() to abstract BMEC x86/resctrl: Change mon_event_config_{read,write}() to be arch helpers x86/resctrl: Move mbm_cfg_mask to struct rdt_resource x86/resctrl: Allow resctrl_arch_mon_event_config_write() to return an
error
x86/resctrl: Add resctrl_arch_ prefix to pseudo lock functions x86/resctrl: Allow an architecture to disable pseudo lock x86/resctrl: Make prefetch_disable_bits belong to the arch code x86/resctrl: Make resctrl_arch_pseudo_lock_fn() take a plr x86/resctrl: Move thread_throttle_mode_init() to be managed by resctrl x86/resctrl: Move get_config_index() to a header x86/resctrl: Claim get_domain_from_cpu() for resctrl x86/resctrl: Describe resctrl's bitmap size assumptions x86/resctrl: Rename resctrl_sched_in() to begin with "resctrl_arch_" x86/resctrl: Drop __init/__exit on assorted symbols fs/resctrl: Add boiler plate for external resctrl code x86/resctrl: Move the filesystem bits to headers visible to fs/resctrl x86/resctrl: Move the resctrl filesystem code to /fs/resctrl
MAINTAINERS | 2 + arch/Kconfig | 8 + arch/x86/Kconfig | 5 +- arch/x86/include/asm/resctrl.h | 45 +- arch/x86/kernel/cpu/resctrl/Makefile | 5 +- arch/x86/kernel/cpu/resctrl/core.c | 119 +- arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 506 +-- arch/x86/kernel/cpu/resctrl/internal.h | 436 +-- arch/x86/kernel/cpu/resctrl/monitor.c | 813 +--- arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 1130 +----- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 4205 +-------------------- arch/x86/kernel/process_32.c | 2 +- arch/x86/kernel/process_64.c | 2 +- fs/Kconfig | 1 + fs/Makefile | 1 + fs/resctrl/Kconfig | 36 + fs/resctrl/Makefile | 3 + fs/resctrl/ctrlmondata.c | 527 +++ fs/resctrl/internal.h | 338 ++ fs/resctrl/monitor.c | 843 +++++ fs/resctrl/pseudo_lock.c | 1122 ++++++ fs/resctrl/rdtgroup.c | 4013 ++++++++++++++++++++ include/linux/resctrl.h | 157 +- include/linux/resctrl_types.h | 98 + 24 files changed, 7402 insertions(+), 7015 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/pseudo_lock.c create mode 100644 fs/resctrl/rdtgroup.c create mode 100644 include/linux/resctrl_types.h
Interdiff:
arch/Kconfig +4 -4
@@ -1409,10 +1409,10 @@ config ARCH_HAS_PHYS_TO_DMA config ARCH_HAS_CPU_RESCTRL bool help - The 'resctrl' filesystem allows CPU controls of shared resources - such as caches and memory bandwidth to be configured. An architecture - selects this if it provides the arch-specific hooks for the filesystem - and needs the per-task CLOSID/RMID properties. + 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
arch/x86/include/asm/resctrl.h +1 -1
@@ -6,8 +6,8 @@#include <linux/jump_label.h> #include <linux/percpu.h> -#include <linux/sched.h> #include <linux/resctrl_types.h> +#include <linux/sched.h> /* * This value can never be a valid CLOSID, and is used when mapping a
arch/x86/kernel/cpu/resctrl/internal.h +1 -2
@@ -7,10 +7,9 @@#include <linux/kernfs.h> #include <linux/fs_context.h> #include <linux/jump_label.h> +#include <linux/resctrl.h> #include <linux/tick.h> -#include <asm/resctrl.h> -#define L3_QOS_CDP_ENABLE 0x01ULL#define L2_QOS_CDP_ENABLE 0x01ULL
arch/x86/kernel/cpu/resctrl/pseudo_lock.c +2 -2
@@ -11,6 +11,7 @@#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt +#include <linux/cacheflush.h> #include <linux/cacheinfo.h> #include <linux/cpu.h> #include <linux/cpumask.h>
@@ -19,12 +20,11 @@#include <linux/mman.h> #include <linux/perf_event.h> #include <linux/pm_qos.h> +#include <linux/resctrl.h> #include <linux/slab.h> #include <linux/uaccess.h> -#include <asm/cacheflush.h> #include <asm/intel-family.h> -#include <asm/resctrl.h> #include <asm/perf_event.h> #include "../../events/perf_event.h" /* For X86_CONFIG() */
arch/x86/kernel/cpu/resctrl/rdtgroup.c +4 -4
@@ -13,9 +13,9 @@#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt#include <linux/cpu.h> +#include <linux/resctrl.h> #include <linux/slab.h> -#include <asm/resctrl.h> #include "internal.h" DEFINE_STATIC_KEY_FALSE (rdt_enable_key);
@@ -28,9 +28,9 @@ DEFINE_STATIC_KEY_FALSE(rdt_alloc_enable_key);* from update_closid_rmid() is protected against __switch_to() because * preemption is disabled. */ -void resctrl_arch_sync_cpu_defaults (void *info) +void resctrl_arch_sync_cpu_closid_rmid (void *info) { -struct resctrl_cpu_sync *r = info; +struct resctrl_cpu_defaults *r = info;if (r) {this_cpu_write (pqr_state.default_closid, r->closid);
@@ -255,6 +255,6 @@ void resctrl_arch_reset_resources(void) {struct rdt_resource *r; -for_each_capable_rdt_resource (r) +for_each_alloc_capable_rdt_resource (r)reset_all_ctrls (r); }
fs/resctrl/Kconfig +20 -7
@@ -2,18 +2,31 @@ config RESCTRL_FS bool "CPU Resource Control Filesystem (resctrl)" depends on ARCH_HAS_CPU_RESCTRL select KERNFS - select PROC_CPU_RESCTRL if PROC_FS + select PROC_CPU_RESCTRL if PROC_FS help - Resctrl is a filesystem interface - to control allocation and - monitoring of system resources - used by the CPUs. + 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. + + If unsure, it is safe to say N. + + See <file:Documentation/arch/x86/resctrl.rst> for more information. config RESCTRL_FS_PSEUDO_LOCK bool help - Software mechanism to pin data in a cache portion using - micro-architecture specific knowledge. + Software mechanism to pin data in a cache portion using + micro-architecture specific knowledge. config RESCTRL_RMID_DEPENDS_ON_CLOSID bool
fs/resctrl/Makefile +1 -1
@@ -1,3 +1,3 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_RESCTRL_FS) += rdtgroup.o ctrlmondata.o monitor.o -obj-$(CONFIG_RESCTRL_FS_PSEUDO_LOCK) += psuedo_lock.o +obj-$(CONFIG_RESCTRL_FS_PSEUDO_LOCK) += pseudo_lock.o
fs/resctrl/internal.h +0 -2
@@ -9,8 +9,6 @@#include <linux/jump_label.h> #include <linux/tick.h> -#include <asm/resctrl.h> -/** * cpumask_any_housekeeping() - Choose any CPU in @mask, preferring those that * aren't marked nohz_full
fs/resctrl/monitor.c +1 -1
@@ -745,7 +745,7 @@ static int dom_data_init(struct rdt_resource *r)/* * RESCTRL_RESERVED_CLOSID and RESCTRL_RESERVED_RMID are special and * are always allocated. These are used for the rdtgroup_default -* control group, which will be setup later in rdtgroup_init(). +* control group, which will be setup later in resctrl_init(). */ idx =resctrl_arch_rmid_idx_encode (RESCTRL_RESERVED_CLOSID ,RESCTRL_RESERVED_RMID );
fs/resctrl/pseudo_lock.c renamed from fs/resctrl/psuedo_lock.c +2 -2
@@ -11,6 +11,7 @@#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt +#include <linux/cacheflush.h> #include <linux/cacheinfo.h> #include <linux/cpu.h> #include <linux/cpumask.h>
@@ -19,11 +20,10 @@#include <linux/mman.h> #include <linux/perf_event.h> #include <linux/pm_qos.h> +#include <linux/resctrl.h> #include <linux/slab.h> #include <linux/uaccess.h> -#include <asm/cacheflush.h> -#include <asm/resctrl.h> #include <asm/perf_event.h> #include "internal.h"
fs/resctrl/rdtgroup.c +20 -20
@@ -19,6 +19,7 @@#include <linux/fs_parser.h> #include <linux/sysfs.h> #include <linux/kernfs.h> +#include <linux/resctrl.h> #include <linux/seq_buf.h> #include <linux/seq_file.h> #include <linux/sched/signal.h>
@@ -29,7 +30,6 @@#include <uapi/linux/magic.h> -#include <asm/resctrl.h> #include "internal.h" /* Mutex to protect rdtgroup access. */
@@ -363,17 +363,15 @@ static int rdtgroup_cpus_show(struct kernfs_open_file *of,static void update_closid_rmid (const struct cpumask *cpu_mask,struct rdtgroup *r) { -struct resctrl_cpu_sync defaults; -struct resctrl_cpu_sync *defaults_p =NULL ; +struct resctrl_cpu_defaults defaults, *p =NULL ;if (r) { defaults.closid = r->closid; defaults.rmid = r->mon.rmid; - defaults_p = &defaults; + p = &defaults; } -on_each_cpu_mask (cpu_mask, resctrl_arch_sync_cpu_defaults, defaults_p, -1 ); +on_each_cpu_mask (cpu_mask, resctrl_arch_sync_cpu_closid_rmid, p,1 ); } static int cpus_mon_write(struct rdtgroup *rdtgrp, cpumask_var_t newmask,
@@ -966,7 +964,7 @@ static int rdt_num_closids_show(struct kernfs_open_file *of, }static int rdt_default_ctrl_show (struct kernfs_open_file *of, -struct seq_file *seq,void *v) +struct seq_file *seq,void *v) {struct resctrl_schema *s = of->kn->parent->priv;struct rdt_resource *r = s->res;
@@ -976,7 +974,7 @@ static int rdt_default_ctrl_show(struct kernfs_open_file *of, }static int rdt_min_cbm_bits_show (struct kernfs_open_file *of, -struct seq_file *seq,void *v) +struct seq_file *seq,void *v) {struct resctrl_schema *s = of->kn->parent->priv;struct rdt_resource *r = s->res;
@@ -1092,7 +1090,7 @@ static int rdt_bit_usage_show(struct kernfs_open_file *of, }static int rdt_min_bw_show (struct kernfs_open_file *of, -struct seq_file *seq,void *v) +struct seq_file *seq,void *v) {struct resctrl_schema *s = of->kn->parent->priv;struct rdt_resource *r = s->res;
@@ -1127,7 +1125,7 @@ static int rdt_mon_features_show(struct kernfs_open_file *of, }static int rdt_bw_gran_show (struct kernfs_open_file *of, -struct seq_file *seq,void *v) +struct seq_file *seq,void *v) {struct resctrl_schema *s = of->kn->parent->priv;struct rdt_resource *r = s->res;
@@ -1137,7 +1135,7 @@ static int rdt_bw_gran_show(struct kernfs_open_file *of, }static int rdt_delay_linear_show (struct kernfs_open_file *of, -struct seq_file *seq,void *v) +struct seq_file *seq,void *v) {struct resctrl_schema *s = of->kn->parent->priv;struct rdt_resource *r = s->res;
@@ -1935,7 +1933,6 @@ static struct rftype res_common_files[] = { .seq_show = rdtgroup_closid_show, .fflags = RFTYPE_CTRL_BASE | RFTYPE_DEBUG, }, - };static int rdtgroup_add_files (struct kernfs_node *kn,unsigned long fflags)
@@ -2161,7 +2158,7 @@ static int rdtgroup_create_info_dir(struct kernfs_node *parent_kn)if (!r->mon_capable)continue ; - fflags = r->fflags |RFTYPE_MON_INFO ; + fflags = r->fflags |RFTYPE_MON_INFO ;sprintf (name,"%s_MON" , r->name); ret =rdtgroup_mkdir_info_resdir (r, name, fflags);if (ret)
@@ -2449,7 +2446,7 @@ static int schemata_list_add(struct rdt_resource *r, enum resctrl_conf_type type/* * Choose a width for the resource data based on the resource that has -* widest name and cbm. +* widest name and CBM. */ max_data_width =max (max_data_width, r->data_width);
@@ -2499,10 +2496,10 @@ static void schemata_list_destroy(void)static int rdt_get_tree (struct fs_context *fc) { -struct rdt_resource *l3 =resctrl_arch_get_resource (RDT_RESOURCE_L3 );struct rdt_fs_context *ctx =rdt_fc2context (fc);unsigned long flags =RFTYPE_CTRL_BASE ;struct rdt_domain *dom; +struct rdt_resource *r;int ret;cpus_read_lock ();
@@ -2575,7 +2572,8 @@ static int rdt_get_tree(struct fs_context *fc) resctrl_mounted = true;if (resctrl_is_mbm_enabled ()) { -list_for_each_entry (dom, &l3->domains, list) + r =resctrl_arch_get_resource (RDT_RESOURCE_L3 ); +list_for_each_entry (dom, &r->domains, list)mbm_setup_overflow_handler (dom,MBM_OVERFLOW_INTERVAL ,RESCTRL_PICK_ANY_CPU ); }
@@ -2669,7 +2667,7 @@ static int rdt_init_fs_context(struct fs_context *fc) {struct rdt_fs_context *ctx; - ctx =kzalloc (sizeof (struct rdt_fs_context ),GFP_KERNEL ); + ctx =kzalloc (sizeof (*ctx),GFP_KERNEL );if (!ctx)return -ENOMEM ;
@@ -3180,7 +3178,6 @@ static int rdtgroup_init_alloc(struct rdtgroup *rdtgrp)rdt_last_cmd_puts ("Failed to initialize allocations\n" ); goto out; } - } rdtgrp->mode =RDT_MODE_SHAREABLE ;
@@ -3466,8 +3463,11 @@ static int rdtgroup_rmdir_mon(struct rdtgroup *rdtgrp, cpumask_var_t tmpmask)/* Give any tasks back to the parent group */ rdt_move_group_tasks (rdtgrp, prdtgrp, tmpmask); -/* Update per cpu rmid of the moved CPUs first */ - closid = rdtgrp->closid; +/* +* Update per cpu closid/rmid of the moved CPUs first. +* Note: the closid will not change, but the arch code still needs it. +*/ + closid = prdtgrp->closid; rmid = prdtgrp->mon.rmid;for_each_cpu (cpu, &rdtgrp->cpu_mask)resctrl_arch_set_cpu_default_closid_rmid (cpu, closid, rmid);
include/linux/resctrl.h +23 -15
@@ -41,9 +41,6 @@ int proc_resctrl_show(struct seq_file *m,*/ #define RESCTRL_MAX_CBM 32 -extern unsigned int resctrl_rmid_realloc_limit; -extern unsigned int resctrl_rmid_realloc_threshold; -/** * struct pseudo_lock_region - pseudo-lock region information * @s: Resctrl schema for the resource to which this
@@ -248,24 +245,35 @@ struct resctrl_schema {u32 num_closid; }; -struct resctrl_cpu_sync { +struct resctrl_cpu_defaults {u32 closid;u32 rmid; };struct resctrl_mon_config_info { -struct rdt_resource *r; -struct rdt_domain *d; -u32 evtid; -u32 mon_config; -int err; +struct rdt_resource *r; +struct rdt_domain *d; +u32 evtid; +u32 mon_config; +int err; }; -/* -* Update and re-load this CPUs defaults. Called via IPI, takes a pointer to -* struct resctrl_cpu_sync, or NULL. +/** +* resctrl_arch_sync_cpu_closid_rmid() - Refresh this CPU's CLOSID and RMID. +* Call via IPI. +* @info: If non-NULL, a pointer to a struct resctrl_cpu_defaults +* specifying the new CLOSID and RMID for tasks in the default +* resctrl ctrl and mon group when running on this CPU. If NULL, +* this CPU is not re-assigned to a different default group. +* +* Propagates reassignment of CPUs and/or tasks to different resctrl groups +* when requested by the resctrl core code. +* +* This function records the per-cpu defaults specified by @info (if any), +* and then reconfigures the CPU's hardware CLOSID and RMID for subsequent +* execution based on @current, in the same way as during a task switch. */ -void resctrl_arch_sync_cpu_defaults (void *info); +void resctrl_arch_sync_cpu_closid_rmid (void *info);/* The number of closid supported by this resource regardless of CDP */ u32 resctrl_arch_get_num_closid (struct rdt_resource *r);
@@ -286,9 +294,9 @@ static inline u32 resctrl_get_config_index(u32 closid,case CDP_NONE :return closid;case CDP_CODE : -return (closid *2 ) +1 ; +return closid *2 +1 ;case CDP_DATA : -return (closid *2 ); +return closid *2 ; } }
Signature · 1 line
2.34.1
Dave Martin
reviewerPATCH v2 1/35 x86/resctrl: Fix allocation of cleanest CLOSID on platforms with no monitors
From: James Morse <[email protected]>
commit 6eac36bb9eb0 ("x86/resctrl: Allocate the cleanest CLOSID by searching closid_num_dirty_rmid") added logic that causes resctrl to search for the CLOSID with the fewest dirty cache lines when creating a new control group, if requested by the arch code. This depends on the values read from the llc_occupancy counters. The logic is applicable to architectures where the CLOSID effectively forms part of the monitoring identifier and so do not allow complete freedom to choose an unused monitoring identifier for a given CLOSID.
This support missed that some platforms may not have these counters. This causes a NULL pointer dereference when creating a new control group as the array was not allocated by dom_data_init().
As this feature isn't necessary on platforms that don't have cache occupancy monitors, add this to the check that occurs when a new control group is allocated.
The existing code is not selected by any upstream platform, it makes no sense to backport this patch to stable.
---
Changes in v2:
* [Commit message only] Reword the first paragraph to make it clear that the issue being fixed wasn't directly associated with addition of a Kconfig option. (Actually, the option is not in Kconfig yet, and gets added later in this series.)
--- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/resctrl/rdtgroup.c +2 -1
@@ -149,7 +149,8 @@ static int closid_alloc(void)lockdep_assert_held (&rdtgroup_mutex); -if (IS_ENABLED (CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID )) { +if (IS_ENABLED (CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID ) && +is_llc_occupancy_enabled ()) { cleanest_closid =resctrl_find_cleanest_closid ();if (cleanest_closid <0 )return cleanest_closid;
Signature · 1 line
2.34.1
Dave Martin
reviewerPATCH v2 2/35 x86/resctrl: Add a helper to avoid reaching into the arch code resource list
From: James Morse <[email protected]>
Resctrl occasionally wants to know something about a specific resource, in these cases it reaches into the arch code's rdt_resources_all[] array.
Once the filesystem parts of resctrl are moved to /fs/, this means it will need visibility of the architecture specific struct rdt_hw_resource definition, and the array of all resources. All architectures would also need a r_resctrl member in this struct.
Instead, abstract this via a helper to allow architectures to do different things here. Move the level enum to the resctrl header and add a helper to retrieve the struct rdt_resource by 'rid'.
resctrl_arch_get_resource() should not return NULL for any value in the enum, it may instead return a dummy resource that is !alloc_enabled && !mon_enabled.
---
FYI: David Hildenbrand <[email protected]>
* Dropped your Reviewed-by due to changes in the patch.
Are you happy for it to be reapplied?
Changes in v2:
* Backed out non-functional renaming of "r" to "l3" in rdt_get_tree(), and unhoisted the assignment of r (as now is) back into the if () where it started out. There seem to be no uses of this variable outside this if().
* [Commit message only] Typo fix:
s/resctrl_hw_resource/rdt_hw_resource/g
--- arch/x86/kernel/cpu/resctrl/core.c | 10 +++++++++- arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 2 +- arch/x86/kernel/cpu/resctrl/internal.h | 10 ---------- arch/x86/kernel/cpu/resctrl/monitor.c | 8 ++++---- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 12 ++++++------ include/linux/resctrl.h | 17 +++++++++++++++++ 6 files changed, 37 insertions(+), 22 deletions(-)
arch/x86/kernel/cpu/resctrl/core.c +9 -1
@@ -122,6 +122,14 @@ struct rdt_hw_resource rdt_resources_all[] = { }, }; +struct rdt_resource *resctrl_arch_get_resource (enum resctrl_res_level l) +{ +if (l >=RDT_NUM_RESOURCES ) +return NULL ; + +return &rdt_resources_all[l].r_resctrl; +} +/* * cache_alloc_hsw_probe() - Have to probe for Intel haswell server CPUs * as they do not have CPUID enumeration support for Cache allocation.
@@ -169,7 +177,7 @@ static inline void cache_alloc_hsw_probe(void)bool is_mba_sc (struct rdt_resource *r) {if (!r) -return rdt_resources_all[RDT_RESOURCE_MBA ].r_resctrl.membw.mba_sc; + r =resctrl_arch_get_resource (RDT_RESOURCE_MBA );/* * The software controller support is only applicable to MBA resource.
arch/x86/kernel/cpu/resctrl/ctrlmondata.c +1 -1
@@ -599,7 +599,7 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg) domid = md.u.domid; evtid = md.u.evtid; - r = &rdt_resources_all[resid].r_resctrl; + r =resctrl_arch_get_resource (resid); d =rdt_find_domain (r, domid,NULL );if (IS_ERR_OR_NULL (d)) { ret = -ENOENT ;
arch/x86/kernel/cpu/resctrl/internal.h +0 -10
@@ -466,16 +466,6 @@ extern struct rdt_hw_resource rdt_resources_all[];extern struct rdtgroup rdtgroup_default;extern struct dentry *debugfs_resctrl; -enum resctrl_res_level { -RDT_RESOURCE_L3 , -RDT_RESOURCE_L2 , -RDT_RESOURCE_MBA , -RDT_RESOURCE_SMBA , - -/* Must be the last */ -RDT_NUM_RESOURCES , -}; -static inline struct rdt_resource *resctrl_inc (struct rdt_resource *res) {struct rdt_hw_resource *hw_res =resctrl_to_arch_res (res);
arch/x86/kernel/cpu/resctrl/monitor.c +4 -4
@@ -321,7 +321,7 @@ static void limbo_release_entry(struct rmid_entry *entry)*/ void __check_limbo (struct rdt_domain *d,bool force_free) { -struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3 ].r_resctrl; +struct rdt_resource *r =resctrl_arch_get_resource (RDT_RESOURCE_L3 );u32 idx_limit =resctrl_arch_system_num_rmid_idx ();struct rmid_entry *entry;u32 idx, cur_idx =1 ;
@@ -467,7 +467,7 @@ int alloc_rmid(u32 closid)static void add_rmid_to_limbo (struct rmid_entry *entry) { -struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3 ].r_resctrl; +struct rdt_resource *r =resctrl_arch_get_resource (RDT_RESOURCE_L3 );struct rdt_domain *d;u32 idx;
@@ -669,7 +669,7 @@ static void update_mba_bw(struct rdtgroup *rgrp, struct rdt_domain *dom_mbm)if (!is_mbm_local_enabled ())return ; - r_mba = &rdt_resources_all[RDT_RESOURCE_MBA ].r_resctrl; + r_mba =resctrl_arch_get_resource (RDT_RESOURCE_MBA ); closid = rgrp->closid; rmid = rgrp->mon.rmid;
@@ -839,7 +839,7 @@ void mbm_handle_overflow(struct work_struct *work)if (!resctrl_mounted || !resctrl_arch_mon_capable ()) goto out_unlock; - r = &rdt_resources_all[RDT_RESOURCE_L3 ].r_resctrl; + r =resctrl_arch_get_resource (RDT_RESOURCE_L3 ); d = container_of(work, struct rdt_domain, mbm_over.work);list_for_each_entry (prgrp, &rdt_all_groups, rdtgroup_list) {
arch/x86/kernel/cpu/resctrl/rdtgroup.c +6 -6
@@ -2253,7 +2253,7 @@ static void l2_qos_cfg_update(void *arg)static inline bool is_mba_linear (void ) { -return rdt_resources_all[RDT_RESOURCE_MBA ].r_resctrl.membw.delay_linear; +return resctrl_arch_get_resource (RDT_RESOURCE_MBA )->membw.delay_linear; }static int set_cache_qos_cfg (int level,bool enable)
@@ -2341,7 +2341,7 @@ static void mba_sc_domain_destroy(struct rdt_resource *r,*/ static bool supports_mba_mbps (void ) { -struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_MBA ].r_resctrl; +struct rdt_resource *r =resctrl_arch_get_resource (RDT_RESOURCE_MBA );return (is_mbm_local_enabled () && r->alloc_capable &&is_mba_linear ());
@@ -2353,7 +2353,7 @@ static bool supports_mba_mbps(void)*/ static int set_mba_sc (bool mba_sc) { -struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_MBA ].r_resctrl; +struct rdt_resource *r =resctrl_arch_get_resource (RDT_RESOURCE_MBA );u32 num_closid =resctrl_arch_get_num_closid (r);struct rdt_domain *d;int i;
@@ -2701,7 +2701,7 @@ static int rdt_get_tree(struct fs_context *fc) resctrl_mounted = true;if (is_mbm_enabled ()) { - r = &rdt_resources_all[RDT_RESOURCE_L3 ].r_resctrl; + r =resctrl_arch_get_resource (RDT_RESOURCE_L3 );list_for_each_entry (dom, &r->domains, list)mbm_setup_overflow_handler (dom,MBM_OVERFLOW_INTERVAL ,RESCTRL_PICK_ANY_CPU );
@@ -3878,7 +3878,7 @@ static int rdtgroup_show_options(struct seq_file *seq, struct kernfs_root *kf)if (resctrl_arch_get_cdp_enabled (RDT_RESOURCE_L2 ))seq_puts (seq,",cdpl2" ); -if (is_mba_sc (&rdt_resources_all[RDT_RESOURCE_MBA ].r_resctrl)) +if (is_mba_sc (resctrl_arch_get_resource (RDT_RESOURCE_MBA )))seq_puts (seq,",mba_MBps" );if (resctrl_debug)
@@ -4068,7 +4068,7 @@ static void clear_childcpus(struct rdtgroup *r, unsigned int cpu)void resctrl_offline_cpu (unsigned int cpu) { -struct rdt_resource *l3 = &rdt_resources_all[RDT_RESOURCE_L3 ].r_resctrl; +struct rdt_resource *l3 =resctrl_arch_get_resource (RDT_RESOURCE_L3 );struct rdtgroup *rdtgrp;struct rdt_domain *d;
include/linux/resctrl.h +17 -0
@@ -36,6 +36,16 @@ enum resctrl_conf_type { CDP_DATA, }; +enum resctrl_res_level { +RDT_RESOURCE_L3 , +RDT_RESOURCE_L2 , +RDT_RESOURCE_MBA , +RDT_RESOURCE_SMBA , + +/* Must be the last */ +RDT_NUM_RESOURCES , +}; +#define CDP_NUM_TYPES (CDP_DATA + 1)/*
@@ -190,6 +200,13 @@ struct rdt_resource {bool cdp_capable; }; +/* +* Get the resource that exists at this level. If the level is not supported +* a dummy/not-capable resource can be returned. Levels >= RDT_NUM_RESOURCES +* will return NULL. +*/ +struct rdt_resource *resctrl_arch_get_resource (enum resctrl_res_level l); +/** * struct resctrl_schema - configuration abilities of a resource presented to * user-space
Signature · 1 line
2.34.1
Dave Martin
reviewerPATCH v2 3/35 x86/resctrl: Move ctrlval string parsing policy away from the arch code
In reply to Dave MartinFrom: James Morse <[email protected]>
The policy for parsing the configuration values as a string from user-space is specified by a function pointer the arch code specifies.
These strings are part of resctrl's ABI, and the functions and their caller both live in the same file. Exporting the parsing functions and allowing the architecture to choose how a schema is parsed allows an architecture to get this wrong.
Keep this all in the filesystem parts of resctrl. This should prevent any architecture's string-parsing behaviour from varying without core code changes. Use the fflags to spot caches and bandwidth resources, and use the appropriate helper.
---
FYI: Dave Martin (et al.):
* Needs refactoring to minimise exposure of resctrl internals to arch code, particularly regarding fflags, print format and format parser.
See discussion thread:
https://lore.kernel.org/all/[email protected]/
Changes in v2:
* [Commit message only] Typo fix:
s/flesystem/filesystem/g
--- arch/x86/kernel/cpu/resctrl/core.c | 4 ---- arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 28 +++++++++++++++++++---- arch/x86/kernel/cpu/resctrl/internal.h | 10 -------- include/linux/resctrl.h | 7 ------ 4 files changed, 23 insertions(+), 26 deletions(-)
arch/x86/kernel/cpu/resctrl/core.c +0 -4
@@ -75,7 +75,6 @@ struct rdt_hw_resource rdt_resources_all[] = { .name = "L3", .cache_level = 3, .domains = domain_init(RDT_RESOURCE_L3), - .parse_ctrlval = parse_cbm, .format_str = "%d=%0*x", .fflags = RFTYPE_RES_CACHE, },
@@ -89,7 +88,6 @@ struct rdt_hw_resource rdt_resources_all[] = { .name = "L2", .cache_level = 2, .domains = domain_init(RDT_RESOURCE_L2), - .parse_ctrlval = parse_cbm, .format_str = "%d=%0*x", .fflags = RFTYPE_RES_CACHE, },
@@ -103,7 +101,6 @@ struct rdt_hw_resource rdt_resources_all[] = { .name = "MB", .cache_level = 3, .domains = domain_init(RDT_RESOURCE_MBA), - .parse_ctrlval = parse_bw, .format_str = "%d=%*u", .fflags = RFTYPE_RES_MB, },
@@ -115,7 +112,6 @@ struct rdt_hw_resource rdt_resources_all[] = { .name = "SMBA", .cache_level = 3, .domains = domain_init(RDT_RESOURCE_SMBA), - .parse_ctrlval = parse_bw, .format_str = "%d=%*u", .fflags = RFTYPE_RES_MB, },
arch/x86/kernel/cpu/resctrl/ctrlmondata.c +23 -5
@@ -23,6 +23,15 @@#include "internal.h" +struct rdt_parse_data { +struct rdtgroup *rdtgrp; +char *buf; +}; + +typedef int (ctrlval_parser_t )(struct rdt_parse_data *data, +struct resctrl_schema *s, +struct rdt_domain *d); +/* * Check whether MBA bandwidth percentage value is correct. The value is * checked against the minimum and max bandwidth values specified by the
@@ -59,8 +68,8 @@ static bool bw_validate(char *buf, unsigned long *data, struct rdt_resource *r)return true; } -int parse_bw (struct rdt_parse_data *data,struct resctrl_schema *s, -struct rdt_domain *d) +static int parse_bw (struct rdt_parse_data *data,struct resctrl_schema *s, +struct rdt_domain *d) {struct resctrl_staged_config *cfg;u32 closid = data->rdtgrp->closid;
@@ -138,8 +147,8 @@ static bool cbm_validate(char *buf, u32 *data, struct rdt_resource *r)* Read one cache bit mask (hex). Check that it is valid for the current * resource type. */ -int parse_cbm (struct rdt_parse_data *data,struct resctrl_schema *s, -struct rdt_domain *d) +static int parse_cbm (struct rdt_parse_data *data,struct resctrl_schema *s, +struct rdt_domain *d) {struct rdtgroup *rdtgrp = data->rdtgrp;struct resctrl_staged_config *cfg;
@@ -195,6 +204,14 @@ int parse_cbm(struct rdt_parse_data *data, struct resctrl_schema *s,return 0 ; } +static ctrlval_parser_t *get_parser (struct rdt_resource *res) +{ +if (res->fflags &RFTYPE_RES_CACHE ) +return &parse_cbm; +else +return &parse_bw; +} +/* * For each domain in this resource we expect to find a series of: * id=mask
@@ -204,6 +221,7 @@ int parse_cbm(struct rdt_parse_data *data, struct resctrl_schema *s,static int parse_line (char *line,struct resctrl_schema *s,struct rdtgroup *rdtgrp) { +ctrlval_parser_t *parse_ctrlval =get_parser (s->res);enum resctrl_conf_type t = s->conf_type;struct resctrl_staged_config *cfg;struct rdt_resource *r = s->res;
@@ -235,7 +253,7 @@ static int parse_line(char *line, struct resctrl_schema *s,if (d->id == dom_id) { data.buf = dom; data.rdtgrp = rdtgrp; -if (r->parse_ctrlval (&data, s, d)) +if (parse_ctrlval (&data, s, d))return -EINVAL ;if (rdtgrp->mode ==RDT_MODE_PSEUDO_LOCKSETUP ) { cfg = &d->staged_config[t];
arch/x86/kernel/cpu/resctrl/internal.h +0 -10
@@ -413,11 +413,6 @@ static inline bool is_mbm_event(int e) e <= QOS_L3_MBM_LOCAL_EVENT_ID); } -struct rdt_parse_data { -struct rdtgroup *rdtgrp; -char *buf; -}; -/** * struct rdt_hw_resource - arch private attributes of a resctrl resource * @r_resctrl: Attributes of the resource used directly by resctrl.
@@ -455,11 +450,6 @@ static inline struct rdt_hw_resource *resctrl_to_arch_res(struct rdt_resource *r return container_of(r, struct rdt_hw_resource, r_resctrl); } -int parse_cbm (struct rdt_parse_data *data,struct resctrl_schema *s, -struct rdt_domain *d); -int parse_bw (struct rdt_parse_data *data,struct resctrl_schema *s, -struct rdt_domain *d); -extern struct mutex rdtgroup_mutex;extern struct rdt_hw_resource rdt_resources_all[];
include/linux/resctrl.h +0 -7
@@ -157,9 +157,6 @@ struct resctrl_membw {u32 *mb_map; }; -struct rdt_parse_data ; -struct resctrl_schema ; -/** * struct rdt_resource - attributes of a resctrl resource * @rid: The index of the resource
@@ -174,7 +171,6 @@ struct resctrl_schema;* @data_width: Character width of data when displaying * @default_ctrl: Specifies default cache cbm or memory B/W percent. * @format_str: Per resource format string to show domain value -* @parse_ctrlval: Per resource function pointer to parse control values * @evt_list: List of monitoring events * @fflags: flags to choose base and info files * @cdp_capable: Is the CDP feature available on this resource
@@ -192,9 +188,6 @@ struct rdt_resource {int data_width;u32 default_ctrl;const char *format_str; -int (*parse_ctrlval)(struct rdt_parse_data *data, -struct resctrl_schema *s, -struct rdt_domain *d);struct list_head evt_list;unsigned long fflags;bool cdp_capable;
Signature · 1 line
2.34.1
Dave Martin
reviewerPATCH v2 4/35 x86/resctrl: Add helper for setting CPU default properties
In reply to Dave MartinFrom: James Morse <[email protected]>
rdtgroup_rmdir_ctrl() and rdtgroup_rmdir_mon() set the per-CPU pqr_state for CPUs that were part of the rmdir()'d group.
Another architecture might not have a 'pqr_state', its hardware may need the values in a different format. MPAM's equivalent of RMID values are not unique, and always need the CLOSID to be provided too.
There is only one caller that modifies a single value, (rdtgroup_rmdir_mon()). MPAM always needs both CLOSID and RMID for the hardware value as these are written to the same system register.
As rdtgroup_rmdir_mon() has the CLOSID on hand, only provide a helper to set both values. These values are read by __resctrl_sched_in(), but may be written by a different CPU without any locking, add READ/WRTE_ONCE() to avoid torn values.
---
Changes in v2:
* In rdtgroup_rmdir_mon(), (re)set CPU default closid based on the parent control group, to avoid the appearance of referencing something that we're in the process of destroying (even if it doesn't make a difference because the victim mon group necessarily has the same closid as the parent control group).
Update comment to match.
No (intentional) functional change.
--- arch/x86/include/asm/resctrl.h | 14 +++++++++++--- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 20 ++++++++++++++------ 2 files changed, 25 insertions(+), 9 deletions(-)
arch/x86/include/asm/resctrl.h +11 -3
@@ -4,8 +4,9 @@#ifdef CONFIG_X86_CPU_RESCTRL -#include <linux/sched.h> #include <linux/jump_label.h> +#include <linux/percpu.h> +#include <linux/sched.h> /* * This value can never be a valid CLOSID, and is used when mapping a
@@ -96,8 +97,8 @@ static inline void resctrl_arch_disable_mon(void)static inline void __resctrl_sched_in (struct task_struct *tsk) {struct resctrl_pqr_state *state =this_cpu_ptr (&pqr_state); -u32 closid = state->default_closid; -u32 rmid = state->default_rmid; +u32 closid =READ_ONCE (state->default_closid); +u32 rmid =READ_ONCE (state->default_rmid);u32 tmp;/*
@@ -132,6 +133,13 @@ static inline unsigned int resctrl_arch_round_mon_val(unsigned int val)return val * scale; } +static inline void resctrl_arch_set_cpu_default_closid_rmid (int cpu,u32 closid, +u32 rmid) +{ +WRITE_ONCE (per_cpu (pqr_state.default_closid, cpu), closid); +WRITE_ONCE (per_cpu (pqr_state.default_rmid, cpu), rmid); +} +static inline void resctrl_arch_set_closid_rmid (struct task_struct *tsk,u32 closid,u32 rmid) {
arch/x86/kernel/cpu/resctrl/rdtgroup.c +14 -6
@@ -3624,14 +3624,21 @@ static int rdtgroup_mkdir(struct kernfs_node *parent_kn, const char *name,static int rdtgroup_rmdir_mon (struct rdtgroup *rdtgrp,cpumask_var_t tmpmask) {struct rdtgroup *prdtgrp = rdtgrp->mon.parent; +u32 closid, rmid;int cpu;/* Give any tasks back to the parent group */ rdt_move_group_tasks (rdtgrp, prdtgrp, tmpmask); -/* Update per cpu rmid of the moved CPUs first */ +/* +* Update per cpu closid/rmid of the moved CPUs first. +* Note: the closid will not change, but the arch code still needs it. +*/ + closid = prdtgrp->closid; + rmid = prdtgrp->mon.rmid;for_each_cpu (cpu, &rdtgrp->cpu_mask) -per_cpu (pqr_state.default_rmid, cpu) = prdtgrp->mon.rmid; +resctrl_arch_set_cpu_default_closid_rmid (cpu, closid, rmid); +/* * Update the MSR on moved CPUs and CPUs which have moved * task running on them.
@@ -3664,6 +3671,7 @@ static int rdtgroup_ctrl_remove(struct rdtgroup *rdtgrp)static int rdtgroup_rmdir_ctrl (struct rdtgroup *rdtgrp,cpumask_var_t tmpmask) { +u32 closid, rmid;int cpu;/* Give any tasks back to the default group */
@@ -3674,10 +3682,10 @@ static int rdtgroup_rmdir_ctrl(struct rdtgroup *rdtgrp, cpumask_var_t tmpmask) &rdtgroup_default.cpu_mask, &rdtgrp->cpu_mask);/* Update per cpu closid and rmid of the moved CPUs first */ -for_each_cpu (cpu, &rdtgrp->cpu_mask) { -per_cpu (pqr_state.default_closid, cpu) = rdtgroup_default.closid; -per_cpu (pqr_state.default_rmid, cpu) = rdtgroup_default.mon.rmid; - } + closid = rdtgroup_default.closid; + rmid = rdtgroup_default.mon.rmid; +for_each_cpu (cpu, &rdtgrp->cpu_mask) +resctrl_arch_set_cpu_default_closid_rmid (cpu, closid, rmid);/* * Update the MSR on moved CPUs and CPUs which have moved
Signature · 1 line
2.34.1
Dave Martin
reviewerPATCH v2 5/35 x86/resctrl: Remove rdtgroup from update_cpu_closid_rmid()
In reply to Dave MartinFrom: James Morse <[email protected]>
update_cpu_closid_rmid() takes a struct rdtgroup as an argument, which it uses to update the local CPUs default pqr values. This is a problem once the resctrl parts move out to /fs/, as the arch code cannot poke around inside struct rdtgroup.
Rename update_cpu_closid_rmid() as resctrl_arch_sync_cpus_defaults() to be used as the target of an IPI, and pass the effective CLOSID and RMID in a new struct.
---
Changes in v2:
* To clarify the meanings of the new helper and struct:
Rename resctrl_arch_sync_cpu_default() to resctrl_arch_sync_cpu_closid_rmid();
Rename struct resctrl_cpu_sync to struct resctrl_cpu_defaults;
Flesh out the comment block in <linux/resctrl.h>.
No functional change.
--- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 17 +++++++++++++---- include/linux/resctrl.h | 22 ++++++++++++++++++++++ 2 files changed, 35 insertions(+), 4 deletions(-)
arch/x86/kernel/cpu/resctrl/rdtgroup.c +13 -4
@@ -341,13 +341,13 @@ static int rdtgroup_cpus_show(struct kernfs_open_file *of,* from update_closid_rmid() is protected against __switch_to() because * preemption is disabled. */ -static void update_cpu_closid_rmid (void *info) +void resctrl_arch_sync_cpu_closid_rmid (void *info) { -struct rdtgroup *r = info; +struct resctrl_cpu_defaults *r = info;if (r) {this_cpu_write (pqr_state.default_closid, r->closid); -this_cpu_write (pqr_state.default_rmid, r->mon.rmid); +this_cpu_write (pqr_state.default_rmid, r->rmid); }/*
@@ -362,11 +362,20 @@ static void update_cpu_closid_rmid(void *info)* Update the PGR_ASSOC MSR on all cpus in @cpu_mask, * * Per task closids/rmids must have been set up before calling this function. +* @r may be NULL. */ static void update_closid_rmid (const struct cpumask *cpu_mask,struct rdtgroup *r) { -on_each_cpu_mask (cpu_mask, update_cpu_closid_rmid, r,1 ); +struct resctrl_cpu_defaults defaults, *p =NULL ; + +if (r) { + defaults.closid = r->closid; + defaults.rmid = r->mon.rmid; + p = &defaults; + } + +on_each_cpu_mask (cpu_mask, resctrl_arch_sync_cpu_closid_rmid, p,1 ); } static int cpus_mon_write(struct rdtgroup *rdtgrp, cpumask_var_t newmask,
include/linux/resctrl.h +22 -0
@@ -220,6 +220,28 @@ struct resctrl_schema {u32 num_closid; }; +struct resctrl_cpu_defaults { +u32 closid; +u32 rmid; +}; + +/** +* resctrl_arch_sync_cpu_closid_rmid() - Refresh this CPU's CLOSID and RMID. +* Call via IPI. +* @info: If non-NULL, a pointer to a struct resctrl_cpu_defaults +* specifying the new CLOSID and RMID for tasks in the default +* resctrl ctrl and mon group when running on this CPU. If NULL, +* this CPU is not re-assigned to a different default group. +* +* Propagates reassignment of CPUs and/or tasks to different resctrl groups +* when requested by the resctrl core code. +* +* This function records the per-cpu defaults specified by @info (if any), +* and then reconfigures the CPU's hardware CLOSID and RMID for subsequent +* execution based on @current, in the same way as during a task switch. +*/ +void resctrl_arch_sync_cpu_closid_rmid (void *info); +/* The number of closid supported by this resource regardless of CDP */ u32 resctrl_arch_get_num_closid (struct rdt_resource *r);int resctrl_arch_update_domains (struct rdt_resource *r,u32 closid);
Signature · 1 line
2.34.1
Dave Martin
reviewerPATCH v2 6/35 x86/resctrl: Export resctrl fs's init function
In reply to Dave MartinFrom: James Morse <[email protected]>
rdtgroup_init() needs exporting so that arch code can call it once it lives in core code. As this is one of the few functions exported, rename it to have "resctrl" in the name. The same goes for the exit call.
x86's arch code init functions for RDT are renamed to have an arch prefix to make it clear these are part of the architecture code.
---
Changes in v2:
* Rename stale rdtgroup_init() to resctrl_init() in arch/x86/kernel/cpu/resctrl/monitor.c comments.
No functional change.
* [Commit message only] Minor rewording to avoid "impersonating code".
* [Commit message only] Typo fix:
s/to have the resctrl/to have resctrl/ in commit message.
--- arch/x86/kernel/cpu/resctrl/core.c | 12 ++++++------ arch/x86/kernel/cpu/resctrl/internal.h | 3 --- arch/x86/kernel/cpu/resctrl/monitor.c | 2 +- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 8 ++++---- include/linux/resctrl.h | 3 +++ 5 files changed, 14 insertions(+), 14 deletions(-)
arch/x86/kernel/cpu/resctrl/core.c +6 -6
@@ -938,7 +938,7 @@ void resctrl_cpu_detect(struct cpuinfo_x86 *c) } } -static int __init resctrl_late_init (void ) +static int __init resctrl_arch_late_init (void ) {struct rdt_resource *r;int state, ret;
@@ -963,7 +963,7 @@ static int __init resctrl_late_init(void)if (state <0 )return state; - ret =rdtgroup_init (); + ret =resctrl_init ();if (ret) {cpuhp_remove_state (state);return ret;
@@ -979,18 +979,18 @@ static int __init resctrl_late_init(void)return 0 ; } -late_initcall (resctrl_late_init); +late_initcall (resctrl_arch_late_init); -static void __exit resctrl_exit(void) +static void __exit resctrl_arch_exit(void) {struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3 ].r_resctrl;cpuhp_remove_state (rdt_online); -rdtgroup_exit (); +resctrl_exit ();if (r->mon_capable)rdt_put_mon_l3_config (); } -__exitcall (resctrl_exit); +__exitcall (resctrl_arch_exit);
arch/x86/kernel/cpu/resctrl/internal.h +0 -3
@@ -300,9 +300,6 @@ extern struct list_head rdt_all_groups;extern int max_name_width, max_data_width; -int __init rdtgroup_init (void ); -void __exit rdtgroup_exit(void); -/** * struct rftype - describe each file in the resctrl file system * @name: File name
arch/x86/kernel/cpu/resctrl/monitor.c +1 -1
@@ -941,7 +941,7 @@ static int dom_data_init(struct rdt_resource *r)/* * RESCTRL_RESERVED_CLOSID and RESCTRL_RESERVED_RMID are special and * are always allocated. These are used for the rdtgroup_default -* control group, which will be setup later in rdtgroup_init(). +* control group, which will be setup later in resctrl_init(). */ idx =resctrl_arch_rmid_idx_encode (RESCTRL_RESERVED_CLOSID ,RESCTRL_RESERVED_RMID );
arch/x86/kernel/cpu/resctrl/rdtgroup.c +4 -4
@@ -4118,14 +4118,14 @@ void resctrl_offline_cpu(unsigned int cpu) }/* -* rdtgroup_init - rdtgroup initialization +* resctrl_init - resctrl filesystem initialization * * Setup resctrl file system including set up root, create mount point, -* register rdtgroup filesystem, and initialize files under root directory. +* register resctrl filesystem, and initialize files under root directory. * * Return: 0 on success or -errno */ -int __init rdtgroup_init (void ) +int __init resctrl_init (void ) {int ret =0 ;
@@ -4173,7 +4173,7 @@ int __init rdtgroup_init(void)return ret; } -void __exit rdtgroup_exit(void) +void __exit resctrl_exit(void) {debugfs_remove_recursive (debugfs_resctrl);unregister_filesystem (&rdt_fs_type);
include/linux/resctrl.h +3 -0
@@ -336,4 +336,7 @@ void resctrl_arch_reset_rmid_all(struct rdt_resource *r, struct rdt_domain *d);extern unsigned int resctrl_rmid_realloc_threshold;extern unsigned int resctrl_rmid_realloc_limit; +int __init resctrl_init (void ); +void __exit resctrl_exit(void); +#endif /* _RESCTRL_H */
Signature · 1 line
2.34.1
RE: [PATCH v2 06/35] x86/resctrl: Export resctrl fs's init function
Hello Dave, James
I think there is no problem.
Quoted 155 lines
From: James Morse <[email protected]>
rdtgroup_init()needs exporting so that arch code can call it once it lives in core code. As this is one of the few functions exported, rename it to have "resctrl" in the name. The same goes for the exit call.x86's arch code init functions for RDT are renamed to have an arch prefix to make it clear these are part of the architecture code.
Signed-off-by James Morse <[email protected]>Signed-off-by Dave Martin <[email protected]>---
Changes in v2:
* Rename stale
rdtgroup_init()toresctrl_init()inarch/x86/kernel/cpu/resctrl/monitor.ccomments.No functional change.
* [Commit message only] Minor rewording to avoid "impersonating code".
* [Commit message only] Typo fix:
s/to have the resctrl/to have resctrl/ in commit message.--- arch/x86/kernel/cpu/resctrl/core.c | 12 ++++++------ arch/x86/kernel/cpu/resctrl/internal.h | 3 --- arch/x86/kernel/cpu/resctrl/monitor.c | 2 +- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 8 ++++---- include/linux/resctrl.h | 3 +++ 5 files changed, 14 insertions(+), 14 deletions(-)arch/x86/kernel/cpu/resctrl/core.c +6
-6@@ -938,7 +938,7 @@ void resctrl_cpu_detect(struct cpuinfo_x86 *c) } } -static int __init resctrl_late_init (void ) +static int __init resctrl_arch_late_init (void ) {struct rdt_resource *r;int state, ret;@@ -963,7 +963,7 @@ static int __init resctrl_late_init(void)if (state <0 )return state; - ret =rdtgroup_init (); + ret =resctrl_init ();if (ret) {cpuhp_remove_state (state);return ret;@@ -979,18 +979,18 @@ static int __init resctrl_late_init(void)return 0 ; } -late_initcall (resctrl_late_init); +late_initcall (resctrl_arch_late_init); -static void __exit resctrl_exit(void) +static void __exit resctrl_arch_exit(void) {struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3 ].r_resctrl;cpuhp_remove_state (rdt_online); -rdtgroup_exit (); +resctrl_exit ();if (r->mon_capable)rdt_put_mon_l3_config (); } -__exitcall (resctrl_exit); +__exitcall (resctrl_arch_exit);arch/x86/kernel/cpu/resctrl/internal.h +0
-3@@ -300,9 +300,6 @@ extern struct list_head rdt_all_groups;extern int max_name_width, max_data_width; -int __init rdtgroup_init (void ); -void __exit rdtgroup_exit(void); -/** * struct rftype - describe each file in the resctrl file system * @name: File name arch/x86/kernel/cpu/resctrl/monitor.c +0
-0@@ -941,7 +941,7 @@ static int dom_data_init(struct rdt_resource *r)/* * RESCTRL_RESERVED_CLOSID and RESCTRL_RESERVED_RMID are special and
arch/x86/kernel/cpu/resctrl/monitor.c +1
-1* are always allocated. These are used for the rdtgroup_default -* control group, which will be setup later in rdtgroup_init(). +* control group, which will be setup later in resctrl_init(). */ idx =resctrl_arch_rmid_idx_encode (RESCTRL_RESERVED_CLOSID ,RESCTRL_RESERVED_RMID );arch/x86/kernel/cpu/resctrl/rdtgroup.c +4
-4@@ -4118,14 +4118,14 @@ void resctrl_offline_cpu(unsigned int cpu) }/* -* rdtgroup_init - rdtgroup initialization +* resctrl_init - resctrl filesystem initialization * * Setup resctrl file system including set up root, create mount point, -* register rdtgroup filesystem, and initialize files under root directory. +* register resctrl filesystem, and initialize files under root directory. * * Return: 0 on success or -errno */ -int __init rdtgroup_init (void ) +int __init resctrl_init (void ) {int ret =0 ;@@ -4173,7 +4173,7 @@ int __init rdtgroup_init(void)return ret; } -void __exit rdtgroup_exit(void) +void __exit resctrl_exit(void) {debugfs_remove_recursive (debugfs_resctrl);unregister_filesystem (&rdt_fs_type);include/linux/resctrl.h index renamed from include/linux/resctrl.h +0
-0
bf736ec22f71..de0297f6167a100644include/linux/resctrl.h +3
-1@@ -336,4 +336,7 @@ void resctrl_arch_reset_rmid_all(struct rdt_resource *r, struct rdt_domain *d); extern unsigned int resctrl_rmid_realloc_threshold;extern unsigned int resctrl_rmid_realloc_limit; +int __init resctrl_init (void ); +void __exit resctrl_exit(void); +#endif /* _RESCTRL_H */ --2.34.1
Dave Martin
reviewerPATCH v2 7/35 x86/resctrl: Wrap resctrl_arch_find_domain() around rdt_find_domain()
In reply to Dave MartinFrom: James Morse <[email protected]>
rdt_find_domain() finds a domain given a resource and a cache-id. It's not quite right for the resctrl arch API as it also returns the position to insert a new domain, which is needed when bringing a domain online in the arch code.
Wrap rdt_find_domain() in another function resctrl_arch_find_domain() in order to avoid the unnecessary argument outside the arch code.
---
Changes in v2:
* [Commit message only] Minor rewording to avoid "impersonating code".
* [Commit message only] Typo fix:
s/in a another/in another/ in commit message.
--- arch/x86/kernel/cpu/resctrl/core.c | 9 +++++++-- arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 2 +- arch/x86/kernel/cpu/resctrl/internal.h | 2 -- include/linux/resctrl.h | 2 ++ 4 files changed, 10 insertions(+), 5 deletions(-)
arch/x86/kernel/cpu/resctrl/core.c +7 -2
@@ -405,8 +405,8 @@ void rdt_ctrl_update(void *arg)* caller, return the first domain whose id is bigger than the input id. * The domain list is sorted by id in ascending order. */ -struct rdt_domain *rdt_find_domain (struct rdt_resource *r,int id, -struct list_head **pos) +static struct rdt_domain *rdt_find_domain (struct rdt_resource *r,int id, +struct list_head **pos) {struct rdt_domain *d;struct list_head *l;
@@ -430,6 +430,11 @@ struct rdt_domain *rdt_find_domain(struct rdt_resource *r, int id,return NULL ; } +struct rdt_domain *resctrl_arch_find_domain (struct rdt_resource *r,int id) +{ +return rdt_find_domain (r, id,NULL ); +} +static void setup_default_ctrlval (struct rdt_resource *r,u32 *dc) {struct rdt_hw_resource *hw_res =resctrl_to_arch_res (r);
arch/x86/kernel/cpu/resctrl/ctrlmondata.c +1 -1
@@ -618,7 +618,7 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg) evtid = md.u.evtid; r =resctrl_arch_get_resource (resid); - d =rdt_find_domain (r, domid,NULL ); + d =resctrl_arch_find_domain (r, domid);if (IS_ERR_OR_NULL (d)) { ret = -ENOENT ; goto out;
arch/x86/kernel/cpu/resctrl/internal.h +0 -2
@@ -533,8 +533,6 @@ void rdtgroup_kn_unlock(struct kernfs_node *kn);int rdtgroup_kn_mode_restrict (struct rdtgroup *r,const char *name);int rdtgroup_kn_mode_restore (struct rdtgroup *r,const char *name,umode_t mask); -struct rdt_domain *rdt_find_domain (struct rdt_resource *r,int id, -struct list_head **pos);ssize_t rdtgroup_schemata_write (struct kernfs_open_file *of,char *buf,size_t nbytes,loff_t off); int rdtgroup_schemata_show(struct kernfs_open_file *of,
include/linux/resctrl.h +2 -0
@@ -244,6 +244,8 @@ void resctrl_arch_sync_cpu_closid_rmid(void *info);/* The number of closid supported by this resource regardless of CDP */ u32 resctrl_arch_get_num_closid (struct rdt_resource *r); + +struct rdt_domain *resctrl_arch_find_domain (struct rdt_resource *r,int id);int resctrl_arch_update_domains (struct rdt_resource *r,u32 closid);/*
Signature · 1 line
2.34.1
Dave Martin
reviewerPATCH v2 8/35 x86/resctrl: Move resctrl types to a separate header
In reply to Dave MartinFrom: James Morse <[email protected]>
When resctrl is fully factored into core and per-arch code, each arch will need to use some resctrl common definitions in order to define its own specializations and helpers. Following conventional practice, it would be desirable to put the dependent arch definitions in an <asm/resctrl.h> header that is included by the common <linux/resctrl.h> header. However, this can make it awkward to avoid a circular dependency between <linux/resctrl.h> and the arch header.
To avoid such dependencies, move the affected common types and constants into a new header that does not need to depend on <linux/resctrl.h> or on the arch headers.
The same logic applies to the monitor-configuration defines, move these too.
The maintainers entry for these headers was missed when resctrl.h was created. Add a wildcard entry to match both resctrl.h and resctrl_types.h.
---
FYI: James Morse (et al.)
* This patch needs review to see how many of the x86-specific definitions really ought to be exported...
* The header should have a comment explaining its content and purpose (once we have that nailed down).
Changes in v2:
* [Commit message only] Rewrite commit message to clarify the the rationale for refactoring the headers in this way.
--- MAINTAINERS | 1 + arch/x86/kernel/cpu/resctrl/internal.h | 24 --------- include/linux/resctrl.h | 35 +------------ include/linux/resctrl_types.h | 68 ++++++++++++++++++++++++++ 4 files changed, 70 insertions(+), 58 deletions(-) create mode 100644 include/linux/resctrl_types.h
MAINTAINERS +1 -0
@@ -18543,6 +18543,7 @@ S: Supported F: Documentation/arch/x86/resctrl* F: arch/x86/include/asm/resctrl.h F: arch/x86/kernel/cpu/resctrl/ +F: include/linux/resctrl*.h F: tools/testing/selftests/resctrl/ READ-COPY UPDATE (RCU)
arch/x86/kernel/cpu/resctrl/internal.h +0 -24
@@ -32,30 +32,6 @@*/ #define MBM_CNTR_WIDTH_OFFSET_MAX (62 - MBM_CNTR_WIDTH_BASE) -/* Reads to Local DRAM Memory */ -#define READS_TO_LOCAL_MEM BIT(0) - -/* Reads to Remote DRAM Memory */ -#define READS_TO_REMOTE_MEM BIT(1) - -/* Non-Temporal Writes to Local Memory */ -#define NON_TEMP_WRITE_TO_LOCAL_MEM BIT(2) - -/* Non-Temporal Writes to Remote Memory */ -#define NON_TEMP_WRITE_TO_REMOTE_MEM BIT(3) - -/* Reads to Local Memory the system identifies as "Slow Memory" */ -#define READS_TO_LOCAL_S_MEM BIT(4) - -/* Reads to Remote Memory the system identifies as "Slow Memory" */ -#define READS_TO_REMOTE_S_MEM BIT(5) - -/* Dirty Victims to All Types of Memory */ -#define DIRTY_VICTIMS_TO_ALL_MEM BIT(6) - -/* Max event bits supported */ -#define MAX_EVT_CONFIG_BITS GENMASK(6, 0) -/** * cpumask_any_housekeeping() - Choose any CPU in @mask, preferring those that * aren't marked nohz_full
include/linux/resctrl.h +1 -34
@@ -5,6 +5,7 @@#include <linux/kernel.h> #include <linux/list.h> #include <linux/pid.h> +#include <linux/resctrl_types.h> /* CLOSID, RMID value used by the default control group */ #define RESCTRL_RESERVED_CLOSID 0
@@ -24,40 +25,6 @@ int proc_resctrl_show(struct seq_file *m,/* max value for struct rdt_domain's mbps_val */ #define MBA_MAX_MBPS U32_MAX -/** -* enum resctrl_conf_type - The type of configuration. -* @CDP_NONE: No prioritisation, both code and data are controlled or monitored. -* @CDP_CODE: Configuration applies to instruction fetches. -* @CDP_DATA: Configuration applies to reads and writes. -*/ -enum resctrl_conf_type { -CDP_NONE , -CDP_CODE , -CDP_DATA , -}; - -enum resctrl_res_level { -RDT_RESOURCE_L3 , -RDT_RESOURCE_L2 , -RDT_RESOURCE_MBA , -RDT_RESOURCE_SMBA , - -/* Must be the last */ -RDT_NUM_RESOURCES , -}; - -#define CDP_NUM_TYPES (CDP_DATA + 1) - -/* -* Event IDs, the values match those used to program IA32_QM_EVTSEL before -* reading IA32_QM_CTR on RDT systems. -*/ -enum resctrl_event_id { -QOS_L3_OCCUP_EVENT_ID =0x01 , -QOS_L3_MBM_TOTAL_EVENT_ID =0x02 , -QOS_L3_MBM_LOCAL_EVENT_ID =0x03 , -}; -/** * struct resctrl_staged_config - parsed configuration to be applied * @new_ctrl: new ctrl value to be loaded
include/linux/resctrl_types.h new file +68 -0
68 lines not on this page · raw message
Signature · 1 line
2.34.1
Dave Martin
reviewerPATCH v2 9/35 x86/resctrl: Add a resctrl helper to reset all the resources
In reply to Dave MartinFrom: James Morse <[email protected]>
On umount(), resctrl resets each resource back to its default configuration. It only ever does this for all resources in one go.
reset_all_ctrls() is architecture specific as it works with struct rdt_hw_resource.
Add an architecture helper to reset all resources.
---
FYI: James Morse:
* Review the v2 change detailed below. If the original change in v1 was intentional, the rationale needs to be spelled out.
Changes in v2:
* Rename the for_each_capable_rdt_resource() introduced in the new function resctrl_arch_reset_resources(), back to for_each_alloc_capable_rdt_resource() as it was in the original code.
The change looked unintentional; and presumably a resource that does not support resource allocation doesn't have any properties to reset...
--- arch/x86/include/asm/resctrl.h | 2 ++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 16 +++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-)
arch/x86/include/asm/resctrl.h +2 -0
@@ -15,6 +15,8 @@*/ #define X86_RESCTRL_EMPTY_CLOSID ((u32)~0) +void resctrl_arch_reset_resources (void ); +/** * struct resctrl_pqr_state - State cache for the PQR MSR * @cur_rmid: The cached Resource Monitoring ID
arch/x86/kernel/cpu/resctrl/rdtgroup.c +11 -5
@@ -2858,6 +2858,14 @@ static int reset_all_ctrls(struct rdt_resource *r)return 0 ; } +void resctrl_arch_reset_resources (void ) +{ +struct rdt_resource *r; + +for_each_alloc_capable_rdt_resource (r) +reset_all_ctrls (r); +} +/* * Move tasks from one to the other group. If @from is NULL, then all tasks * in the systems are moved unconditionally (used for teardown).
@@ -2967,16 +2975,14 @@ static void rmdir_all_sub(void)static void rdt_kill_sb (struct super_block *sb) { -struct rdt_resource *r; -cpus_read_lock ();mutex_lock (&rdtgroup_mutex);rdt_disable_ctx (); -/*Put everything back to default values. */ -for_each_alloc_capable_rdt_resource (r) -reset_all_ctrls (r); +/* Put everything back to default values. */ +resctrl_arch_reset_resources (); +rmdir_all_sub ();rdt_pseudo_lock_release (); rdtgroup_default.mode =RDT_MODE_SHAREABLE ;
Signature · 1 line
2.34.1
Dave Martin
reviewerPATCH v2 10/35 x86/resctrl: Move monitor init work to a resctrl init call
In reply to Dave MartinFrom: James Morse <[email protected]>
rdt_get_mon_l3_config() is called from the architecture's resctrl_arch_late_init(), and initialises both architecture specific fields, such as hw_res->mon_scale and resctrl filesystem fields by calling dom_data_init().
To separate the filesystem and architecture parts of resctrl, this function needs splitting up.
Add resctrl_mon_resource_init() to do the filesystem specific work, and call it from resctrl_init(). This runs later, but is still before the filesystem is mounted and the rmid_ptrs[] array can be used.
--- arch/x86/kernel/cpu/resctrl/internal.h | 1 + arch/x86/kernel/cpu/resctrl/monitor.c | 24 +++++++++++++++++------- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 4 ++++ 3 files changed, 22 insertions(+), 7 deletions(-)
arch/x86/kernel/cpu/resctrl/internal.h +1 -0
@@ -540,6 +540,7 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg);void mon_event_read (struct rmid_read *rr,struct rdt_resource *r,struct rdt_domain *d,struct rdtgroup *rdtgrp,int evtid,int first); +int resctrl_mon_resource_init (void );void mbm_setup_overflow_handler (struct rdt_domain *dom,unsigned long delay_ms,int exclude_cpu);
arch/x86/kernel/cpu/resctrl/monitor.c +17 -7
@@ -1003,12 +1003,28 @@ static void l3_mon_evt_init(struct rdt_resource *r)list_add_tail (&mbm_local_event.list, &r->evt_list); } +int resctrl_mon_resource_init (void ) +{ +struct rdt_resource *r =resctrl_arch_get_resource (RDT_RESOURCE_L3 ); +int ret; + +if (!r->mon_capable) +return 0 ; + + ret =dom_data_init (r); +if (ret) +return ret; + +l3_mon_evt_init (r); + +return 0 ; +} +int __init rdt_get_mon_l3_config (struct rdt_resource *r) {unsigned int mbm_offset = boot_cpu_data.x86_cache_mbm_width_offset;struct rdt_hw_resource *hw_res =resctrl_to_arch_res (r);unsigned int threshold; -int ret; resctrl_rmid_realloc_limit = boot_cpu_data.x86_cache_size *1024 ; hw_res->mon_scale = boot_cpu_data.x86_cache_occ_scale;
@@ -1036,10 +1052,6 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r)*/ resctrl_rmid_realloc_threshold =resctrl_arch_round_mon_val (threshold); - ret =dom_data_init (r); -if (ret) -return ret; -if (rdt_cpu_has (X86_FEATURE_BMEC )) {u32 eax, ebx, ecx, edx;
@@ -1057,8 +1069,6 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r) } } -l3_mon_evt_init (r); - r->mon_capable = true;return 0 ;
arch/x86/kernel/cpu/resctrl/rdtgroup.c +4 -0
@@ -4140,6 +4140,10 @@ int __init resctrl_init(void)rdtgroup_setup_default (); + ret =resctrl_mon_resource_init (); +if (ret) +return ret; + ret =sysfs_create_mount_point (fs_kobj,"resctrl" );if (ret)return ret;
Signature · 1 line
2.34.1
Dave Martin
reviewerPATCH v2 11/35 x86/resctrl: Move monitor exit work to a resctrl exit call
In reply to Dave MartinFrom: James Morse <[email protected]>
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[] arrays. In reality this code is marked __exit, and is removed by the linker as resctrl can't be built as a module.
Since there is no immediate need to change them, leave the __exit annotations as-is. This will need to be revisited as and when there is a need to call these functions other than at __exit time.
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() resctrl_mon_resource_exit() and call it from resctrl_exit(). The kfree() is currently dependent on r->mon_capable. resctrl_mon_resource_init() takes no arguments, so resctrl_mon_resource_exit() shouldn't take any either. Add the check to dom_data_exit(), making it take the resource as an argument. This makes it more symmetrical with dom_data_init().
---
Changes in v2:
* [Commit message only] Typo fixes:
s/restrl/resctrl/g
s/resctl/resctrl/g
* [Commit message only] Reword second paragraph to remove reference to the MPAM error interrupt, which provides background rationale for a later patch rather than for this patch, and so it is not really relevant here.
--- 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, 11 insertions(+), 10 deletions(-)
arch/x86/kernel/cpu/resctrl/core.c +0 -5
@@ -988,14 +988,9 @@ late_initcall(resctrl_arch_late_init); static void __exit resctrl_arch_exit(void) { -struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3 ].r_resctrl; -cpuhp_remove_state (rdt_online);resctrl_exit (); - -if (r->mon_capable) -rdt_put_mon_l3_config (); }__exitcall (resctrl_arch_exit);
arch/x86/kernel/cpu/resctrl/internal.h +1 -1
@@ -533,7 +533,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);
arch/x86/kernel/cpu/resctrl/monitor.c +8 -4
@@ -954,10 +954,12 @@ static int dom_data_init(struct rdt_resource *r)return err; } -static void __exit dom_data_exit(void) +static void __exit dom_data_exit(struct rdt_resource *r) { -mutex_lock (&rdtgroup_mutex); +if (!r->mon_capable) +return ; +mutex_lock (&rdtgroup_mutex);if (IS_ENABLED (CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID )) {kfree (closid_num_dirty_rmid); closid_num_dirty_rmid =NULL ;
@@ -1074,9 +1076,11 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r)return 0 ; } -void __exit rdt_put_mon_l3_config(void) +void __exit resctrl_mon_resource_exit(void) { -dom_data_exit (); +struct rdt_resource *r =resctrl_arch_get_resource (RDT_RESOURCE_L3 ); + +dom_data_exit (r); }void __init intel_rdt_mbm_apply_quirk (void )
arch/x86/kernel/cpu/resctrl/rdtgroup.c +2 -0
@@ -4188,4 +4188,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 (); }
Signature · 1 line
2.34.1
Dave Martin
reviewerPATCH v2 12/35 x86/resctrl: Move max_{name,data}_width into resctrl code
In reply to Dave MartinFrom: James Morse <[email protected]>
max_name_width and max_data_width are used to pad the strings in the resctrl schemata file.
This should be part of the fs code as it influences the user-space interface, but currently max_data_width is generated by the arch init code. max_name_width is already managed by schemata_list_add().
Move the variables and max_data_width's initialisation code to rdtgroup.c. There is no need for an extra rdt_init_padding() helper as the length of the name can be considered when schemata_list_add() creates each schema entry.
---
Changes in v2:
* Up-case "CBM" in the comment retained from rdt_init_padding(), for consistency with usage in comments elsewhere in the resctrl code.
No functional change.
--- arch/x86/kernel/cpu/resctrl/core.c | 22 ---------------------- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 12 ++++++++++++ 2 files changed, 12 insertions(+), 22 deletions(-)
arch/x86/kernel/cpu/resctrl/core.c +0 -22
@@ -44,12 +44,6 @@ static DEFINE_MUTEX(domain_list_lock);*/ DEFINE_PER_CPU(struct resctrl_pqr_state, pqr_state); -/* -* Used to store the max resource name width and max resource data width -* to display the schemata in a tabular format -*/ -int max_name_width, max_data_width; -/* * Global boolean for rdt_alloc which is true if any * resource allocation is enabled.
@@ -648,20 +642,6 @@ static int resctrl_arch_offline_cpu(unsigned int cpu)return 0 ; } -/* -* Choose a width for the resource name and resource data based on the -* resource that has widest name and cbm. -*/ -static __init void rdt_init_padding (void ) -{ -struct rdt_resource *r; - -for_each_alloc_capable_rdt_resource (r) { -if (r->data_width > max_data_width) - max_data_width = r->data_width; - } -} -enum {RDT_FLAG_CMT ,RDT_FLAG_MBM_TOTAL ,
@@ -959,8 +939,6 @@ static int __init resctrl_arch_late_init(void)if (!get_rdt_resources ())return -ENODEV ; -rdt_init_padding (); - state = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "x86/resctrl/cat:online:", resctrl_arch_online_cpu,
arch/x86/kernel/cpu/resctrl/rdtgroup.c +12 -0
@@ -58,6 +58,12 @@ static struct kernfs_node *kn_mongrp;/* Kernel fs node for "mon_data" directory under root */ static struct kernfs_node *kn_mondata; +/* +* Used to store the max resource name width and max resource data width +* to display the schemata in a tabular format +*/ +int max_name_width, max_data_width; +static struct seq_buf last_cmd_status;static char last_cmd_status_buf[512 ];
@@ -2593,6 +2599,12 @@ static int schemata_list_add(struct rdt_resource *r, enum resctrl_conf_type typeif (cl > max_name_width) max_name_width = cl; +/* +* Choose a width for the resource data based on the resource that has +* widest name and CBM. +*/ + max_data_width =max (max_data_width, r->data_width); +INIT_LIST_HEAD (&s->list);list_add (&s->list, &resctrl_schema_all);
Signature · 1 line
2.34.1
Dave Martin
reviewerPATCH v2 13/35 x86/resctrl: Stop using the for_each_*_rdt_resource() walkers
In reply to Dave MartinFrom: James Morse <[email protected]>
The for_each_*_rdt_resource() helpers walk the architecture's array of structures, using the resctrl visible part as an iterator. These became over-complex when the structures were split into a filesystem and architecture-specific struct. This approach avoided the need to touch every call site.
Once the filesystem parts of resctrl are moved to /fs/, both the architecture's resource array, and the definition of those structures is no longer accessible. To support resctrl, each architecture would have to provide equally complex macros.
Change the resctrl code that uses these to walk through the resource_level enum and check the mon/alloc capable flags instead. Instances in core.c, and resctrl_arch_reset_resources() remain part of x86's architecture specific code.
---
Changes in v2:
* [Whitespace only] Fix bogus whitespace introduced in rdtgroup_create_info_dir().
* [Commit message only] Typo fix:
s/architectures/architecture's/g
--- arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 7 +++++- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 28 +++++++++++++++++++---- 2 files changed, 30 insertions(+), 5 deletions(-)
arch/x86/kernel/cpu/resctrl/pseudo_lock.c +6 -1
@@ -840,6 +840,7 @@ bool rdtgroup_cbm_overlaps_pseudo_locked(struct rdt_domain *d, unsigned long cbmbool rdtgroup_pseudo_locked_in_hierarchy (struct rdt_domain *d) {cpumask_var_t cpu_with_psl; +enum resctrl_res_level i;struct rdt_resource *r;struct rdt_domain *d_i;bool ret = false;
@@ -854,7 +855,11 @@ bool rdtgroup_pseudo_locked_in_hierarchy(struct rdt_domain *d)* First determine which cpus have pseudo-locked regions * associated with them. */ -for_each_alloc_capable_rdt_resource (r) { +for (i =0 ; i <RDT_NUM_RESOURCES ; i++) { + r =resctrl_arch_get_resource (i); +if (!r->alloc_capable) +continue ; +list_for_each_entry (d_i, &r->domains, list) {if (d_i->plr) cpumask_or(cpu_with_psl, cpu_with_psl,
arch/x86/kernel/cpu/resctrl/rdtgroup.c +24 -4
@@ -98,12 +98,17 @@ void rdt_last_cmd_printf(const char *fmt, ...)void rdt_staged_configs_clear (void ) { +enum resctrl_res_level i;struct rdt_resource *r;struct rdt_domain *dom;lockdep_assert_held (&rdtgroup_mutex); -for_each_alloc_capable_rdt_resource (r) { +for (i =0 ; i <RDT_NUM_RESOURCES ; i++) { + r =resctrl_arch_get_resource (i); +if (!r->alloc_capable) +continue ; +list_for_each_entry (dom, &r->domains, list)memset (dom->staged_config,0 ,sizeof (dom->staged_config)); }
@@ -2179,6 +2184,7 @@ static int rdtgroup_mkdir_info_resdir(void *priv, char *name,static int rdtgroup_create_info_dir (struct kernfs_node *parent_kn) { +enum resctrl_res_level i;struct resctrl_schema *s;struct rdt_resource *r;unsigned long fflags;
@@ -2203,7 +2209,11 @@ static int rdtgroup_create_info_dir(struct kernfs_node *parent_kn) goto out_destroy; } -for_each_mon_capable_rdt_resource (r) { +for (i =0 ; i <RDT_NUM_RESOURCES ; i++) { + r =resctrl_arch_get_resource (i); +if (!r->mon_capable) +continue ; + fflags = r->fflags |RFTYPE_MON_INFO ;sprintf (name,"%s_MON" , r->name); ret =rdtgroup_mkdir_info_resdir (r, name, fflags);
@@ -2613,10 +2623,15 @@ static int schemata_list_add(struct rdt_resource *r, enum resctrl_conf_type typestatic int schemata_list_create (void ) { +enum resctrl_res_level i;struct rdt_resource *r;int ret =0 ; -for_each_alloc_capable_rdt_resource (r) { +for (i =0 ; i <RDT_NUM_RESOURCES ; i++) { + r =resctrl_arch_get_resource (i); +if (!r->alloc_capable) +continue ; +if (resctrl_arch_get_cdp_enabled (r->rid)) { ret =schemata_list_add (r,CDP_CODE );if (ret)
@@ -3165,6 +3180,7 @@ static int mkdir_mondata_all(struct kernfs_node *parent_kn,struct rdtgroup *prgrp, struct kernfs_node **dest_kn) { + enum resctrl_res_level i;struct rdt_resource *r;struct kernfs_node *kn;int ret;
@@ -3183,7 +3199,11 @@ static int mkdir_mondata_all(struct kernfs_node *parent_kn,* Create the subdirectories for each domain. Note that all events * in a domain like L3 are grouped into a resource whose domain is L3 */ -for_each_mon_capable_rdt_resource (r) { +for (i =0 ; i <RDT_NUM_RESOURCES ; i++) { + r =resctrl_arch_get_resource (i); +if (!r->mon_capable) +continue ; + ret =mkdir_mondata_subdir_alldom (kn, r, prgrp);if (ret) goto out_destroy;
Signature · 1 line
2.34.1
Dave Martin
reviewerPATCH v2 14/35 x86/resctrl: Export the is_mbm_*_enabled() helpers to asm/resctrl.h
In reply to Dave MartinFrom: James Morse <[email protected]>
The architecture specific parts of resctrl have helpers to hide accesses to the rdt_mon_features bitmap.
Once the filesystem parts of resctrl are moved, these can no longer live in internal.h. Once these are exposed to the wider kernel, they should have a 'resctrl_arch_' prefix, to fit the rest of the arch<->fs interface.
Move and rename the helpers that touch rdt_mon_features directly. is_mbm_event() and is_mbm_enabled() are only called from rdtgroup.c, so can be moved into that file.
---
Changes in v2:
* Realphabetise inserted #include (since the neighbouring #includes appear unrelated and unlikely to conflict).
No functional change.
--- arch/x86/include/asm/resctrl.h | 17 +++++++++++ arch/x86/kernel/cpu/resctrl/core.c | 4 +-- arch/x86/kernel/cpu/resctrl/internal.h | 27 ----------------- arch/x86/kernel/cpu/resctrl/monitor.c | 18 ++++++------ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 40 +++++++++++++++++--------- 5 files changed, 54 insertions(+), 52 deletions(-)
arch/x86/include/asm/resctrl.h +17 -0
@@ -6,6 +6,7 @@#include <linux/jump_label.h> #include <linux/percpu.h> +#include <linux/resctrl_types.h> #include <linux/sched.h> /*
@@ -43,6 +44,7 @@ DECLARE_PER_CPU(struct resctrl_pqr_state, pqr_state);extern bool rdt_alloc_capable;extern bool rdt_mon_capable; +extern unsigned int rdt_mon_features;DECLARE_STATIC_KEY_FALSE (rdt_enable_key);DECLARE_STATIC_KEY_FALSE (rdt_alloc_enable_key);
@@ -82,6 +84,21 @@ static inline void resctrl_arch_disable_mon(void)static_branch_dec_cpuslocked (&rdt_enable_key); } +static inline bool resctrl_arch_is_llc_occupancy_enabled (void ) +{ +return (rdt_mon_features & (1 <<QOS_L3_OCCUP_EVENT_ID )); +} + +static inline bool resctrl_arch_is_mbm_total_enabled (void ) +{ +return (rdt_mon_features & (1 <<QOS_L3_MBM_TOTAL_EVENT_ID )); +} + +static inline bool resctrl_arch_is_mbm_local_enabled (void ) +{ +return (rdt_mon_features & (1 <<QOS_L3_MBM_LOCAL_EVENT_ID )); +} +/* * __resctrl_sched_in() - Writes the task's CLOSid/RMID to IA32_PQR_MSR *
arch/x86/kernel/cpu/resctrl/core.c +2 -2
@@ -481,13 +481,13 @@ static int arch_domain_mbm_alloc(u32 num_rmid, struct rdt_hw_domain *hw_dom) {size_t tsize; -if (is_mbm_total_enabled ()) { +if (resctrl_arch_is_mbm_total_enabled ()) { tsize =sizeof (*hw_dom->arch_mbm_total); hw_dom->arch_mbm_total =kcalloc (num_rmid, tsize,GFP_KERNEL );if (!hw_dom->arch_mbm_total)return -ENOMEM ; } -if (is_mbm_local_enabled ()) { +if (resctrl_arch_is_mbm_local_enabled ()) { tsize =sizeof (*hw_dom->arch_mbm_local); hw_dom->arch_mbm_local =kcalloc (num_rmid, tsize,GFP_KERNEL );if (!hw_dom->arch_mbm_local) {
arch/x86/kernel/cpu/resctrl/internal.h +0 -27
@@ -130,7 +130,6 @@ struct rmid_read {void *arch_mon_ctx; }; -extern unsigned int rdt_mon_features;extern struct list_head resctrl_schema_all;extern bool resctrl_mounted;
@@ -360,32 +359,6 @@ struct msr_param {u32 high; }; -static inline bool is_llc_occupancy_enabled (void ) -{ -return (rdt_mon_features & (1 <<QOS_L3_OCCUP_EVENT_ID )); -} - -static inline bool is_mbm_total_enabled (void ) -{ -return (rdt_mon_features & (1 <<QOS_L3_MBM_TOTAL_EVENT_ID )); -} - -static inline bool is_mbm_local_enabled (void ) -{ -return (rdt_mon_features & (1 <<QOS_L3_MBM_LOCAL_EVENT_ID )); -} - -static inline bool is_mbm_enabled (void ) -{ -return (is_mbm_total_enabled () ||is_mbm_local_enabled ()); -} - -static inline bool is_mbm_event (int e) -{ -return (e >=QOS_L3_MBM_TOTAL_EVENT_ID && - e <=QOS_L3_MBM_LOCAL_EVENT_ID ); -} -/** * struct rdt_hw_resource - arch private attributes of a resctrl resource * @r_resctrl: Attributes of the resource used directly by resctrl.
arch/x86/kernel/cpu/resctrl/monitor.c +9 -9
@@ -251,11 +251,11 @@ void resctrl_arch_reset_rmid_all(struct rdt_resource *r, struct rdt_domain *d) {struct rdt_hw_domain *hw_dom =resctrl_to_arch_dom (d); -if (is_mbm_total_enabled ()) +if (resctrl_arch_is_mbm_total_enabled ())memset (hw_dom->arch_mbm_total,0 ,sizeof (*hw_dom->arch_mbm_total) * r->num_rmid); -if (is_mbm_local_enabled ()) +if (resctrl_arch_is_mbm_local_enabled ())memset (hw_dom->arch_mbm_local,0 ,sizeof (*hw_dom->arch_mbm_local) * r->num_rmid); }
@@ -514,7 +514,7 @@ void free_rmid(u32 closid, u32 rmid) entry =__rmid_entry (idx); -if (is_llc_occupancy_enabled ()) +if (resctrl_arch_is_llc_occupancy_enabled ())add_rmid_to_limbo (entry);else list_add_tail (&entry->list, &rmid_free_lru);
@@ -666,7 +666,7 @@ static void update_mba_bw(struct rdtgroup *rgrp, struct rdt_domain *dom_mbm)struct list_head *head;struct rdtgroup *entry; -if (!is_mbm_local_enabled ()) +if (!resctrl_arch_is_mbm_local_enabled ())return ; r_mba =resctrl_arch_get_resource (RDT_RESOURCE_MBA );
@@ -735,7 +735,7 @@ static void mbm_update(struct rdt_resource *r, struct rdt_domain *d,* This is protected from concurrent reads from user * as both the user and we hold the global mutex. */ -if (is_mbm_total_enabled ()) { +if (resctrl_arch_is_mbm_total_enabled ()) { rr.evtid =QOS_L3_MBM_TOTAL_EVENT_ID ; rr.val =0 ; rr.arch_mon_ctx =resctrl_arch_mon_ctx_alloc (rr.r, rr.evtid);
@@ -749,7 +749,7 @@ static void mbm_update(struct rdt_resource *r, struct rdt_domain *d,resctrl_arch_mon_ctx_free (rr.r, rr.evtid, rr.arch_mon_ctx); } -if (is_mbm_local_enabled ()) { +if (resctrl_arch_is_mbm_local_enabled ()) { rr.evtid =QOS_L3_MBM_LOCAL_EVENT_ID ; rr.val =0 ; rr.arch_mon_ctx =resctrl_arch_mon_ctx_alloc (rr.r, rr.evtid);
@@ -997,11 +997,11 @@ static void l3_mon_evt_init(struct rdt_resource *r) {INIT_LIST_HEAD (&r->evt_list); -if (is_llc_occupancy_enabled ()) +if (resctrl_arch_is_llc_occupancy_enabled ())list_add_tail (&llc_occupancy_event.list, &r->evt_list); -if (is_mbm_total_enabled ()) +if (resctrl_arch_is_mbm_total_enabled ())list_add_tail (&mbm_total_event.list, &r->evt_list); -if (is_mbm_local_enabled ()) +if (resctrl_arch_is_mbm_local_enabled ())list_add_tail (&mbm_local_event.list, &r->evt_list); }
arch/x86/kernel/cpu/resctrl/rdtgroup.c +26 -14
@@ -114,6 +114,18 @@ void rdt_staged_configs_clear(void) } } +static bool resctrl_is_mbm_enabled (void ) +{ +return (resctrl_arch_is_mbm_total_enabled () || +resctrl_arch_is_mbm_local_enabled ()); +} + +static bool resctrl_is_mbm_event (int e) +{ +return (e >=QOS_L3_MBM_TOTAL_EVENT_ID && + e <=QOS_L3_MBM_LOCAL_EVENT_ID ); +} +/* * Trivial allocator for CLOSIDs. Since h/w only supports a small number, * we can keep a bitmap of free CLOSIDs in a single integer.
@@ -161,7 +173,7 @@ static int closid_alloc(void)lockdep_assert_held (&rdtgroup_mutex);if (IS_ENABLED (CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID ) && -is_llc_occupancy_enabled ()) { +resctrl_arch_is_llc_occupancy_enabled ()) { cleanest_closid =resctrl_find_cleanest_closid ();if (cleanest_closid <0 )return cleanest_closid;
@@ -2368,7 +2380,7 @@ static bool supports_mba_mbps(void) {struct rdt_resource *r =resctrl_arch_get_resource (RDT_RESOURCE_MBA ); -return (is_mbm_local_enabled () && +return (resctrl_arch_is_mbm_local_enabled () && r->alloc_capable &&is_mba_linear ()); }
@@ -2736,7 +2748,7 @@ static int rdt_get_tree(struct fs_context *fc)if (resctrl_arch_alloc_capable () ||resctrl_arch_mon_capable ()) resctrl_mounted = true; -if (is_mbm_enabled ()) { +if (resctrl_is_mbm_enabled ()) { r =resctrl_arch_get_resource (RDT_RESOURCE_L3 );list_for_each_entry (dom, &r->domains, list) mbm_setup_overflow_handler(dom, MBM_OVERFLOW_INTERVAL,
@@ -3106,7 +3118,7 @@ static int mkdir_mondata_subdir(struct kernfs_node *parent_kn,if (ret) goto out_destroy; -if (is_mbm_event (mevt->evtid)) +if (resctrl_is_mbm_event (mevt->evtid))mon_event_read (&rr, r, d, prgrp, mevt->evtid, true); }kernfs_activate (kn);
@@ -4008,9 +4020,9 @@ void resctrl_offline_domain(struct rdt_resource *r, struct rdt_domain *d)if (resctrl_mounted &&resctrl_arch_mon_capable ())rmdir_mondata_subdir_allrdtgrp (r, d->id); -if (is_mbm_enabled ()) +if (resctrl_is_mbm_enabled ())cancel_delayed_work (&d->mbm_over); -if (is_llc_occupancy_enabled () &&has_busy_rmid (d)) { +if (resctrl_arch_is_llc_occupancy_enabled () &&has_busy_rmid (d)) {/* * When a package is going down, forcefully * decrement rmid->ebusy. There is no way to know
@@ -4034,12 +4046,12 @@ static int domain_setup_mon_state(struct rdt_resource *r, struct rdt_domain *d)u32 idx_limit =resctrl_arch_system_num_rmid_idx ();size_t tsize; -if (is_llc_occupancy_enabled ()) { +if (resctrl_arch_is_llc_occupancy_enabled ()) { d->rmid_busy_llc =bitmap_zalloc (idx_limit,GFP_KERNEL );if (!d->rmid_busy_llc)return -ENOMEM ; } -if (is_mbm_total_enabled ()) { +if (resctrl_arch_is_mbm_total_enabled ()) { tsize =sizeof (*d->mbm_total); d->mbm_total =kcalloc (idx_limit, tsize,GFP_KERNEL );if (!d->mbm_total) {
@@ -4047,7 +4059,7 @@ static int domain_setup_mon_state(struct rdt_resource *r, struct rdt_domain *d)return -ENOMEM ; } } -if (is_mbm_local_enabled ()) { +if (resctrl_arch_is_mbm_local_enabled ()) { tsize =sizeof (*d->mbm_local); d->mbm_local =kcalloc (idx_limit, tsize,GFP_KERNEL );if (!d->mbm_local) {
@@ -4079,13 +4091,13 @@ int resctrl_online_domain(struct rdt_resource *r, struct rdt_domain *d)if (err) goto out_unlock; -if (is_mbm_enabled ()) { +if (resctrl_is_mbm_enabled ()) {INIT_DELAYED_WORK (&d->mbm_over, mbm_handle_overflow);mbm_setup_overflow_handler (d,MBM_OVERFLOW_INTERVAL ,RESCTRL_PICK_ANY_CPU ); } -if (is_llc_occupancy_enabled ()) +if (resctrl_arch_is_llc_occupancy_enabled ())INIT_DELAYED_WORK (&d->cqm_limbo, cqm_handle_limbo);/*
@@ -4140,12 +4152,12 @@ void resctrl_offline_cpu(unsigned int cpu) d =get_domain_from_cpu (cpu, l3);if (d) { -if (is_mbm_enabled () && cpu == d->mbm_work_cpu) { +if (resctrl_is_mbm_enabled () && cpu == d->mbm_work_cpu) {cancel_delayed_work (&d->mbm_over);mbm_setup_overflow_handler (d,0 , cpu); } -if (is_llc_occupancy_enabled () && cpu == d->cqm_work_cpu && -has_busy_rmid (d)) { +if (resctrl_arch_is_llc_occupancy_enabled () && + cpu == d->cqm_work_cpu &&has_busy_rmid (d)) {cancel_delayed_work (&d->cqm_limbo);cqm_setup_limbo_handler (d,0 , cpu); }
Signature · 1 line
2.34.1
Dave Martin
reviewerPATCH v2 15/35 x86/resctrl: Add resctrl_arch_is_evt_configurable() to abstract BMEC
In reply to Dave MartinFrom: James Morse <[email protected]>
When BMEC is supported the resctrl event can be configured in a number of ways. This depends on architecture support. rdt_get_mon_l3_config() modifies the struct mon_evt and calls mbm_config_rftype_init() to create the files that allow the configuration.
Splitting this into separate architecture and filesystem parts would require the struct mon_evt and mbm_config_rftype_init() to be exposed.
Instead, add resctrl_arch_is_evt_configurable(), and use this from resctrl_mon_resource_init() to initialise struct mon_evt and call mbm_config_rftype_init(). resctrl_arch_is_evt_configurable() calls rdt_cpu_has() so it doesn't obviously benefit from being inlined. Putting it in core.c will allow rdt_cpu_has() to eventually become static.
resctrl_arch_is_evt_configurable() uses rdt_cpu_has() from resctrl_mon_resource_init(), which isn't marked __init. In addition, MPAM needs to initialise resctrl late. Drop the __init on the relevant functions.
--- arch/x86/kernel/cpu/resctrl/core.c | 19 +++++++++++++++++-- arch/x86/kernel/cpu/resctrl/internal.h | 4 ++-- arch/x86/kernel/cpu/resctrl/monitor.c | 18 +++++++++--------- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 2 +- include/linux/resctrl.h | 2 ++ 5 files changed, 31 insertions(+), 14 deletions(-)
arch/x86/kernel/cpu/resctrl/core.c +17 -2
@@ -667,7 +667,7 @@ struct rdt_options {bool force_off, force_on; }; -static struct rdt_options rdt_options[]__initdata = { +static struct rdt_options rdt_options[]__ro_after_init = {RDT_OPT (RDT_FLAG_CMT ,"cmt" ,X86_FEATURE_CQM_OCCUP_LLC ),RDT_OPT (RDT_FLAG_MBM_TOTAL ,"mbmtotal" ,X86_FEATURE_CQM_MBM_TOTAL ),RDT_OPT (RDT_FLAG_MBM_LOCAL ,"mbmlocal" ,X86_FEATURE_CQM_MBM_LOCAL ),
@@ -707,7 +707,7 @@ static int __init set_rdt_options(char *str) }__setup ("rdt" , set_rdt_options); -bool __init rdt_cpu_has (int flag) +bool rdt_cpu_has (int flag) {bool ret =boot_cpu_has (flag);struct rdt_options *o;
@@ -727,6 +727,21 @@ bool __init rdt_cpu_has(int flag)return ret; } +bool resctrl_arch_is_evt_configurable (enum resctrl_event_id evt) +{ +if (!rdt_cpu_has (X86_FEATURE_BMEC )) +return false; + +switch (evt) { +case QOS_L3_MBM_TOTAL_EVENT_ID : +return rdt_cpu_has (X86_FEATURE_CQM_MBM_TOTAL ); +case QOS_L3_MBM_LOCAL_EVENT_ID : +return rdt_cpu_has (X86_FEATURE_CQM_MBM_LOCAL ); +default : +return false; + } +} +static __init bool get_mem_config (void ) {struct rdt_hw_resource *hw_res = &rdt_resources_all[RDT_RESOURCE_MBA ];
arch/x86/kernel/cpu/resctrl/internal.h +2 -2
@@ -507,7 +507,7 @@ int alloc_rmid(u32 closid);void free_rmid (u32 closid,u32 rmid);int rdt_get_mon_l3_config (struct rdt_resource *r); void __exit resctrl_mon_resource_exit(void); -bool __init rdt_cpu_has (int flag); +bool rdt_cpu_has (int flag);void mon_event_count (void *info);int rdtgroup_mondata_show (struct seq_file *m,void *arg); void mon_event_read(struct rmid_read *rr, struct rdt_resource *r,
@@ -527,7 +527,7 @@ bool has_busy_rmid(struct rdt_domain *d);void __check_limbo (struct rdt_domain *d,bool force_free);void rdt_domain_reconfigure_cdp (struct rdt_resource *r);void __init thread_throttle_mode_init (void ); -void __init mbm_config_rftype_init (const char *config); +void mbm_config_rftype_init (const char *config);void rdt_staged_configs_clear (void );bool closid_allocated (unsigned int closid);int resctrl_find_cleanest_closid (void );
arch/x86/kernel/cpu/resctrl/monitor.c +9 -9
@@ -1019,6 +1019,15 @@ int resctrl_mon_resource_init(void)l3_mon_evt_init (r); +if (resctrl_arch_is_evt_configurable (QOS_L3_MBM_TOTAL_EVENT_ID )) { + mbm_total_event.configurable = true; +mbm_config_rftype_init ("mbm_total_bytes_config" ); + } +if (resctrl_arch_is_evt_configurable (QOS_L3_MBM_LOCAL_EVENT_ID )) { + mbm_local_event.configurable = true; +mbm_config_rftype_init ("mbm_local_bytes_config" ); + } +return 0 ; }
@@ -1060,15 +1069,6 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r)/* Detect list of bandwidth sources that can be tracked */ cpuid_count (0x80000020 ,3 , &eax, &ebx, &ecx, &edx); hw_res->mbm_cfg_mask = ecx &MAX_EVT_CONFIG_BITS ; - -if (rdt_cpu_has (X86_FEATURE_CQM_MBM_TOTAL )) { - mbm_total_event.configurable = true; -mbm_config_rftype_init ("mbm_total_bytes_config" ); - } -if (rdt_cpu_has (X86_FEATURE_CQM_MBM_LOCAL )) { - mbm_local_event.configurable = true; -mbm_config_rftype_init ("mbm_local_bytes_config" ); - } } r->mon_capable = true;
arch/x86/kernel/cpu/resctrl/rdtgroup.c +1 -1
@@ -2066,7 +2066,7 @@ void __init thread_throttle_mode_init(void) rft->fflags =RFTYPE_CTRL_INFO |RFTYPE_RES_MB ; } -void __init mbm_config_rftype_init (const char *config) +void mbm_config_rftype_init (const char *config) {struct rftype *rft;
include/linux/resctrl.h +2 -0
@@ -215,6 +215,8 @@ u32 resctrl_arch_get_num_closid(struct rdt_resource *r);struct rdt_domain *resctrl_arch_find_domain (struct rdt_resource *r,int id);int resctrl_arch_update_domains (struct rdt_resource *r,u32 closid); +bool resctrl_arch_is_evt_configurable (enum resctrl_event_id evt); +/* * Update the ctrl_val and apply this config right now. * Must be called on one of the domain's CPUs.
Signature · 1 line
2.34.1
Dave Martin
reviewerPATCH v2 16/35 x86/resctrl: Change mon_event_config_{read,write}() to be arch helpers
In reply to Dave MartinFrom: James Morse <[email protected]>
mon_event_config_{read,write}() are called via IPI and access model specific registers to do their work.
To support another architecture, this needs abstracting.
Rename mon_event_config_{read,write}() to have a "resctrl_arch_" prefix, and move their struct mon_config_info parameter into <linux/resctrl.h>. This allows another architecture to supply an implementation of these.
As struct mon_config_info is now exposed globally, give it a 'resctrl_' prefix. MPAM systems need access to the domain to do this work, add the resource and domain to struct resctrl_mon_config_info.
---
Changes in v2:
* [Whitespace only] Re-tabbed struct resctrl_mon_config_info in <linux/resctrl.h> to fit the prevailing style.
Non-functional change.
* [Commit message only] Reword to align with the actual naming of the definitions and destination header file.
--- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 34 +++++++++++++------------- include/linux/resctrl.h | 9 +++++++ 2 files changed, 26 insertions(+), 17 deletions(-)
arch/x86/kernel/cpu/resctrl/rdtgroup.c +17 -17
@@ -1578,11 +1578,6 @@ static int rdtgroup_size_show(struct kernfs_open_file *of,return ret; } -struct mon_config_info { -u32 evtid; -u32 mon_config; -}; -#define INVALID_CONFIG_INDEX UINT_MAX/**
@@ -1607,9 +1602,9 @@ static inline unsigned int mon_event_config_index_get(u32 evtid) } } -static void mon_event_config_read (void *info) +void resctrl_arch_mon_event_config_read (void *info) { -struct mon_config_info *mon_info = info; +struct resctrl_mon_config_info *mon_info = info;unsigned int index;u64 msrval;
@@ -1624,14 +1619,15 @@ static void mon_event_config_read(void *info) mon_info->mon_config = msrval &MAX_EVT_CONFIG_BITS ; } -static void mondata_config_read (struct rdt_domain *d,struct mon_config_info *mon_info) +static void mondata_config_read (struct resctrl_mon_config_info *mon_info) { -smp_call_function_any (&d->cpu_mask, mon_event_config_read, mon_info,1 ); +smp_call_function_any (&mon_info->d->cpu_mask, + resctrl_arch_mon_event_config_read, mon_info,1 ); }static int mbm_config_show (struct seq_file *s,struct rdt_resource *r,u32 evtid) { -struct mon_config_info mon_info = {0 }; +struct resctrl_mon_config_info mon_info = {0 };struct rdt_domain *dom;bool sep = false;
@@ -1642,9 +1638,11 @@ static int mbm_config_show(struct seq_file *s, struct rdt_resource *r, u32 evtidif (sep)seq_puts (s,";" ); -memset (&mon_info,0 ,sizeof (struct mon_config_info )); +memset (&mon_info,0 ,sizeof (struct resctrl_mon_config_info )); + mon_info.r = r; + mon_info.d = dom; mon_info.evtid = evtid; -mondata_config_read (dom, &mon_info); +mondata_config_read (&mon_info);seq_printf (s,"%d=0x%02x" , dom->id, mon_info.mon_config); sep = true;
@@ -1677,9 +1675,9 @@ static int mbm_local_bytes_config_show(struct kernfs_open_file *of,return 0 ; } -static void mon_event_config_write (void *info) +void resctrl_arch_mon_event_config_write (void *info) { -struct mon_config_info *mon_info = info; +struct resctrl_mon_config_info *mon_info = info;unsigned int index; index =mon_event_config_index_get (mon_info->evtid);
@@ -1693,14 +1691,16 @@ static void mon_event_config_write(void *info)static void mbm_config_write_domain (struct rdt_resource *r,struct rdt_domain *d,u32 evtid,u32 val) { -struct mon_config_info mon_info = {0 }; +struct resctrl_mon_config_info mon_info = {0 };/* * Read the current config value first. If both are the same then * no need to write it again. */ + mon_info.r = r; + mon_info.d = d; mon_info.evtid = evtid; -mondata_config_read (d, &mon_info); +mondata_config_read (&mon_info);if (mon_info.mon_config == val)return ;
@@ -1712,7 +1712,7 @@ static void mbm_config_write_domain(struct rdt_resource *r,* are scoped at the domain level. Writing any of these MSRs * on one CPU is observed by all the CPUs in the domain. */ -smp_call_function_any (&d->cpu_mask, mon_event_config_write, +smp_call_function_any (&d->cpu_mask, resctrl_arch_mon_event_config_write, &mon_info,1 );/*
include/linux/resctrl.h +9 -0
@@ -192,6 +192,13 @@ struct resctrl_cpu_defaults {u32 rmid; }; +struct resctrl_mon_config_info { +struct rdt_resource *r; +struct rdt_domain *d; +u32 evtid; +u32 mon_config; +}; +/** * resctrl_arch_sync_cpu_closid_rmid() - Refresh this CPU's CLOSID and RMID. * Call via IPI.
@@ -216,6 +223,8 @@ struct rdt_domain *resctrl_arch_find_domain(struct rdt_resource *r, int id);int resctrl_arch_update_domains (struct rdt_resource *r,u32 closid);bool resctrl_arch_is_evt_configurable (enum resctrl_event_id evt); +void resctrl_arch_mon_event_config_write (void *info); +void resctrl_arch_mon_event_config_read (void *info);/* * Update the ctrl_val and apply this config right now.
Signature · 1 line
2.34.1
Dave Martin
reviewerPATCH v2 17/35 x86/resctrl: Move mbm_cfg_mask to struct rdt_resource
In reply to Dave MartinFrom: James Morse <[email protected]>
The mbm_cfg_mask field lists the bits that user-space can set when configuring an event. This value is output via the last_cmd_status file.
Once the filesystem parts of resctrl are moved to live in /fs/, the struct rdt_hw_resource is inaccessible to the filesystem code. Because this value is output to user-space, it has to be accessible to the filesystem code.
Move it to struct rdt_resource.
---
FYI: Dave Martin (et al.):
* Reword comments to avoid being overly arch-specific.
Is the _content_ of mbm_cfg_mask arch-independent?
Changes in v2:
(none)
--- arch/x86/kernel/cpu/resctrl/internal.h | 3 --- arch/x86/kernel/cpu/resctrl/monitor.c | 2 +- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 5 ++--- include/linux/resctrl.h | 3 +++ 4 files changed, 6 insertions(+), 7 deletions(-)
arch/x86/kernel/cpu/resctrl/internal.h +0 -3
@@ -371,8 +371,6 @@ struct msr_param {* @msr_update: Function pointer to update QOS MSRs * @mon_scale: cqm counter * mon_scale = occupancy in bytes * @mbm_width: Monitor width, to detect and correct for overflow. -* @mbm_cfg_mask: Bandwidth sources that can be tracked when Bandwidth -* Monitoring Event Configuration (BMEC) is supported. * @cdp_enabled: CDP state of this resource * * Members of this structure are either private to the architecture
@@ -387,7 +385,6 @@ struct rdt_hw_resource { struct rdt_resource *r);unsigned int mon_scale;unsigned int mbm_width; -unsigned int mbm_cfg_mask;bool cdp_enabled; };
arch/x86/kernel/cpu/resctrl/monitor.c +1 -1
@@ -1068,7 +1068,7 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r)/* Detect list of bandwidth sources that can be tracked */ cpuid_count (0x80000020 ,3 , &eax, &ebx, &ecx, &edx); - hw_res->mbm_cfg_mask = ecx &MAX_EVT_CONFIG_BITS ; + r->mbm_cfg_mask = ecx &MAX_EVT_CONFIG_BITS ; } r->mon_capable = true;
arch/x86/kernel/cpu/resctrl/rdtgroup.c +2 -3
@@ -1729,7 +1729,6 @@ static void mbm_config_write_domain(struct rdt_resource *r,static int mon_config_write (struct rdt_resource *r,char *tok,u32 evtid) { -struct rdt_hw_resource *hw_res =resctrl_to_arch_res (r);char *dom_str =NULL , *id_str;unsigned long dom_id, val;struct rdt_domain *d;
@@ -1756,9 +1755,9 @@ static int mon_config_write(struct rdt_resource *r, char *tok, u32 evtid) }/* Value from user cannot be more than the supported set of events */ -if ((val & hw_res->mbm_cfg_mask) != val) { +if ((val & r->mbm_cfg_mask) != val) {rdt_last_cmd_printf ("Invalid event configuration: max valid mask is 0x%02x\n" , - hw_res->mbm_cfg_mask); + r->mbm_cfg_mask);return -EINVAL ; }
include/linux/resctrl.h +3 -0
@@ -140,6 +140,8 @@ struct resctrl_membw {* @format_str: Per resource format string to show domain value * @evt_list: List of monitoring events * @fflags: flags to choose base and info files +* @mbm_cfg_mask: Bandwidth sources that can be tracked when Bandwidth +* Monitoring Event Configuration (BMEC) is supported. * @cdp_capable: Is the CDP feature available on this resource */ struct rdt_resource {
@@ -157,6 +159,7 @@ struct rdt_resource {const char *format_str;struct list_head evt_list;unsigned long fflags; +unsigned int mbm_cfg_mask;bool cdp_capable; };
Signature · 1 line
2.34.1
James Morse
reviewerRe: [PATCH v2 17/35] x86/resctrl: Move mbm_cfg_mask to struct rdt_resource
Hi Dave,
Quoted 11 lines · Dave Martin
From: James Morse <[email protected]>
The
mbm_cfg_maskfield lists the bits that user-space can set when configuring an event. This value is output via thelast_cmd_statusfile.Once the filesystem parts of resctrl are moved to live in /fs/, the struct
rdt_hw_resourceis inaccessible to the filesystem code. Because this value is output to user-space, it has to be accessible to the filesystem code.
Quoted 6 lines
Move it to struct
rdt_resource.* Reword comments to avoid being overly arch-specific.
Is the _content_ of
mbm_cfg_maskarch-independent?
This comes from the mbm_total_bytes_config, nothing in Documentation/arch/x86/resctrl.rst says this is AMD specific, so it can be assumed to be defined by resctrl, but depending on some hardware feature.
I'm not sure we can make this retroactively platform specific.
Thanks,
James
Dave Martin
reviewerPATCH v2 18/35 x86/resctrl: Allow resctrl_arch_mon_event_config_write() to return an error
In reply to Dave MartinFrom: James Morse <[email protected]>
resctrl_arch_mon_event_config_write() writes a bitmap of events provided by user-space into the configuration register for the monitors.
This assumes that all architectures support all the features each bit corresponds to.
MPAM can filter monitors based on read, write, or both, but there are many more options in the existing bitmap. To allow this interface to work for machines with MPAM, allow the architecture helper to return an error if an incompatible bitmap is set.
When valid values are provided, there is no change in behaviour. If an invalid value is provided, currently it is silently ignored, but last_cmd_status is updated. After this change, the parser will stop at the first invalid value and return an error to user-space. This matches the way changes to the schemata file are made.
---
FYI: James Morse (et al.):
* Can this patch be dropped?
It looks like the core code will handling checking cfg values gracefully if the arch backend initialises rdt_resource::
mbm_cfg_mask to something suitable?
Is there any reason why we can't detect bad values globally before cross-calling?
Changes in v2:
* [Whitespace only] Re-tabbed resctrl_mon_config_info::err field declaration in <linux/resctrl.h> to match the prevailing style.
No functional change.
--- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 20 ++++++++++++++++---- include/linux/resctrl.h | 1 + 2 files changed, 17 insertions(+), 4 deletions(-)
arch/x86/kernel/cpu/resctrl/rdtgroup.c +16 -4
@@ -1683,13 +1683,16 @@ void resctrl_arch_mon_event_config_write(void *info) index =mon_event_config_index_get (mon_info->evtid);if (index ==INVALID_CONFIG_INDEX ) {pr_warn_once ("Invalid event id %d\n" , mon_info->evtid); + mon_info->err = -EINVAL ;return ; }wrmsr (MSR_IA32_EVT_CFG_BASE + index, mon_info->mon_config,0 ); + + mon_info->err =0 ; } -static void mbm_config_write_domain (struct rdt_resource *r, -struct rdt_domain *d,u32 evtid,u32 val) +static int mbm_config_write_domain (struct rdt_resource *r, +struct rdt_domain *d,u32 evtid,u32 val) {struct resctrl_mon_config_info mon_info = {0 };
@@ -1702,7 +1705,7 @@ static void mbm_config_write_domain(struct rdt_resource *r, mon_info.evtid = evtid;mondata_config_read (&mon_info);if (mon_info.mon_config == val) -return ; +return 0 ; mon_info.mon_config = val;
@@ -1714,6 +1717,10 @@ static void mbm_config_write_domain(struct rdt_resource *r,*/ smp_call_function_any (&d->cpu_mask, resctrl_arch_mon_event_config_write, &mon_info,1 ); +if (mon_info.err) { +rdt_last_cmd_puts ("Invalid event configuration\n" ); +return mon_info.err; + }/* * When an Event Configuration is changed, the bandwidth counters
@@ -1725,6 +1732,8 @@ static void mbm_config_write_domain(struct rdt_resource *r,* mbm_local and mbm_total counts for all the RMIDs. */ resctrl_arch_reset_rmid_all (r, d); + +return 0 ; }static int mon_config_write (struct rdt_resource *r,char *tok,u32 evtid)
@@ -1732,6 +1741,7 @@ static int mon_config_write(struct rdt_resource *r, char *tok, u32 evtid)char *dom_str =NULL , *id_str;unsigned long dom_id, val;struct rdt_domain *d; +int err;/* Walking r->domains, ensure it can't race with cpuhp */ lockdep_assert_cpus_held ();
@@ -1763,7 +1773,9 @@ static int mon_config_write(struct rdt_resource *r, char *tok, u32 evtid)list_for_each_entry (d, &r->domains, list) {if (d->id == dom_id) { -mbm_config_write_domain (r, d, evtid, val); + err =mbm_config_write_domain (r, d, evtid, val); +if (err) +return err; goto next; } }
include/linux/resctrl.h +1 -0
@@ -200,6 +200,7 @@ struct resctrl_mon_config_info {struct rdt_domain *d;u32 evtid;u32 mon_config; +int err; };/**
Signature · 1 line
2.34.1
Dave Martin
reviewerPATCH v2 19/35 x86/resctrl: Add resctrl_arch_ prefix to pseudo lock functions
In reply to Dave MartinFrom: James Morse <[email protected]>
resctrl's pseudo lock has some copy-to-cache and measurement functions that are micro-architecture specific. pseudo_lock_fn() is not at all portable. Label these 'resctrl_arch_' so they stay under /arch/x86.
--- arch/x86/include/asm/resctrl.h | 5 ++++ arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 36 ++++++++++++----------- 2 files changed, 24 insertions(+), 17 deletions(-)
arch/x86/include/asm/resctrl.h +5 -0
@@ -211,6 +211,11 @@ static inline void *resctrl_arch_mon_ctx_alloc(struct rdt_resource *r, int evtidstatic inline void resctrl_arch_mon_ctx_free (struct rdt_resource *r,int evtid,void *ctx) { }; +u64 resctrl_arch_get_prefetch_disable_bits (void ); +int resctrl_arch_pseudo_lock_fn (void *_rdtgrp); +int resctrl_arch_measure_cycles_lat_fn (void *_plr); +int resctrl_arch_measure_l2_residency (void *_plr); +int resctrl_arch_measure_l3_residency (void *_plr);void resctrl_cpu_detect (struct cpuinfo_x86 *c);#else
arch/x86/kernel/cpu/resctrl/pseudo_lock.c +19 -17
@@ -62,7 +62,8 @@ static const struct class pseudo_lock_class = { };/** -* get_prefetch_disable_bits - prefetch disable bits of supported platforms +* resctrl_arch_get_prefetch_disable_bits - prefetch disable bits of supported +* platforms * @void: It takes no parameters. * * Capture the list of platforms that have been validated to support
@@ -76,13 +77,13 @@ static const struct class pseudo_lock_class = {* in the SDM. * * When adding a platform here also add support for its cache events to -* measure_cycles_perf_fn() +* resctrl_arch_measure_l*_residency() * * Return: * If platform is supported, the bits to disable hardware prefetchers, 0 * if platform is not supported. */ -static u64 get_prefetch_disable_bits (void ) +u64 resctrl_arch_get_prefetch_disable_bits (void ) {if (boot_cpu_data.x86_vendor !=X86_VENDOR_INTEL || boot_cpu_data.x86 !=6 )
@@ -410,7 +411,7 @@ static void pseudo_lock_free(struct rdtgroup *rdtgrp) }/** -* pseudo_lock_fn - Load kernel memory into cache +* resctrl_arch_pseudo_lock_fn - Load kernel memory into cache * @_rdtgrp: resource group to which pseudo-lock region belongs * * This is the core pseudo-locking flow.
@@ -428,7 +429,7 @@ static void pseudo_lock_free(struct rdtgroup *rdtgrp)* * Return: 0. Waiter on waitqueue will be woken on completion. */ -static int pseudo_lock_fn (void *_rdtgrp) +int resctrl_arch_pseudo_lock_fn (void *_rdtgrp) {struct rdtgroup *rdtgrp = _rdtgrp;struct pseudo_lock_region *plr = rdtgrp->plr;
@@ -714,7 +715,7 @@ int rdtgroup_locksetup_enter(struct rdtgroup *rdtgrp)* Not knowing the bits to disable prefetching implies that this * platform does not support Cache Pseudo-Locking. */ - prefetch_disable_bits =get_prefetch_disable_bits (); + prefetch_disable_bits =resctrl_arch_get_prefetch_disable_bits ();if (prefetch_disable_bits ==0 ) {rdt_last_cmd_puts ("Pseudo-locking not supported\n" );return -EINVAL ;
@@ -879,7 +880,8 @@ bool rdtgroup_pseudo_locked_in_hierarchy(struct rdt_domain *d) }/** -* measure_cycles_lat_fn - Measure cycle latency to read pseudo-locked memory +* resctrl_arch_measure_cycles_lat_fn - Measure cycle latency to read +* pseudo-locked memory * @_plr: pseudo-lock region to measure * * There is no deterministic way to test if a memory region is cached. One
@@ -892,7 +894,7 @@ bool rdtgroup_pseudo_locked_in_hierarchy(struct rdt_domain *d)* * Return: 0. Waiter on waitqueue will be woken on completion. */ -static int measure_cycles_lat_fn (void *_plr) +int resctrl_arch_measure_cycles_lat_fn (void *_plr) {struct pseudo_lock_region *plr = _plr;u32 saved_low, saved_high;
@@ -1076,7 +1078,7 @@ static int measure_residency_fn(struct perf_event_attr *miss_attr,return 0 ; } -static int measure_l2_residency (void *_plr) +int resctrl_arch_measure_l2_residency (void *_plr) {struct pseudo_lock_region *plr = _plr;struct residency_counts counts = {0 };
@@ -1114,7 +1116,7 @@ static int measure_l2_residency(void *_plr)return 0 ; } -static int measure_l3_residency (void *_plr) +int resctrl_arch_measure_l3_residency (void *_plr) {struct pseudo_lock_region *plr = _plr;struct residency_counts counts = {0 };
@@ -1212,18 +1214,18 @@ static int pseudo_lock_measure_cycles(struct rdtgroup *rdtgrp, int sel) plr->cpu = cpu;if (sel ==1 ) - thread =kthread_create_on_node (measure_cycles_lat_fn, plr, -cpu_to_node (cpu), + thread =kthread_create_on_node (resctrl_arch_measure_cycles_lat_fn, + plr,cpu_to_node (cpu),"pseudo_lock_measure/%u" , cpu);else if (sel ==2 ) - thread =kthread_create_on_node (measure_l2_residency, plr, -cpu_to_node (cpu), + thread =kthread_create_on_node (resctrl_arch_measure_l2_residency, + plr,cpu_to_node (cpu),"pseudo_lock_measure/%u" , cpu);else if (sel ==3 ) - thread =kthread_create_on_node (measure_l3_residency, plr, -cpu_to_node (cpu), + thread =kthread_create_on_node (resctrl_arch_measure_l3_residency, + plr,cpu_to_node (cpu),"pseudo_lock_measure/%u" , cpu);else
@@ -1322,7 +1324,7 @@ int rdtgroup_pseudo_lock_create(struct rdtgroup *rdtgrp) plr->thread_done =0 ; - thread =kthread_create_on_node (pseudo_lock_fn, rdtgrp, + thread =kthread_create_on_node (resctrl_arch_pseudo_lock_fn, rdtgrp,cpu_to_node (plr->cpu),"pseudo_lock/%u" , plr->cpu);if (IS_ERR (thread)) {
Signature · 1 line
2.34.1
Dave Martin
reviewerPATCH v2 20/35 x86/resctrl: Allow an architecture to disable pseudo lock
In reply to Dave MartinFrom: James Morse <[email protected]>
Pseudo-lock relies on knowledge of the micro-architecture to disable prefetchers etc.
On arm64 these controls are typically secure only, meaning linux can't access them. Arm's cache-lockdown feature works in a very different way. Resctrl's pseudo-lock isn't going to be used on arm64 platforms.
Add a Kconfig symbol that can be selected by the architecture. This enables or disables building of the pseudo_lock.c file, and replaces the functions with stubs. An additional IS_ENABLED() check is needed in rdtgroup_mode_write() so that attempting to enable pseudo-lock reports an "Unknown or unsupported mode" to user-space.
---
Changes in v2:
* [Commit message only] Typo fix:
s/psuedo/pseudo/g
--- arch/x86/Kconfig | 7 ++++ arch/x86/kernel/cpu/resctrl/Makefile | 5 +-- arch/x86/kernel/cpu/resctrl/internal.h | 48 +++++++++++++++++++++----- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 3 +- 4 files changed, 52 insertions(+), 11 deletions(-)
arch/x86/Kconfig +7 -0
@@ -481,6 +481,7 @@ config X86_CPU_RESCTRL depends on X86 && (CPU_SUP_INTEL || CPU_SUP_AMD) select KERNFS select PROC_CPU_RESCTRL if PROC_FS + select RESCTRL_FS_PSEUDO_LOCK help Enable x86 CPU resource control support.
@@ -506,6 +507,12 @@ config X86_FRED ring transitions and exception/interrupt handling if the system supports. +config RESCTRL_FS_PSEUDO_LOCK + bool + help + Software mechanism to pin data in a cache portion using + micro-architecture specific knowledge. + if X86_32 config X86_BIGSMP bool "Support for big SMP systems with more than 8 CPUs"
arch/x86/kernel/cpu/resctrl/Makefile +3 -2
@@ -1,4 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -obj-$(CONFIG_X86_CPU_RESCTRL) += core.o rdtgroup.o monitor.o -obj-$(CONFIG_X86_CPU_RESCTRL) += ctrlmondata.o pseudo_lock.o +obj-$(CONFIG_X86_CPU_RESCTRL) += core.o rdtgroup.o monitor.o +obj-$(CONFIG_X86_CPU_RESCTRL) += ctrlmondata.o +obj-$(CONFIG_RESCTRL_FS_PSEUDO_LOCK) += pseudo_lock.o CFLAGS_pseudo_lock.o = -I$(src)
arch/x86/kernel/cpu/resctrl/internal.h +40 -8
58 lines not on this page · raw message
arch/x86/kernel/cpu/resctrl/rdtgroup.c +2 -1
@@ -1450,7 +1450,8 @@ static ssize_t rdtgroup_mode_write(struct kernfs_open_file *of, goto out; } rdtgrp->mode =RDT_MODE_EXCLUSIVE ; - }else if (!strcmp (buf,"pseudo-locksetup" )) { + }else if (IS_ENABLED (CONFIG_RESCTRL_FS_PSEUDO_LOCK ) && + !strcmp (buf,"pseudo-locksetup" )) { ret =rdtgroup_locksetup_enter (rdtgrp);if (ret) goto out;
Signature · 1 line
2.34.1
Dave Martin
reviewerPATCH v2 21/35 x86/resctrl: Make prefetch_disable_bits belong to the arch code
In reply to Dave MartinFrom: James Morse <[email protected]>
prefetch_disable_bits is set by rdtgroup_locksetup_enter() from a value provided by the architecture, but is largely read by other architecture helpers.
Instead of exporting this value, make resctrl_arch_get_prefetch_disable_bits() set it so that the other arch-code helpers can use the cached-value.
--- arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
arch/x86/kernel/cpu/resctrl/pseudo_lock.c +8 -5
@@ -85,6 +85,8 @@ static const struct class pseudo_lock_class = {*/ u64 resctrl_arch_get_prefetch_disable_bits (void ) { + prefetch_disable_bits =0 ; +if (boot_cpu_data.x86_vendor !=X86_VENDOR_INTEL || boot_cpu_data.x86 !=6 )return 0 ;
@@ -100,7 +102,8 @@ u64 resctrl_arch_get_prefetch_disable_bits(void)* 3 DCU IP Prefetcher Disable (R/W) * 63:4 Reserved */ -return 0xF ; + prefetch_disable_bits =0xF ; +break ;case INTEL_FAM6_ATOM_GOLDMONT :case INTEL_FAM6_ATOM_GOLDMONT_PLUS :/*
@@ -111,10 +114,11 @@ u64 resctrl_arch_get_prefetch_disable_bits(void)* 2 DCU Hardware Prefetcher Disable (R/W) * 63:3 Reserved */ -return 0x5 ; + prefetch_disable_bits =0x5 ; +break ; } -return 0 ; +return prefetch_disable_bits; }/**
@@ -715,8 +719,7 @@ int rdtgroup_locksetup_enter(struct rdtgroup *rdtgrp)* Not knowing the bits to disable prefetching implies that this * platform does not support Cache Pseudo-Locking. */ - prefetch_disable_bits =resctrl_arch_get_prefetch_disable_bits (); -if (prefetch_disable_bits ==0 ) { +if (resctrl_arch_get_prefetch_disable_bits () ==0 ) {rdt_last_cmd_puts ("Pseudo-locking not supported\n" );return -EINVAL ; }
Signature · 1 line
2.34.1
Dave Martin
reviewerPATCH v2 22/35 x86/resctrl: Make resctrl_arch_pseudo_lock_fn() take a plr
In reply to Dave MartinFrom: James Morse <[email protected]>
resctrl_arch_pseudo_lock_fn() has architecture specific behaviour, and takes a struct rdtgroup as an argument.
After the filesystem code moves to /fs/, the definition of struct rdtgroup will not be available to the architecture code.
The only reason resctrl_arch_pseudo_lock_fn() wants the rdtgroup is for the CLOSID. Embed that in the pseudo_lock_region as a closid, and move the definition of struct pseudo_lock_region to resctrl.h.
---
FYI: James Morse:
* Review the v2 change below, in case there was any functional reason for distinguishing "hw" closids here.
Changes in v2:
* [Commit message only] Typo fix:
s/hw_closid/closid/g
(The name "closid" is used in the code. If there is a distinction between "hardware" closids and resctrl closids, it doesn't seem to be explicit in the naming elsewhere.)
--- arch/x86/include/asm/resctrl.h | 2 +- arch/x86/kernel/cpu/resctrl/internal.h | 37 --------------------- arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 13 ++++---- include/linux/resctrl.h | 39 +++++++++++++++++++++++ 4 files changed, 47 insertions(+), 44 deletions(-)
arch/x86/include/asm/resctrl.h +1 -1
@@ -212,7 +212,7 @@ static inline void resctrl_arch_mon_ctx_free(struct rdt_resource *r, int evtid, void *ctx) { };u64 resctrl_arch_get_prefetch_disable_bits (void ); -int resctrl_arch_pseudo_lock_fn (void *_rdtgrp); +int resctrl_arch_pseudo_lock_fn (void *_plr);int resctrl_arch_measure_cycles_lat_fn (void *_plr);int resctrl_arch_measure_l2_residency (void *_plr);int resctrl_arch_measure_l3_residency (void *_plr);
arch/x86/kernel/cpu/resctrl/internal.h +0 -37
@@ -182,43 +182,6 @@ struct mongroup {u32 rmid; }; -/** -* struct pseudo_lock_region - pseudo-lock region information -* @s: Resctrl schema for the resource to which this -* pseudo-locked region belongs -* @d: RDT domain to which this pseudo-locked region -* belongs -* @cbm: bitmask of the pseudo-locked region -* @lock_thread_wq: waitqueue used to wait on the pseudo-locking thread -* completion -* @thread_done: variable used by waitqueue to test if pseudo-locking -* thread completed -* @cpu: core associated with the cache on which the setup code -* will be run -* @line_size: size of the cache lines -* @size: size of pseudo-locked region in bytes -* @kmem: the kernel memory associated with pseudo-locked region -* @minor: minor number of character device associated with this -* region -* @debugfs_dir: pointer to this region's directory in the debugfs -* filesystem -* @pm_reqs: Power management QoS requests related to this region -*/ -struct pseudo_lock_region { -struct resctrl_schema *s; -struct rdt_domain *d; -u32 cbm; -wait_queue_head_t lock_thread_wq; -int thread_done; -int cpu; -unsigned int line_size; -unsigned int size; -void *kmem; -unsigned int minor; -struct dentry *debugfs_dir; -struct list_head pm_reqs; -}; -/** * struct rdtgroup - store rdtgroup's data in resctrl file system. * @kn: kernfs node
arch/x86/kernel/cpu/resctrl/pseudo_lock.c +7 -6
@@ -416,7 +416,7 @@ static void pseudo_lock_free(struct rdtgroup *rdtgrp)/** * resctrl_arch_pseudo_lock_fn - Load kernel memory into cache -* @_rdtgrp: resource group to which pseudo-lock region belongs +* @_plr: the pseudo-lock region descriptor * * This is the core pseudo-locking flow. *
@@ -433,10 +433,9 @@ static void pseudo_lock_free(struct rdtgroup *rdtgrp)* * Return: 0. Waiter on waitqueue will be woken on completion. */ -int resctrl_arch_pseudo_lock_fn (void *_rdtgrp) +int resctrl_arch_pseudo_lock_fn (void *_plr) { -struct rdtgroup *rdtgrp = _rdtgrp; -struct pseudo_lock_region *plr = rdtgrp->plr; +struct pseudo_lock_region *plr = _plr;u32 rmid_p, closid_p;unsigned long i;u64 saved_msr;
@@ -496,7 +495,8 @@ int resctrl_arch_pseudo_lock_fn(void *_rdtgrp)* pseudo-locked followed by reading of kernel memory to load it * into the cache. */ -__wrmsr (MSR_IA32_PQR_ASSOC , rmid_p, rdtgrp->closid); +__wrmsr (MSR_IA32_PQR_ASSOC , rmid_p, plr->closid); +/* * Cache was flushed earlier. Now access kernel memory to read it * into cache region associated with just activated plr->closid.
@@ -1327,7 +1327,8 @@ int rdtgroup_pseudo_lock_create(struct rdtgroup *rdtgrp) plr->thread_done =0 ; - thread =kthread_create_on_node (resctrl_arch_pseudo_lock_fn, rdtgrp, + plr->closid = rdtgrp->closid; + thread =kthread_create_on_node (resctrl_arch_pseudo_lock_fn, plr,cpu_to_node (plr->cpu),"pseudo_lock/%u" , plr->cpu);if (IS_ERR (thread)) {
include/linux/resctrl.h +39 -0
@@ -25,6 +25,45 @@ int proc_resctrl_show(struct seq_file *m,/* max value for struct rdt_domain's mbps_val */ #define MBA_MAX_MBPS U32_MAX +/** +* struct pseudo_lock_region - pseudo-lock region information +* @s: Resctrl schema for the resource to which this +* pseudo-locked region belongs +* @closid: The closid that this pseudo-locked region uses +* @d: RDT domain to which this pseudo-locked region +* belongs +* @cbm: bitmask of the pseudo-locked region +* @lock_thread_wq: waitqueue used to wait on the pseudo-locking thread +* completion +* @thread_done: variable used by waitqueue to test if pseudo-locking +* thread completed +* @cpu: core associated with the cache on which the setup code +* will be run +* @line_size: size of the cache lines +* @size: size of pseudo-locked region in bytes +* @kmem: the kernel memory associated with pseudo-locked region +* @minor: minor number of character device associated with this +* region +* @debugfs_dir: pointer to this region's directory in the debugfs +* filesystem +* @pm_reqs: Power management QoS requests related to this region +*/ +struct pseudo_lock_region { +struct resctrl_schema *s; +u32 closid; +struct rdt_domain *d; +u32 cbm; +wait_queue_head_t lock_thread_wq; +int thread_done; +int cpu; +unsigned int line_size; +unsigned int size; +void *kmem; +unsigned int minor; +struct dentry *debugfs_dir; +struct list_head pm_reqs; +}; +/** * struct resctrl_staged_config - parsed configuration to be applied * @new_ctrl: new ctrl value to be loaded
Signature · 1 line
2.34.1
James Morse
reviewerRe: [PATCH v2 22/35] x86/resctrl: Make resctrl_arch_pseudo_lock_fn() take a plr
Hi Dave,
Quoted 17 lines · Dave Martin
From: James Morse <[email protected]>
resctrl_arch_pseudo_lock_fn()has architecture specific behaviour, and takes a struct rdtgroup as an argument.After the filesystem code moves to /fs/, the definition of struct rdtgroup will not be available to the architecture code.
The only reason
resctrl_arch_pseudo_lock_fn()wants the rdtgroup is for the CLOSID. Embed that in thepseudo_lock_regionas a closid, and move the definition of structpseudo_lock_regiontoresctrl.h.FYI: James Morse:
* Review the v2 change below, in case there was any functional reason for distinguishing "hw" closids here.
Quoted 8 lines
Changes in v2:
* [Commit message only] Typo fix:
s/hw_closid/closid/g(The name "closid" is used in the code. If there is a distinction between "hardware" closids and resctrl closids, it doesn't seem to be explicit in the naming elsewhere.)
Heh, this is a blast from the past!
In 2018 I was trying to get resctrl to convert 'closid' to 'hw_closid' using some architecture provided helpers. This was an alternative way of folding the CDP code to hide the differences between x86/arm64. I decided the fs/resctrl code was cleaner without it - and arm64 can just juggle the numbers instead.
Thanks,
James
Dave Martin
reviewerPATCH v2 23/35 x86/resctrl: Move thread_throttle_mode_init() to be managed by resctrl
In reply to Dave MartinFrom: James Morse <[email protected]>
thread_throttle_mode_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 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.
Call thread_throttle_mode_init() from resctrl_setup(), check the membw.throttle_mode on the MBA resource. This avoids publishing an extra function between the architecture and filesystem code.
--- arch/x86/kernel/cpu/resctrl/core.c | 1 - arch/x86/kernel/cpu/resctrl/internal.h | 1 - arch/x86/kernel/cpu/resctrl/rdtgroup.c | 9 ++++++++- 3 files changed, 8 insertions(+), 3 deletions(-)
arch/x86/kernel/cpu/resctrl/core.c +0 -1
@@ -227,7 +227,6 @@ static bool __get_mem_config_intel(struct rdt_resource *r) r->membw.throttle_mode =THREAD_THROTTLE_PER_THREAD ; else r->membw.throttle_mode = THREAD_THROTTLE_MAX; -thread_throttle_mode_init (); r->alloc_capable = true;
arch/x86/kernel/cpu/resctrl/internal.h +0 -1
@@ -478,7 +478,6 @@ void cqm_handle_limbo(struct work_struct *work);bool has_busy_rmid (struct rdt_domain *d);void __check_limbo (struct rdt_domain *d,bool force_free);void rdt_domain_reconfigure_cdp (struct rdt_resource *r); -void __init thread_throttle_mode_init (void );void mbm_config_rftype_init (const char *config);void rdt_staged_configs_clear (void );bool closid_allocated (unsigned int closid);
arch/x86/kernel/cpu/resctrl/rdtgroup.c +8 -1
@@ -2067,10 +2067,15 @@ static struct rftype *rdtgroup_get_rftype_by_name(const char *name)return NULL ; } -void __init thread_throttle_mode_init (void ) +static void __init thread_throttle_mode_init (void ) { +struct rdt_resource *r =resctrl_arch_get_resource (RDT_RESOURCE_MBA );struct rftype *rft; +if (!r->alloc_capable || + r->membw.throttle_mode ==THREAD_THROTTLE_UNDEFINED ) +return ; + rft =rdtgroup_get_rftype_by_name ("thread_throttle_mode" );if (!rft)return ;
@@ -4196,6 +4201,8 @@ int __init resctrl_init(void)rdtgroup_setup_default (); +thread_throttle_mode_init (); + ret =resctrl_mon_resource_init ();if (ret)return ret;
Signature · 1 line
2.34.1
Dave Martin
reviewerPATCH v2 24/35 x86/resctrl: Move get_config_index() to a header
In reply to Dave MartinFrom: James Morse <[email protected]>
get_config_index() is used by the architecture specific code to map a CLOSID+type pair to an index in the configuration arrays.
MPAM needs to do this too to preserve the ABI to user-space, there is no reason to do it differently.
Move the helper to a header file.
---
Changes in v2:
* Reindent resctrl_get_config_index() as per coding-style.rst rules.
* Remove redundant parentheses from arithmetic in resctrl_get_config_index(), so as to match the original source version of this moved code.
No functional change.
--- arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 19 +++---------------- include/linux/resctrl.h | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 16 deletions(-)
arch/x86/kernel/cpu/resctrl/ctrlmondata.c +3 -16
@@ -277,19 +277,6 @@ static int parse_line(char *line, struct resctrl_schema *s,return -EINVAL ; } -static u32 get_config_index (u32 closid,enum resctrl_conf_type type) -{ -switch (type) { -default : -case CDP_NONE : -return closid; -case CDP_CODE : -return closid *2 +1 ; -case CDP_DATA : -return closid *2 ; - } -} -static bool apply_config (struct rdt_hw_domain *hw_dom,struct resctrl_staged_config *cfg,u32 idx,cpumask_var_t cpu_mask)
@@ -311,7 +298,7 @@ int resctrl_arch_update_one(struct rdt_resource *r, struct rdt_domain *d, {struct rdt_hw_resource *hw_res =resctrl_to_arch_res (r);struct rdt_hw_domain *hw_dom =resctrl_to_arch_dom (d); -u32 idx =get_config_index (closid, t); +u32 idx =resctrl_get_config_index (closid, t);struct msr_param msr_param;if (!cpumask_test_cpu (smp_processor_id (), &d->cpu_mask))
@@ -351,7 +338,7 @@ int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid)if (!cfg->have_new_ctrl)continue ; - idx =get_config_index (closid, t); + idx =resctrl_get_config_index (closid, t);if (!apply_config (hw_dom, cfg, idx, cpu_mask))continue ;
@@ -476,7 +463,7 @@ u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_domain *d, u32 closid, enum resctrl_conf_type type) {struct rdt_hw_domain *hw_dom =resctrl_to_arch_dom (d); -u32 idx =get_config_index (closid, type); +u32 idx =resctrl_get_config_index (closid, type);return hw_dom->ctrl_val[idx]; }
include/linux/resctrl.h +15 -0
@@ -269,6 +269,21 @@ bool resctrl_arch_is_evt_configurable(enum resctrl_event_id evt);void resctrl_arch_mon_event_config_write (void *info);void resctrl_arch_mon_event_config_read (void *info); +/* For use by arch code to remap resctrl's smaller CDP CLOSID range */ +static inline u32 resctrl_get_config_index (u32 closid, +enum resctrl_conf_type type) +{ +switch (type) { +default : +case CDP_NONE : +return closid; +case CDP_CODE : +return closid *2 +1 ; +case CDP_DATA : +return closid *2 ; + } +} +/* * Update the ctrl_val and apply this config right now. * Must be called on one of the domain's CPUs.
Signature · 1 line
2.34.1
Dave Martin
reviewerPATCH v2 25/35 x86/resctrl: Claim get_domain_from_cpu() for resctrl
In reply to Dave MartinFrom: James Morse <[email protected]>
get_domain_from_cpu() is a handy helper that both the arch code and resctrl need to use. Rename it resctrl_get_domain_from_cpu() so it gets moved out to /fs, and exported back to the arch code.
--- arch/x86/kernel/cpu/resctrl/core.c | 15 +-------------- arch/x86/kernel/cpu/resctrl/internal.h | 1 - arch/x86/kernel/cpu/resctrl/monitor.c | 2 +- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 2 +- include/linux/resctrl.h | 19 +++++++++++++++++++ 5 files changed, 22 insertions(+), 17 deletions(-)
arch/x86/kernel/cpu/resctrl/core.c +1 -14
@@ -355,19 +355,6 @@ cat_wrmsr(struct rdt_domain *d, struct msr_param *m, struct rdt_resource *r)wrmsrl (hw_res->msr_base + i, hw_dom->ctrl_val[i]); } -struct rdt_domain *get_domain_from_cpu (int cpu,struct rdt_resource *r) -{ -struct rdt_domain *d; - -list_for_each_entry (d, &r->domains, list) { -/* Find the domain that contains this CPU */ -if (cpumask_test_cpu (cpu, &d->cpu_mask)) -return d; - } - -return NULL ; -} -u32 resctrl_arch_get_num_closid (struct rdt_resource *r) {return resctrl_to_arch_res (r)->num_closid;
@@ -381,7 +368,7 @@ void rdt_ctrl_update(void *arg)int cpu =smp_processor_id ();struct rdt_domain *d; - d =get_domain_from_cpu (cpu, r); + d =resctrl_get_domain_from_cpu (cpu, r);if (d) { hw_res->msr_update (d, m, r);return ;
arch/x86/kernel/cpu/resctrl/internal.h +0 -1
@@ -452,7 +452,6 @@ unsigned int rdtgroup_cbm_to_size(struct rdt_resource *r, struct rdt_domain *d, unsigned long cbm);enum rdtgrp_mode rdtgroup_mode_by_closid (int closid);int rdtgroup_tasks_assigned (struct rdtgroup *r); -struct rdt_domain *get_domain_from_cpu (int cpu,struct rdt_resource *r);int closids_supported (void );void closid_free (int closid);int alloc_rmid (u32 closid);
arch/x86/kernel/cpu/resctrl/monitor.c +1 -1
@@ -676,7 +676,7 @@ static void update_mba_bw(struct rdtgroup *rgrp, struct rdt_domain *dom_mbm) idx =resctrl_arch_rmid_idx_encode (closid, rmid); pmbm_data = &dom_mbm->mbm_local[idx]; - dom_mba =get_domain_from_cpu (smp_processor_id (), r_mba); + dom_mba =resctrl_get_domain_from_cpu (smp_processor_id (), r_mba);if (!dom_mba) {pr_warn_once ("Failure to get domain for MBA update\n" );return ;
arch/x86/kernel/cpu/resctrl/rdtgroup.c +1 -1
@@ -4167,7 +4167,7 @@ void resctrl_offline_cpu(unsigned int cpu)if (!l3->mon_capable) goto out_unlock; - d =get_domain_from_cpu (cpu, l3); + d =resctrl_get_domain_from_cpu (cpu, l3);if (d) {if (resctrl_is_mbm_enabled () && cpu == d->mbm_work_cpu) {cancel_delayed_work (&d->mbm_over);
include/linux/resctrl.h +19 -0
@@ -2,6 +2,7 @@#ifndef _RESCTRL_H#define _RESCTRL_H +#include <linux/cpu.h> #include <linux/kernel.h> #include <linux/list.h> #include <linux/pid.h>
@@ -284,6 +285,24 @@ static inline u32 resctrl_get_config_index(u32 closid, } } +/* +* Caller must hold the cpuhp read lock to prevent the struct rdt_domain being +* freed. +*/ +static inline struct rdt_domain * +resctrl_get_domain_from_cpu (int cpu,struct rdt_resource *r) +{ +struct rdt_domain *d; + +list_for_each_entry_rcu (d, &r->domains, list) { +/* Find the domain that contains this CPU */ +if (cpumask_test_cpu (cpu, &d->cpu_mask)) +return d; + } + +return NULL ; +} +/* * Update the ctrl_val and apply this config right now. * Must be called on one of the domain's CPUs.
Signature · 1 line
2.34.1
Dave Martin
reviewerPATCH v2 26/35 x86/resctrl: Describe resctrl's bitmap size assumptions
In reply to Dave MartinFrom: James Morse <[email protected]>
resctrl operates on configuration bitmaps and a bitmap of allocated CLOSID, both are stored in a u32.
MPAM supports configuration/portion bitmaps and PARTIDs larger than will fit in a u32.
Add some preprocessor values that make it clear why MPAM clamps some of these values. This will make it easier to find code related to these values if this resctrl behaviour ever changes.
--- include/linux/resctrl.h | 11 +++++++++++ 1 file changed, 11 insertions(+)
include/linux/resctrl.h +11 -0
@@ -26,6 +26,17 @@ int proc_resctrl_show(struct seq_file *m,/* max value for struct rdt_domain's mbps_val */ #define MBA_MAX_MBPS U32_MAX +/* +* Resctrl uses a u32 as a closid bitmap. The maximum closid is 32. +*/ +#define RESCTRL_MAX_CLOSID 32 + +/* +* Resctrl uses u32 to hold the user-space config. The maximum bitmap size is +* 32. +*/ +#define RESCTRL_MAX_CBM 32 +/** * struct pseudo_lock_region - pseudo-lock region information * @s: Resctrl schema for the resource to which this
Signature · 1 line
2.34.1
Dave Martin
reviewerPATCH v2 27/35 x86/resctrl: Rename resctrl_sched_in() to begin with "resctrl_arch_"
In reply to Dave MartinFrom: James Morse <[email protected]>
resctrl_sched_in() loads the architecture specific CPU MSRs with the CLOSID and RMID values. This function was named before resctrl was split to have architecture specific code, and generic filesystem code.
This function is obviously architecture specific, but does not begin with 'resctrl_arch_', making it the odd one out in the functions an architecture needs to support to enable resctrl.
Rename it for consistency. This is purely cosmetic.
---
Changes in v2:
* [Commit message only] Typo fix:
s/concistency/consistency/g
* [Commit message only] Clarify subject line to be less cryptic.
--- arch/x86/include/asm/resctrl.h | 4 ++-- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 12 ++++++------ arch/x86/kernel/process_32.c | 2 +- arch/x86/kernel/process_64.c | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-)
arch/x86/include/asm/resctrl.h +2 -2
@@ -177,7 +177,7 @@ static inline bool resctrl_arch_match_rmid(struct task_struct *tsk, u32 ignored,return READ_ONCE (tsk->rmid) == rmid; } -static inline void resctrl_sched_in (struct task_struct *tsk) +static inline void resctrl_arch_sched_in (struct task_struct *tsk) {if (static_branch_likely (&rdt_enable_key))__resctrl_sched_in (tsk);
@@ -220,7 +220,7 @@ void resctrl_cpu_detect(struct cpuinfo_x86 *c);#else -static inline void resctrl_sched_in (struct task_struct *tsk) {} +static inline void resctrl_arch_sched_in (struct task_struct *tsk) {}static inline void resctrl_cpu_detect (struct cpuinfo_x86 *c) {}#endif /* CONFIG_X86_CPU_RESCTRL */
arch/x86/kernel/cpu/resctrl/rdtgroup.c +6 -6
@@ -359,7 +359,7 @@ static int rdtgroup_cpus_show(struct kernfs_open_file *of, }/* -* This is safe against resctrl_sched_in() called from __switch_to() +* This is safe against resctrl_arch_sched_in() called from __switch_to() * because __switch_to() is executed with interrupts disabled. A local call * from update_closid_rmid() is protected against __switch_to() because * preemption is disabled.
@@ -378,7 +378,7 @@ void resctrl_arch_sync_cpu_closid_rmid(void *info)* executing task might have its own closid selected. Just reuse * the context switch code. */ -resctrl_sched_in (current); +resctrl_arch_sched_in (current); }/*
@@ -603,7 +603,7 @@ static void _update_task_closid_rmid(void *task)* Otherwise, the MSR is updated when the task is scheduled in. */ if (task == current) -resctrl_sched_in (task); +resctrl_arch_sched_in (task); }static void update_task_closid_rmid (struct task_struct *t)
@@ -661,7 +661,7 @@ static int __rdtgroup_move_task(struct task_struct *tsk,* Ensure the task's closid and rmid are written before determining if * the task is current that will decide if it will be interrupted. * This pairs with the full barrier between the rq->curr update and -* resctrl_sched_in() during context switch. +* resctrl_arch_sched_in() during context switch. */ smp_mb ();
@@ -2945,8 +2945,8 @@ static void rdt_move_group_tasks(struct rdtgroup *from, struct rdtgroup *to,/* * Order the closid/rmid stores above before the loads * in task_curr(). This pairs with the full barrier -* between the rq->curr update and resctrl_sched_in() -* during context switch. +* between the rq->curr update and +* resctrl_arch_sched_in() during context switch. */ smp_mb ();
arch/x86/kernel/process_32.c +1 -1
@@ -211,7 +211,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)switch_fpu_finish (next_p);/* Load the Intel cache allocation PQR MSR. */ -resctrl_sched_in (next_p); +resctrl_arch_sched_in (next_p);return prev_p; }
arch/x86/kernel/process_64.c +1 -1
@@ -707,7 +707,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p) }/* Load the Intel cache allocation PQR MSR. */ -resctrl_sched_in (next_p); +resctrl_arch_sched_in (next_p);return prev_p; }
Signature · 1 line
2.34.1
Dave Martin
reviewerPATCH v2 28/35 x86/resctrl: Drop __init/__exit on assorted symbols
In reply to Dave MartinFrom: James Morse <[email protected]>
Because ARM's MPAM controls are probed using MMIO, resctrl can't be initialised until enough CPUs are online to have determined the system-wide supported num_closid. Arm64 also supports 'late onlined secondaries', where only a subset of CPUs are online during boot.
These two combine to mean the MPAM driver may not be able to initialise resctrl until user-space has brought 'enough' CPUs online.
To allow MPAM to initialise resctrl after __init text has been free'd, remove all the __init markings from resctrl.
The existing __exit markings cause these functions to be removed by the linker as it has never been possible to build resctrl as a module. MPAM has an error interrupt which causes the driver to reset and disable itself. Remove the __exit markings to allow the MPAM driver to tear down resctrl when an error occurs.
--- arch/x86/kernel/cpu/resctrl/internal.h | 2 +- arch/x86/kernel/cpu/resctrl/monitor.c | 4 ++-- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 8 ++++---- include/linux/resctrl.h | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-)
arch/x86/kernel/cpu/resctrl/internal.h +1 -1
@@ -457,7 +457,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 resctrl_mon_resource_exit(void); +void resctrl_mon_resource_exit (void );bool rdt_cpu_has (int flag);void mon_event_count (void *info);int rdtgroup_mondata_show (struct seq_file *m,void *arg);
arch/x86/kernel/cpu/resctrl/monitor.c +2 -2
@@ -954,7 +954,7 @@ static int dom_data_init(struct rdt_resource *r)return err; } -static void __exit dom_data_exit(struct rdt_resource *r) +static void dom_data_exit (struct rdt_resource *r) {if (!r->mon_capable)return ;
@@ -1076,7 +1076,7 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r)return 0 ; } -void __exit resctrl_mon_resource_exit(void) +void resctrl_mon_resource_exit (void ) {struct rdt_resource *r =resctrl_arch_get_resource (RDT_RESOURCE_L3 );
arch/x86/kernel/cpu/resctrl/rdtgroup.c +4 -4
@@ -2067,7 +2067,7 @@ static struct rftype *rdtgroup_get_rftype_by_name(const char *name)return NULL ; } -static void __init thread_throttle_mode_init (void ) +static void thread_throttle_mode_init (void ) {struct rdt_resource *r =resctrl_arch_get_resource (RDT_RESOURCE_MBA );struct rftype *rft;
@@ -3999,7 +3999,7 @@ static void rdtgroup_destroy_root(void) rdtgroup_default.kn =NULL ; } -static void __init rdtgroup_setup_default (void ) +static void rdtgroup_setup_default (void ) {mutex_lock (&rdtgroup_mutex);
@@ -4192,7 +4192,7 @@ void resctrl_offline_cpu(unsigned int cpu)* * Return: 0 on success or -errno */ -int __init resctrl_init (void ) +int resctrl_init (void ) {int ret =0 ;
@@ -4246,7 +4246,7 @@ int __init resctrl_init(void)return ret; } -void __exit resctrl_exit(void) +void resctrl_exit (void ) {debugfs_remove_recursive (debugfs_resctrl);unregister_filesystem (&rdt_fs_type);
include/linux/resctrl.h +2 -2
@@ -404,7 +404,7 @@ void resctrl_arch_reset_rmid_all(struct rdt_resource *r, struct rdt_domain *d);extern unsigned int resctrl_rmid_realloc_threshold;extern unsigned int resctrl_rmid_realloc_limit; -int __init resctrl_init (void ); -void __exit resctrl_exit(void); +int resctrl_init (void ); +void resctrl_exit (void );#endif /* _RESCTRL_H */
Signature · 1 line
2.34.1
Dave Martin
reviewerPATCH v2 29/35 fs/resctrl: Add boiler plate for external resctrl code
In reply to Dave MartinFrom: James Morse <[email protected]>
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 depend on this.
---
FYI: Dave Martin, James Morse (et al.):
* Review the new Kconfig RESCTRL_FS help text.
* Because RESCTRL_FS combines a userspace interface and a kernel library providing services to its own backends, there is a circular dependency between this option and the arch-specific options (CONFIG_X86_RESCTRL and eventually CONFIG_ARM64_MPAM) that nastifies the presentation of these options in Kconfig.
Can this be improved?
The current situation works, but is not very user-friendly for menuconfig users.
Changes in v2:
* Rename new file psuedo_lock.c to pseudo_lock.c, to match the name of the original file (and to be less surprising).
* [Whitespace only] Under RESCTRL_FS in fs/resctrl/Kconfig, delete alignment space in orphaned select ... if (which has nothing to line up with any more).
* [Whitespace only] Reflow and re-tab Kconfig additions.
--- MAINTAINERS | 1 + arch/Kconfig | 8 ++++++++ arch/x86/Kconfig | 10 +++------- fs/Kconfig | 1 + fs/Makefile | 1 + fs/resctrl/Kconfig | 36 ++++++++++++++++++++++++++++++++++++ fs/resctrl/Makefile | 3 +++ fs/resctrl/ctrlmondata.c | 0 fs/resctrl/internal.h | 0 fs/resctrl/monitor.c | 0 fs/resctrl/pseudo_lock.c | 0 fs/resctrl/rdtgroup.c | 0 include/linux/resctrl.h | 4 ++++ 13 files changed, 57 insertions(+), 7 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/pseudo_lock.c create mode 100644 fs/resctrl/rdtgroup.c
MAINTAINERS +1 -0
@@ -18543,6 +18543,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/
arch/Kconfig +8 -0
@@ -1406,6 +1406,14 @@ config STRICT_MODULE_RWX config ARCH_HAS_PHYS_TO_DMA bool +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
arch/x86/Kconfig +3 -7
@@ -479,8 +479,10 @@ config GOLDFISH config X86_CPU_RESCTRL bool "x86 CPU resource control support" depends on X86 && (CPU_SUP_INTEL || CPU_SUP_AMD) + depends on MISC_FILESYSTEMS select KERNFS - select PROC_CPU_RESCTRL if PROC_FS + select ARCH_HAS_CPU_RESCTRL + select RESCTRL_FS select RESCTRL_FS_PSEUDO_LOCK help Enable x86 CPU resource control support.
@@ -507,12 +509,6 @@ config X86_FRED ring transitions and exception/interrupt handling if the system supports. -config RESCTRL_FS_PSEUDO_LOCK - bool - help - Software mechanism to pin data in a cache portion using - micro-architecture specific knowledge. - if X86_32 config X86_BIGSMP bool "Support for big SMP systems with more than 8 CPUs"
fs/Kconfig +1 -0
@@ -331,6 +331,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/sysv/Kconfig"
fs/Makefile +1 -0
@@ -129,3 +129,4 @@ obj-$(CONFIG_EFIVAR_FS) += efivarfs/ obj-$(CONFIG_EROFS_FS) += erofs/ obj-$(CONFIG_VBOXSF_FS) += vboxsf/ obj-$(CONFIG_ZONEFS_FS) += zonefs/ +obj-$(CONFIG_RESCTRL_FS) += resctrl/
fs/resctrl/Kconfig new file +36 -0
@@ -0,0 +1,36 @@ +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. + + If unsure, it is safe to say N. + + See <file:Documentation/arch/x86/resctrl.rst> for more information. + +config RESCTRL_FS_PSEUDO_LOCK + bool + help + Software mechanism to pin data in a cache portion using + micro-architecture specific knowledge. + +config RESCTRL_RMID_DEPENDS_ON_CLOSID + bool + help + Enable by the architecture when the RMID values depend on the CLOSID. + This causes the closid allocator to search for CLOSID with clean + RMID.
fs/resctrl/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0 +obj-$(CONFIG_RESCTRL_FS) += rdtgroup.o ctrlmondata.o monitor.o +obj-$(CONFIG_RESCTRL_FS_PSEUDO_LOCK) += pseudo_lock.o
fs/resctrl/ctrlmondata.c new file +0 -0
fs/resctrl/internal.h new file +0 -0
fs/resctrl/monitor.c new file +0 -0
fs/resctrl/pseudo_lock.c new file +0 -0
fs/resctrl/rdtgroup.c new file +0 -0
include/linux/resctrl.h +4 -0
@@ -8,6 +8,10 @@#include <linux/pid.h> #include <linux/resctrl_types.h> +#ifdef CONFIG_ARCH_HAS_CPU_RESCTRL +#include <asm/resctrl.h> +#endif +/* CLOSID, RMID value used by the default control group */ #define RESCTRL_RESERVED_CLOSID 0#define RESCTRL_RESERVED_RMID 0
Signature · 1 line
2.34.1
James Morse
reviewerRe: [PATCH v2 29/35] fs/resctrl: Add boiler plate for external resctrl code
Hi Dave,
Quoted 17 lines · Dave Martin
From: James Morse <[email protected]>
Add
MakefileandKconfigfor fs/resctrl. AddARCH_HAS_CPU_RESCTRLfor the common parts of the resctrl interface and makeX86_CPU_RESCTRLdepend on this.FYI: Dave Martin, James Morse (et al.):
* Review the new
KconfigRESCTRL_FShelp text.* Because
RESCTRL_FScombines a userspace interface and a kernel library providing services to its own backends, there is a circular dependency between this option and the arch-specific options (CONFIG_X86_RESCTRLand eventuallyCONFIG_ARM64_MPAM) that nastifies the presentation of these options inKconfig.
Quoted 4 lines
Can this be improved?
The current situation works, but is not very user-friendly for menuconfig users.
I don't follow what the circular dependency is - Kconfig would bark if there was one.
I agree its odd that you can't disable the filesystem under the filesystem menu - but that is so that the existing Kconfig symbol name remains the switch for this. It's possible no-one cares about that...
A more obvious approach would be a switch for the arch hardware feature, that when enabled allows the filesystem to be selected. This seems overkill as there is only one user.
Thanks,
James
Dave Martin
reviewerPATCH v2 30/35 x86/resctrl: Squelch whitespace anomalies in resctrl core code
In reply to Dave Martincheckpatch.pl complains about some whitespace anomalies in the resctrl core code.
This doesn't matter, but since this code is about to be factored out and made generic, this is a good opportunity to fix these issues and so reduce future checkpatch fuzz.
Fix them.
No functional change.
---
Changes in v2:
* New patch.
--- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
arch/x86/kernel/cpu/resctrl/rdtgroup.c +5 -7
@@ -991,7 +991,7 @@ static int rdt_num_closids_show(struct kernfs_open_file *of, }static int rdt_default_ctrl_show (struct kernfs_open_file *of, -struct seq_file *seq,void *v) +struct seq_file *seq,void *v) {struct resctrl_schema *s = of->kn->parent->priv;struct rdt_resource *r = s->res;
@@ -1001,7 +1001,7 @@ static int rdt_default_ctrl_show(struct kernfs_open_file *of, }static int rdt_min_cbm_bits_show (struct kernfs_open_file *of, -struct seq_file *seq,void *v) +struct seq_file *seq,void *v) {struct resctrl_schema *s = of->kn->parent->priv;struct rdt_resource *r = s->res;
@@ -1117,7 +1117,7 @@ static int rdt_bit_usage_show(struct kernfs_open_file *of, }static int rdt_min_bw_show (struct kernfs_open_file *of, -struct seq_file *seq,void *v) +struct seq_file *seq,void *v) {struct resctrl_schema *s = of->kn->parent->priv;struct rdt_resource *r = s->res;
@@ -1152,7 +1152,7 @@ static int rdt_mon_features_show(struct kernfs_open_file *of, }static int rdt_bw_gran_show (struct kernfs_open_file *of, -struct seq_file *seq,void *v) +struct seq_file *seq,void *v) {struct resctrl_schema *s = of->kn->parent->priv;struct rdt_resource *r = s->res;
@@ -1162,7 +1162,7 @@ static int rdt_bw_gran_show(struct kernfs_open_file *of, }static int rdt_delay_linear_show (struct kernfs_open_file *of, -struct seq_file *seq,void *v) +struct seq_file *seq,void *v) {struct resctrl_schema *s = of->kn->parent->priv;struct rdt_resource *r = s->res;
@@ -2017,7 +2017,6 @@ static struct rftype res_common_files[] = { .seq_show = rdtgroup_closid_show, .fflags = RFTYPE_CTRL_BASE | RFTYPE_DEBUG, }, - };static int rdtgroup_add_files (struct kernfs_node *kn,unsigned long fflags)
@@ -3420,7 +3419,6 @@ static int rdtgroup_init_alloc(struct rdtgroup *rdtgrp)rdt_last_cmd_puts ("Failed to initialize allocations\n" ); goto out; } - } rdtgrp->mode =RDT_MODE_SHAREABLE ;
Signature · 1 line
2.34.1
Dave Martin
reviewerPATCH v2 31/35 x86/resctrl: Prefer alloc(sizeof(*foo)) idiom in rdt_init_fs_context()
In reply to Dave Martinrdt_init_fs_context() sizes a typed allocation using an explicit sizeof(type) expression, which checkpatch.pl complains about.
Since this code is about to be factored out and made generic, this is a good opportunity to fix the code to size the allocation based on the target pointer instead, to reduce the chance of future mis- maintenance.
Fix it.
No functional change.
---
Changes in v2:
* New patch.
--- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/resctrl/rdtgroup.c +1 -1
@@ -2860,7 +2860,7 @@ static int rdt_init_fs_context(struct fs_context *fc) {struct rdt_fs_context *ctx; - ctx =kzalloc (sizeof (struct rdt_fs_context ),GFP_KERNEL ); + ctx =kzalloc (sizeof (*ctx),GFP_KERNEL );if (!ctx)return -ENOMEM ;
Signature · 1 line
2.34.1
Dave Martin
reviewerPATCH v2 32/35 x86/resctrl: Relax some asm #includes
In reply to Dave Martincheckpatch.pl identifies some direct #includes of asm headers that can be satisfied by including the corresponding <linux/...> header instead.
Fix them.
No intentional functional change.
---
Changes in v2:
* New patch.
--- arch/x86/kernel/cpu/resctrl/internal.h | 3 +-- arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 4 ++-- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-)
arch/x86/kernel/cpu/resctrl/internal.h +1 -2
@@ -7,10 +7,9 @@#include <linux/kernfs.h> #include <linux/fs_context.h> #include <linux/jump_label.h> +#include <linux/resctrl.h> #include <linux/tick.h> -#include <asm/resctrl.h> -#define L3_QOS_CDP_ENABLE 0x01ULL#define L2_QOS_CDP_ENABLE 0x01ULL
arch/x86/kernel/cpu/resctrl/pseudo_lock.c +2 -2
@@ -11,6 +11,7 @@#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt +#include <linux/cacheflush.h> #include <linux/cacheinfo.h> #include <linux/cpu.h> #include <linux/cpumask.h>
@@ -19,12 +20,11 @@#include <linux/mman.h> #include <linux/perf_event.h> #include <linux/pm_qos.h> +#include <linux/resctrl.h> #include <linux/slab.h> #include <linux/uaccess.h> -#include <asm/cacheflush.h> #include <asm/intel-family.h> -#include <asm/resctrl.h> #include <asm/perf_event.h> #include "../../events/perf_event.h" /* For X86_CONFIG() */
arch/x86/kernel/cpu/resctrl/rdtgroup.c +1 -1
@@ -19,6 +19,7 @@#include <linux/fs_parser.h> #include <linux/sysfs.h> #include <linux/kernfs.h> +#include <linux/resctrl.h> #include <linux/seq_buf.h> #include <linux/seq_file.h> #include <linux/sched/signal.h>
@@ -29,7 +30,6 @@#include <uapi/linux/magic.h> -#include <asm/resctrl.h> #include "internal.h" DEFINE_STATIC_KEY_FALSE (rdt_enable_key);
Signature · 1 line
2.34.1
Dave Martin
reviewerPATCH v2 33/35 x86/resctrl: Move the filesystem bits to headers visible to fs/resctrl
In reply to Dave MartinFrom: James Morse <[email protected]>
Once the filesystem parts of resctrl move to fs/resctrl, it cannot rely on definitions in x86's internal.h.
Move definitions in internal.h that need to be shared between the filesystem and architecture code to header files that fs/resctrl can include.
Doing this separately means the filesystem code only moves between files of the same name, instead of having these changes mixed in too.
---
FYI: James Morse (et al.):
* This patch needs review to see how many of the x86-specific definitions really ought to be exported...
* The resctrl_types.h header should have a comment explaining its content and purpose (once we have that nailed down).
Changes in v2:
* Revert apparently unintentional duplication of a couple of variable declarations in <linux/resctrl.h>.
No functional change.
--- arch/x86/include/asm/resctrl.h | 3 +++ arch/x86/kernel/cpu/resctrl/core.c | 5 ++++ arch/x86/kernel/cpu/resctrl/internal.h | 36 -------------------------- include/linux/resctrl_types.h | 30 +++++++++++++++++++++ 4 files changed, 38 insertions(+), 36 deletions(-)
arch/x86/include/asm/resctrl.h +3 -0
@@ -218,6 +218,9 @@ int resctrl_arch_measure_l2_residency(void *_plr);int resctrl_arch_measure_l3_residency (void *_plr);void resctrl_cpu_detect (struct cpuinfo_x86 *c); +bool resctrl_arch_get_cdp_enabled (enum resctrl_res_level l); +int resctrl_arch_set_cdp_enabled (enum resctrl_res_level l,bool enable); +#else static inline void resctrl_arch_sched_in (struct task_struct *tsk) {}
arch/x86/kernel/cpu/resctrl/core.c +5 -0
@@ -306,6 +306,11 @@ static void rdt_get_cdp_l2_config(void)rdt_get_cdp_config (RDT_RESOURCE_L2 ); } +bool resctrl_arch_get_cdp_enabled (enum resctrl_res_level l) +{ +return rdt_resources_all[l].cdp_enabled; +} +static void mba_wrmsr_amd (struct rdt_domain *d,struct msr_param *m,struct rdt_resource *r) {
arch/x86/kernel/cpu/resctrl/internal.h +0 -36
@@ -14,12 +14,6 @@#define L2_QOS_CDP_ENABLE 0x01ULL -#define CQM_LIMBOCHECK_INTERVAL 1000 - -#define MBM_CNTR_WIDTH_BASE 24 -#define MBM_OVERFLOW_INTERVAL 1000 -#define MAX_MBA_BW 100u -#define MBA_IS_LINEAR 0x4#define MBM_CNTR_WIDTH_OFFSET_AMD 20#define RMID_VAL_ERROR BIT_ULL(63)
@@ -209,29 +203,6 @@ struct rdtgroup {struct pseudo_lock_region *plr; }; -/* rdtgroup.flags */ -#define RDT_DELETED 1 - -/* rftype.flags */ -#define RFTYPE_FLAGS_CPUS_LIST 1 - -/* -* Define the file type flags for base and info directories. -*/ -#define RFTYPE_INFO BIT(0) -#define RFTYPE_BASE BIT(1) -#define RFTYPE_CTRL BIT(4) -#define RFTYPE_MON BIT(5) -#define RFTYPE_TOP BIT(6) -#define RFTYPE_RES_CACHE BIT(8) -#define RFTYPE_RES_MB BIT(9) -#define RFTYPE_DEBUG BIT(10) -#define RFTYPE_CTRL_INFO (RFTYPE_INFO | RFTYPE_CTRL) -#define RFTYPE_MON_INFO (RFTYPE_INFO | RFTYPE_MON) -#define RFTYPE_TOP_INFO (RFTYPE_INFO | RFTYPE_TOP) -#define RFTYPE_CTRL_BASE (RFTYPE_BASE | RFTYPE_CTRL) -#define RFTYPE_MON_BASE (RFTYPE_BASE | RFTYPE_MON) -/* List of all resource groups */ extern struct list_head rdt_all_groups;
@@ -369,13 +340,6 @@ static inline struct rdt_resource *resctrl_inc(struct rdt_resource *res)return &hw_res->r_resctrl; } -static inline bool resctrl_arch_get_cdp_enabled (enum resctrl_res_level l) -{ -return rdt_resources_all[l].cdp_enabled; -} - -int resctrl_arch_set_cdp_enabled (enum resctrl_res_level l,bool enable); -/* * To return the common struct rdt_resource, which is contained in struct * rdt_hw_resource, walk the resctrl member of struct rdt_hw_resource.
include/linux/resctrl_types.h +30 -0
@@ -7,6 +7,36 @@#ifndef __LINUX_RESCTRL_TYPES_H#define __LINUX_RESCTRL_TYPES_H +#define CQM_LIMBOCHECK_INTERVAL 1000 + +#define MBM_CNTR_WIDTH_BASE 24 +#define MBM_OVERFLOW_INTERVAL 1000 +#define MAX_MBA_BW 100u +#define MBA_IS_LINEAR 0x4 + +/* rdtgroup.flags */ +#define RDT_DELETED 1 + +/* rftype.flags */ +#define RFTYPE_FLAGS_CPUS_LIST 1 + +/* +* Define the file type flags for base and info directories. +*/ +#define RFTYPE_INFO BIT(0) +#define RFTYPE_BASE BIT(1) +#define RFTYPE_CTRL BIT(4) +#define RFTYPE_MON BIT(5) +#define RFTYPE_TOP BIT(6) +#define RFTYPE_RES_CACHE BIT(8) +#define RFTYPE_RES_MB BIT(9) +#define RFTYPE_DEBUG BIT(10) +#define RFTYPE_CTRL_INFO (RFTYPE_INFO | RFTYPE_CTRL) +#define RFTYPE_MON_INFO (RFTYPE_INFO | RFTYPE_MON) +#define RFTYPE_TOP_INFO (RFTYPE_INFO | RFTYPE_TOP) +#define RFTYPE_CTRL_BASE (RFTYPE_BASE | RFTYPE_CTRL) +#define RFTYPE_MON_BASE (RFTYPE_BASE | RFTYPE_MON) +/* Reads to Local DRAM Memory */ #define READS_TO_LOCAL_MEM BIT(0)
Signature · 1 line
2.34.1
Dave Martin
reviewerPATCH v2 34/35 x86/resctrl: Move the resctrl filesystem code to /fs/resctrl
In reply to Dave MartinFrom: James Morse <[email protected]>
resctrl is linux's defacto interface for managing cache and bandwidth policies for groups of tasks.
To allow other architectures to make use of this pseudo filesystem, move it to live in /fs/resctrl instead of /arch/x86.
This move leaves behind the parts of resctrl that form the architecture interface for x86.
---
FYI: James Morse (et al.):
* This patch has been manually rebased on top of other changes to the series and needs to be rebuilt.
* Break this patch up into smaller patches, if this can be done without adding excessive temporary glue to the constituent patches.
Changes in v2:
* [Commit message only]: Typo fix:
s/more it live/move it to live/
--- arch/x86/kernel/cpu/resctrl/core.c | 15 - arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 505 --- arch/x86/kernel/cpu/resctrl/internal.h | 310 -- arch/x86/kernel/cpu/resctrl/monitor.c | 821 ---- arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 1093 ------ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 4288 +-------------------- fs/resctrl/ctrlmondata.c | 527 +++ fs/resctrl/internal.h | 340 ++ fs/resctrl/monitor.c | 843 ++++ fs/resctrl/pseudo_lock.c | 1122 ++++++ fs/resctrl/rdtgroup.c | 4013 +++++++++++++++++++ 11 files changed, 6992 insertions(+), 6885 deletions(-)
arch/x86/kernel/cpu/resctrl/core.c +0 -15
@@ -164,21 +164,6 @@ static inline void cache_alloc_hsw_probe(void) rdt_alloc_capable = true; } -bool is_mba_sc (struct rdt_resource *r) -{ -if (!r) - r =resctrl_arch_get_resource (RDT_RESOURCE_MBA ); - -/* -* The software controller support is only applicable to MBA resource. -* Make sure to check for resource type. -*/ -if (r->rid !=RDT_RESOURCE_MBA ) -return false; - -return r->membw.mba_sc; -} -/* * rdt_get_mb_table() - get a mapping of bandwidth(b/w) percentage values * exposed to user interface and the h/w understandable delay values.
arch/x86/kernel/cpu/resctrl/ctrlmondata.c +0 -505
520 lines not on this page · raw message
arch/x86/kernel/cpu/resctrl/internal.h +0 -310
333 lines not on this page · raw message
arch/x86/kernel/cpu/resctrl/monitor.c +0 -821
851 lines not on this page · raw message
arch/x86/kernel/cpu/resctrl/pseudo_lock.c +0 -1093
1,114 lines not on this page · raw message
arch/x86/kernel/cpu/resctrl/rdtgroup.c +147 -4141
161 lines not on this page · raw message
fs/resctrl/ctrlmondata.c +527 -0
527 lines not on this page · raw message
fs/resctrl/internal.h +340 -0
340 lines not on this page · raw message
fs/resctrl/monitor.c +843 -0
843 lines not on this page · raw message
fs/resctrl/pseudo_lock.c +1122 -0
1,122 lines not on this page · raw message
fs/resctrl/rdtgroup.c +4013 -0
4,013 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.34.1
Part of the diff is not shown here. View the raw message.
Dave Martin
reviewerPATCH v2 35/35 x86/resctrl: Move the resctrl filesystem code to /fs/resctrl
In reply to Dave MartinRelax asm #includes identified by checkpatch.pl as satisfiable by a <linux/> include in the destination files of this code move.
---
FYI: James Morse (et al.):
* This patch is kept separate for now so that these changes do not get lost when rebuilding the previous code-movement patch.
It should be folded into the previous patch or dropped once the series is final.
Changes in v2:
* New patch.
--- fs/resctrl/internal.h | 2 -- fs/resctrl/pseudo_lock.c | 4 ++-- fs/resctrl/rdtgroup.c | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-)
fs/resctrl/internal.h +0 -2
@@ -9,8 +9,6 @@#include <linux/jump_label.h> #include <linux/tick.h> -#include <asm/resctrl.h> -/** * cpumask_any_housekeeping() - Choose any CPU in @mask, preferring those that * aren't marked nohz_full
fs/resctrl/pseudo_lock.c +2 -2
@@ -11,6 +11,7 @@#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt +#include <linux/cacheflush.h> #include <linux/cacheinfo.h> #include <linux/cpu.h> #include <linux/cpumask.h>
@@ -19,11 +20,10 @@#include <linux/mman.h> #include <linux/perf_event.h> #include <linux/pm_qos.h> +#include <linux/resctrl.h> #include <linux/slab.h> #include <linux/uaccess.h> -#include <asm/cacheflush.h> -#include <asm/resctrl.h> #include <asm/perf_event.h> #include "internal.h"
fs/resctrl/rdtgroup.c +1 -1
@@ -19,6 +19,7 @@#include <linux/fs_parser.h> #include <linux/sysfs.h> #include <linux/kernfs.h> +#include <linux/resctrl.h> #include <linux/seq_buf.h> #include <linux/seq_file.h> #include <linux/sched/signal.h>
@@ -29,7 +30,6 @@#include <uapi/linux/magic.h> -#include <asm/resctrl.h> #include "internal.h" /* Mutex to protect rdtgroup access. */
Signature · 1 line
2.34.1
Hi Dave (and James),
Quoted 138 lines · Dave Martin
Hi all,
This is a respin of the resctrl refactoring series described below, addressing review feedback. Many thanks to those to responded with feedback on the v1 series [2].
See Notes and FYIs in the individual patches for details on the changes and outstanding issues.
This series has not been rebased since the v1 posting, and remains based on the following upstream commit:
commit
23956900041d968f9ad0f30db6dede4daccd7aa9
Merge tag 'v6.9-rc-smb3-server-fixes' ofgit://git.samba.org/ksmbdThe actual code changes against v1 are few in number and rather spread around. For reviewer convenience, a diff against v1 is appended to this cover letter.
Due to the limited code changes, this series has *not* received any additional runtime testing over than done for v1 (other than build bisect testing).
Cheers
---Dave[2] v1 series:
[PATCH v1 00/31] x86/resctrl: Move the resctrl filesystem code to /fs/resctrl
https://lore.kernel.org/all/[email protected]/--8<-- Original blurb
This is the final series that allows other architectures to implement resctrl. The last patch just moves the code, and its a bit of a monster. I don't expect that to get merged as part of this series - we should wait for it to make less impact on other series. It's included here to show what gets moved, and that structures/function-prototypes have the right visibility.
Otherwise this series renames functions and moves code around. With the exception of invalid configurations for the configurable-events, there should be no changes in behaviour caused by this series.
The driving pattern is to make things like struct rdtgroup private to resctrl. Features like pseudo-lock aren't going to work on arm64, the ability to disable it at compile time is added.
After this, I can start posting the MPAM driver to make use of resctrl on arm64. (What's MPAM? See the cover letter of the first series. [1])
This series is based on Linus' commit
23956900041dand can be retrieved from:
https://git.kernel.org/pub/scm/linux/kernel/git/morse/linux.git
mpam/move_to_fs/v1Sorry for the mid-merge window base, I'm away for a few weeks - this should rebase trivially onto rc1.
As ever - bugs welcome,
Thanks,James
[1] https://lore.kernel.org/lkml/[email protected]/
-->8--
Dave Martin (4):
x86/resctrl: Squelch whitespace anomalies in resctrl core code x86/resctrl: Prefer alloc(sizeof(*foo)) idiom inrdt_init_fs_context()x86/resctrl: Relax some asm #includes
[SQUASHME] x86/resctrl: Move the resctrl filesystem code to
/fs/resctrlJames Morse (31):
x86/resctrl: Fix allocation of cleanest CLOSID on platforms with no
monitors
x86/resctrl: Add a helper to avoid reaching into the arch code
resource list
x86/resctrl: Move ctrlval string parsing policy away from the arch
code
x86/resctrl: Add helper for setting CPU default properties x86/resctrl: Remove rdtgroup fromupdate_cpu_closid_rmid()x86/resctrl: Export resctrl fs's init function x86/resctrl: Wrapresctrl_arch_find_domain()aroundrdt_find_domain()x86/resctrl: Move resctrl types to a separate header x86/resctrl: Add a resctrl helper to reset all the resources x86/resctrl: Move monitor init work to a resctrl init call x86/resctrl: Move monitor exit work to a resctrl exit call x86/resctrl: Move max_{name,data}_width into resctrl code x86/resctrl: Stop using the for_each_*_rdt_resource() walkers x86/resctrl: Export the is_mbm_*_enabled() helpers toasm/resctrl.hx86/resctrl: Addresctrl_arch_is_evt_configurable()to abstract BMEC x86/resctrl: Change mon_event_config_{read,write}() to be arch helpers x86/resctrl: Movembm_cfg_maskto structrdt_resourcex86/resctrl: Allowresctrl_arch_mon_event_config_write()to return an
error
x86/resctrl: Addresctrl_arch_prefix to pseudo lock functions x86/resctrl: Allow an architecture to disable pseudo lock x86/resctrl: Makeprefetch_disable_bitsbelong to the arch code x86/resctrl: Makeresctrl_arch_pseudo_lock_fn()take a plr x86/resctrl: Movethread_throttle_mode_init()to be managed by resctrl x86/resctrl: Moveget_config_index()to a header x86/resctrl: Claimget_domain_from_cpu()for resctrl x86/resctrl: Describe resctrl's bitmap size assumptions x86/resctrl: Renameresctrl_sched_in()to begin with "resctrl_arch_" x86/resctrl: Drop __init/__exit on assorted symbols fs/resctrl: Add boiler plate for external resctrl code x86/resctrl: Move the filesystem bits to headers visible to fs/resctrl x86/resctrl: Move the resctrl filesystem code to /fs/resctrlMAINTAINERS | 2 + arch/Kconfig | 8 + arch/x86/Kconfig | 5 +- arch/x86/include/asm/resctrl.h | 45 +- arch/x86/kernel/cpu/resctrl/Makefile | 5 +- arch/x86/kernel/cpu/resctrl/core.c | 119 +- arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 506 +-- arch/x86/kernel/cpu/resctrl/internal.h | 436 +-- arch/x86/kernel/cpu/resctrl/monitor.c | 813 +--- arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 1130 +----- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 4205 +-------------------- arch/x86/kernel/process_32.c | 2 +- arch/x86/kernel/process_64.c | 2 +- fs/Kconfig | 1 + fs/Makefile | 1 + fs/resctrl/Kconfig | 36 + fs/resctrl/Makefile | 3 + fs/resctrl/ctrlmondata.c | 527 +++ fs/resctrl/internal.h | 338 ++ fs/resctrl/monitor.c | 843 +++++ fs/resctrl/pseudo_lock.c | 1122 ++++++ fs/resctrl/rdtgroup.c | 4013 ++++++++++++++++++++ include/linux/resctrl.h | 157 +- include/linux/resctrl_types.h | 98 + 24 files changed, 7402 insertions(+), 7015 deletions(-)
Quoted 8 lines
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/pseudo_lock.c create mode 100644 fs/resctrl/rdtgroup.c create mode 100644 include/linux/resctrl_types.h
I was able to build a kernel with the changes and ran through our internal suite of functional tests on the following implementations:
- AMD EPYC 7B12 64-Core Processor
- Intel(R) Xeon(R) Platinum 8581C
and the results looked good.
Thanks!
Dave Martin
reviewerHi Peter,
Quoted 153 lines · Peter Newman
Hi Dave (and James),
Quoted 138 lines · Dave Martin
Hi all,
This is a respin of the resctrl refactoring series described below, addressing review feedback. Many thanks to those to responded with feedback on the v1 series [2].
See Notes and FYIs in the individual patches for details on the changes and outstanding issues.
This series has not been rebased since the v1 posting, and remains based on the following upstream commit:
commit
23956900041d968f9ad0f30db6dede4daccd7aa9
Merge tag 'v6.9-rc-smb3-server-fixes' ofgit://git.samba.org/ksmbdThe actual code changes against v1 are few in number and rather spread around. For reviewer convenience, a diff against v1 is appended to this cover letter.
Due to the limited code changes, this series has *not* received any additional runtime testing over than done for v1 (other than build bisect testing).
Cheers
---Dave[2] v1 series:
[PATCH v1 00/31] x86/resctrl: Move the resctrl filesystem code to /fs/resctrl
https://lore.kernel.org/all/[email protected]/--8<-- Original blurb
This is the final series that allows other architectures to implement resctrl. The last patch just moves the code, and its a bit of a monster. I don't expect that to get merged as part of this series - we should wait for it to make less impact on other series. It's included here to show what gets moved, and that structures/function-prototypes have the right visibility.
Otherwise this series renames functions and moves code around. With the exception of invalid configurations for the configurable-events, there should be no changes in behaviour caused by this series.
The driving pattern is to make things like struct rdtgroup private to resctrl. Features like pseudo-lock aren't going to work on arm64, the ability to disable it at compile time is added.
After this, I can start posting the MPAM driver to make use of resctrl on arm64. (What's MPAM? See the cover letter of the first series. [1])
This series is based on Linus' commit
23956900041dand can be retrieved from:
https://git.kernel.org/pub/scm/linux/kernel/git/morse/linux.git
mpam/move_to_fs/v1Sorry for the mid-merge window base, I'm away for a few weeks - this should rebase trivially onto rc1.
As ever - bugs welcome,
Thanks,James
[1] https://lore.kernel.org/lkml/[email protected]/
-->8--
Dave Martin (4):
x86/resctrl: Squelch whitespace anomalies in resctrl core code x86/resctrl: Prefer alloc(sizeof(*foo)) idiom inrdt_init_fs_context()x86/resctrl: Relax some asm #includes
[SQUASHME] x86/resctrl: Move the resctrl filesystem code to
/fs/resctrlJames Morse (31):
x86/resctrl: Fix allocation of cleanest CLOSID on platforms with no
monitors
x86/resctrl: Add a helper to avoid reaching into the arch code
resource list
x86/resctrl: Move ctrlval string parsing policy away from the arch
code
x86/resctrl: Add helper for setting CPU default properties x86/resctrl: Remove rdtgroup fromupdate_cpu_closid_rmid()x86/resctrl: Export resctrl fs's init function x86/resctrl: Wrapresctrl_arch_find_domain()aroundrdt_find_domain()x86/resctrl: Move resctrl types to a separate header x86/resctrl: Add a resctrl helper to reset all the resources x86/resctrl: Move monitor init work to a resctrl init call x86/resctrl: Move monitor exit work to a resctrl exit call x86/resctrl: Move max_{name,data}_width into resctrl code x86/resctrl: Stop using the for_each_*_rdt_resource() walkers x86/resctrl: Export the is_mbm_*_enabled() helpers toasm/resctrl.hx86/resctrl: Addresctrl_arch_is_evt_configurable()to abstract BMEC x86/resctrl: Change mon_event_config_{read,write}() to be arch helpers x86/resctrl: Movembm_cfg_maskto structrdt_resourcex86/resctrl: Allowresctrl_arch_mon_event_config_write()to return an
error
x86/resctrl: Addresctrl_arch_prefix to pseudo lock functions x86/resctrl: Allow an architecture to disable pseudo lock x86/resctrl: Makeprefetch_disable_bitsbelong to the arch code x86/resctrl: Makeresctrl_arch_pseudo_lock_fn()take a plr x86/resctrl: Movethread_throttle_mode_init()to be managed by resctrl x86/resctrl: Moveget_config_index()to a header x86/resctrl: Claimget_domain_from_cpu()for resctrl x86/resctrl: Describe resctrl's bitmap size assumptions x86/resctrl: Renameresctrl_sched_in()to begin with "resctrl_arch_" x86/resctrl: Drop __init/__exit on assorted symbols fs/resctrl: Add boiler plate for external resctrl code x86/resctrl: Move the filesystem bits to headers visible to fs/resctrl x86/resctrl: Move the resctrl filesystem code to /fs/resctrlMAINTAINERS | 2 + arch/Kconfig | 8 + arch/x86/Kconfig | 5 +- arch/x86/include/asm/resctrl.h | 45 +- arch/x86/kernel/cpu/resctrl/Makefile | 5 +- arch/x86/kernel/cpu/resctrl/core.c | 119 +- arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 506 +-- arch/x86/kernel/cpu/resctrl/internal.h | 436 +-- arch/x86/kernel/cpu/resctrl/monitor.c | 813 +--- arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 1130 +----- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 4205 +-------------------- arch/x86/kernel/process_32.c | 2 +- arch/x86/kernel/process_64.c | 2 +- fs/Kconfig | 1 + fs/Makefile | 1 + fs/resctrl/Kconfig | 36 + fs/resctrl/Makefile | 3 + fs/resctrl/ctrlmondata.c | 527 +++ fs/resctrl/internal.h | 338 ++ fs/resctrl/monitor.c | 843 +++++ fs/resctrl/pseudo_lock.c | 1122 ++++++ fs/resctrl/rdtgroup.c | 4013 ++++++++++++++++++++ include/linux/resctrl.h | 157 +- include/linux/resctrl_types.h | 98 + 24 files changed, 7402 insertions(+), 7015 deletions(-)Quoted 8 lines
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/pseudo_lock.c create mode 100644 fs/resctrl/rdtgroup.c create mode 100644 include/linux/resctrl_types.hI was able to build a kernel with the changes and ran through our internal suite of functional tests on the following implementations:
Quoted 9 lines
- AMD EPYC 7B12 64-Core Processor
- Intel(R) Xeon(R) Platinum 8581Cand the results looked good.
Tested-by Peter Newman <[email protected]>Thanks!
Great, thanks for the testing!
Cheers
---Dave
Reinette Chatre
maintainerHi Dave,
Quoted 6 lines · Dave Martin
This is a respin of the resctrl refactoring series described below, addressing review feedback. Many thanks to those to responded with feedback on the v1 series [2].
See Notes and FYIs in the individual patches for details on the changes and outstanding issues.
What are your expectations regarding this series while considering [1] and [2]?
Reinette
[1] https://lore.kernel.org/lkml/ZiE8%[email protected]/
[2] https://lore.kernel.org/lkml/[email protected]/
Dave Martin
reviewerHi Reinette,
Quoted 10 lines · Reinette Chatre
Hi Dave,
Quoted 6 lines · Dave Martin
This is a respin of the resctrl refactoring series described below, addressing review feedback. Many thanks to those to responded with feedback on the v1 series [2].
See Notes and FYIs in the individual patches for details on the changes and outstanding issues.
Quoted 7 lines
What are your expectations regarding this series while considering [1] and [2]?
Reinette
[1] https://lore.kernel.org/lkml/ZiE8%[email protected]/
[2] https://lore.kernel.org/lkml/[email protected]/
I plan to propose a reworked version of the fflags and string parser stuff, and take a look at the other more minor outstanding issues.
The series does need rebasing, but otherwise I don't anticipate much change to the code from the Arm side unless there are further review comments.
Do you have a preference on how this series should proceed?
Cheers
---Dave
Reinette Chatre
maintainerHi Dave,
Quoted 17 lines · Dave Martin
Quoted 8 lines · Reinette Chatre
Quoted 6 lines · Dave Martin
This is a respin of the resctrl refactoring series described below, addressing review feedback. Many thanks to those to responded with feedback on the v1 series [2].
See Notes and FYIs in the individual patches for details on the changes and outstanding issues.
Quoted 7 lines
What are your expectations regarding this series while considering [1] and [2]?
Reinette
[1] https://lore.kernel.org/lkml/ZiE8%[email protected]/
[2] https://lore.kernel.org/lkml/[email protected]/
Quoted 8 lines
I plan to propose a reworked version of the fflags and string parser stuff, and take a look at the other more minor outstanding issues.
The series does need rebasing, but otherwise I don't anticipate much change to the code from the Arm side unless there are further review comments.
Do you have a preference on how this series should proceed?
I believe that I already answered this question in [2], hence my confusion about this posting.
Reinette
Dave Martin
reviewerHi Reinette,
Apologies for the slow response...
Quoted 27 lines · Reinette Chatre
Hi Dave,
Quoted 24 lines · Dave Martin
Quoted 8 lines · Reinette Chatre
Quoted 6 lines · Dave Martin
This is a respin of the resctrl refactoring series described below, addressing review feedback. Many thanks to those to responded with feedback on the v1 series [2].
See Notes and FYIs in the individual patches for details on the changes and outstanding issues.
Quoted 7 lines
What are your expectations regarding this series while considering [1] and [2]?
Reinette
[1] https://lore.kernel.org/lkml/ZiE8%[email protected]/
[2] https://lore.kernel.org/lkml/[email protected]/I plan to propose a reworked version of the fflags and string parser stuff, and take a look at the other more minor outstanding issues.
The series does need rebasing, but otherwise I don't anticipate much change to the code from the Arm side unless there are further review comments.
Quoted 6 lines
Quoted 1 line
Do you have a preference on how this series should proceed?
I believe that I already answered this question in [2], hence my confusion about this posting.
Reinette
I guess James and I need to tidy up the loose ends and repost this.
I'm hoping we can get a v3 out over the next few weeks or so.
Cheers
---Dave
Quoted 34 lines · Dave Martin
Hi Reinette,
Apologies for the slow response...
Quoted 29 lines · Reinette Chatre
Hi Dave,
Quoted 25 lines · Dave Martin
Quoted 8 lines · Reinette Chatre
Quoted 6 lines · Dave Martin
This is a respin of the resctrl refactoring series described below, addressing review feedback. Many thanks to those to responded with feedback on the v1 series [2].
See Notes and FYIs in the individual patches for details on the changes and outstanding issues.
Quoted 7 lines
What are your expectations regarding this series while considering [1] and [2]?
Reinette
[1] https://lore.kernel.org/lkml/ZiE8%[email protected]/
[2] https://lore.kernel.org/lkml/[email protected]/I plan to propose a reworked version of the fflags and string parser stuff, and take a look at the other more minor outstanding issues.
The series does need rebasing, but otherwise I don't anticipate much change to the code from the Arm side unless there are further review comments.
Do you have a preference on how this series should proceed?
Quoted 8 lines
Quoted 4 lines
I believe that I already answered this question in [2], hence my confusion about this posting.
Reinette
I guess James and I need to tidy up the loose ends and repost this.
I'm hoping we can get a v3 out over the next few weeks or so.
Finally having more time to review this (I hope ...) does it make sense to review this v2 or wait for v3?
Signature · 3 lines
Cheers, David / dhildenb
Dave Martin
reviewerHi David,
Quoted 38 lines · David Hildenbrand
Quoted 37 lines · Dave Martin
Hi Reinette,
Apologies for the slow response...
Quoted 32 lines · Reinette Chatre
Hi Dave,
Quoted 17 lines · Dave Martin
Quoted 8 lines · Reinette Chatre
Quoted 6 lines · Dave Martin
This is a respin of the resctrl refactoring series described below, addressing review feedback. Many thanks to those to responded with feedback on the v1 series [2].
See Notes and FYIs in the individual patches for details on the changes and outstanding issues.
Quoted 7 lines
What are your expectations regarding this series while considering [1] and [2]?
Reinette
[1] https://lore.kernel.org/lkml/ZiE8%[email protected]/
[2] https://lore.kernel.org/lkml/[email protected]/Quoted 8 lines
I plan to propose a reworked version of the fflags and string parser stuff, and take a look at the other more minor outstanding issues.
The series does need rebasing, but otherwise I don't anticipate much change to the code from the Arm side unless there are further review comments.
Do you have a preference on how this series should proceed?
I believe that I already answered this question in [2], hence my confusion about this posting.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Reinette
I guess James and I need to tidy up the loose ends and repost this.
I'm hoping we can get a v3 out over the next few weeks or so.
Finally having more time to review this (I hope ...) does it make sense to review this v2 or wait for v3?
It's up to you. All review is appreciated, but v2 mostly dealt with minor cosmetic cleanups, and as Reinette highlights, there are few more significant changes pending.
So, it may be a better use of your time if you wait for v3 and review it then.
Cheers
---Dave
Hello Dave,James
I ran resctrl selftest on Intel(R) Xeon(R) Gold 6254 CPU, there is no problem.
Best regards,
Shaopeng TAN
James Morse
reviewerHello,
Quoted 2 lines · Shaopeng Tan (Fujitsu)
I ran resctrl selftest on Intel(R) Xeon(R) Gold 6254 CPU, there is no problem.
Thanks for the testing!
James