x86/resctrl: Move the resctrl filesystem code to /fs/resctrl
Subsystems (4)
James Morse
reviewerv9 cover x86/resctrl: Move the resctrl filesystem code to /fs/resctrl
Changes since v8:
* Added check for closid_init() on monitor only platforms.
* Moved end-marker into array and added default cases.
* Additional patches to move prototpyes between header files.
Changes otherwise noted on each patch.
---
Patches 20-26 should be squashed together when merged, taking the commit message of patch 21. They are posted like this to allow folk to re-generate patch 21, then review the differences on top. Not squashing them together would expose a ftrace build warning during bisect. (but who does that!)
That would look like this:git://git.kernel.org/pub/scm/linux/kernel/git/morse/linux.git mpam/move_to_fs/v9_final
This series is based on rc3, and can be retrieved from:git://git.kernel.org/pub/scm/linux/kernel/git/morse/linux.git mpam/move_to_fs/v9
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. It is now possible for throttle_mode to report 'undefined', but no known platform will do this.
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])
As ever - bugs welcome,
Thanks,
James
[v8] https://lore.kernel.org/all/[email protected]
[v7] https://lore.kernel.org/all/[email protected]/
[v6] https://lore.kernel.org/lkml/[email protected]/
[v5] https://lore.kernel.org/r/[email protected]
[v4] https://lore.kernel.org/all/[email protected]/
[v3] https://lore.kernel.org/r/[email protected]
[v2] https://lore.kernel.org/r/[email protected]
[v1] https://lore.kernel.org/r/[email protected]
[1] https://lore.kernel.org/lkml/[email protected]/
Amit Singh Tomar (1):
x86/resctrl: Remove the limit on the number of CLOSID
Dave Martin (3):
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
James Morse (23):
x86/resctrl: Rename resctrl_sched_in() to begin with "resctrl_arch_" x86/resctrl: Check all domains are offline in resctrl_exit() x86/resctrl: resctrl_exit() teardown resctrl but leave the mount point x86/resctrl: Drop __init/__exit on assorted symbols x86/resctrl: Move is_mba_sc() out of core.c
x86/resctrl: Add end-marker to the resctrl_event_id enum x86/resctrl: Expand the width of domid by replacing mon_data_bits x86/resctrl: Split trace.h
x86/resctrl: Add 'resctrl' to the title of the resctrl documentation fs/resctrl: Add boiler plate for external resctrl code x86/resctrl: Move the filesystem bits to headers visible to fs/resctrl x86/resctrl: Move enum resctrl_event_id to resctrl.h x86/resctrl: Fix types in resctrl_arch_mon_ctx_alloc() and free stubs x86/resctrl: Move pseudo lock prototypes to include/linux/resctrl.h x86/resctrl: Always initialise rid field in rdt_resources_all[] x86/resctrl: Remove a newline to avoid confusing the code move script x86/resctrl: Add python script to move resctrl code to /fs/resctrl x86,fs/resctrl: Move the resctrl filesystem code to live in
/fs/resctrl
x86,fs/resctrl: Remove duplicated trace header files fs/resctrl: Remove unnecessary includes
fs/resctrl: Change internal.h's header guard macros x86,fs/resctrl: Move resctrl.rst to live under
Documentation/filesystems
MAINTAINERS: Add reviewers for fs/resctrl
Documentation/arch/x86/index.rst | 1 -
Documentation/filesystems/index.rst | 1 +
.../{arch/x86 => filesystems}/resctrl.rst | 6 +-
MAINTAINERS | 5 +-
arch/Kconfig | 8 +
arch/x86/Kconfig | 11 +-
arch/x86/include/asm/resctrl.h | 15 +-
arch/x86/kernel/cpu/resctrl/Makefile | 2 +
arch/x86/kernel/cpu/resctrl/core.c | 31 +-
arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 635 ---
arch/x86/kernel/cpu/resctrl/internal.h | 399 +-
arch/x86/kernel/cpu/resctrl/monitor.c | 918 +---
arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 1092 +----
.../resctrl/{trace.h => pseudo_lock_trace.h} | 26 +-
arch/x86/kernel/cpu/resctrl/rdtgroup.c | 4164 +---------------
arch/x86/kernel/process_32.c | 2 +-
arch/x86/kernel/process_64.c | 2 +-
fs/Kconfig | 1 +
fs/Makefile | 1 +
fs/resctrl/Kconfig | 39 +
fs/resctrl/Makefile | 6 +
fs/resctrl/ctrlmondata.c | 660 +++
fs/resctrl/internal.h | 440 ++
fs/resctrl/monitor.c | 929 ++++
fs/resctrl/monitor_trace.h | 33 +
fs/resctrl/pseudo_lock.c | 1105 +++++
fs/resctrl/rdtgroup.c | 4344 +++++++++++++++++
include/linux/resctrl.h | 36 +-
include/linux/resctrl_types.h | 16 +-
resctrl_copy_pasta.py | 823 ++++
30 files changed, 8490 insertions(+), 7261 deletions(-)
rename Documentation/{arch/x86 => filesystems}/resctrl.rst (99%)
rename arch/x86/kernel/cpu/resctrl/{trace.h => pseudo_lock_trace.h} (56%)
create mode 100644 fs/resctrl/Kconfig
create mode 100644 fs/resctrl/Makefile
create mode 100644 fs/resctrl/ctrlmondata.c
create mode 100644 fs/resctrl/internal.h
create mode 100644 fs/resctrl/monitor.c
create mode 100644 fs/resctrl/monitor_trace.h
create mode 100644 fs/resctrl/pseudo_lock.c
create mode 100644 fs/resctrl/rdtgroup.c
create mode 100644 resctrl_copy_pasta.pySignature · 1 line
2.39.5
James Morse
reviewerPATCH v9 1/27 x86/resctrl: Remove the limit on the number of CLOSID
From: Amit Singh Tomar <[email protected]>
Resctrl allocates and finds free CLOSID values using the bits of a u32. This restricts the number of control groups that can be created by user-space.
MPAM has an architectural limit of 2^16 CLOSID values, Intel x86 could be extended beyond 32 values. There is at least one MPAM platform which supports more than 32 CLOSID values.
Replace the fixed size bitmap with calls to the bitmap API to allocate an array of a sufficient size.
ffs() returns '1' for bit 0, hence the existing code subtracts 1 from the index to get the CLOSID value. find_first_bit() returns the bit number which does not need adjusting.
[ morse: fixed the off-by-one in the allocator and the wrong
not-found value. Removed the limit. Rephrase the commit message. ]
---
Changes since v8:
* Added check for closid_init() on monitor only platforms.
Changes since v7:
* Moved closid_exit() earlier in rdt_kill_sb() to match what rdt_get_tree() does.
Changes since v6:
* Set variable to NULL after kfree()ing it.
* Call closid_exit() from rdt_kill_sb() to prevent a memory leak.
Changes since v5:
* This patch got pulled into this series.
--- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 51 ++++++++++++++++++-------- 1 file changed, 35 insertions(+), 16 deletions(-)
arch/x86/kernel/cpu/resctrl/rdtgroup.c +35 -16
@@ -130,8 +130,8 @@ static bool resctrl_is_mbm_event(int e) }/* -* Trivial allocator for CLOSIDs. Since h/w only supports a small number, -* we can keep a bitmap of free CLOSIDs in a single integer. +* Trivial allocator for CLOSIDs. Use BITMAP APIs to manipulate a bitmap +* of free CLOSIDs. * * Using a global CLOSID across all resources has some advantages and * some drawbacks:
@@ -144,7 +144,7 @@ static bool resctrl_is_mbm_event(int e)* - Our choices on how to configure each resource become progressively more * limited as the number of resources grows. */ -static unsigned long closid_free_map; +static unsigned long *closid_free_map;static int closid_free_map_len;int closids_supported (void )
@@ -152,20 +152,35 @@ int closids_supported(void)return closid_free_map_len; } -static void closid_init (void ) +static int closid_init (void ) {struct resctrl_schema *s; -u32 rdt_min_closid =32 ; +u32 rdt_min_closid = ~0 ; + +/* Monitor only platforms still call closid_init() */ +if (list_empty (&resctrl_schema_all)) +return 0 ;/* Compute rdt_min_closid across all resources */ list_for_each_entry (s, &resctrl_schema_all, list) rdt_min_closid =min (rdt_min_closid, s->num_closid); - closid_free_map =BIT_MASK (rdt_min_closid) -1 ; + closid_free_map =bitmap_alloc (rdt_min_closid,GFP_KERNEL ); +if (!closid_free_map) +return -ENOMEM ; +bitmap_fill (closid_free_map, rdt_min_closid);/* RESCTRL_RESERVED_CLOSID is always reserved for the default group */ -__clear_bit (RESCTRL_RESERVED_CLOSID , &closid_free_map); +__clear_bit (RESCTRL_RESERVED_CLOSID , closid_free_map); closid_free_map_len = rdt_min_closid; + +return 0 ; +} + +static void closid_exit (void ) +{ +bitmap_free (closid_free_map); + closid_free_map =NULL ; }static int closid_alloc (void )
@@ -182,12 +197,11 @@ static int closid_alloc(void)return cleanest_closid; closid = cleanest_closid; }else { - closid =ffs (closid_free_map); -if (closid ==0 ) + closid =find_first_bit (closid_free_map, closid_free_map_len); +if (closid == closid_free_map_len)return -ENOSPC ; - closid--; } -__clear_bit (closid, &closid_free_map); +__clear_bit (closid, closid_free_map);return closid; }
@@ -196,7 +210,7 @@ void closid_free(int closid) {lockdep_assert_held (&rdtgroup_mutex); -__set_bit (closid, &closid_free_map); +__set_bit (closid, closid_free_map); }/**
@@ -210,7 +224,7 @@ bool closid_allocated(unsigned int closid) {lockdep_assert_held (&rdtgroup_mutex); -return !test_bit (closid, &closid_free_map); +return !test_bit (closid, closid_free_map); }/**
@@ -2765,20 +2779,22 @@ static int rdt_get_tree(struct fs_context *fc) goto out_ctx; } -closid_init (); + ret =closid_init (); +if (ret) + goto out_schemata_free;if (resctrl_arch_mon_capable ()) flags |=RFTYPE_MON ; ret =rdtgroup_add_files (rdtgroup_default.kn, flags);if (ret) - goto out_schemata_free; + goto out_closid_exit;kernfs_activate (rdtgroup_default.kn); ret =rdtgroup_create_info_dir (rdtgroup_default.kn);if (ret <0 ) - goto out_schemata_free; + goto out_closid_exit;if (resctrl_arch_mon_capable ()) { ret = mongroup_create_dir(rdtgroup_default.kn,
@@ -2829,6 +2845,8 @@ static int rdt_get_tree(struct fs_context *fc)kernfs_remove (kn_mongrp); out_info:kernfs_remove (kn_info); +out_closid_exit: +closid_exit (); out_schemata_free:schemata_list_destroy (); out_ctx:
@@ -3076,6 +3094,7 @@ static void rdt_kill_sb(struct super_block *sb)rmdir_all_sub ();rdt_pseudo_lock_release (); rdtgroup_default.mode =RDT_MODE_SHAREABLE ; +closid_exit ();schemata_list_destroy ();rdtgroup_destroy_root ();if (resctrl_arch_alloc_capable ())
Signature · 1 line
2.39.5
James Morse
reviewerPATCH v9 2/27 x86/resctrl: Rename resctrl_sched_in() to begin with "resctrl_arch_"
In reply to James Morseresctrl_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.
--- 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
@@ -175,7 +175,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);
@@ -212,7 +212,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
@@ -376,7 +376,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.
@@ -395,7 +395,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); }/*
@@ -620,7 +620,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)
@@ -678,7 +678,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 ();
@@ -2994,8 +2994,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.39.5
James Morse
reviewerPATCH v9 3/27 x86/resctrl: Check all domains are offline in resctrl_exit()
In reply to James Morseresctrl_exit() removes things like the resctrl mount point directory and unregisters the filesystem prior to freeing data structures that were allocated during resctrl_init().
This assumes that there are no online domains when resctrl_exit() is called. If any domain were online, the limbo or overflow handler could be scheduled to run.
Add a check for any online control or monitor domains, and document that the architecture code is required to do this.
---
Changes since v8:
* This patch is new.
--- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
arch/x86/kernel/cpu/resctrl/rdtgroup.c +24 -0
@@ -4420,8 +4420,32 @@ int __init resctrl_init(void)return ret; } +static bool __exit resctrl_online_domains_exist(void) +{ +struct rdt_resource *r; + +for_each_rdt_resource (r) { +if (!list_empty (&r->ctrl_domains) || !list_empty (&r->mon_domains)) +return true; + } + +return false; +} + +/* +* resctrl_exit() - Remove the resctrl filesystem and free resources. +* +* When called by the architecture code, all CPUs and resctrl domains must be +* offline. This ensures the limbo and overflow handlers are not scheduled to +* run, meaning the data structures they access can be freed by +* resctrl_mon_resource_exit(). +*/ void __exit resctrl_exit(void) { +cpus_read_lock (); +WARN_ON_ONCE (resctrl_online_domains_exist ()); +cpus_read_unlock (); +debugfs_remove_recursive (debugfs_resctrl);unregister_filesystem (&rdt_fs_type);sysfs_remove_mount_point (fs_kobj,"resctrl" );
Signature · 1 line
2.39.5
Reinette Chatre
maintainerRe: [PATCH v9 03/27] x86/resctrl: Check all domains are offline in resctrl_exit()
Hi James,
Quoted 10 lines · James Morse
resctrl_exit()removes things like the resctrl mount point directory and unregisters the filesystem prior to freeing data structures that were allocated duringresctrl_init().This assumes that there are no online domains when
resctrl_exit()is called. If any domain were online, the limbo or overflow handler could be scheduled to run.Add a check for any online control or monitor domains, and document that the architecture code is required to do this.
nit: It may not be obvious at this point what "this" means. Above could be:
Add a check for any online control or monitor domains, and document that the architecture code is required to offline all monitor and control domains before calling resctrl_exit().
Quoted 6 lines
Suggested-by Reinette Chatre <[email protected]>Signed-off-by James Morse <[email protected]>---
Changes since v8:
* This patch is new.
Thank you for adding this.
Quoted 9 lines
--- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)arch/x86/kernel/cpu/resctrl/rdtgroup.c +0
-0
arch/x86/kernel/cpu/resctrl/rdtgroup.c int __init resctrl_init(void) · line 4428
Quoted 9 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +6
-0@@ -4420,8 +4420,32 @@ int __init resctrl_init(void)return ret; } +static bool __exit resctrl_online_domains_exist(void) +{ +struct rdt_resource *r; + +for_each_rdt_resource (r) { +if (!list_empty (&r->ctrl_domains) || !list_empty (&r->mon_domains))
A list needs to be initialized for list_empty() to behave as intended. A list within an uninitialized or "kzalloc()'ed" struct will not be considered empty. resctrl_arch_get_resource() as used by for_each_rdt_resource() already establishes that if an architecture does not support a particular resource then it can (should?) return a "dummy/not-capable" resource. I do not think resctrl should require anything additionally like initializing the lists of a dummy/not-capable resource to support things like this loop.
Considering this, could this be made more specific? For example,
for_each_alloc_capable_rdt_resource(r) {
if (!list_empty(&r->ctrl_domains))
return true;
}
for_each_mon_capable_rdt_resource(r) {
if (!list_empty(&r->mon_domains))
return true;
}Quoted 13 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +13
-0+return true; + } + +return false; +} + +/* +* resctrl_exit() - Remove the resctrl filesystem and free resources. +* +* When called by the architecture code, all CPUs and resctrl domains must be +* offline. This ensures the limbo and overflow handlers are not scheduled to +* run, meaning the data structures they access can be freed by +* resctrl_mon_resource_exit().
arch/x86/kernel/cpu/resctrl/rdtgroup.c int __init resctrl_init(void) · line 4451
Quoted 10 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +5
-0+*/ void __exit resctrl_exit(void) { +cpus_read_lock (); +WARN_ON_ONCE (resctrl_online_domains_exist ()); +cpus_read_unlock (); +debugfs_remove_recursive (debugfs_resctrl);unregister_filesystem (&rdt_fs_type);sysfs_remove_mount_point (fs_kobj,"resctrl" );
Thank you.
Reinette
James Morse
reviewerPATCH v9 4/27 x86/resctrl: resctrl_exit() teardown resctrl but leave the mount point
In reply to James Morseresctrl_exit() was intended for use when the 'resctrl' module was unloaded. resctrl can't be built as a module, and the kernfs helpers are not exported so this is unlikely to change. MPAM has an error interrupt which indicates the MPAM driver has gone haywire. Should this occur tasks could run with the wrong control values, leading to bad performance for important tasks. In this scenario the MPAM driver will reset the hardware, but it needs a way to tell resctrl that no further configuration should be attempted.
In particular, moving tasks between control or monitor groups does not interact with the architecture code, so there is no opportunity for the arch code to indicate that the hardware is no-longer functioning.
Using resctrl_exit() for this leaves the system in a funny state as resctrl is still mounted, but cannot be un-mounted because the sysfs directory that is typically used has been removed. Dave Martin suggests this may cause systemd trouble in the future as not all filesystems can be unmounted.
Add calls to remove all the files and directories in resctrl, and remove the sysfs_remove_mount_point() call that leaves the system in a funny state. When triggered, this causes all the resctrl files to disappear. resctrl can be unmounted, but not mounted again.
---
Changes since v8:
* Call resctrl_fs_teardown() under cpuhp lock, for good measure.
* Set debugfs_resctrl to NULL to be robust against a second call.
* Added more documentation commentary.
* Moved some words around to change the tone.
Changes since v7:
* Moved kernfs cleanup functions to resctrl_fs_teardown(), and call this from rescrl_exit().
* Added description of MPAM resetting the hardware to the commit message.
Changes since v6:
* Added kdoc and comment to resctrl_exit().
Changes since v5:
* Serialise rdtgroup_destroy_root() against umount().
* Check rdtgroup_default.kn to protect against duplicate calls.
--- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 48 +++++++++++++++++++++----- 1 file changed, 40 insertions(+), 8 deletions(-)
arch/x86/kernel/cpu/resctrl/rdtgroup.c +40 -8
@@ -3078,6 +3078,22 @@ static void rmdir_all_sub(void)kernfs_remove (kn_mondata); } +static void resctrl_fs_teardown (void ) +{ +lockdep_assert_held (&rdtgroup_mutex); + +/* Cleared by rdtgroup_destroy_root() */ +if (!rdtgroup_default.kn) +return ; + +rmdir_all_sub (); +rdt_pseudo_lock_release (); + rdtgroup_default.mode =RDT_MODE_SHAREABLE ; +closid_exit (); +schemata_list_destroy (); +rdtgroup_destroy_root (); +} +static void rdt_kill_sb (struct super_block *sb) {struct rdt_resource *r;
@@ -3091,12 +3107,7 @@ static void rdt_kill_sb(struct super_block *sb)for_each_alloc_capable_rdt_resource (r)resctrl_arch_reset_all_ctrls (r); -rmdir_all_sub (); -rdt_pseudo_lock_release (); - rdtgroup_default.mode =RDT_MODE_SHAREABLE ; -closid_exit (); -schemata_list_destroy (); -rdtgroup_destroy_root (); +resctrl_fs_teardown ();if (resctrl_arch_alloc_capable ())resctrl_arch_disable_alloc ();if (resctrl_arch_mon_capable ())
@@ -4127,6 +4138,8 @@ static int rdtgroup_setup_root(struct rdt_fs_context *ctx)static void rdtgroup_destroy_root (void ) { +lockdep_assert_held (&rdtgroup_mutex); +kernfs_destroy_root (rdt_root); rdtgroup_default.kn =NULL ; }
@@ -4432,23 +4445,42 @@ static bool __exit resctrl_online_domains_exist(void)return false; } -/* +/** * resctrl_exit() - Remove the resctrl filesystem and free resources. * +* Called by the architecture code in response to a fatal error. +* Removes resctrl files and structures from kernfs to prevent further +* configuration. +* * When called by the architecture code, all CPUs and resctrl domains must be * offline. This ensures the limbo and overflow handlers are not scheduled to * run, meaning the data structures they access can be freed by * resctrl_mon_resource_exit(). +* +* After this function has returned, the architecture code should return an +* from all resctrl_arch_ functions that can do this. +* resctrl_arch_get_resource() must continue to return struct rdt_resources +* with the correct rid field to ensure the filesystem can be unmounted. */ void __exit resctrl_exit(void) {cpus_read_lock ();WARN_ON_ONCE (resctrl_online_domains_exist ()); + +mutex_lock (&rdtgroup_mutex); +resctrl_fs_teardown (); +mutex_unlock (&rdtgroup_mutex); +cpus_read_unlock ();debugfs_remove_recursive (debugfs_resctrl); + debugfs_resctrl =NULL ;unregister_filesystem (&rdt_fs_type); -sysfs_remove_mount_point (fs_kobj,"resctrl" ); + +/* +* Do not remove the sysfs mount point added by resctrl_init() so that +* it can be used to umount resctrl. +*/ resctrl_mon_resource_exit (); }
Signature · 1 line
2.39.5
Reinette Chatre
maintainerRe: [PATCH v9 04/27] x86/resctrl: resctrl_exit() teardown resctrl but leave the mount point
Hi James,
arch/x86/kernel/cpu/resctrl/rdtgroup.c static bool __exit resctrl_online_domains_exist(void) · line 4448
Quoted 6 lines · James Morse
arch/x86/kernel/cpu/resctrl/rdtgroup.c +1
-1@@ -4432,23 +4445,42 @@ static bool __exit resctrl_online_domains_exist(void)return false; } -/* +/**
Why make the switch to kernel-doc now? The benefit is not clear considering resctrl_init() is not using kernel-doc.
arch/x86/kernel/cpu/resctrl/rdtgroup.c static bool __exit resctrl_online_domains_exist(void) · line 4460
Quoted 12 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +6
-0* resctrl_exit() - Remove the resctrl filesystem and free resources. * +* Called by the architecture code in response to a fatal error. +* Removes resctrl files and structures from kernfs to prevent further +* configuration. +* * When called by the architecture code, all CPUs and resctrl domains must be * offline. This ensures the limbo and overflow handlers are not scheduled to * run, meaning the data structures they access can be freed by * resctrl_mon_resource_exit(). +* +* After this function has returned, the architecture code should return an
nit: "After this function has returned," -> "After resctrl_exit() returns, "
"should return an" -> "should return an error"?
arch/x86/kernel/cpu/resctrl/rdtgroup.c static bool __exit resctrl_online_domains_exist(void) · line 4463
Quoted 3 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +3
-0+* from all resctrl_arch_ functions that can do this. +* resctrl_arch_get_resource() must continue to return struct rdt_resources +* with the correct rid field to ensure the filesystem can be unmounted.
Is this to get through set_mba_sc() and the for_each_alloc_capable_rdt_resource(r) loop in rdt_kill_sb() or is there something more subtle?
Quoted 14 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +6
-0*/ void __exit resctrl_exit(void) {cpus_read_lock ();WARN_ON_ONCE (resctrl_online_domains_exist ()); + +mutex_lock (&rdtgroup_mutex); +resctrl_fs_teardown (); +mutex_unlock (&rdtgroup_mutex); +cpus_read_unlock ();debugfs_remove_recursive (debugfs_resctrl); + debugfs_resctrl =NULL ;
arch/x86/kernel/cpu/resctrl/rdtgroup.c static bool __exit resctrl_online_domains_exist(void) · line 4486
Quoted 10 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +5
-1unregister_filesystem (&rdt_fs_type); -sysfs_remove_mount_point (fs_kobj,"resctrl" ); + +/* +* Do not remove the sysfs mount point added by resctrl_init() so that +* it can be used to umount resctrl. +*/ resctrl_mon_resource_exit (); }
Looks good to me.
Thank you.
Reinette
James Morse
reviewerRe: [PATCH v9 04/27] x86/resctrl: resctrl_exit() teardown resctrl but leave the mount point
Hi Reinette,
Quoted 10 lines · Reinette Chatre
arch/x86/kernel/cpu/resctrl/rdtgroup.c static bool __exit resctrl_online_domains_exist(void) · line 4448
Quoted 6 lines · James Morse
arch/x86/kernel/cpu/resctrl/rdtgroup.c +1
-1@@ -4432,23 +4445,42 @@ static bool __exit resctrl_online_domains_exist(void)return false; } -/* +/** Why make the switch to kernel-doc now? The benefit is not clear considering
resctrl_init()is not using kernel-doc.
Just the ratcheting of 'add a comment' eventually leading to 'put it in kernel-doc' once the comment becomes sufficiently long.
Quoted 13 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c static bool __exit resctrl_online_domains_exist(void) · line 4460
Quoted 12 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +6
-0* resctrl_exit() - Remove the resctrl filesystem and free resources. * +* Called by the architecture code in response to a fatal error. +* Removes resctrl files and structures from kernfs to prevent further +* configuration. +* * When called by the architecture code, all CPUs and resctrl domains must be * offline. This ensures the limbo and overflow handlers are not scheduled to * run, meaning the data structures they access can be freed by * resctrl_mon_resource_exit(). +* +* After this function has returned, the architecture code should return an
Quoted 1 line
nit: "After this function has returned," -> "After
resctrl_exit()returns, "
Sure,
Quoted 1 line
"should return an" -> "should return an error"?
Fixed, thanks!
Quoted 6 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c static bool __exit resctrl_online_domains_exist(void) · line 4463
Quoted 3 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +3
-0+* from all resctrl_arch_ functions that can do this. +* resctrl_arch_get_resource() must continue to return struct rdt_resources +* with the correct rid field to ensure the filesystem can be unmounted. Is this to get through
set_mba_sc()and thefor_each_alloc_capable_rdt_resource(r)loop inrdt_kill_sb()or is there something more subtle?
The for_each walkers, which may also get used by the arch code. I don't have an example of where this would go wrong, but felt it was worth noting that resctrl_arch_get_resource() should not return NULL for all possible resources in this case - resctrl doesn't expect that for any entry in the enum. Adding that error handling was too noisy, given that today x86 has all the resources.
Tony suggested that get changed to searching a list if the list of possible resources starts to grow.
Quoted 22 lines
Quoted 22 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +11
-1*/ void __exit resctrl_exit(void) {cpus_read_lock ();WARN_ON_ONCE (resctrl_online_domains_exist ()); + +mutex_lock (&rdtgroup_mutex); +resctrl_fs_teardown (); +mutex_unlock (&rdtgroup_mutex); +cpus_read_unlock ();debugfs_remove_recursive (debugfs_resctrl); + debugfs_resctrl =NULL ;unregister_filesystem (&rdt_fs_type); -sysfs_remove_mount_point (fs_kobj,"resctrl" ); + +/* +* Do not remove the sysfs mount point added by resctrl_init() so that +* it can be used to umount resctrl. +*/
Quoted 4 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c static bool __exit resctrl_online_domains_exist(void) · line 4486
Quoted 2 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +0
-0resctrl_mon_resource_exit (); }Looks good to me.
Thanks!
James
Reinette Chatre
maintainerRe: [PATCH v9 04/27] x86/resctrl: resctrl_exit() teardown resctrl but leave the mount point
Hi James,
Quoted 8 lines · James Morse
Hi Reinette,
Quoted 5 lines · Reinette Chatre
Quoted 4 lines · James Morse
arch/x86/kernel/cpu/resctrl/rdtgroup.c +0
-0@@ -4432,23 +4445,42 @@ static bool __exit resctrl_online_domains_exist(void)return false; }
Quoted 8 lines
Quoted 5 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c static bool __exit resctrl_online_domains_exist(void) · line 4448
Quoted 2 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +1
-1-/* +/** Why make the switch to kernel-doc now? The benefit is not clear considering
resctrl_init()is not using kernel-doc.Just the ratcheting of 'add a comment' eventually leading to 'put it in kernel-doc' once the comment becomes sufficiently long.
I see. Not something to pick on since resctrl surely is not consistent in this regard.
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +3
-0+* from all resctrl_arch_ functions that can do this. +* resctrl_arch_get_resource() must continue to return struct rdt_resources +* with the correct rid field to ensure the filesystem can be unmounted.
Quoted 8 lines
Quoted 2 lines
Is this to get through
set_mba_sc()and thefor_each_alloc_capable_rdt_resource(r)loop inrdt_kill_sb()or is there something more subtle?The
for_eachwalkers, which may also get used by the arch code. I don't have an example of where this would go wrong, but felt it was worth noting thatresctrl_arch_get_resource()should not return NULL for all possible resources in this case - resctrl doesn't expect that for any entry in the enum. Adding that error handling was too noisy, given that today x86 has all the resources.
I see. I also find resctrl_arch_get_resource()'s comment in include/linux/resctrl.h supportive of this. Having the extra note here is enforces this requirement.
Quoted 4 lines
Tony suggested that get changed to searching a list if the list of possible resources starts to grow.
ack.
Reinette
James Morse
reviewerPATCH v9 5/27 x86/resctrl: Drop __init/__exit on assorted symbols
In reply to James MorseBecause 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.
---
Changes since v8:
* Removed __exit from a new symbol.
Changes since v4:
* Earlier __init marker removal migrated here.
--- arch/x86/kernel/cpu/resctrl/core.c | 6 +++--- arch/x86/kernel/cpu/resctrl/internal.h | 4 ++-- arch/x86/kernel/cpu/resctrl/monitor.c | 2 +- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 8 ++++---- include/linux/resctrl.h | 6 +++--- 5 files changed, 13 insertions(+), 13 deletions(-)
arch/x86/kernel/cpu/resctrl/core.c +3 -3
@@ -737,7 +737,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 ),
@@ -777,7 +777,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;
@@ -797,7 +797,7 @@ bool __init rdt_cpu_has(int flag)return ret; } -__init bool resctrl_arch_is_evt_configurable (enum resctrl_event_id evt) +bool resctrl_arch_is_evt_configurable (enum resctrl_event_id evt) {if (!rdt_cpu_has (X86_FEATURE_BMEC ))return false;
arch/x86/kernel/cpu/resctrl/internal.h +2 -2
@@ -486,13 +486,13 @@ int alloc_rmid(u32 closid);void free_rmid (u32 closid,u32 rmid);int rdt_get_mon_l3_config (struct rdt_resource *r);void 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,struct rdt_mon_domain *d,struct rdtgroup *rdtgrp,cpumask_t *cpumask,int evtid,int first); -int __init resctrl_mon_resource_init (void ); +int resctrl_mon_resource_init (void );void mbm_setup_overflow_handler (struct rdt_mon_domain *dom,unsigned long delay_ms,int exclude_cpu);
arch/x86/kernel/cpu/resctrl/monitor.c +1 -1
@@ -1204,7 +1204,7 @@ static __init int snc_get_config(void)* * Returns 0 for success, or -ENOMEM. */ -int __init resctrl_mon_resource_init (void ) +int resctrl_mon_resource_init (void ) {struct rdt_resource *r =resctrl_arch_get_resource (RDT_RESOURCE_L3 );int ret;
arch/x86/kernel/cpu/resctrl/rdtgroup.c +4 -4
@@ -4144,7 +4144,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);
@@ -4376,7 +4376,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 ;
@@ -4433,7 +4433,7 @@ int __init resctrl_init(void)return ret; } -static bool __exit resctrl_online_domains_exist(void) +static bool resctrl_online_domains_exist (void ) {struct rdt_resource *r;
@@ -4462,7 +4462,7 @@ static bool __exit resctrl_online_domains_exist(void)* resctrl_arch_get_resource() must continue to return struct rdt_resources * with the correct rid field to ensure the filesystem can be unmounted. */ -void __exit resctrl_exit(void) +void resctrl_exit (void ) {cpus_read_lock ();WARN_ON_ONCE (resctrl_online_domains_exist ());
include/linux/resctrl.h +3 -3
@@ -358,7 +358,7 @@ u32 resctrl_arch_get_num_closid(struct rdt_resource *r);u32 resctrl_arch_system_num_rmid_idx (void );int resctrl_arch_update_domains (struct rdt_resource *r,u32 closid); -__init bool resctrl_arch_is_evt_configurable (enum resctrl_event_id evt); +bool resctrl_arch_is_evt_configurable (enum resctrl_event_id evt);/** * resctrl_arch_mon_event_config_write() - Write the config for an event.
@@ -514,7 +514,7 @@ void resctrl_arch_reset_all_ctrls(struct rdt_resource *r);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.39.5
James Morse
reviewerPATCH v9 6/27 x86/resctrl: Move is_mba_sc() out of core.c
In reply to James Morseis_mba_sc() is defined in core.c, but has no callers there. It does not access any architecture private structures.
Move this to rdtgroup.c where the majority of callers are. This makes the move of the filesystem code to /fs/ cleaner.
---
Changes since v2:
* This patch is new.
--- arch/x86/kernel/cpu/resctrl/core.c | 15 --------------- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 15 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/rdtgroup.c +15 -0
@@ -1535,6 +1535,21 @@ unsigned int rdtgroup_cbm_to_size(struct rdt_resource *r,return size; } +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; +} +/* * rdtgroup_size_show - Display size in bytes of allocated regions *
Signature · 1 line
2.39.5
James Morse
reviewerPATCH v9 7/27 x86/resctrl: Add end-marker to the resctrl_event_id enum
In reply to James MorseThe resctrl_event_id enum gives names to the counter event numbers on x86. These are used directly by resctrl.
To allow the MPAM driver to keep an array of these the size of the enum needs to be known.
Add a 'num_events' enum entry which can be used to size an array. This is added to the enum to reduce conflicts with another series, which in turn requires get_arch_mbm_state() to have a default case.
---
Changes since v8:
* Move the last marker into the enum and add a default case.
--- arch/x86/kernel/cpu/resctrl/monitor.c | 9 ++++----- include/linux/resctrl_types.h | 3 +++ 2 files changed, 7 insertions(+), 5 deletions(-)
arch/x86/kernel/cpu/resctrl/monitor.c +4 -5
@@ -260,12 +260,11 @@ static struct arch_mbm_state *get_arch_mbm_state(struct rdt_hw_mon_domain *hw_doreturn &hw_dom->arch_mbm_total[rmid];case QOS_L3_MBM_LOCAL_EVENT_ID :return &hw_dom->arch_mbm_local[rmid]; +default : +/* Never expect to get here */ +WARN_ON_ONCE (1 ); +return NULL ; } - -/* Never expect to get here */ -WARN_ON_ONCE (1 ); - -return NULL ; } void resctrl_arch_reset_rmid(struct rdt_resource *r, struct rdt_mon_domain *d,
include/linux/resctrl_types.h +3 -0
@@ -49,6 +49,9 @@ enum resctrl_event_id {QOS_L3_OCCUP_EVENT_ID =0x01 ,QOS_L3_MBM_TOTAL_EVENT_ID =0x02 ,QOS_L3_MBM_LOCAL_EVENT_ID =0x03 , + +/* Must be the last */ + QOS_NUM_EVENTS, };#endif /* __LINUX_RESCTRL_TYPES_H */
Signature · 1 line
2.39.5
Re: [PATCH v9 07/27] x86/resctrl: Add end-marker to the resctrl_event_id enum
Hi James,
Quoted 6 lines · James Morse
The
resctrl_event_idenum gives names to the counter event numbers on x86. These are used directly by resctrl.To allow the MPAM driver to keep an array of these the size of the enum needs to be known.
Quoted 6 lines
Add a '
num_events' enum entry which can be used to size an array. This is added to the enum to reduce conflicts with another series, which in turn requiresget_arch_mbm_state()to have a default case.Signed-off-by James Morse <[email protected]>---
Reinette
James Morse
reviewerPATCH v9 8/27 x86/resctrl: Expand the width of domid by replacing mon_data_bits
In reply to James MorseMPAM platforms retrieve the cache-id property from the ACPI PPTT table. The cache-id field is 32 bits wide. Under resctrl, the cache-id becomes the domain-id, and is packed into the mon_data_bits union bitfield. The width of cache-id in this field is 14 bits.
Expanding the union would break 32bit x86 platforms as this union is stored as the kernfs kn->priv pointer. This saved allocating memory for the priv data storage.
The firmware on MPAM platforms have used the PPTT cache-id field to expose the interconnect's id for the cache, which is sparse and uses more than 14 bits. Use of this id is to enable PCIe direct cache injection hints. Using this feature with VFIO means the value provided by the ACPI table should be exposed to user-space.
To support cache-id values greater than 14 bits, convert the mon_data_bits union to a structure. These are shared between control and monitor groups, and are allocated on first use. The list of allocated struct mon_data is free'd when the filesystem is umount()ed.
---
Previously the MPAM tree repainted the cache-id to compact them, argue-ing there was no other user. With VFIO use of this PCIe feature, this is no longer an option.
Changes since v8:
* Removed underscore in dom_id in the patch subject.
* Change types in struct mon_data to match the data.
* Renamed the global list to be more descriptive.
* Numerous comments were clarified.
Changes since v7:
* Replaced with Tony Luck's list based version.
Changes since v6:
* Added the get/put helpers.
* Special case the creation of the mondata files for the default control group.
* Removed wording about files living longer than expected, the corresponding error handling is wrapped in WARN_ON_ONCE() as this indicates a bug.
--- arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 19 ++++-- arch/x86/kernel/cpu/resctrl/internal.h | 39 ++++++----- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 79 +++++++++++++++++++++-- 3 files changed, 103 insertions(+), 34 deletions(-)
arch/x86/kernel/cpu/resctrl/ctrlmondata.c +12 -7
@@ -667,7 +667,7 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg)u32 resid, evtid, domid;struct rdtgroup *rdtgrp;struct rdt_resource *r; -union mon_data_bits md; +struct mon_data *md;int ret =0 ; rdtgrp =rdtgroup_kn_lock_live (of->kn);
@@ -676,17 +676,22 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg) goto out; } - md.priv = of->kn->priv; - resid = md.u.rid; - domid = md.u.domid; - evtid = md.u.evtid; + md = of->kn->priv; +if (WARN_ON_ONCE (!md)) { + ret = -EIO ; + goto out; + } + + resid = md->rid; + domid = md->domid; + evtid = md->evtid; r =resctrl_arch_get_resource (resid); -if (md.u.sum) { +if (md->sum) {/* * This file requires summing across all domains that share * the L3 cache id that was provided in the "domid" field of the -* mon_data_bits union. Search all domains in the resource for +* struct mon_data. Search all domains in the resource for * one that matches this cache id. */ list_for_each_entry (d, &r->mon_domains, hdr.list) {
arch/x86/kernel/cpu/resctrl/internal.h +19 -20
@@ -103,27 +103,26 @@ struct mon_evt { };/** -* union mon_data_bits - Monitoring details for each event file. -* @priv: Used to store monitoring event data in @u -* as kernfs private data. -* @u.rid: Resource id associated with the event file. -* @u.evtid: Event id associated with the event file. -* @u.sum: Set when event must be summed across multiple -* domains. -* @u.domid: When @u.sum is zero this is the domain to which -* the event file belongs. When @sum is one this -* is the id of the L3 cache that all domains to be -* summed share. -* @u: Name of the bit fields struct. +* struct mon_data - Monitoring details for each event file. +* @list: Member of the global @mon_data_kn_priv_list list. +* @rid: Resource id associated with the event file. +* @evtid: Event id associated with the event file. +* @sum: Set when event must be summed across multiple +* domains. +* @domid: When @sum is zero this is the domain to which +* the event file belongs. When @sum is one this +* is the id of the L3 cache that all domains to be +* summed share. +* +* Pointed to by the kernfs kn->priv field of monitoring event files. +* Readers and writers must hold rdtgroup_mutex. */ -union mon_data_bits { -void *priv; -struct { -unsigned int rid :10 ; -enum resctrl_event_id evtid :7 ; -unsigned int sum :1 ; -unsigned int domid :14 ; - } u; +struct mon_data { +struct list_head list; +enum resctrl_res_level rid; +enum resctrl_event_id evtid; +int domid; +bool sum; };/**
arch/x86/kernel/cpu/resctrl/rdtgroup.c +72 -7
109 lines not on this page · raw message
Signature · 1 line
2.39.5
Reinette Chatre
maintainerRe: [PATCH v9 08/27] x86/resctrl: Expand the width of domid by replacing mon_data_bits
Hi James,
arch/x86/kernel/cpu/resctrl/ctrlmondata.c int rdtgroup_mondata_show(struct seq_file *m, void *arg) · line 667
Quoted 12 lines · James Morse
--- arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 19 ++++-- arch/x86/kernel/cpu/resctrl/internal.h | 39 ++++++----- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 79 +++++++++++++++++++++-- 3 files changed, 103 insertions(+), 34 deletions(-)arch/x86/kernel/cpu/resctrl/ctrlmondata.c +0
-0@@ -667,7 +667,7 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg)u32 resid, evtid, domid;
I was expecting this to look differently after reading
https://lore.kernel.org/lkml/[email protected]/
I believe u32 was used for resid, evtid, and domid because of how they used to be initialized from the bitfield within the union. With the switch to a struct that now has the proper types these can also use proper types.
enum resctrl_res_level resid; enum resctrl_event_id evtid; int domid;
This highlights that the incorrect type propagated from rdtgroup_mondata_show() to mon_event_read() where its "int evtid" parameter should also be "enum resctrl_event_id evtid", which is a good complement to patch #14 that fixes the type used by functions called by mon_event_read().
Quoted 49 lines
arch/x86/kernel/cpu/resctrl/ctrlmondata.c +1
-1struct rdtgroup *rdtgrp;struct rdt_resource *r; -union mon_data_bits md; +struct mon_data *md;int ret =0 ; rdtgrp =rdtgroup_kn_lock_live (of->kn);arch/x86/kernel/cpu/resctrl/internal.h +13
-18@@ -103,27 +103,26 @@ struct mon_evt { };/** -* union mon_data_bits - Monitoring details for each event file. -* @priv: Used to store monitoring event data in @u -* as kernfs private data. -* @u.rid: Resource id associated with the event file. -* @u.evtid: Event id associated with the event file. -* @u.sum: Set when event must be summed across multiple -* domains. -* @u.domid: When @u.sum is zero this is the domain to which -* the event file belongs. When @sum is one this -* is the id of the L3 cache that all domains to be -* summed share. -* @u: Name of the bit fields struct. +* struct mon_data - Monitoring details for each event file. +* @list: Member of the global @mon_data_kn_priv_list list. +* @rid: Resource id associated with the event file. +* @evtid: Event id associated with the event file. +* @sum: Set when event must be summed across multiple +* domains. +* @domid: When @sum is zero this is the domain to which +* the event file belongs. When @sum is one this +* is the id of the L3 cache that all domains to be +* summed share. +* +* Pointed to by the kernfs kn->priv field of monitoring event files. +* Readers and writers must hold rdtgroup_mutex. */ -union mon_data_bits { -void *priv; -struct { -unsigned int rid :10 ; -enum resctrl_event_id evtid :7 ; -unsigned int sum :1 ;
arch/x86/kernel/cpu/resctrl/internal.h struct mon_evt { · line 127
Quoted 10 lines
arch/x86/kernel/cpu/resctrl/internal.h +6
-2- unsigned int domid : 14; - } u; +struct mon_data { +struct list_head list; +enum resctrl_res_level rid; +enum resctrl_event_id evtid; +int domid; +bool sum; };
Thank you.
Quoted 26 lines
arch/x86/kernel/cpu/resctrl/internal.h +0
-0/** arch/x86/kernel/cpu/resctrl/rdtgroup.c +10
-0@@ -45,6 +45,12 @@ LIST_HEAD(rdt_all_groups);/* list of entries for the schemata file */ LIST_HEAD (resctrl_schema_all); +/* +* List of struct mon_data containing private data of event files for use by +* rdtgroup_mondata_show(). Protected by rdtgroup_mutex. +*/ +static LIST_HEAD (mon_data_kn_priv_list); +/* The filesystem can only be mounted once. */ bool resctrl_mounted;@@ -3093,6 +3099,63 @@ static void rmdir_all_sub(void)kernfs_remove (kn_mondata); } +/** +* mon_get_kn_priv() - Get the mon_data priv data for this event. +* +* The same values are used across the mon_data directories of all control and
arch/x86/kernel/cpu/resctrl/rdtgroup.c static void rmdir_all_sub(void) · line 3115
Quoted 10 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +10
-0+* monitor groups for the same event in the same domain. Keep a list of +* allocated structures and re-use an existing one with the same values for +* @rid, @domid, etc. +* +* @rid: The resource id for the event file being created. +* @domid: The domain id for the event file being created. +* @mevt: The type of event file being created. +* @do_sum: Whether SNC summing monitors are being created. +*/ +static struct mon_data *mon_get_kn_priv(int rid, int domid,
"int rid" -> "enum resctrl_res_level rid"
Quoted 36 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +36
-0+ struct mon_evt *mevt, + bool do_sum) +{ +struct mon_data *priv; + +lockdep_assert_held (&rdtgroup_mutex); + +list_for_each_entry (priv, &mon_data_kn_priv_list, list) { +if (priv->rid == rid && priv->domid == domid && + priv->sum == do_sum && priv->evtid == mevt->evtid) +return priv; + } + + priv =kzalloc (sizeof (*priv),GFP_KERNEL ); +if (!priv) +return NULL ; + + priv->rid = rid; + priv->domid = domid; + priv->sum = do_sum; + priv->evtid = mevt->evtid; +list_add_tail (&priv->list, &mon_data_kn_priv_list); + +return priv; +} + +/** +* mon_put_kn_priv() - Free all allocated mon_data structures. +* +* Called when resctrl file system is unmounted. +*/ +static void mon_put_kn_priv (void ) +{ +struct mon_data *priv, *tmp; + +lockdep_assert_held (&rdtgroup_mutex);
arch/x86/kernel/cpu/resctrl/rdtgroup.c static void rmdir_all_sub(void) · line 3161
Quoted 10 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +7
-0+ +list_for_each_entry_safe (priv, tmp, &mon_data_kn_priv_list, list) { +list_del (&priv->list); +kfree (priv); + } +} +static void resctrl_fs_teardown (void ) {lockdep_assert_held (&rdtgroup_mutex);
Reinette
James Morse
reviewerRe: [PATCH v9 08/27] x86/resctrl: Expand the width of domid by replacing mon_data_bits
Hi Reinette,
Quoted 10 lines · Reinette Chatre
arch/x86/kernel/cpu/resctrl/ctrlmondata.c int rdtgroup_mondata_show(struct seq_file *m, void *arg) · line 667
Quoted 6 lines · James Morse
arch/x86/kernel/cpu/resctrl/ctrlmondata.c +0
-0@@ -667,7 +667,7 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg)u32 resid, evtid, domid;I was expecting this to look differently after reading
https://lore.kernel.org/lkml/[email protected]/
I changed the structure, but missed the usage here.
Quoted 4 lines
I believe u32 was used for resid, evtid, and domid because of how they used to be initialized from the bitfield within the union. With the switch to a struct that now has the proper types these can also use proper types.
Quoted 8 lines
enum resctrl_res_level resid; enum resctrl_event_id evtid; int domid;This highlights that the incorrect type propagated from
rdtgroup_mondata_show()tomon_event_read()where its "int evtid" parameter should also be "enumresctrl_event_idevtid", which is a good complement to patch #14 that fixes the type used by functions called bymon_event_read().
Fixed now.
[...]
Quoted 6 lines
Quoted 5 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +0
-0@@ -45,6 +45,12 @@ LIST_HEAD(rdt_all_groups);
Quoted 16 lines
Quoted 4 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +4
-0+/** +* mon_get_kn_priv() - Get the mon_data priv data for this event. +* +* The same values are used across the mon_data directories of all control and arch/x86/kernel/cpu/resctrl/rdtgroup.c static void rmdir_all_sub(void) · line 3115
Quoted 10 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +10
-0+* monitor groups for the same event in the same domain. Keep a list of +* allocated structures and re-use an existing one with the same values for +* @rid, @domid, etc. +* +* @rid: The resource id for the event file being created. +* @domid: The domain id for the event file being created. +* @mevt: The type of event file being created. +* @do_sum: Whether SNC summing monitors are being created. +*/ +static struct mon_data *mon_get_kn_priv(int rid, int domid,"int rid" -> "enum
resctrl_res_levelrid"
Fixed.
Thanks,
James
James Morse
reviewerPATCH v9 9/27 x86/resctrl: Split trace.h
In reply to James Morsetrace.h contains all the tracepoints. After the move to /fs/resctrl, some of these will be left behind. All the pseudo_lock tracepoints remain part of the architecture. The lone tracepoint in monitor.c moves to /fs/resctrl.
Split trace.h so that each C file includes a different trace header file. This means the trace header files are not modified when they are moved.
---
arch/x86/kernel/cpu/resctrl/Makefile | 3 ++
arch/x86/kernel/cpu/resctrl/monitor.c | 4 ++-
arch/x86/kernel/cpu/resctrl/monitor_trace.h | 31 +++++++++++++++++++
arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 2 +-
.../resctrl/{trace.h => pseudo_lock_trace.h} | 24 +++-----------
5 files changed, 42 insertions(+), 22 deletions(-)
create mode 100644 arch/x86/kernel/cpu/resctrl/monitor_trace.h
rename arch/x86/kernel/cpu/resctrl/{trace.h => pseudo_lock_trace.h} (56%)arch/x86/kernel/cpu/resctrl/Makefile +3 -0
@@ -2,4 +2,7 @@ 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 + +# To allow define_trace.h's recursive include: CFLAGS_pseudo_lock.o = -I$(src) +CFLAGS_monitor.o = -I$(src)
arch/x86/kernel/cpu/resctrl/monitor.c +3 -1
@@ -26,7 +26,9 @@#include <asm/resctrl.h> #include "internal.h" -#include "trace.h" + +#define CREATE_TRACE_POINTS +#include "monitor_trace.h" /** * struct rmid_entry - dirty tracking for all RMID.
arch/x86/kernel/cpu/resctrl/monitor_trace.h new file +31 -0
@@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM resctrl + +#if !defined(_FS_RESCTRL_MONITOR_TRACE_H) || defined(TRACE_HEADER_MULTI_READ ) +#define _FS_RESCTRL_MONITOR_TRACE_H + +#include <linux/tracepoint.h> + +TRACE_EVENT (mon_llc_occupancy_limbo, + TP_PROTO(u32 ctrl_hw_id, u32 mon_hw_id, int domain_id, u64 llc_occupancy_bytes), +TP_ARGS (ctrl_hw_id, mon_hw_id, domain_id, llc_occupancy_bytes), + TP_STRUCT__entry(__field(u32, ctrl_hw_id) + __field(u32, mon_hw_id) + __field(int, domain_id) +__field (u64, llc_occupancy_bytes)), + TP_fast_assign(__entry->ctrl_hw_id = ctrl_hw_id; + __entry->mon_hw_id = mon_hw_id; + __entry->domain_id = domain_id; + __entry->llc_occupancy_bytes = llc_occupancy_bytes;), +TP_printk ("ctrl_hw_id=%u mon_hw_id=%u domain_id=%d llc_occupancy_bytes=%llu" , + __entry->ctrl_hw_id, __entry->mon_hw_id, __entry->domain_id, + __entry->llc_occupancy_bytes) + ); + +#endif /* _FS_RESCTRL_MONITOR_TRACE_H */ + +#undef TRACE_INCLUDE_PATH +#define TRACE_INCLUDE_PATH . +#define TRACE_INCLUDE_FILE monitor_trace +#include <trace/define_trace.h>
arch/x86/kernel/cpu/resctrl/pseudo_lock.c +1 -1
@@ -30,7 +30,7 @@#include "internal.h" #define CREATE_TRACE_POINTS -#include "trace.h" +#include "pseudo_lock_trace.h" /* * The bits needed to disable hardware prefetching varies based on the
arch/x86/kernel/cpu/resctrl/pseudo_lock_trace.h renamed from arch/x86/kernel/cpu/resctrl/trace.h +4 -20
@@ -2,8 +2,8 @@#undef TRACE_SYSTEM#define TRACE_SYSTEM resctrl -#if !defined(_TRACE_RESCTRL_H) || defined(TRACE_HEADER_MULTI_READ ) -#define _TRACE_RESCTRL_H +#if !defined(_X86_RESCTRL_PSEUDO_LOCK_TRACE_H) || defined(TRACE_HEADER_MULTI_READ ) +#define _X86_RESCTRL_PSEUDO_LOCK_TRACE_H#include <linux/tracepoint.h>
@@ -35,25 +35,9 @@ TRACE_EVENT(pseudo_lock_l3,TP_printk ("hits=%llu miss=%llu" , __entry->l3_hits, __entry->l3_miss)); -TRACE_EVENT (mon_llc_occupancy_limbo, - TP_PROTO(u32 ctrl_hw_id, u32 mon_hw_id, int domain_id, u64 llc_occupancy_bytes), -TP_ARGS (ctrl_hw_id, mon_hw_id, domain_id, llc_occupancy_bytes), - TP_STRUCT__entry(__field(u32, ctrl_hw_id) - __field(u32, mon_hw_id) - __field(int, domain_id) -__field (u64, llc_occupancy_bytes)), - TP_fast_assign(__entry->ctrl_hw_id = ctrl_hw_id; - __entry->mon_hw_id = mon_hw_id; - __entry->domain_id = domain_id; - __entry->llc_occupancy_bytes = llc_occupancy_bytes;), -TP_printk ("ctrl_hw_id=%u mon_hw_id=%u domain_id=%d llc_occupancy_bytes=%llu" , - __entry->ctrl_hw_id, __entry->mon_hw_id, __entry->domain_id, - __entry->llc_occupancy_bytes) - ); - -#endif /* _TRACE_RESCTRL_H */ +#endif /* _X86_RESCTRL_PSEUDO_LOCK_TRACE_H */ #undef TRACE_INCLUDE_PATH#define TRACE_INCLUDE_PATH . -#define TRACE_INCLUDE_FILE trace +#define TRACE_INCLUDE_FILE pseudo_lock_trace#include <trace/define_trace.h>
Signature · 1 line
2.39.5
James Morse
reviewerPATCH v9 10/27 x86/resctrl: Add 'resctrl' to the title of the resctrl documentation
In reply to James MorseThe resctrl documentation is titled "User Interface for Resource Control feature".
Once the documentation follows the code in a move to the filesystem, this appears in the list of filesystems, but doesn't contain the name of the filesystem, making it hard to find.
Add 'resctrl' to the title.
---
Changes since v8:
* This patch is new.
--- Documentation/arch/x86/resctrl.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Documentation/arch/x86/resctrl.rst +3 -3
@@ -1,9 +1,9 @@ .. SPDX-License-Identifier: GPL-2.0 .. include:: <isonum.txt> -=========================================== -User Interface for Resource Control feature -=========================================== +===================================================== +User Interface for Resource Control feature (resctrl) +===================================================== :Copyright: |copy| 2016 Intel Corporation :Authors: - Fenghua Yu <[email protected]>
Signature · 1 line
2.39.5
Reinette Chatre
maintainerRe: [PATCH v9 10/27] x86/resctrl: Add 'resctrl' to the title of the resctrl documentation
Hi James,
Quoted 9 lines · James Morse
The resctrl documentation is titled "User Interface for Resource Control feature".
Once the documentation follows the code in a move to the filesystem, this appears in the list of filesystems, but doesn't contain the name of the filesystem, making it hard to find.
Add 'resctrl' to the title.
Thank you.
Quoted 1 line
Suggeted-by Reinette Chatre <[email protected]>
Quoted 2 lines
Signed-off-by James Morse <[email protected]>---
With typos fixed.
| Reviewed-by: Reinette Chatre <[email protected]>
Reinette
Re: [PATCH v9 10/27] x86/resctrl: Add 'resctrl' to the title of the resctrl documentation
In reply to James MorseQuoted 10 lines · James Morse
The resctrl documentation is titled "User Interface for Resource Control feature".
Once the documentation follows the code in a move to the filesystem, this appears in the list of filesystems, but doesn't contain the name of the filesystem, making it hard to find.
Add 'resctrl' to the title.
Suggeted-by Reinette Chatre <[email protected]>
s/Suggeted-by/Suggested-by/
Quoted 1 line
Signed-off-by James Morse <[email protected]>
Quoted 14 lines
---
Changes since v8:
* This patch is new.--- Documentation/arch/x86/resctrl.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)Documentation/arch/x86/resctrl.rst +0
-0@@ -1,9 +1,9 @@ .. SPDX-License-Identifier: GPL-2.0 .. include:: <isonum.txt>
Documentation/arch/x86/resctrl.rst line 9
Quoted 10 lines
Documentation/arch/x86/resctrl.rst +3
-3-=========================================== -User Interface for Resource Control feature -=========================================== +===================================================== +User Interface for Resource Control feature (resctrl) +===================================================== :Copyright: |copy| 2016 Intel Corporation :Authors: - Fenghua Yu <[email protected]>
Thanks.
-Fenghua
James Morse
reviewerPATCH v9 11/27 fs/resctrl: Add boiler plate for external resctrl code
In reply to James MorseAdd Makefile and Kconfig for fs/resctrl. Add ARCH_HAS_CPU_RESCTRL for the common parts of the resctrl interface and make X86_CPU_RESCTRL select this.
Adding an include of asm/resctrl.h to linux/resctrl.h allows the /fs/resctrl files to switch over to using this header instead.
---
Changes since v6:
* Added 'depends on RESCTRL_FS' to the hidden kconfig options.
Changes since v5:
* Removed double include.
* Removed duplicate pseudo lock Kconfig define
* Grammar fix and closid capitalisation change.
Changes since v4:
* Tweaking of the commit message.
Changes since v3:
* Reworded 'if unsure say N' from the Kconfig text, the user doesn't have the choice anyway at this point.
* Added PWD to monitor.o's CFLAGS for the ftrace rube-goldberg build machine.
* Added split trace files.
Changes since v2:
* Dropped KERNFS dependency from arch side Kconfig.
* Added empty trace.h file.
* Merged asm->linux includes from Dave's patch to decouple those patches from this series.
Changes since v1:
* 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 | 11 ++----- arch/x86/kernel/cpu/resctrl/internal.h | 2 -- arch/x86/kernel/cpu/resctrl/monitor.c | 2 +- arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 2 +- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 2 +- fs/Kconfig | 1 + fs/Makefile | 1 + fs/resctrl/Kconfig | 39 +++++++++++++++++++++++ fs/resctrl/Makefile | 6 ++++ fs/resctrl/ctrlmondata.c | 0 fs/resctrl/internal.h | 0 fs/resctrl/monitor.c | 0 fs/resctrl/monitor_trace.h | 0 fs/resctrl/pseudo_lock.c | 0 fs/resctrl/pseudo_lock_trace.h | 0 fs/resctrl/rdtgroup.c | 0 include/linux/resctrl.h | 4 +++ 19 files changed, 66 insertions(+), 13 deletions(-) create mode 100644 fs/resctrl/Kconfig create mode 100644 fs/resctrl/Makefile create mode 100644 fs/resctrl/ctrlmondata.c create mode 100644 fs/resctrl/internal.h create mode 100644 fs/resctrl/monitor.c create mode 100644 fs/resctrl/monitor_trace.h create mode 100644 fs/resctrl/pseudo_lock.c create mode 100644 fs/resctrl/pseudo_lock_trace.h create mode 100644 fs/resctrl/rdtgroup.c
MAINTAINERS +1 -0
@@ -20343,6 +20343,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
@@ -1518,6 +1518,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 -8
@@ -507,8 +507,9 @@ config X86_MPPARSE config X86_CPU_RESCTRL bool "x86 CPU resource control support" depends on X86 && (CPU_SUP_INTEL || CPU_SUP_AMD) - select KERNFS - select PROC_CPU_RESCTRL if PROC_FS + depends on MISC_FILESYSTEMS + select ARCH_HAS_CPU_RESCTRL + select RESCTRL_FS select RESCTRL_FS_PSEUDO_LOCK help Enable x86 CPU resource control support.
@@ -526,12 +527,6 @@ config X86_CPU_RESCTRL Say N if unsure. -config RESCTRL_FS_PSEUDO_LOCK - bool - help - Software mechanism to pin data in a cache portion using - micro-architecture specific knowledge. - config X86_FRED bool "Flexible Return and Event Delivery" depends on X86_64
arch/x86/kernel/cpu/resctrl/internal.h +0 -2
@@ -9,8 +9,6 @@#include <linux/jump_label.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/monitor.c +1 -1
@@ -19,11 +19,11 @@#include <linux/cpu.h> #include <linux/module.h> +#include <linux/resctrl.h> #include <linux/sizes.h> #include <linux/slab.h> #include <asm/cpu_device_id.h> -#include <asm/resctrl.h> #include "internal.h"
arch/x86/kernel/cpu/resctrl/pseudo_lock.c +1 -1
@@ -18,12 +18,12 @@#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/cpu_device_id.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
@@ -18,6 +18,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>
@@ -28,7 +29,6 @@#include <uapi/linux/magic.h> -#include <asm/resctrl.h> #include "internal.h" DEFINE_STATIC_KEY_FALSE (rdt_enable_key);
fs/Kconfig +1 -0
@@ -335,6 +335,7 @@ source "fs/omfs/Kconfig" source "fs/hpfs/Kconfig" source "fs/qnx4/Kconfig" source "fs/qnx6/Kconfig" +source "fs/resctrl/Kconfig" source "fs/romfs/Kconfig" source "fs/pstore/Kconfig" source "fs/ufs/Kconfig"
fs/Makefile +1 -0
@@ -128,3 +128,4 @@ obj-$(CONFIG_EROFS_FS) += erofs/ obj-$(CONFIG_VBOXSF_FS) += vboxsf/ obj-$(CONFIG_ZONEFS_FS) += zonefs/ obj-$(CONFIG_BPF_LSM) += bpf_fs_kfuncs.o +obj-$(CONFIG_RESCTRL_FS) += resctrl/
fs/resctrl/Kconfig new file +39 -0
@@ -0,0 +1,39 @@ +config RESCTRL_FS + bool "CPU Resource Control Filesystem (resctrl)" + depends on ARCH_HAS_CPU_RESCTRL + select KERNFS + select PROC_CPU_RESCTRL if PROC_FS + help + Some architectures provide hardware facilities to group tasks and + monitor and control their usage of memory system resources such as + caches and memory bandwidth. Examples of such facilities include + Intel's Resource Director Technology (Intel(R) RDT) and AMD's + Platform Quality of Service (AMD QoS). + + If your system has the necessary support and you want to be able to + assign tasks to groups and manipulate the associated resource + monitors and controls from userspace, say Y here to get a mountable + 'resctrl' filesystem that lets you do just that. + + If nothing mounts or prods the 'resctrl' filesystem, resource + controls and monitors are left in a quiescent, permissive state. + + On architectures where this can be disabled independently, it is + safe to say N. + + See <file:Documentation/arch/x86/resctrl.rst> for more information. + +config RESCTRL_FS_PSEUDO_LOCK + bool + depends on RESCTRL_FS + help + Software mechanism to pin data in a cache portion using + micro-architecture specific knowledge. + +config RESCTRL_RMID_DEPENDS_ON_CLOSID + bool + depends on RESCTRL_FS + help + Enabled by the architecture when the RMID values depend on the CLOSID. + This causes the CLOSID allocator to search for CLOSID with clean + RMID.
fs/resctrl/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# 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 + +# To allow define_trace.h's recursive include: +CFLAGS_monitor.o = -I$(src)
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/monitor_trace.h new file +0 -0
fs/resctrl/pseudo_lock.c new file +0 -0
fs/resctrl/pseudo_lock_trace.h 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.39.5
James Morse
reviewerPATCH v9 12/27 x86/resctrl: Move the filesystem bits to headers visible to fs/resctrl
In reply to James MorseOnce 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.
---
Changes since v8:
* Moved resctrl_arch_get_cdp_enabled()/resctrl_arch_set_cdp_enabled() to include/linux/resctrl.h
Changes since v6:
* Moved resctrl_arch_set_cdp_enabled() to rdtgroup.c instead of core.c
Changes since v3:
* Changed the number of hyphens at the end of the commit message.
Changes since v2:
* Dropped the rfflags and some other defines from being moved.
Changes since v1:
* Revert apparently unintentional duplication of a couple of variable declarations in <linux/resctrl.h>.
No functional change.
--- arch/x86/kernel/cpu/resctrl/internal.h | 9 --------- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 5 +++++ include/linux/resctrl.h | 3 +++ include/linux/resctrl_types.h | 3 +++ 4 files changed, 11 insertions(+), 9 deletions(-)
arch/x86/kernel/cpu/resctrl/internal.h +0 -9
@@ -16,8 +16,6 @@#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
@@ -410,13 +408,6 @@ extern struct rdtgroup rdtgroup_default;extern struct dentry *debugfs_resctrl;extern enum resctrl_event_id mba_mbps_default_event; -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); -void arch_mon_domain_online (struct rdt_resource *r,struct rdt_mon_domain *d);/* CPUID.(EAX=10H, ECX=ResID=1).EAX */
arch/x86/kernel/cpu/resctrl/rdtgroup.c +5 -0
@@ -2541,6 +2541,11 @@ int resctrl_arch_set_cdp_enabled(enum resctrl_res_level l, bool enable)return 0 ; } +bool resctrl_arch_get_cdp_enabled (enum resctrl_res_level l) +{ +return rdt_resources_all[l].cdp_enabled; +} +/* * We don't allow rdtgroup directories to be created anywhere * except the root directory. Thus when looking for the rdtgroup
include/linux/resctrl.h +3 -0
@@ -403,6 +403,9 @@ static inline u32 resctrl_get_config_index(u32 closid, } } +bool resctrl_arch_get_cdp_enabled (enum resctrl_res_level l); +int resctrl_arch_set_cdp_enabled (enum resctrl_res_level l,bool enable); +/* * Update the ctrl_val and apply this config right now. * Must be called on one of the domain's CPUs.
include/linux/resctrl_types.h +3 -0
@@ -7,6 +7,9 @@#ifndef __LINUX_RESCTRL_TYPES_H#define __LINUX_RESCTRL_TYPES_H +#define MAX_MBA_BW 100u +#define MBM_OVERFLOW_INTERVAL 1000 +/* Reads to Local DRAM Memory */ #define READS_TO_LOCAL_MEM BIT(0)
Signature · 1 line
2.39.5
James Morse
reviewerPATCH v9 13/27 x86/resctrl: Move enum resctrl_event_id to resctrl.h
In reply to James MorseA previous patch moved enum resctrl_event_id into a smaller header file, resctrl_types.h, so that architectures could use these types in their definitions of asm/resctrl.h. Specifically this was for resctrl_arch_get_cdp_enabled() and resctrl_arch_set_cdp_enabled().
Those two functions are no longer inlined by any architecture, so the enum can be moved to resctrl.h.
---
Changes since v8:
* This patch is new.
--- include/linux/resctrl.h | 10 ++++++++++ include/linux/resctrl_types.h | 10 ---------- 2 files changed, 10 insertions(+), 10 deletions(-)
include/linux/resctrl.h +10 -0
@@ -48,6 +48,16 @@ int proc_resctrl_show(struct seq_file *m, for_each_rdt_resource((r)) \if ((r)->mon_capable) +enum resctrl_res_level { +RDT_RESOURCE_L3 , +RDT_RESOURCE_L2 , +RDT_RESOURCE_MBA , +RDT_RESOURCE_SMBA , + +/* Must be the last */ + RDT_NUM_RESOURCES, +}; +/** * enum resctrl_conf_type - The type of configuration. * @CDP_NONE: No prioritisation, both code and data are controlled or monitored.
include/linux/resctrl_types.h +0 -10
@@ -34,16 +34,6 @@/* Max event bits supported */ #define MAX_EVT_CONFIG_BITS GENMASK(6, 0) -enum resctrl_res_level { -RDT_RESOURCE_L3 , -RDT_RESOURCE_L2 , -RDT_RESOURCE_MBA , -RDT_RESOURCE_SMBA , - -/* Must be the last */ -RDT_NUM_RESOURCES , -}; -/* * Event IDs, the values match those used to program IA32_QM_EVTSEL before * reading IA32_QM_CTR on RDT systems.
Signature · 1 line
2.39.5
Reinette Chatre
maintainerRe: [PATCH v9 13/27] x86/resctrl: Move enum resctrl_event_id to resctrl.h
Hi James,
Quoted 1 line · James Morse
A previous patch moved enum
resctrl_event_idinto a smaller header file,
We have had trouble using "previous patch" and "next patch" in changelogs because of how patches may be re-organized after merge and backports and such.
Considering this I'd propose something like (please feel free to improve):
resctrl_types.h contains common types and constants to enable architectures to use these types in their definitions within asm/resctrl.h.
enum resctrl_event_id was placed in resctrl_types.h for resctrl_arch_get_cdp_enabled() and resctrl_arch_set_cdp_enabled(), but these two functions are no longer inlined by any architecture.
Move enum resctrl_event_id to resctrl.h.
Quoted 9 lines
resctrl_types.h, so that architectures could use these types in their definitions ofasm/resctrl.h. Specifically this was forresctrl_arch_get_cdp_enabled()andresctrl_arch_set_cdp_enabled().Those two functions are no longer inlined by any architecture, so the enum can be moved to
resctrl.h.Signed-off-by James Morse <[email protected]>---
With "previous patch" addressed:
| Reviewed-by: Reinette Chatre <[email protected]>
Thank you.
Reinette
James Morse
reviewerRe: [PATCH v9 13/27] x86/resctrl: Move enum resctrl_event_id to resctrl.h
Hi Reinette,
Quoted 5 lines · Reinette Chatre
Quoted 1 line · James Morse
A previous patch moved enum
resctrl_event_idinto a smaller header file,We have had trouble using "previous patch" and "next patch" in changelogs because of how patches may be re-organized after merge and backports and such.
I glossed over this because it was the distant past!
Quoted 10 lines
Considering this I'd propose something like (please feel free to improve):
resctrl_types.hcontains common types and constants to enable architectures to use these types in their definitions withinasm/resctrl.h.enum
resctrl_event_idwas placed inresctrl_types.hforresctrl_arch_get_cdp_enabled()andresctrl_arch_set_cdp_enabled(), but these two functions are no longer inlined by any architecture.Move enum
resctrl_event_idtoresctrl.h.
I've taken this as it is.
Quoted 2 lines
With "previous patch" addressed:
| Reviewed-by: Reinette Chatre <[email protected]>
Thanks!
James
James Morse
reviewerPATCH v9 14/27 x86/resctrl: Fix types in resctrl_arch_mon_ctx_alloc() and free stubs
In reply to James Morseresctrl_arch_mon_ctx_alloc() and resctrl_arch_mon_ctx_free() take an enum resctrl_event_id. This in turn requires the enum to be defined in resctrl_types.h so that it is accessible to asm/resctrl.h.
The x86 stubs take an int. Fix that.
---
Changes since v8:
* This patch is new.
--- arch/x86/include/asm/resctrl.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
arch/x86/include/asm/resctrl.h +4 -2
@@ -194,13 +194,15 @@ static inline u32 resctrl_arch_rmid_idx_encode(u32 ignored, u32 rmid)/* x86 can always read an rmid, nothing needs allocating */ struct rdt_resource ; -static inline void *resctrl_arch_mon_ctx_alloc (struct rdt_resource *r,int evtid) +static inline void *resctrl_arch_mon_ctx_alloc (struct rdt_resource *r, +enum resctrl_event_id evtid) {might_sleep ();return NULL ; }; -static inline void resctrl_arch_mon_ctx_free (struct rdt_resource *r,int evtid, +static inline void resctrl_arch_mon_ctx_free (struct rdt_resource *r, +enum resctrl_event_id evtid,void *ctx) { };u64 resctrl_arch_get_prefetch_disable_bits (void );
Signature · 1 line
2.39.5
Reinette Chatre
maintainerRe: [PATCH v9 14/27] x86/resctrl: Fix types in resctrl_arch_mon_ctx_alloc() and free stubs
Hi James,
The shortlog sounds like the stubs themselves are being free'd. How about
x86/resctrl: Fix types in resctrl_arch_mon_ctx_{alloc,free}() stubs
Quoted 3 lines · James Morse
resctrl_arch_mon_ctx_alloc()andresctrl_arch_mon_ctx_free()take an enumresctrl_event_id. This in turn requires the enum to be defined inresctrl_types.hso that it is accessible toasm/resctrl.h.
I found the "This in turn requires ..." to indicate that this dependency still needs to be met. How about:
resctrl_arch_mon_ctx_alloc() and resctrl_arch_mon_ctx_free() take an enum resctrl_event_id that is already defined in resctrl_types.h to be accessible to asm/resctrl.h.
Quoted 13 lines
The x86 stubs take an int. Fix that.
Signed-off-by James Morse <[email protected]>---
arch/x86/include/asm/resctrl.h +0
-0
arch/x86/include/asm/resctrl.h static inline u32 resctrl_arch_rmid_idx_encode(u32 ignored, u32 rmid) · line 202
Quoted 10 lines
arch/x86/include/asm/resctrl.h +2
-1@@ -194,13 +194,15 @@ static inline u32 resctrl_arch_rmid_idx_encode(u32 ignored, u32 rmid)/* x86 can always read an rmid, nothing needs allocating */ struct rdt_resource ; -static inline void *resctrl_arch_mon_ctx_alloc (struct rdt_resource *r,int evtid) +static inline void *resctrl_arch_mon_ctx_alloc (struct rdt_resource *r, +enum resctrl_event_id evtid) {might_sleep ();return NULL ; };
I missed this stray ";" sneaking in ...
arch/x86/include/asm/resctrl.h static inline u32 resctrl_arch_rmid_idx_encode(u32 ignored, u32 rmid) · line 207
Quoted 6 lines
arch/x86/include/asm/resctrl.h +2
-1-static inline void resctrl_arch_mon_ctx_free (struct rdt_resource *r,int evtid, +static inline void resctrl_arch_mon_ctx_free (struct rdt_resource *r, +enum resctrl_event_id evtid,void *ctx) { };
... and this one.
arch/x86/include/asm/resctrl.h static inline u32 resctrl_arch_rmid_idx_encode(u32 ignored, u32 rmid) · line 208
Quoted 1 line
arch/x86/include/asm/resctrl.h +0
-0u64 resctrl_arch_get_prefetch_disable_bits (void );
Reinette
James Morse
reviewerRe: [PATCH v9 14/27] x86/resctrl: Fix types in resctrl_arch_mon_ctx_alloc() and free stubs
Hi Reinette,
Quoted 2 lines · Reinette Chatre
The shortlog sounds like the stubs themselves are being free'd. How about
x86/resctrl: Fix types in resctrl_arch_mon_ctx_{alloc,free}() stubs
Sure,
Quoted 11 lines · James Morse
Quoted 3 lines
resctrl_arch_mon_ctx_alloc()andresctrl_arch_mon_ctx_free()take an enumresctrl_event_id. This in turn requires the enum to be defined inresctrl_types.hso that it is accessible toasm/resctrl.h.I found the "This in turn requires ..." to indicate that this dependency still needs to be met. How about:
resctrl_arch_mon_ctx_alloc()andresctrl_arch_mon_ctx_free()take an enumresctrl_event_idthat is already defined inresctrl_types.hto be accessible toasm/resctrl.h.
Done,
Quoted 26 lines
Quoted 12 lines
The x86 stubs take an int. Fix that.
Signed-off-by James Morse <[email protected]>---
arch/x86/include/asm/resctrl.h +0
-0arch/x86/include/asm/resctrl.h static inline u32 resctrl_arch_rmid_idx_encode(u32 ignored, u32 rmid) · line 202
Quoted 10 lines
arch/x86/include/asm/resctrl.h +2
-1@@ -194,13 +194,15 @@ static inline u32 resctrl_arch_rmid_idx_encode(u32 ignored, u32 rmid)/* x86 can always read an rmid, nothing needs allocating */ struct rdt_resource ; -static inline void *resctrl_arch_mon_ctx_alloc (struct rdt_resource *r,int evtid) +static inline void *resctrl_arch_mon_ctx_alloc (struct rdt_resource *r, +enum resctrl_event_id evtid) {might_sleep ();return NULL ; };I missed this stray ";" sneaking in ...
Quoted 1 line
Quoted 6 lines
arch/x86/include/asm/resctrl.h static inline u32 resctrl_arch_rmid_idx_encode(u32 ignored, u32 rmid) · line 206
Quoted 5 lines
arch/x86/include/asm/resctrl.h +2
-1-static inline void resctrl_arch_mon_ctx_free (struct rdt_resource *r,int evtid, +static inline void resctrl_arch_mon_ctx_free (struct rdt_resource *r, +enum resctrl_event_id evtid,void *ctx) { };... and this one.
Both removed - not sure how that happened!
Thanks,
James
James Morse
reviewerPATCH v9 15/27 x86/resctrl: Move pseudo lock prototypes to include/linux/resctrl.h
In reply to James MorseThe resctrl pseudo-lock feature allows an architecture to allocate data into particular cache portions, which are then treated as reserved to avoid that data ever being evicted. Setting this up is deeply architecture specific as it involves disabling prefetchers etc. It is not possible to support this kind of feature on arm64. Risc-V is assumed to be the same.
The prototypes for the architecture code were added to x86's asm/resctrl.h, with other architectures able to provide subs for their architecture. This forces other architectures to provide identical stubs.
Move the prototypes and stubs to linux/resctrl.h, and switch between them using the existing Kconfig symbol.
---
I'm assuming risc-v's hardware prefetcher controls are restricted to the higehst privilege level, and that this isn't where linux runs.
Changse since v8:
* This patch is new.
--- arch/x86/include/asm/resctrl.h | 5 ----- include/linux/resctrl.h | 13 +++++++++++++ 2 files changed, 13 insertions(+), 5 deletions(-)
arch/x86/include/asm/resctrl.h +0 -5
@@ -205,11 +205,6 @@ static inline void resctrl_arch_mon_ctx_free(struct rdt_resource *r,enum resctrl_event_id evtid, void *ctx) { }; -u64 resctrl_arch_get_prefetch_disable_bits (void ); -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);void resctrl_cpu_detect (struct cpuinfo_x86 *c);#else
include/linux/resctrl.h +13 -0
@@ -534,4 +534,17 @@ extern unsigned int resctrl_rmid_realloc_limit;int resctrl_init (void );void resctrl_exit (void ); +#ifdef CONFIG_RESCTRL_FS_PSEUDO_LOCK +u64 resctrl_arch_get_prefetch_disable_bits (void ); +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); +#else +static inline u64 resctrl_arch_get_prefetch_disable_bits (void ) {return 0 ; } +static inline int resctrl_arch_pseudo_lock_fn (void *_plr) {return 0 ; } +static inline int resctrl_arch_measure_cycles_lat_fn (void *_plr) {return 0 ; } +static inline int resctrl_arch_measure_l2_residency (void *_plr) {return 0 ; } +static inline int resctrl_arch_measure_l3_residency (void *_plr) {return 0 ; } +#endif /* CONFIG_RESCTRL_FS_PSEUDO_LOCK */ #endif /* _RESCTRL_H */
Signature · 1 line
2.39.5
Re: [PATCH v9 15/27] x86/resctrl: Move pseudo lock prototypes to include/linux/resctrl.h
Hi James,
Quoted 9 lines · James Morse
The resctrl pseudo-lock feature allows an architecture to allocate data into particular cache portions, which are then treated as reserved to avoid that data ever being evicted. Setting this up is deeply architecture specific as it involves disabling prefetchers etc. It is not possible to support this kind of feature on arm64. Risc-V is assumed to be the same.
The prototypes for the architecture code were added to x86's
asm/resctrl.h, with other architectures able to provide subs for their architecture. This
subs -> stubs?
Quoted 7 lines
forces other architectures to provide identical stubs.
Move the prototypes and stubs to
linux/resctrl.h, and switch between them using the existingKconfigsymbol.Signed-off-by James Morse <[email protected]>---
Reinette
James Morse
reviewerPATCH v9 16/27 x86/resctrl: Squelch whitespace anomalies in resctrl core code
In reply to James MorseFrom: Dave Martin <[email protected]>
checkpatch.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.
--- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
arch/x86/kernel/cpu/resctrl/rdtgroup.c +5 -7
@@ -1024,7 +1024,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 =rdt_kn_parent_priv (of->kn);struct rdt_resource *r = s->res;
@@ -1034,7 +1034,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 =rdt_kn_parent_priv (of->kn);struct rdt_resource *r = s->res;
@@ -1150,7 +1150,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 =rdt_kn_parent_priv (of->kn);struct rdt_resource *r = s->res;
@@ -1185,7 +1185,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 =rdt_kn_parent_priv (of->kn);struct rdt_resource *r = s->res;
@@ -1195,7 +1195,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 =rdt_kn_parent_priv (of->kn);struct rdt_resource *r = s->res;
@@ -2068,7 +2068,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)
@@ -3628,7 +3627,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.39.5
James Morse
reviewerPATCH v9 17/27 x86/resctrl: Prefer alloc(sizeof(*foo)) idiom in rdt_init_fs_context()
In reply to James MorseFrom: Dave Martin <[email protected]>
rdt_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.
--- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/resctrl/rdtgroup.c +1 -1
@@ -2951,7 +2951,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.39.5
James Morse
reviewerPATCH v9 18/27 x86/resctrl: Relax some asm #includes
In reply to James MorseFrom: Dave Martin <[email protected]>
checkpatch.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 since v2:
* asm->linux for resctrl.h moved into an earlier patch.
--- arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/resctrl/pseudo_lock.c +2 -1
@@ -11,6 +11,8 @@#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt +#include <linux/cacheflush.h> +#include <linux/cacheinfo.h> #include <linux/cpu.h> #include <linux/cpumask.h> #include <linux/debugfs.h>
@@ -22,7 +24,6 @@#include <linux/slab.h> #include <linux/uaccess.h> -#include <asm/cacheflush.h> #include <asm/cpu_device_id.h> #include <asm/perf_event.h>
Signature · 1 line
2.39.5
James Morse
reviewerPATCH v9 19/27 x86/resctrl: Always initialise rid field in rdt_resources_all[]
In reply to James Morsex86 has an array, rdt_resources_all[], of all possible resources. The for-each-resource walkers depend on the rid field of all resources being initialised.
If the array ever grows due to another architecture adding a resource type that is not defined on x86, the for-each-resources walkers will loop forever.
Initialise all the rid values in resctrl_arch_late_init() before any for-each-resource walker can be called.
---
Changes since v8:
* Clarified a comment.
Changes since v7:
* Split out of a previous patch due to a botched merged conflict.
--- arch/x86/kernel/cpu/resctrl/core.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
arch/x86/kernel/cpu/resctrl/core.c +5 -5
@@ -60,7 +60,6 @@ struct rdt_hw_resource rdt_resources_all[RDT_NUM_RESOURCES] = { [RDT_RESOURCE_L3] = { .r_resctrl = { - .rid = RDT_RESOURCE_L3, .name = "L3", .ctrl_scope = RESCTRL_L3_CACHE, .mon_scope = RESCTRL_L3_CACHE,
@@ -74,7 +73,6 @@ struct rdt_hw_resource rdt_resources_all[RDT_NUM_RESOURCES] = { [RDT_RESOURCE_L2] = { .r_resctrl = { - .rid = RDT_RESOURCE_L2, .name = "L2", .ctrl_scope = RESCTRL_L2_CACHE, .ctrl_domains = ctrl_domain_init(RDT_RESOURCE_L2),
@@ -86,7 +84,6 @@ struct rdt_hw_resource rdt_resources_all[RDT_NUM_RESOURCES] = { [RDT_RESOURCE_MBA] = { .r_resctrl = { - .rid = RDT_RESOURCE_MBA, .name = "MB", .ctrl_scope = RESCTRL_L3_CACHE, .ctrl_domains = ctrl_domain_init(RDT_RESOURCE_MBA),
@@ -96,7 +93,6 @@ struct rdt_hw_resource rdt_resources_all[RDT_NUM_RESOURCES] = { [RDT_RESOURCE_SMBA] = { .r_resctrl = { - .rid = RDT_RESOURCE_SMBA, .name = "SMBA", .ctrl_scope = RESCTRL_L3_CACHE, .ctrl_domains = ctrl_domain_init(RDT_RESOURCE_SMBA),
@@ -996,7 +992,11 @@ void resctrl_cpu_detect(struct cpuinfo_x86 *c)static int __init resctrl_arch_late_init (void ) {struct rdt_resource *r; -int state, ret; +int state, ret, i; + +/* for_each_rdt_resource() requires all rid to be initialised. */ +for (i =0 ; i <RDT_NUM_RESOURCES ; i++) + rdt_resources_all[i].r_resctrl.rid = i;/* * Initialize functions(or definitions) that are different
Signature · 1 line
2.39.5
Re: [PATCH v9 19/27] x86/resctrl: Always initialise rid field in rdt_resources_all[]
Hi James,
Quoted 8 lines · James Morse
x86 has an array, rdt_resources_all[], of all possible resources. The for-each-resource walkers depend on the rid field of all resources being initialised.
If the array ever grows due to another architecture adding a resource type that is not defined on x86, the for-each-resources walkers will loop forever.
Quoted 6 lines
Initialise all the rid values in
resctrl_arch_late_init()before any for-each-resource walker can be called.Signed-off-by James Morse <[email protected]>---
Reinette
James Morse
reviewerPATCH v9 20/27 x86/resctrl: Remove a newline to avoid confusing the code move script
In reply to James MorseThe resctrl filesystem code will shortly be moved to /fs/. This involves splitting all the existing files, with some functions remaining under arch/x86, and others moving to fs/resctrl.
To make this reproducible, a python script does the heavy lif^W copy-and-paste. This involves some clunky parsing of C code.
The parser gets confused by the newline after this #ifdef. Just remove it.
--- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 1 - 1 file changed, 1 deletion(-)
arch/x86/kernel/cpu/resctrl/rdtgroup.c +0 -1
@@ -903,7 +903,6 @@ static int rdtgroup_rmid_show(struct kernfs_open_file *of, }#ifdef CONFIG_PROC_CPU_RESCTRL -/* * A task can only be part of one resctrl control group and of one monitor * group which is associated to that control group.
Signature · 1 line
2.39.5
James Morse
reviewerPATCH v9 21/27 x86/resctrl: Add python script to move resctrl code to /fs/resctrl
In reply to James MorseTo support more than one architecture resctrl needs to move from arch/x86 to live under fs. Moving all the code breaks any series on the mailing list, so needs scheduling carefully.
Maintaining the patch that moves all this code has proved labour intensive. It's also near-impossible to review that no inadvertent changes have crept in.
To solve these problems, temporarily add a hacky python program that lists all the functions that should move, and those that should stay.
No attempt to parse C code is made, this thing tries to name 'blocks' based on heuristics about the kernel coding style. It's fragile, but good enough for its single use here.
This only exists to show I have nothing up my sleeve. I don't suggested this gets merged.
The patch this script generates has the following corner cases:
* The original files are regenerated, which will add newlines that are not present in the original file.
* An trace-point header file the only contains boiler-plate is created in the arch and filesystem code. The parser doesn't know how to remove the includes for these - but its easy to 'keep' the file contents on the correct side. A follow-up patch will remove these files and their includes.
* asm/cpu_device_id.h and a relative path for 'X86_CONFIG()' are kept in the filesystem code to ensure x86 builds. A follow-up patch will remove these.
* This script doesn't know how to move the documentation, and update the links in comments. A follow-up patch does this.
---
Changes since v5:
* Regex twiddling to match surprise tabs.
* Added else case to avoid double output of #defines.
--- resctrl_copy_pasta.py | 823 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 823 insertions(+) create mode 100644 resctrl_copy_pasta.py
resctrl_copy_pasta.py new file +823 -0
@@ -0,0 +1,823 @@ +#!/usr/bin/python +import sys; +import os; +import re; + +############ + +SRC_DIR = "arch/x86/kernel/cpu/resctrl"; +DST_DIR = "fs/resctrl"; + +resctrl_files = [ + "ctrlmondata.c", + "internal.h", + "monitor.c", + "pseudo_lock.c", + "rdtgroup.c", + "pseudo_lock_trace.h", + "monitor_trace.h", +]; + +functions_to_keep = [ + # common + "pr_fmt", + + # core.c + "domain_list_lock", + "resctrl_arch_late_init", + "resctrl_arch_exit", + "resctrl_cpu_detect", + "rdt_cpu_has", + "resctrl_arch_is_evt_configurable", + "get_mem_config", + "get_slow_mem_config", + "get_rdt_alloc_resources", + "get_rdt_mon_resources", + "__check_quirks_intel", + "check_quirks", + "get_rdt_resources", + "rdt_init_res_defs_intel", + "rdt_init_res_defs_amd", + "rdt_init_res_defs", + "resctrl_cpu_detect", + "resctrl_arch_late_init", + "resctrl_arch_exit", + "setup_default_ctrlval", + "domain_free", + "domain_setup_ctrlval", + "arch_domain_mbm_alloc", + "domain_add_cpu", + "domain_remove_cpu", + "clear_closid_rmid", + "resctrl_arch_online_cpu", + "resctrl_arch_offline_cpu", + "resctrl_arch_get_num_closid", + "rdt_ctrl_update", + "domain_init", + "resctrl_arch_get_resource", + "cache_alloc_hsw_probe", + "rdt_get_mb_table", + "__get_mem_config_intel", + "__rdt_get_mem_config_amd", + "rdt_get_cache_alloc_cfg", + "rdt_get_cdp_config", + "rdt_get_cdp_l3_config", + "rdt_get_cdp_l2_config", + "resctrl_arch_get_cdp_enabled", + "set_rdt_options", + "pqr_state", + "rdt_resources_all", + "delay_bw_map", + "rdt_options", + "cat_wrmsr", + "mba_wrmsr_amd", + "mba_wrmsr_intel", + "anonymous-enum", + "rdt_find_domain", + "rdt_alloc_capable", + "rdt_online", + "RDT_OPT", + + # ctrlmon.c + "apply_config", + "resctrl_arch_update_one", + "resctrl_arch_update_domains", + "resctrl_arch_get_config", + + # internal.h + "L3_QOS_CDP_ENABLE", + "L2_QOS_CDP_ENABLE", + "MBM_CNTR_WIDTH_BASE", + "MBA_IS_LINEAR", + "MBM_CNTR_WIDTH_OFFSET_AMD", + "RMID_VAL_ERROR", + "RMID_VAL_UNAVAIL", + "MBM_CNTR_WIDTH_OFFSET_MAX", + "arch_mbm_state", + "rdt_hw_ctrl_domain", + "rdt_hw_mon_domain", + "resctrl_to_arch_ctrl_dom", + "resctrl_to_arch_mon_dom", + "msr_param", + "rdt_hw_resource", + "resctrl_to_arch_res", + "rdt_resources_all", + "resctrl_inc", + "for_each_rdt_resource", + "for_each_capable_rdt_resource", + "for_each_alloc_capable_rdt_resource", + "for_each_mon_capable_rdt_resource", + "arch_mon_domain_online", + "cpuid_0x10_1_eax", + "cpuid_0x10_3_eax", + "cpuid_0x10_x_ecx", + "cpuid_0x10_x_edx", + "rdt_ctrl_update", + "rdt_get_mon_l3_config", + "rdt_cpu_has", + "intel_rdt_mbm_apply_quirk", + "rdt_domain_reconfigure_cdp", + + # monitor.c + "rdt_mon_capable", + "rdt_mon_features", + "CF", + "snc_nodes_per_l3_cache", + "mbm_cf_table", + "mbm_cf_rmidthreshold", + "mbm_cf", + "logical_rmid_to_physical_rmid", + "__rmid_read_phys", + "get_corrected_mbm_count", + "__rmid_read", + "get_arch_mbm_state", + "resctrl_arch_reset_rmid", + "resctrl_arch_reset_rmid_all", + "mbm_overflow_count", + "resctrl_arch_rmid_read", + "snc_cpu_ids", + "snc_get_config", + "rdt_get_mon_l3_config", + "intel_rdt_mbm_apply_quirk", + + # pseudo_lock.c + "prefetch_disable_bits", + "resctrl_arch_get_prefetch_disable_bits", + "resctrl_arch_pseudo_lock_fn", + "resctrl_arch_measure_cycles_lat_fn", + "perf_miss_attr", + "perf_hit_attr", + "residency_counts", + "measure_residency_fn", + "resctrl_arch_measure_l2_residency", + "resctrl_arch_measure_l3_residency", + + # rdtgroup.c + "rdt_enable_key", + "rdt_mon_enable_key", + "rdt_alloc_enable_key", + "resctrl_arch_sync_cpu_closid_rmid", + "INVALID_CONFIG_INDEX", + "mon_event_config_index_get", + "resctrl_arch_mon_event_config_read", + "resctrl_arch_mon_event_config_write", + "l3_qos_cfg_update", + "l2_qos_cfg_update", + "set_cache_qos_cfg", + "rdt_domain_reconfigure_cdp", + "cdp_enable", + "cdp_disable", + "resctrl_arch_set_cdp_enabled", + "resctrl_arch_reset_all_ctrls", + + # pseudo_lock_trace.h + "TRACE_SYSTEM", + "pseudo_lock_mem_latency", + "pseudo_lock_l2", + "pseudo_lock_l3", + "TRACE_INCLUDE_PATH", + "TRACE_INCLUDE_FILE", +]; + +functions_to_move = [ + # common + "pr_fmt", + + # ctrlmon.c + "rdt_parse_data", + "(ctrlval_parser_t)", + "bw_validate", + "parse_bw", + "cbm_validate", + "parse_cbm", + "get_parser", + "parse_line", + "rdtgroup_parse_resource", + "rdtgroup_schemata_write", + "show_doms", + "rdtgroup_schemata_show", + "smp_mon_event_count", + "rdtgroup_mba_mbps_event_write", + "rdtgroup_mba_mbps_event_show", + "resctrl_find_domain", + "mon_event_read", + "rdtgroup_mondata_show", + + # internal.h + "MBM_OVERFLOW_INTERVAL", + "CQM_LIMBOCHECK_INTERVAL", + "cpumask_any_housekeeping", + "rdt_kn_name", + "rdt_fs_context", + "rdt_fc2context", + "mon_evt", + "mon_data", + "rmid_read", + "resctrl_schema_all", + "resctrl_mounted", + "rdt_group_type", + "rdtgrp_mode", + "mongroup", + "rdtgroup", + "RDT_DELETED", + "RFTYPE_FLAGS_CPUS_LIST", + "RFTYPE_INFO", + "RFTYPE_BASE", + "RFTYPE_CTRL", + "RFTYPE_MON", + "RFTYPE_TOP", + "RFTYPE_RES_CACHE", + "RFTYPE_RES_MB", + "RFTYPE_DEBUG", + "RFTYPE_CTRL_INFO", + "RFTYPE_MON_INFO", + "RFTYPE_TOP_INFO", + "RFTYPE_CTRL_BASE", + "RFTYPE_MON_BASE", + "rdt_all_groups", + "rftype", + "mbm_state", + "is_mba_sc", + + # monitor.c + "rmid_entry", + "rmid_free_lru", + "closid_num_dirty_rmid", + "rmid_limbo_count", + "rmid_ptrs", + "resctrl_rmid_realloc_threshold", + "resctrl_rmid_realloc_limit", + "__rmid_entry", + "limbo_release_entry", + "__check_limbo", + "has_busy_rmid", + "resctrl_find_free_rmid", + "resctrl_find_cleanest_closid", + "alloc_rmid", + "add_rmid_to_limbo", + "free_rmid", + "get_mbm_state", + "__mon_event_count", + "mbm_bw_count", + "mon_event_count", + "get_ctrl_domain_from_cpu", + "update_mba_bw", + "mbm_update_one_event", + "mbm_update", + "cqm_handle_limbo", + "cqm_setup_limbo_handler", + "mbm_handle_overflow", + "mbm_setup_overflow_handler", + "dom_data_init", + "dom_data_exit", + "llc_occupancy_event", + "mbm_total_event", + "mbm_local_event", + "l3_mon_evt_init", + "resctrl_mon_resource_init", + "resctrl_mon_resource_exit", + + # pseudo_lock.c + "pseudo_lock_major", + "pseudo_lock_minor_avail", + "pseudo_lock_devnode", + "pseudo_lock_class", + "pseudo_lock_minor_get", + "pseudo_lock_minor_release", + "region_find_by_minor", + "pseudo_lock_pm_req", + "pseudo_lock_cstates_relax", + "pseudo_lock_cstates_constrain", + "pseudo_lock_region_clear", + "pseudo_lock_region_init", + "pseudo_lock_init", + "pseudo_lock_region_alloc", + "pseudo_lock_free", + "rdtgroup_monitor_in_progress", + "rdtgroup_locksetup_user_restrict", + "rdtgroup_locksetup_user_restore", + "rdtgroup_locksetup_enter", + "rdtgroup_locksetup_exit", + "rdtgroup_cbm_overlaps_pseudo_locked", + "rdtgroup_pseudo_locked_in_hierarchy", + "pseudo_lock_measure_cycles", + "pseudo_lock_measure_trigger", + "pseudo_measure_fops", + "rdtgroup_pseudo_lock_create", + "rdtgroup_pseudo_lock_remove", + "pseudo_lock_dev_open", + "pseudo_lock_dev_release", + "pseudo_lock_dev_mremap", + "pseudo_mmap_ops", + "pseudo_lock_dev_mmap", + "pseudo_lock_dev_fops", + "rdt_pseudo_lock_init", + "rdt_pseudo_lock_release", + + # rdtgroup.c + "rdtgroup_mutex", + "rdt_root", + "rdtgroup_default", + "rdt_all_groups", + "resctrl_schema_all", + "mon_data_kn_priv_list", + "resctrl_mounted", + "kn_info", + "kn_mongrp", + "kn_mondata", + "max_name_width", + "last_cmd_status", + "last_cmd_status_buf", + "rdtgroup_setup_root", + "rdtgroup_destroy_root", + "debugfs_resctrl", + "mba_mbps_default_event", + "resctrl_debug", + "rdt_last_cmd_clear", + "rdt_last_cmd_puts", + "rdt_last_cmd_printf", + "rdt_staged_configs_clear", + "resctrl_is_mbm_enabled", + "resctrl_is_mbm_event", + "closid_free_map", + "closid_free_map_len", + "closids_supported", + "closid_init", + "closid_exit", + "closid_alloc", + "closid_free", + "closid_allocated", + "rdtgroup_mode_by_closid", + "rdt_mode_str", + "rdtgroup_mode_str", + "rdtgroup_kn_set_ugid", + "rdtgroup_add_file", + "rdtgroup_seqfile_show", + "rdtgroup_file_write", + "rdtgroup_kf_single_ops", + "kf_mondata_ops", + "is_cpu_list", + "rdtgroup_cpus_show", + "update_closid_rmid", + "cpus_mon_write", + "cpumask_rdtgrp_clear", + "cpus_ctrl_write", + "rdtgroup_cpus_write", + "rdtgroup_remove", + "_update_task_closid_rmid", + "update_task_closid_rmid", + "task_in_rdtgroup", + "__rdtgroup_move_task", + "is_closid_match", + "is_rmid_match", + "rdtgroup_tasks_assigned", + "rdtgroup_task_write_permission", + "rdtgroup_move_task", + "rdtgroup_tasks_write", + "show_rdt_tasks", + "rdtgroup_tasks_show", + "rdtgroup_closid_show", + "rdtgroup_rmid_show", + "proc_resctrl_show", + "rdt_last_cmd_status_show", + "rdt_kn_parent_priv", + "rdt_num_closids_show", + "rdt_default_ctrl_show", + "rdt_min_cbm_bits_show", + "rdt_shareable_bits_show", + "rdt_bit_usage_show", + "rdt_min_bw_show", + "rdt_num_rmids_show", + "rdt_mon_features_show", + "rdt_bw_gran_show", + "rdt_delay_linear_show", + "max_threshold_occ_show", + "rdt_thread_throttle_mode_show", + "max_threshold_occ_write", + "rdtgroup_mode_show", + "resctrl_peer_type", + "rdt_has_sparse_bitmasks_show", + "__rdtgroup_cbm_overlaps", + "rdtgroup_cbm_overlaps", + "rdtgroup_mode_test_exclusive", + "rdtgroup_mode_write", + "rdtgroup_cbm_to_size", + "rdtgroup_size_show", + "mondata_config_read", + "mbm_config_show", + "mbm_total_bytes_config_show", + "mbm_local_bytes_config_show", + "mbm_config_write_domain", + "mon_config_write", + "mbm_total_bytes_config_write", + "mbm_local_bytes_config_write", + "res_common_files", + "rdtgroup_add_files", + "rdtgroup_get_rftype_by_name", + "thread_throttle_mode_init", + "resctrl_file_fflags_init", + "rdtgroup_kn_mode_restrict", + "rdtgroup_kn_mode_restore", + "rdtgroup_mkdir_info_resdir", + "fflags_from_resource", + "rdtgroup_create_info_dir", + "mongroup_create_dir", + "is_mba_linear", + "mba_sc_domain_allocate", + "mba_sc_domain_destroy", + "supports_mba_mbps", + "set_mba_sc", + "kernfs_to_rdtgroup", + "rdtgroup_kn_get", + "rdtgroup_kn_put", + "rdtgroup_kn_lock_live", + "rdtgroup_kn_unlock", + "rdt_disable_ctx", + "rdt_enable_ctx", + "schemata_list_add", + "schemata_list_create", + "schemata_list_destroy", + "rdt_get_tree", + "rdt_param", + "rdt_fs_parameters", + "rdt_parse_param", + "rdt_fs_context_free", + "rdt_fs_context_ops", + "rdt_init_fs_context", + "rdt_move_group_tasks", + "free_all_child_rdtgrp", + "rmdir_all_sub", + "resctrl_fs_teardown", + "rdt_kill_sb", + "rdt_fs_type", + "mon_get_kn_priv", + "mon_put_kn_priv", + "mon_addfile", + "mon_rmdir_one_subdir", + "rmdir_mondata_subdir_allrdtgrp", + "mon_add_all_files", + "mkdir_mondata_subdir", + "mkdir_mondata_subdir_allrdtgrp", + "mkdir_mondata_subdir_alldom", + "mkdir_mondata_all", + "cbm_ensure_valid", + "__init_one_rdt_domain", + "rdtgroup_init_cat", + "rdtgroup_init_mba", + "rdtgroup_init_alloc", + "mkdir_rdt_prepare_rmid_alloc", + "mkdir_rdt_prepare_rmid_free", + "mkdir_rdt_prepare", + "mkdir_rdt_prepare_clean", + "rdtgroup_mkdir_mon", + "rdtgroup_mkdir_ctrl_mon", + "is_mon_groups", + "rdtgroup_mkdir", + "rdtgroup_rmdir_mon", + "rdtgroup_ctrl_remove", + "rdtgroup_rmdir_ctrl", + "rdt_kn_parent", + "rdtgroup_rmdir", + "mongrp_reparent", + "rdtgroup_rename", + "rdtgroup_show_options", + "rdtgroup_kf_syscall_ops", + "rdtgroup_setup_root", + "rdtgroup_destroy_root", + "rdtgroup_setup_default", + "domain_destroy_mon_state", + "resctrl_offline_ctrl_domain", + "resctrl_offline_mon_domain", + "domain_setup_mon_state", + "resctrl_online_ctrl_domain", + "resctrl_online_mon_domain", + "resctrl_online_cpu", + "clear_childcpus", + "get_mon_domain_from_cpu", + "resctrl_offline_cpu", + "resctrl_init", + "resctrl_online_domains_exist", + "resctrl_exit", + + # monitor_trace.h + "TRACE_SYSTEM", + "mon_llc_occupancy_limbo", + "TRACE_INCLUDE_PATH", + "TRACE_INCLUDE_FILE", +]; + +############ + +builtin_non_functions = ["__setup", "__exitcall", "__printf"]; +builtin_one_arg_macros = ["LIST_HEAD", "DEFINE_MUTEX", "DEFINE_STATIC_KEY_FALSE"]; +types = ["bool", "char", "int", "u32", "long", "u64"]; + +def get_array_name(line): + tok = re.search(r'([^\s]+?)\[\]', line) + if (tok is None): + return None; + return tok.group(1); + + +def get_struct_name(line): + tok = re.search(r'struct ([^\s]+?) {', line) + if (tok is None): + return None; + return tok.group(1); + +def get_enum_name(line): + tok = re.search(r'enum ([^\s]+?) {', line) + if (tok is None): + return None; + return tok.group(1); + +def get_union_name(line): + tok = re.search(r'union ([^\s]+?) {', line) + if (tok is None): + return None; + return tok.group(1); + + +def get_macro_name(line): + # #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + tok = re.search(r'#define[\s]+([^\s]+?)\(', line) + if (tok): + return tok.group(1); + + # #define RFTYPE_CTRL_INFO (RFTYPE_INFO | RFTYPE_CTRL) + tok = re.search(r'#define[\s]+([^\s]+?)[\s]+.+?\n', line) + if (tok): + return tok.group(1); + + return None; + + +def get_macro_target(line): + tok = re.search(r'[^\s]+?\(([^\s]+?)\);\n', line) + if (tok): + return tok.group(1); + + return None; + + +# Things like 'bool my_bool;' +def get_object_name(line): + # remove things that don't change the meaning of the name + if line.startswith("static "): + line = line[len("static "):]; + if line.startswith("extern "): + line = line[len("extern "):]; + if line.startswith("unsigned "): + line = line[len("unsigned "):]; + + # Note the trailing semicolon.. + tok = re.search(r'([^\s]+)\s[\*]*([^\s\[\],;]+)', line) + if tok: + if tok.group(1) in types: + return tok.group(2); + + tok = re.search(r'struct\s[^\s]+\s[\*]*([^\s;]+)', line) + if tok: + return tok.group(1); + + tok = re.search(r'enum\s[^\s]+\s([^\s;]+)', line) + if tok: + return tok.group(1); + + return None; + + +# Is there a name for this block of code? +# +# Function names are the token before '(' ... assuming there is only one '('. +# This also handles structs and arrays, +def get_block_name(line): + # remove things that don't change the meaning of the name + if (" __read_mostly" in line): + line = line.replace(" __read_mostly", ""); + if (" __initconst" in line): + line = line.replace(" __initconst", ""); + + if line == "enum {\n": + return "anonymous-enum"; + if (line.startswith("#define")): + return get_macro_name(line); + + if ("=" in line): + tok = re.search(r'[\*]*([^\s\[\]]+?)[\s\[\]]*=', line) + else: + tok = re.search(r'[\*]*([^\s]+?)\(.+?', line) + + if (tok is None): + if ("[]" in line): + return get_array_name(line); + if (line.startswith("struct") and line.endswith("{\n")): + return get_struct_name(line); + if (line.startswith("enum") and line.endswith("{\n")): + return get_enum_name(line); + if (line.startswith("union") and line.endswith("{\n")): + return get_union_name(line); + if (line.endswith(";\n") and '(' not in line): + return get_object_name(line); + if (line.endswith("= {\n") and '(' not in line): + return get_object_name(line); + return None; + + func_name = tok.group(1); + if (func_name in builtin_one_arg_macros): + tok = re.search(r'[^\(]+\(([^\s]+?)\)', line) + if (tok is None): + return None; + return tok.group(1); + elif (func_name == "DEFINE_PER_CPU"): + tok = re.search(r'DEFINE_PER_CPU\(.+?, ([^\s]+?)\)', line) + if (tok is None): + return None; + return tok.group(1); + elif (func_name == "TRACE_EVENT"): + tok = re.search(r'TRACE_EVENT\((.+?),', line) + if (tok is None): + return None; + return tok.group(1); + elif (func_name == "late_initcall"): + return get_macro_target(line); + else: + return func_name; + +def output_function_body(body, file): + # Mandatory whitespace between blocks + if os.lseek(file.fileno(), 0, os.SEEK_CUR) > 0: + file.write("\n".encode()); + + for out_line in body: + file.write(out_line.encode()); + +# Where should we put this block of code? +def output_function(name, body, files): + output = False; + (new_src, new_dst) = files; + + if (len(body)) == 0: + return; + + # Output to both files + if (name is None): + output_function_body(body, new_src); + output_function_body(body, new_dst); + output = True; + if (name in functions_to_keep): + output_function_body(body, new_src); + output = True; + if (name in functions_to_move): + output_function_body(body, new_dst); + output = True; + + if not output: + print("Missing function name: "+name); + #print(body); + +def reset_parser(): + global function_name; + global define_name; + global function_body; + global in_define; + + function_name = None; + define_name = None; + function_body = []; + in_define = False; + +############ + +for file in resctrl_files: + function_name = None; + # function_names take priority over defines, this is only used when + # no function_name was found + define_name = None; + function_body = []; + # Nothing clever - this is just to detect newlines between functions + in_function = False; + in_define = False; + + src_path = SRC_DIR + "/" + str(file); + if (not os.path.isfile(src_path)): + continue; + dst_path = DST_DIR + "/" + str(file); + + orig_file = open(src_path, "r"); + lines = orig_file.readlines(); + + # Now unlink the original file, so it can be re-created with new + # contents. + try: + os.unlink(src_path); + except Exception as err: + print("Failed to unlink source file: {err}"); + sys.exit(1); + + # non-buffering is so we can snoop the fd offset to avoid trailing newlines + new_src = open(src_path, "wb", buffering=0); + new_dst = open(dst_path, "wb", buffering=0); + + for line in lines: + # Empty lines outside a function - reset the function tracking + if (line == "\n" and not in_function): + if function_name is None and define_name is not None: + function_name = define_name; + output_function(function_name, function_body, (new_src, new_dst)); + reset_parser(); + + # Function prototypes are a funny C thing - reset the function tracking + elif (line[0].isspace() and not in_function and line.endswith(");\n")): + function_body += [line]; + output_function(function_name, function_body, (new_src, new_dst)); + reset_parser(); + + # Lines that begin with whitespace are part of the current function. + elif (line[0].isspace()): + function_body += [line]; + + # Next, try to find the kind of line that contains a function name + + # Ignore lines with comment markers, braces + elif (line.startswith("/*")): + function_body += [line]; + elif (line.startswith("*/")): + function_body += [line]; + elif (line.startswith("//")): + function_body += [line]; + elif (line == "{\n"): + function_body += [line]; + in_function = True; + elif (line == "}\n"): + function_body += [line]; + in_function = False; + elif (line == "};\n"): + function_body += [line]; + in_function = False; + + elif (line.startswith("#include")): + function_body += [line]; + elif (line.startswith("#if ")): + function_body += [line]; + elif (line.startswith("#ifdef ")): + function_body += [line]; + elif (line.startswith("#ifndef ")): + function_body += [line]; + elif (line.startswith("#else")): + function_body += [line]; + elif (line.startswith("#endif")): + function_body += [line]; + elif (line.startswith("#undef ")): + function_body += [line]; + elif (line.startswith("#define")): + function_body += [line]; + define_name = get_block_name(line); + + # Multi-line define? + if line.endswith("\\\n"): + in_define = True; + else: + output_function(define_name, function_body, (new_src, new_dst)); + reset_parser(); + elif in_define and line.endswith("\\\n"): + function_body += [line]; + + # goto was always a crime + elif (' ' not in line and line.endswith(":\n")): + function_body += [line]; + + # Try and parse a function/array name + + # Things like late_initcall() aren't function names, but belong to + # the previous function. + elif (get_block_name(line) in builtin_non_functions): + function_body += [line]; + + # Start a new block if we can get a block name for this line + elif (get_block_name(line) != None and function_name is None): + _name = get_block_name(line); + + if (line.endswith("{\n")): + in_function = True; + + # Is this a function prototype? Output it now + if (line.endswith(";\n")): + function_body += [line]; + output_function(_name, function_body, (new_src, new_dst)); + reset_parser(); + else: + function_name = _name; + function_body += [line]; + + # Failed to parse a function name ... did it get split up? + elif (line.startswith("static")): + function_body += [line]; + + else: + print("Unknown: '" + line + "'"); + + # Output whatever is left in the buffer + output_function(function_name, function_body, (new_src, new_dst)); + + orig_file.close();
Signature · 1 line
2.39.5
James Morse
reviewerPATCH v9 22/27 x86,fs/resctrl: Move the resctrl filesystem code to live in /fs/resctrl
In reply to James MorseResctrl is a filesystem interface to hardware that provides cache allocation policy and bandwidth control for groups of tasks or CPUs.
To support more than one architecture, resctrl needs to live in /fs/.
Move the code that is concerned with the filesystem interface to /fs/resctrl.
---
Changes since *:
* This patch is generated by a script.
--- arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 636 --- arch/x86/kernel/cpu/resctrl/internal.h | 380 +- arch/x86/kernel/cpu/resctrl/monitor.c | 902 +--- arch/x86/kernel/cpu/resctrl/monitor_trace.h | 18 +- arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 1080 +--- .../kernel/cpu/resctrl/pseudo_lock_trace.h | 2 + arch/x86/kernel/cpu/resctrl/rdtgroup.c | 4311 +--------------- fs/resctrl/ctrlmondata.c | 660 +++ fs/resctrl/internal.h | 442 ++ fs/resctrl/monitor.c | 932 ++++ fs/resctrl/monitor_trace.h | 33 + fs/resctrl/pseudo_lock.c | 1115 +++++ fs/resctrl/pseudo_lock_trace.h | 17 + fs/resctrl/rdtgroup.c | 4346 +++++++++++++++++ 14 files changed, 7562 insertions(+), 7312 deletions(-)
arch/x86/kernel/cpu/resctrl/ctrlmondata.c +0 -636
@@ -23,270 +23,6 @@#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_ctrl_domain *d); - -/* -* Check whether MBA bandwidth percentage value is correct. The value is -* checked against the minimum and max bandwidth values specified by the -* hardware. The allocated bandwidth percentage is rounded to the next -* control step available on the hardware. -*/ -static bool bw_validate (char *buf,u32 *data,struct rdt_resource *r) -{ -int ret; -u32 bw; - -/* -* Only linear delay values is supported for current Intel SKUs. -*/ -if (!r->membw.delay_linear && r->membw.arch_needs_linear) { -rdt_last_cmd_puts ("No support for non-linear MB domains\n" ); -return false; - } - - ret =kstrtou32 (buf,10 , &bw); -if (ret) { -rdt_last_cmd_printf ("Invalid MB value %s\n" , buf); -return false; - } - -/* Nothing else to do if software controller is enabled. */ -if (is_mba_sc (r)) { - *data = bw; -return true; - } - -if (bw < r->membw.min_bw || bw > r->membw.max_bw) { -rdt_last_cmd_printf ("MB value %u out of range [%d,%d]\n" , - bw, r->membw.min_bw, r->membw.max_bw); -return false; - } - - *data =roundup (bw, (unsigned long )r->membw.bw_gran); -return true; -} - -static int parse_bw (struct rdt_parse_data *data,struct resctrl_schema *s, -struct rdt_ctrl_domain *d) -{ -struct resctrl_staged_config *cfg; -u32 closid = data->rdtgrp->closid; -struct rdt_resource *r = s->res; -u32 bw_val; - - cfg = &d->staged_config[s->conf_type]; -if (cfg->have_new_ctrl) { -rdt_last_cmd_printf ("Duplicate domain %d\n" , d->hdr.id); -return -EINVAL ; - } - -if (!bw_validate (data->buf, &bw_val, r)) -return -EINVAL ; - -if (is_mba_sc (r)) { - d->mbps_val[closid] = bw_val; -return 0 ; - } - - cfg->new_ctrl = bw_val; - cfg->have_new_ctrl = true; - -return 0 ; -} - -/* -* Check whether a cache bit mask is valid. -* On Intel CPUs, non-contiguous 1s value support is indicated by CPUID: -* - CPUID.0x10.1:ECX[3]: L3 non-contiguous 1s value supported if 1 -* - CPUID.0x10.2:ECX[3]: L2 non-contiguous 1s value supported if 1 -* -* Haswell does not support a non-contiguous 1s value and additionally -* requires at least two bits set. -* AMD allows non-contiguous bitmasks. -*/ -static bool cbm_validate (char *buf,u32 *data,struct rdt_resource *r) -{ -u32 supported_bits =BIT_MASK (r->cache.cbm_len) -1 ; -unsigned int cbm_len = r->cache.cbm_len; -unsigned long first_bit, zero_bit, val; -int ret; - - ret =kstrtoul (buf,16 , &val); -if (ret) { -rdt_last_cmd_printf ("Non-hex character in the mask %s\n" , buf); -return false; - } - -if ((r->cache.min_cbm_bits >0 && val ==0 ) || val > supported_bits) { -rdt_last_cmd_puts ("Mask out of range\n" ); -return false; - } - - first_bit =find_first_bit (&val, cbm_len); - zero_bit =find_next_zero_bit (&val, cbm_len, first_bit); - -/* Are non-contiguous bitmasks allowed? */ -if (!r->cache.arch_has_sparse_bitmasks && - (find_next_bit (&val, cbm_len, zero_bit) < cbm_len)) { -rdt_last_cmd_printf ("The mask %lx has non-consecutive 1-bits\n" , val); -return false; - } - -if ((zero_bit - first_bit) < r->cache.min_cbm_bits) { -rdt_last_cmd_printf ("Need at least %d bits in the mask\n" , - r->cache.min_cbm_bits); -return false; - } - - *data = val; -return true; -} - -/* -* Read one cache bit mask (hex). Check that it is valid for the current -* resource type. -*/ -static int parse_cbm (struct rdt_parse_data *data,struct resctrl_schema *s, -struct rdt_ctrl_domain *d) -{ -struct rdtgroup *rdtgrp = data->rdtgrp; -struct resctrl_staged_config *cfg; -struct rdt_resource *r = s->res; -u32 cbm_val; - - cfg = &d->staged_config[s->conf_type]; -if (cfg->have_new_ctrl) { -rdt_last_cmd_printf ("Duplicate domain %d\n" , d->hdr.id); -return -EINVAL ; - } - -/* -* Cannot set up more than one pseudo-locked region in a cache -* hierarchy. -*/ -if (rdtgrp->mode ==RDT_MODE_PSEUDO_LOCKSETUP && -rdtgroup_pseudo_locked_in_hierarchy (d)) { -rdt_last_cmd_puts ("Pseudo-locked region in hierarchy\n" ); -return -EINVAL ; - } - -if (!cbm_validate (data->buf, &cbm_val, r)) -return -EINVAL ; - -if ((rdtgrp->mode ==RDT_MODE_EXCLUSIVE || - rdtgrp->mode ==RDT_MODE_SHAREABLE ) && -rdtgroup_cbm_overlaps_pseudo_locked (d, cbm_val)) { -rdt_last_cmd_puts ("CBM overlaps with pseudo-locked region\n" ); -return -EINVAL ; - } - -/* -* The CBM may not overlap with the CBM of another closid if -* either is exclusive. -*/ -if (rdtgroup_cbm_overlaps (s, d, cbm_val, rdtgrp->closid, true)) { -rdt_last_cmd_puts ("Overlaps with exclusive group\n" ); -return -EINVAL ; - } - -if (rdtgroup_cbm_overlaps (s, d, cbm_val, rdtgrp->closid, false)) { -if (rdtgrp->mode ==RDT_MODE_EXCLUSIVE || - rdtgrp->mode ==RDT_MODE_PSEUDO_LOCKSETUP ) { -rdt_last_cmd_puts ("Overlaps with other group\n" ); -return -EINVAL ; - } - } - - cfg->new_ctrl = cbm_val; - cfg->have_new_ctrl = true; - -return 0 ; -} - -/* -* For each domain in this resource we expect to find a series of: -* id=mask -* separated by ";". The "id" is in decimal, and must match one of -* the "id"s for this resource. -*/ -static int parse_line (char *line,struct resctrl_schema *s, -struct rdtgroup *rdtgrp) -{ -enum resctrl_conf_type t = s->conf_type; -ctrlval_parser_t *parse_ctrlval =NULL ; -struct resctrl_staged_config *cfg; -struct rdt_resource *r = s->res; -struct rdt_parse_data data; -struct rdt_ctrl_domain *d; -char *dom =NULL , *id; -unsigned long dom_id; - -/* Walking r->domains, ensure it can't race with cpuhp */ -lockdep_assert_cpus_held (); - -switch (r->schema_fmt) { -case RESCTRL_SCHEMA_BITMAP : - parse_ctrlval = &parse_cbm; -break ; -case RESCTRL_SCHEMA_RANGE : - parse_ctrlval = &parse_bw; -break ; - } - -if (WARN_ON_ONCE (!parse_ctrlval)) -return -EINVAL ; - -if (rdtgrp->mode ==RDT_MODE_PSEUDO_LOCKSETUP && - (r->rid ==RDT_RESOURCE_MBA || r->rid ==RDT_RESOURCE_SMBA )) { -rdt_last_cmd_puts ("Cannot pseudo-lock MBA resource\n" ); -return -EINVAL ; - } - -next: -if (!line || line[0 ] =='\0' ) -return 0 ; - dom =strsep (&line,";" ); - id =strsep (&dom,"=" ); -if (!dom ||kstrtoul (id,10 , &dom_id)) { -rdt_last_cmd_puts ("Missing '=' or non-numeric domain\n" ); -return -EINVAL ; - } - dom =strim (dom); -list_for_each_entry (d, &r->ctrl_domains, hdr.list) { -if (d->hdr.id == dom_id) { - data.buf = dom; - data.rdtgrp = rdtgrp; -if (parse_ctrlval (&data, s, d)) -return -EINVAL ; -if (rdtgrp->mode ==RDT_MODE_PSEUDO_LOCKSETUP ) { - cfg = &d->staged_config[t]; -/* -* In pseudo-locking setup mode and just -* parsed a valid CBM that should be -* pseudo-locked. Only one locked region per -* resource group and domain so just do -* the required initialization for single -* region and return. -*/ - rdtgrp->plr->s = s; - rdtgrp->plr->d = d; - rdtgrp->plr->cbm = cfg->new_ctrl; - d->plr = rdtgrp->plr; -return 0 ; - } - goto next; - } - } -return -EINVAL ; -} -int resctrl_arch_update_one (struct rdt_resource *r,struct rdt_ctrl_domain *d,u32 closid,enum resctrl_conf_type t,u32 cfg_val) {
@@ -351,100 +87,6 @@ int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid)return 0 ; } -static int rdtgroup_parse_resource (char *resname,char *tok, -struct rdtgroup *rdtgrp) -{ -struct resctrl_schema *s; - -list_for_each_entry (s, &resctrl_schema_all, list) { -if (!strcmp (resname, s->name) && rdtgrp->closid < s->num_closid) -return parse_line (tok, s, rdtgrp); - } -rdt_last_cmd_printf ("Unknown or unsupported resource name '%s'\n" , resname); -return -EINVAL ; -} - -ssize_t rdtgroup_schemata_write (struct kernfs_open_file *of, -char *buf,size_t nbytes,loff_t off) -{ -struct resctrl_schema *s; -struct rdtgroup *rdtgrp; -struct rdt_resource *r; -char *tok, *resname; -int ret =0 ; - -/* Valid input requires a trailing newline */ -if (nbytes ==0 || buf[nbytes -1 ] !='\n' ) -return -EINVAL ; - buf[nbytes -1 ] ='\0' ; - - rdtgrp =rdtgroup_kn_lock_live (of->kn); -if (!rdtgrp) { -rdtgroup_kn_unlock (of->kn); -return -ENOENT ; - } -rdt_last_cmd_clear (); - -/* -* No changes to pseudo-locked region allowed. It has to be removed -* and re-created instead. -*/ -if (rdtgrp->mode ==RDT_MODE_PSEUDO_LOCKED ) { - ret = -EINVAL ; -rdt_last_cmd_puts ("Resource group is pseudo-locked\n" ); - goto out; - } - -rdt_staged_configs_clear (); - -while ((tok =strsep (&buf,"\n" )) !=NULL ) { - resname =strim (strsep (&tok,":" )); -if (!tok) { -rdt_last_cmd_puts ("Missing ':'\n" ); - ret = -EINVAL ; - goto out; - } -if (tok[0 ] =='\0' ) { -rdt_last_cmd_printf ("Missing '%s' value\n" , resname); - ret = -EINVAL ; - goto out; - } - ret =rdtgroup_parse_resource (resname, tok, rdtgrp); -if (ret) - goto out; - } - -list_for_each_entry (s, &resctrl_schema_all, list) { - r = s->res; - -/* -* Writes to mba_sc resources update the software controller, -* not the control MSR. -*/ -if (is_mba_sc (r)) -continue ; - - ret =resctrl_arch_update_domains (r, rdtgrp->closid); -if (ret) - goto out; - } - -if (rdtgrp->mode ==RDT_MODE_PSEUDO_LOCKSETUP ) { -/* -* If pseudo-locking fails we keep the resource group in -* mode RDT_MODE_PSEUDO_LOCKSETUP with its class of service -* active and updated for just the domain the pseudo-locked -* region was requested for. -*/ - ret =rdtgroup_pseudo_lock_create (rdtgrp); - } - -out: -rdt_staged_configs_clear (); -rdtgroup_kn_unlock (of->kn); -return ret ?: nbytes; -} -u32 resctrl_arch_get_config (struct rdt_resource *r,struct rdt_ctrl_domain *d,u32 closid,enum resctrl_conf_type type) {
@@ -453,281 +95,3 @@ u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_ctrl_domain *d,return hw_dom->ctrl_val[idx]; } - -static void show_doms (struct seq_file *s,struct resctrl_schema *schema,int closid) -{ -struct rdt_resource *r = schema->res; -struct rdt_ctrl_domain *dom; -bool sep = false; -u32 ctrl_val; - -/* Walking r->domains, ensure it can't race with cpuhp */ -lockdep_assert_cpus_held (); - -seq_printf (s,"%*s:" , max_name_width, schema->name); -list_for_each_entry (dom, &r->ctrl_domains, hdr.list) { -if (sep) -seq_puts (s,";" ); - -if (is_mba_sc (r)) - ctrl_val = dom->mbps_val[closid]; -else - ctrl_val =resctrl_arch_get_config (r, dom, closid, - schema->conf_type); - -seq_printf (s, schema->fmt_str, dom->hdr.id, ctrl_val); - sep = true; - } -seq_puts (s,"\n" ); -} - -int rdtgroup_schemata_show (struct kernfs_open_file *of, -struct seq_file *s,void *v) -{ -struct resctrl_schema *schema; -struct rdtgroup *rdtgrp; -int ret =0 ; -u32 closid; - - rdtgrp =rdtgroup_kn_lock_live (of->kn); -if (rdtgrp) { -if (rdtgrp->mode ==RDT_MODE_PSEUDO_LOCKSETUP ) { -list_for_each_entry (schema, &resctrl_schema_all, list) { -seq_printf (s,"%s:uninitialized\n" , schema->name); - } - }else if (rdtgrp->mode ==RDT_MODE_PSEUDO_LOCKED ) { -if (!rdtgrp->plr->d) { -rdt_last_cmd_clear (); -rdt_last_cmd_puts ("Cache domain offline\n" ); - ret = -ENODEV ; - }else { -seq_printf (s,"%s:%d=%x\n" , - rdtgrp->plr->s->res->name, - rdtgrp->plr->d->hdr.id, - rdtgrp->plr->cbm); - } - }else { - closid = rdtgrp->closid; -list_for_each_entry (schema, &resctrl_schema_all, list) { -if (closid < schema->num_closid) -show_doms (s, schema, closid); - } - } - }else { - ret = -ENOENT ; - } -rdtgroup_kn_unlock (of->kn); -return ret; -} - -static int smp_mon_event_count (void *arg) -{ -mon_event_count (arg); - -return 0 ; -} - -ssize_t rdtgroup_mba_mbps_event_write (struct kernfs_open_file *of, -char *buf,size_t nbytes,loff_t off) -{ -struct rdtgroup *rdtgrp; -int ret =0 ; - -/* Valid input requires a trailing newline */ -if (nbytes ==0 || buf[nbytes -1 ] !='\n' ) -return -EINVAL ; - buf[nbytes -1 ] ='\0' ; - - rdtgrp =rdtgroup_kn_lock_live (of->kn); -if (!rdtgrp) { -rdtgroup_kn_unlock (of->kn); -return -ENOENT ; - } -rdt_last_cmd_clear (); - -if (!strcmp (buf,"mbm_local_bytes" )) { -if (resctrl_arch_is_mbm_local_enabled ()) - rdtgrp->mba_mbps_event =QOS_L3_MBM_LOCAL_EVENT_ID ; -else - ret = -EINVAL ; - }else if (!strcmp (buf,"mbm_total_bytes" )) { -if (resctrl_arch_is_mbm_total_enabled ()) - rdtgrp->mba_mbps_event =QOS_L3_MBM_TOTAL_EVENT_ID ; -else - ret = -EINVAL ; - }else { - ret = -EINVAL ; - } - -if (ret) -rdt_last_cmd_printf ("Unsupported event id '%s'\n" , buf); - -rdtgroup_kn_unlock (of->kn); - -return ret ?: nbytes; -} - -int rdtgroup_mba_mbps_event_show (struct kernfs_open_file *of, -struct seq_file *s,void *v) -{ -struct rdtgroup *rdtgrp; -int ret =0 ; - - rdtgrp =rdtgroup_kn_lock_live (of->kn); - -if (rdtgrp) { -switch (rdtgrp->mba_mbps_event) { -case QOS_L3_MBM_LOCAL_EVENT_ID : -seq_puts (s,"mbm_local_bytes\n" ); -break ; -case QOS_L3_MBM_TOTAL_EVENT_ID : -seq_puts (s,"mbm_total_bytes\n" ); -break ; -default : -pr_warn_once ("Bad event %d\n" , rdtgrp->mba_mbps_event); - ret = -EINVAL ; -break ; - } - }else { - ret = -ENOENT ; - } - -rdtgroup_kn_unlock (of->kn); - -return ret; -} - -struct rdt_domain_hdr *resctrl_find_domain (struct list_head *h,int id, -struct list_head **pos) -{ -struct rdt_domain_hdr *d; -struct list_head *l; - -list_for_each (l, h) { - d = list_entry(l, struct rdt_domain_hdr, list); -/* When id is found, return its domain. */ -if (id == d->id) -return d; -/* Stop searching when finding id's position in sorted list. */ -if (id < d->id) -break ; - } - -if (pos) - *pos = l; - -return NULL ; -} - -void mon_event_read (struct rmid_read *rr,struct rdt_resource *r, -struct rdt_mon_domain *d,struct rdtgroup *rdtgrp, -cpumask_t *cpumask,int evtid,int first) -{ -int cpu; - -/* When picking a CPU from cpu_mask, ensure it can't race with cpuhp */ -lockdep_assert_cpus_held (); - -/* -* Setup the parameters to pass to mon_event_count() to read the data. -*/ - rr->rgrp = rdtgrp; - rr->evtid = evtid; - rr->r = r; - rr->d = d; - rr->first = first; - rr->arch_mon_ctx =resctrl_arch_mon_ctx_alloc (r, evtid); -if (IS_ERR (rr->arch_mon_ctx)) { - rr->err = -EINVAL ; -return ; - } - - cpu =cpumask_any_housekeeping (cpumask,RESCTRL_PICK_ANY_CPU ); - -/* -* cpumask_any_housekeeping() prefers housekeeping CPUs, but -* are all the CPUs nohz_full? If yes, pick a CPU to IPI. -* MPAM's resctrl_arch_rmid_read() is unable to read the -* counters on some platforms if its called in IRQ context. -*/ -if (tick_nohz_full_cpu (cpu)) -smp_call_function_any (cpumask, mon_event_count, rr,1 ); -else -smp_call_on_cpu (cpu, smp_mon_event_count, rr, false); - -resctrl_arch_mon_ctx_free (r, evtid, rr->arch_mon_ctx); -} - -int rdtgroup_mondata_show (struct seq_file *m,void *arg) -{ -struct kernfs_open_file *of = m->private; -struct rdt_domain_hdr *hdr; -struct rmid_read rr = {0 }; -struct rdt_mon_domain *d; -u32 resid, evtid, domid; -struct rdtgroup *rdtgrp; -struct rdt_resource *r; -struct mon_data *md; -int ret =0 ; - - rdtgrp =rdtgroup_kn_lock_live (of->kn); -if (!rdtgrp) { - ret = -ENOENT ; - goto out; - } - - md = of->kn->priv; -if (WARN_ON_ONCE (!md)) { - ret = -EIO ; - goto out; - } - - resid = md->rid; - domid = md->domid; - evtid = md->evtid; - r =resctrl_arch_get_resource (resid); - -if (md->sum) { -/* -* This file requires summing across all domains that share -* the L3 cache id that was provided in the "domid" field of the -* struct mon_data. Search all domains in the resource for -* one that matches this cache id. -*/ -list_for_each_entry (d, &r->mon_domains, hdr.list) { -if (d->ci->id == domid) { - rr.ci = d->ci; -mon_event_read (&rr, r,NULL , rdtgrp, - &d->ci->shared_cpu_map, evtid, false); - goto checkresult; - } - } - ret = -ENOENT ; - goto out; - }else { -/* -* This file provides data from a single domain. Search -* the resource to find the domain with "domid". -*/ - hdr =resctrl_find_domain (&r->mon_domains, domid,NULL ); -if (!hdr ||WARN_ON_ONCE (hdr->type !=RESCTRL_MON_DOMAIN )) { - ret = -ENOENT ; - goto out; - } - d = container_of(hdr, struct rdt_mon_domain, hdr); -mon_event_read (&rr, r, d, rdtgrp, &d->hdr.cpu_mask, evtid, false); - } - -checkresult: - -if (rr.err == -EIO ) -seq_puts (m,"Error\n" ); -else if (rr.err == -EINVAL ) -seq_puts (m,"Unavailable\n" ); -else -seq_printf (m,"%llu\n" , rr.val); - -out: -rdtgroup_kn_unlock (of->kn); -return ret; -}
arch/x86/kernel/cpu/resctrl/internal.h +8 -372
415 lines not on this page · raw message
arch/x86/kernel/cpu/resctrl/monitor.c +2 -900
946 lines not on this page · raw message
arch/x86/kernel/cpu/resctrl/monitor_trace.h +2 -16
@@ -7,25 +7,11 @@#include <linux/tracepoint.h> -TRACE_EVENT (mon_llc_occupancy_limbo, - TP_PROTO(u32 ctrl_hw_id, u32 mon_hw_id, int domain_id, u64 llc_occupancy_bytes), -TP_ARGS (ctrl_hw_id, mon_hw_id, domain_id, llc_occupancy_bytes), - TP_STRUCT__entry(__field(u32, ctrl_hw_id) - __field(u32, mon_hw_id) - __field(int, domain_id) -__field (u64, llc_occupancy_bytes)), - TP_fast_assign(__entry->ctrl_hw_id = ctrl_hw_id; - __entry->mon_hw_id = mon_hw_id; - __entry->domain_id = domain_id; - __entry->llc_occupancy_bytes = llc_occupancy_bytes;), -TP_printk ("ctrl_hw_id=%u mon_hw_id=%u domain_id=%d llc_occupancy_bytes=%llu" , - __entry->ctrl_hw_id, __entry->mon_hw_id, __entry->domain_id, - __entry->llc_occupancy_bytes) - ); -#endif /* _FS_RESCTRL_MONITOR_TRACE_H */ #undef TRACE_INCLUDE_PATH#define TRACE_INCLUDE_PATH . +#define TRACE_INCLUDE_FILE monitor_trace +#include <trace/define_trace.h>
arch/x86/kernel/cpu/resctrl/pseudo_lock.c +1 -1079
961 lines not on this page · raw message
arch/x86/kernel/cpu/resctrl/pseudo_lock_trace.h +2 -0
Lines of this file are not shown. View the raw message.
arch/x86/kernel/cpu/resctrl/rdtgroup.c +2 -4309
4,311 lines not on this page · raw message
fs/resctrl/ctrlmondata.c +660 -0
660 lines not on this page · raw message
fs/resctrl/internal.h +442 -0
442 lines not on this page · raw message
fs/resctrl/monitor.c +932 -0
932 lines not on this page · raw message
fs/resctrl/pseudo_lock.c +1115 -0
1,115 lines not on this page · raw message
fs/resctrl/rdtgroup.c +4346 -0
4,346 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.5
Part of the diff is not shown here. View the raw message.
James Morse
reviewerPATCH v9 23/27 x86,fs/resctrl: Remove duplicated trace header files
In reply to James MorseThe copy-pasting python script creates some empty trace point header files. These can cause a build warning from ftrace.
Remove them.
---
Changes since v8:
* Removed stale CFLAGS_monitor.o for ftrace from arch/x86's Makefile.
--- arch/x86/kernel/cpu/resctrl/Makefile | 1 - arch/x86/kernel/cpu/resctrl/monitor.c | 4 ---- arch/x86/kernel/cpu/resctrl/monitor_trace.h | 17 ----------------- fs/resctrl/pseudo_lock.c | 4 ---- fs/resctrl/pseudo_lock_trace.h | 17 ----------------- 5 files changed, 43 deletions(-) delete mode 100644 arch/x86/kernel/cpu/resctrl/monitor_trace.h delete mode 100644 fs/resctrl/pseudo_lock_trace.h
arch/x86/kernel/cpu/resctrl/Makefile +0 -1
@@ -5,4 +5,3 @@ obj-$(CONFIG_RESCTRL_FS_PSEUDO_LOCK) += pseudo_lock.o # To allow define_trace.h's recursive include: CFLAGS_pseudo_lock.o = -I$(src) -CFLAGS_monitor.o = -I$(src)
arch/x86/kernel/cpu/resctrl/monitor.c +0 -4
@@ -27,10 +27,6 @@#include "internal.h" -#define CREATE_TRACE_POINTS - -#include "monitor_trace.h" -/* * Global boolean for rdt_monitor which is true if any * resource monitoring is enabled.
arch/x86/kernel/cpu/resctrl/monitor_trace.h deleted +0 -17
@@ -1,17 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#undef TRACE_SYSTEM -#define TRACE_SYSTEM resctrl - -#if !defined(_FS_RESCTRL_MONITOR_TRACE_H) || defined(TRACE_HEADER_MULTI_READ ) -#define _FS_RESCTRL_MONITOR_TRACE_H - -#include <linux/tracepoint.h> - -#endif /* _FS_RESCTRL_MONITOR_TRACE_H */ - -#undef TRACE_INCLUDE_PATH -#define TRACE_INCLUDE_PATH . - -#define TRACE_INCLUDE_FILE monitor_trace - -#include <trace/define_trace.h>
fs/resctrl/pseudo_lock.c +0 -4
@@ -30,10 +30,6 @@#include "../../events/perf_event.h" /* For X86_CONFIG() */ #include "internal.h" -#define CREATE_TRACE_POINTS - -#include "pseudo_lock_trace.h" -/* * Major number assigned to and shared by all devices exposing * pseudo-locked regions.
fs/resctrl/pseudo_lock_trace.h deleted +0 -17
@@ -1,17 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#undef TRACE_SYSTEM -#define TRACE_SYSTEM resctrl - -#if !defined(_X86_RESCTRL_PSEUDO_LOCK_TRACE_H) || defined(TRACE_HEADER_MULTI_READ ) -#define _X86_RESCTRL_PSEUDO_LOCK_TRACE_H - -#include <linux/tracepoint.h> - -#endif /* _X86_RESCTRL_PSEUDO_LOCK_TRACE_H */ - -#undef TRACE_INCLUDE_PATH -#define TRACE_INCLUDE_PATH . - -#define TRACE_INCLUDE_FILE pseudo_lock_trace - -#include <trace/define_trace.h>
Signature · 1 line
2.39.5
Re: [PATCH v9 23/27] x86,fs/resctrl: Remove duplicated trace header files
Hi James,
Quoted 5 lines · James Morse
The copy-pasting python script creates some empty trace point header files. These can cause a build warning from ftrace.
Remove them.
Quoted 7 lines
Signed-off-by James Morse <[email protected]>Tested-by Peter Newman <[email protected]>Tested-by Shaopeng Tan <[email protected]>Tested-by Babu Moger <[email protected]>---
Reinette
James Morse
reviewerPATCH v9 24/27 fs/resctrl: Remove unnecessary includes
In reply to James MorseWhen splitting and moving the resctrl code to live in fs/resctrl and arch/x86, some code was duplicated. This was done to keep the parser in the script that does the moving simple. This results in unnecessary includes in the arch and filesystem code.
Remove them.
---
Changes since v7:
* Expanded the scope, removed many more includes.
--- arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 4 ---- arch/x86/kernel/cpu/resctrl/internal.h | 5 ----- arch/x86/kernel/cpu/resctrl/monitor.c | 3 --- arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 7 ------- fs/resctrl/internal.h | 2 -- fs/resctrl/monitor.c | 3 --- fs/resctrl/pseudo_lock.c | 6 ------ fs/resctrl/rdtgroup.c | 2 -- 8 files changed, 32 deletions(-)
arch/x86/kernel/cpu/resctrl/ctrlmondata.c +0 -4
@@ -16,10 +16,6 @@#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt#include <linux/cpu.h> -#include <linux/kernfs.h> -#include <linux/seq_file.h> -#include <linux/slab.h> -#include <linux/tick.h> #include "internal.h"
arch/x86/kernel/cpu/resctrl/internal.h +0 -5
@@ -3,11 +3,6 @@#define _ASM_X86_RESCTRL_INTERNAL_H#include <linux/resctrl.h> -#include <linux/sched.h> -#include <linux/kernfs.h> -#include <linux/fs_context.h> -#include <linux/jump_label.h> -#include <linux/tick.h> #define L3_QOS_CDP_ENABLE 0x01ULL
arch/x86/kernel/cpu/resctrl/monitor.c +0 -3
@@ -18,10 +18,7 @@#define pr_fmt (fmt) "resctrl: " fmt#include <linux/cpu.h> -#include <linux/module.h> #include <linux/resctrl.h> -#include <linux/sizes.h> -#include <linux/slab.h> #include <asm/cpu_device_id.h>
arch/x86/kernel/cpu/resctrl/pseudo_lock.c +0 -7
@@ -12,17 +12,10 @@#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt#include <linux/cacheflush.h> -#include <linux/cacheinfo.h> #include <linux/cpu.h> -#include <linux/cpumask.h> -#include <linux/debugfs.h> -#include <linux/kthread.h> -#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/cpu_device_id.h> #include <asm/perf_event.h>
fs/resctrl/internal.h +0 -2
@@ -3,10 +3,8 @@#define _ASM_X86_RESCTRL_INTERNAL_H#include <linux/resctrl.h> -#include <linux/sched.h> #include <linux/kernfs.h> #include <linux/fs_context.h> -#include <linux/jump_label.h> #include <linux/tick.h> #define CQM_LIMBOCHECK_INTERVAL 1000
fs/resctrl/monitor.c +0 -3
@@ -18,13 +18,10 @@#define pr_fmt (fmt) "resctrl: " fmt#include <linux/cpu.h> -#include <linux/module.h> #include <linux/resctrl.h> #include <linux/sizes.h> #include <linux/slab.h> -#include <asm/cpu_device_id.h> -#include "internal.h" #define CREATE_TRACE_POINTS
fs/resctrl/pseudo_lock.c +0 -6
@@ -11,23 +11,17 @@#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt -#include <linux/cacheflush.h> #include <linux/cacheinfo.h> #include <linux/cpu.h> #include <linux/cpumask.h> #include <linux/debugfs.h> #include <linux/kthread.h> #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/cpu_device_id.h> -#include <asm/perf_event.h> - -#include "../../events/perf_event.h" /* For X86_CONFIG() */ #include "internal.h" /*
fs/resctrl/rdtgroup.c +0 -2
@@ -21,10 +21,8 @@#include <linux/resctrl.h> #include <linux/seq_buf.h> #include <linux/seq_file.h> -#include <linux/sched/signal.h> #include <linux/sched/task.h> #include <linux/slab.h> -#include <linux/task_work.h> #include <linux/user_namespace.h> #include <uapi/linux/magic.h>
Signature · 1 line
2.39.5
Re: [PATCH v9 24/27] fs/resctrl: Remove unnecessary includes
Hi James,
Quoted 10 lines · James Morse
When splitting and moving the resctrl code to live in fs/resctrl and
arch/x86, some code was duplicated. This was done to keep the parser in the script that does the moving simple. This results in unnecessary includes in the arch and filesystem code.Remove them.
Signed-off-by James Morse <[email protected]>---
Thank you.
Reinette
Re: [PATCH v9 24/27] fs/resctrl: Remove unnecessary includes
In reply to James MorseQuoted 9 lines · James Morse
When splitting and moving the resctrl code to live in fs/resctrl and
arch/x86, some code was duplicated. This was done to keep the parser in the script that does the moving simple. This results in unnecessary includes in the arch and filesystem code.Remove them.
Signed-off-by James Morse <[email protected]>
Thanks.
-Fenghua
James Morse
reviewerPATCH v9 25/27 fs/resctrl: Change internal.h's header guard macros
In reply to James MorseThe code in internal.h was moved by a script. The script didn't know to change the header guard macros. Do that.
--- fs/resctrl/internal.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/resctrl/internal.h +3 -3
@@ -1,6 +1,6 @@/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _ASM_X86_RESCTRL_INTERNAL_H -#define _ASM_X86_RESCTRL_INTERNAL_H +#ifndef _FS_RESCTRL_INTERNAL_H +#define _FS_RESCTRL_INTERNAL_H#include <linux/resctrl.h> #include <linux/kernfs.h>
@@ -437,4 +437,4 @@ static inline int rdtgroup_pseudo_lock_create(struct rdtgroup *rdtgrp)static inline void rdtgroup_pseudo_lock_remove (struct rdtgroup *rdtgrp) { }#endif /* CONFIG_RESCTRL_FS_PSEUDO_LOCK */ -#endif /* _ASM_X86_RESCTRL_INTERNAL_H */ +#endif /* _FS_RESCTRL_INTERNAL_H */
Signature · 1 line
2.39.5
Re: [PATCH v9 25/27] fs/resctrl: Change internal.h's header guard macros
Hi James,
Quoted 10 lines · James Morse
The code in
internal.hwas moved by a script. The script didn't know to change the header guard macros. Do that.Signed-off-by James Morse <[email protected]>Tested-by Peter Newman <[email protected]>Tested-by Shaopeng Tan <[email protected]>Tested-by Babu Moger <[email protected]>---
Reinette
Re: [PATCH v9 25/27] fs/resctrl: Change internal.h's header guard macros
In reply to James MorseQuoted 9 lines · James Morse
The code in
internal.hwas moved by a script. The script didn't know to change the header guard macros. Do that.Signed-off-by James Morse <[email protected]>Tested-by Peter Newman <[email protected]>Tested-by Shaopeng Tan <[email protected]>Tested-by Babu Moger <[email protected]>
Thanks.
-Fenghua
James Morse
reviewerPATCH v9 26/27 x86,fs/resctrl: Move resctrl.rst to live under Documentation/filesystems
In reply to James MorseThe filesystem code has moved from arch/x86 to fs. Move the documentation too.
---
Documentation/arch/x86/index.rst | 1 -
Documentation/filesystems/index.rst | 1 +
Documentation/{arch/x86 => filesystems}/resctrl.rst | 0
MAINTAINERS | 2 +-
arch/x86/kernel/cpu/resctrl/monitor.c | 2 +-
fs/resctrl/Kconfig | 2 +-
6 files changed, 4 insertions(+), 4 deletions(-)
rename Documentation/{arch/x86 => filesystems}/resctrl.rst (100%)Documentation/arch/x86/index.rst +0 -1
@@ -31,7 +31,6 @@ x86-specific Documentation pti mds microcode - resctrl tsx_async_abort buslock usb-legacy-support
Documentation/filesystems/index.rst +1 -0
@@ -113,6 +113,7 @@ Documentation for filesystem implementations. qnx6 ramfs-rootfs-initramfs relay + resctrl romfs smb/index spufs/index
Documentation/filesystems/resctrl.rst renamed from Documentation/arch/x86/resctrl.rst +0 -0
MAINTAINERS +1 -1
@@ -20340,7 +20340,7 @@ M: Tony Luck <[email protected]> M: Reinette Chatre <[email protected]> L: [email protected] S: Supported -F: Documentation/arch/x86/resctrl* +F: Documentation/filesystems/resctrl.rst F: arch/x86/include/asm/resctrl.h F: arch/x86/kernel/cpu/resctrl/ F: fs/resctrl/
arch/x86/kernel/cpu/resctrl/monitor.c +1 -1
@@ -40,7 +40,7 @@ unsigned int rdt_mon_features;static int snc_nodes_per_l3_cache =1 ;/* -* The correction factor table is documented in Documentation/arch/x86/resctrl.rst. +* The correction factor table is documented in Documentation/filesystems/resctrl.rst. * If rmid > rmid threshold, MBM total and local values should be multiplied * by the correction factor. *
fs/resctrl/Kconfig +1 -1
@@ -21,7 +21,7 @@ config RESCTRL_FS On architectures where this can be disabled independently, it is safe to say N. - See <file:Documentation/arch/x86/resctrl.rst> for more information. + See <file:Documentation/filesystems/resctrl.rst> for more information. config RESCTRL_FS_PSEUDO_LOCK bool
Signature · 1 line
2.39.5
James Morse
reviewerPATCH v9 27/27 MAINTAINERS: Add reviewers for fs/resctrl
In reply to James Morseresctrl has existed for quite a while as a filesystem interface private to arch/x86. To allow other architectures to support the same user interface for similar hardware features, it has been moved to /fs/.
Add those with a vested interest in the common code as reviewers.
--- MAINTAINERS | 2 ++ 1 file changed, 2 insertions(+)
MAINTAINERS +2 -0
@@ -20338,6 +20338,8 @@ F: tools/testing/selftests/net/rds/ RDT - RESOURCE ALLOCATION M: Tony Luck <[email protected]> M: Reinette Chatre <[email protected]> +R: Dave Martin <[email protected]> +R: James Morse <[email protected]> L: [email protected] S: Supported F: Documentation/filesystems/resctrl.rst
Signature · 1 line
2.39.5
Re: [PATCH v9 27/27] MAINTAINERS: Add reviewers for fs/resctrl
Hi,
Quoted 16 lines · James Morse
resctrl has existed for quite a while as a filesystem interface private to
arch/x86. To allow other architectures to support the same user interface for similar hardware features, it has been moved to /fs/.Add those with a vested interest in the common code as reviewers.
Signed-off-by James Morse <[email protected]>--- MAINTAINERS | 2 ++ 1 file changed, 2 insertions(+)MAINTAINERS +0
-0
MAINTAINERS F: tools/testing/selftests/net/rds/ · line 20341
Quoted 4 lines
MAINTAINERS +1
-0@@ -20338,6 +20338,8 @@ F: tools/testing/selftests/net/rds/ RDT - RESOURCE ALLOCATION M: Tony Luck <[email protected]> M: Reinette Chatre <[email protected]> +R: Dave Martin <[email protected]>
I'm happy to do this, though my conributions may continue to be a bit intermittent.
MAINTAINERS F: tools/testing/selftests/net/rds/ · line 20345
Quoted 4 lines
MAINTAINERS +1
-0+R: James Morse <[email protected]> L: [email protected] S: Supported F: Documentation/filesystems/resctrl.rst
[...]
Cheers
---Dave
Quoted 2 lines
Re: [PATCH v9 27/27] MAINTAINERS: Add reviewers for fs/resctrl
In reply to James MorseHi James and Dave,
Quoted 16 lines · James Morse
resctrl has existed for quite a while as a filesystem interface private to
arch/x86. To allow other architectures to support the same user interface for similar hardware features, it has been moved to /fs/.Add those with a vested interest in the common code as reviewers.
Signed-off-by James Morse <[email protected]>--- MAINTAINERS | 2 ++ 1 file changed, 2 insertions(+)MAINTAINERS +0
-0
MAINTAINERS F: tools/testing/selftests/net/rds/ · line 20345
Quoted 8 lines
MAINTAINERS +2
-0@@ -20338,6 +20338,8 @@ F: tools/testing/selftests/net/rds/ RDT - RESOURCE ALLOCATION M: Tony Luck <[email protected]> M: Reinette Chatre <[email protected]> +R: Dave Martin <[email protected]> +R: James Morse <[email protected]> L: [email protected] S: Supported F: Documentation/filesystems/resctrl.rst
Thank you.
Reinette
Reinette Chatre
maintainerHi James,
Quoted 10 lines · James Morse
Changes since v8:
* Added check forclosid_init()on monitor only platforms.
* Moved end-marker into array and added default cases.
* Additional patches to move prototpyes between header files.Changes otherwise noted on each patch.
---
Patches 20-26 should be squashed together when merged, taking the commit message
To make things as simple as possible this needs to be as detailed as possible. For example, drop patch 21, *then* squash patches 20, 22 - 26. Having your repo as reference is a great help.
Quoted 1 line
of patch 21. They are posted like this to allow folk to re-generate patch 21, then
"patch 21" -> "patch 22"
Quoted 9 lines
review the differences on top. Not squashing them together would expose a ftrace build warning during bisect. (but who does that!)
That would look like this:git://git.kernel.org/pub/scm/linux/kernel/git/morse/linux.gitmpam/move_to_fs/v9_finalThis series is based on rc3, and can be retrieved from:
git://git.kernel.org/pub/scm/linux/kernel/git/morse/linux.gitmpam/move_to_fs/v9This series renames functions and moves code around. With the
This series evolved to do more than this ;)
Reinette
James Morse
reviewerHi Reinette,
Quoted 8 lines · Reinette Chatre
Quoted 7 lines · James Morse
Changes since v8:
* Added check forclosid_init()on monitor only platforms.
* Moved end-marker into array and added default cases.
* Additional patches to move prototpyes between header files.Changes otherwise noted on each patch.
Quoted 7 lines
Quoted 3 lines
---
Patches 20-26 should be squashed together when merged, taking the commit message
To make things as simple as possible this needs to be as detailed as possible. For example, drop patch 21, *then* squash patches 20, 22 - 26. Having your repo as reference is a great help.
Ah - I thought I'd deleted the python script from the version posted! I'll tighten up that wording, it should really say which commit message to keep too.
If there is unlikely to be further review for those last patches, the other option is to do this for v9 - but point people at the earlier version if they want to see the changes broken out. This saves some work for the tip folk.
Quoted 9 lines
Quoted 1 line
of patch 21. They are posted like this to allow folk to re-generate patch 21, then
"patch 21" -> "patch 22"
Quoted 5 lines
review the differences on top. Not squashing them together would expose a ftrace build warning during bisect. (but who does that!)
That would look like this:git://git.kernel.org/pub/scm/linux/kernel/git/morse/linux.gitmpam/move_to_fs/v9_final
Quoted 6 lines
Quoted 4 lines
This series is based on rc3, and can be retrieved from:
git://git.kernel.org/pub/scm/linux/kernel/git/morse/linux.gitmpam/move_to_fs/v9This series renames functions and moves code around. With the
This series evolved to do more than this ;)
Good point!
Thanks,
James
Reinette Chatre
maintainerHi James,
Quoted 19 lines · James Morse
Hi Reinette,
Quoted 8 lines · Reinette Chatre
Quoted 7 lines · James Morse
Changes since v8:
* Added check forclosid_init()on monitor only platforms.
* Moved end-marker into array and added default cases.
* Additional patches to move prototpyes between header files.Changes otherwise noted on each patch.
Quoted 7 lines
Quoted 3 lines
---
Patches 20-26 should be squashed together when merged, taking the commit message
To make things as simple as possible this needs to be as detailed as possible. For example, drop patch 21, *then* squash patches 20, 22 - 26. Having your repo as reference is a great help.
Quoted 6 lines
Ah - I thought I'd deleted the python script from the version posted! I'll tighten up that wording, it should really say which commit message to keep too.
If there is unlikely to be further review for those last patches, the other option is to do this for v9 - but point people at the earlier version if they want to see the changes broken out. This saves some work for the tip folk.
(v9 -> v10)
I do not know how much tip folk have been following this work. I also believe that any version should make things as simple and straightforward as possible. To that end I am concerned about requiring folks to compare versions in order to understand a posting. To me it sounds simpler to keep changes broken out. Personally I think squashing clear broken out patches is simpler than trying to understand a bigger change by comparing it to a different version of a series. Of course, this is my opinion with caveat that I am not the one that will be doing this.
Reinette
Hi James, Reinette,
Quoted 117 lines · James Morse
Changes since v8:
* Added check forclosid_init()on monitor only platforms.
* Moved end-marker into array and added default cases.
* Additional patches to move prototpyes between header files.Changes otherwise noted on each patch.
---
Patches 20-26 should be squashed together when merged, taking the commit message of patch 21. They are posted like this to allow folk to re-generate patch 21, then review the differences on top. Not squashing them together would expose a ftrace build warning during bisect. (but who does that!)
That would look like this:git://git.kernel.org/pub/scm/linux/kernel/git/morse/linux.gitmpam/move_to_fs/v9_finalThis series is based on rc3, and can be retrieved from:
git://git.kernel.org/pub/scm/linux/kernel/git/morse/linux.gitmpam/move_to_fs/v9This 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. It is now possible for
throttle_modeto report 'undefined', but no known platform will do this.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])
As ever - bugs welcome,
Thanks,James
[v8] https://lore.kernel.org/all/[email protected]
[v7] https://lore.kernel.org/all/[email protected]/
[v6] https://lore.kernel.org/lkml/[email protected]/
[v5] https://lore.kernel.org/r/[email protected]
[v4] https://lore.kernel.org/all/[email protected]/
[v3] https://lore.kernel.org/r/[email protected]
[v2] https://lore.kernel.org/r/[email protected]
[v1] https://lore.kernel.org/r/[email protected]
[1] https://lore.kernel.org/lkml/[email protected]/Amit Singh Tomar (1):
x86/resctrl: Remove the limit on the number of CLOSIDDave Martin (3):
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 #includesJames Morse (23):
x86/resctrl: Renameresctrl_sched_in()to begin with "resctrl_arch_" x86/resctrl: Check all domains are offline inresctrl_exit()x86/resctrl:resctrl_exit()teardown resctrl but leave the mount point x86/resctrl: Drop __init/__exit on assorted symbols x86/resctrl: Moveis_mba_sc()out ofcore.c
x86/resctrl: Add end-marker to theresctrl_event_idenum x86/resctrl: Expand the width of domid by replacingmon_data_bitsx86/resctrl: Splittrace.h
x86/resctrl: Add 'resctrl' to the title of the resctrl documentation fs/resctrl: Add boiler plate for external resctrl code x86/resctrl: Move the filesystem bits to headers visible to fs/resctrl x86/resctrl: Move enumresctrl_event_idtoresctrl.hx86/resctrl: Fix types inresctrl_arch_mon_ctx_alloc()and free stubs x86/resctrl: Move pseudo lock prototypes toinclude/linux/resctrl.hx86/resctrl: Always initialise rid field in rdt_resources_all[] x86/resctrl: Remove a newline to avoid confusing the code move script x86/resctrl: Add python script to move resctrl code to /fs/resctrl x86,fs/resctrl: Move the resctrl filesystem code to live in
/fs/resctrl
x86,fs/resctrl: Remove duplicated trace header files fs/resctrl: Remove unnecessary includes
fs/resctrl: Change internal.h's header guard macros x86,fs/resctrl: Moveresctrl.rstto live under
Documentation/filesystems
MAINTAINERS: Add reviewers for fs/resctrlDocumentation/arch/x86/index.rst | 1 - Documentation/filesystems/index.rst | 1 + .../{arch/x86 => filesystems}/resctrl.rst | 6 +- MAINTAINERS | 5 +- arch/Kconfig | 8 + arch/x86/Kconfig | 11 +- arch/x86/include/asm/resctrl.h | 15 +- arch/x86/kernel/cpu/resctrl/Makefile | 2 + arch/x86/kernel/cpu/resctrl/core.c | 31 +- arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 635 --- arch/x86/kernel/cpu/resctrl/internal.h | 399 +- arch/x86/kernel/cpu/resctrl/monitor.c | 918 +--- arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 1092 +---- .../resctrl/{trace.h => pseudo_lock_trace.h} | 26 +- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 4164 +--------------- arch/x86/kernel/process_32.c | 2 +- arch/x86/kernel/process_64.c | 2 +- fs/Kconfig | 1 + fs/Makefile | 1 + fs/resctrl/Kconfig | 39 + fs/resctrl/Makefile | 6 + fs/resctrl/ctrlmondata.c | 660 +++ fs/resctrl/internal.h | 440 ++ fs/resctrl/monitor.c | 929 ++++ fs/resctrl/monitor_trace.h | 33 + fs/resctrl/pseudo_lock.c | 1105 +++++ fs/resctrl/rdtgroup.c | 4344 +++++++++++++++++ include/linux/resctrl.h | 36 +- include/linux/resctrl_types.h | 16 +- resctrl_copy_pasta.py | 823 ++++ 30 files changed, 8490 insertions(+), 7261 deletions(-) rename Documentation/{arch/x86 => filesystems}/resctrl.rst (99%) rename arch/x86/kernel/cpu/resctrl/{trace.h => pseudo_lock_trace.h} (56%) create mode 100644 fs/resctrl/Kconfig
Quoted 9 lines
create mode 100644 fs/resctrl/Makefile create mode 100644 fs/resctrl/ctrlmondata.c create mode 100644 fs/resctrl/internal.h create mode 100644 fs/resctrl/monitor.c create mode 100644 fs/resctrl/monitor_trace.h create mode 100644 fs/resctrl/pseudo_lock.c create mode 100644 fs/resctrl/rdtgroup.c create mode 100644 resctrl_copy_pasta.py
I retested the patches on a couple of AMD systems, and everything looks good.
It's very likely that these patches will be merged before my ABMC series [1].
I'm currently working on v13 of the ABMC series and considering rebasing it on top of James' v9. That could potentially eliminate one review cycle during the merge process.
What are your thoughts on this approach?
1. https://lore.kernel.org/lkml/[email protected]/
Signature · 2 lines
Thanks Babu Moger
Reinette Chatre
maintainerHi Babu,
Quoted 4 lines · Babu
I retested the patches on a couple of AMD systems, and everything looks good.
Tested-by Babu Moger [email protected]
Thank you very much.
Quoted 8 lines
It's very likely that these patches will be merged before my ABMC series [1].
I'm currently working on v13 of the ABMC series and considering rebasing it on top of James' v9. That could potentially eliminate one review cycle during the merge process.
What are your thoughts on this approach?
Thanks for considering this. From my viewpoint this sounds like a good plan. I do not have insight into James's schedule to support this but from what I can tell this work is close to being ready for inclusion.
Reinette
Quoted 2 lines
Hi Reinette,
Quoted 7 lines · Reinette Chatre
Hi Babu,
Quoted 4 lines · Babu
I retested the patches on a couple of AMD systems, and everything looks good.
Tested-by Babu Moger [email protected]
Correction:
Quoted 6 lines
Thank you very much.
Quoted 3 lines
It's very likely that these patches will be merged before my ABMC series [1].
Quoted 7 lines
Quoted 5 lines
I'm currently working on v13 of the ABMC series and considering rebasing it on top of James' v9. That could potentially eliminate one review cycle during the merge process.
What are your thoughts on this approach?
Thanks for considering this. From my viewpoint this sounds like a good plan.
Welcome.
Quoted 2 lines
I do not have insight into James's schedule to support this but from what I can tell this work is close to being ready for inclusion.
Sure. Lets wait for James or Martin's response.
Signature · 2 lines
Thanks Babu Moger
James Morse
reviewerHi Babu, Reinette,
Quoted 10 lines · Babu
Quoted 5 lines · Reinette Chatre
Quoted 4 lines · Babu
I retested the patches on a couple of AMD systems, and everything looks good.
Tested-by Babu Moger [email protected]Correction:
Tested-by Babu Moger <[email protected]>
Thanks for re-testing it!
Quoted 11 lines
Quoted 11 lines
Thank you very much.
Quoted 8 lines
It's very likely that these patches will be merged before my ABMC series [1].
I'm currently working on v13 of the ABMC series and considering rebasing it on top of James' v9. That could potentially eliminate one review cycle during the merge process.
What are your thoughts on this approach?
Quoted 8 lines
Quoted 1 line
Thanks for considering this. From my viewpoint this sounds like a good plan.
Welcome.
Quoted 2 lines
I do not have insight into James's schedule to support this but from what I can tell this work is close to being ready for inclusion.
Sure. Lets wait for James or Martin's response.
I've got a v9 to post, rebased on top of the cpumask changes. My only question is whether to post it with the tail end of patches squashed together - to save Boris having to do it.
Thanks,
James
Moger, Babu
reviewerHi James,
Quoted 32 lines · James Morse
Hi Babu, Reinette,
Quoted 10 lines · Babu
Quoted 5 lines · Reinette Chatre
Quoted 4 lines · Babu
I retested the patches on a couple of AMD systems, and everything looks good.
Tested-by Babu Moger [email protected]Correction:
Tested-by Babu Moger <[email protected]>Thanks for re-testing it!
Quoted 15 lines
Quoted 5 lines
Thank you very much.
Quoted 3 lines
It's very likely that these patches will be merged before my ABMC series [1].
Quoted 7 lines
Quoted 5 lines
I'm currently working on v13 of the ABMC series and considering rebasing it on top of James' v9. That could potentially eliminate one review cycle during the merge process.
What are your thoughts on this approach?
Thanks for considering this. From my viewpoint this sounds like a good plan.
Welcome.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
I do not have insight into James's schedule to support this but from what I can tell this work is close to being ready for inclusion.
Sure. Lets wait for James or Martin's response.
I've got a v9 to post, rebased on top of the cpumask changes. My only question is whether to post it with the tail end of patches squashed together - to save Boris having to do it.
You have few comments to address in v9. I would say post v10 with all the comments addressed without squashing. Give the clear instructions about squashing.
Let the maintainer decide how they want to handle it. Pretty sure they have seen these cases already. Worst case you may have to spin another version. My 02 cents.
Signature · 2 lines
Thanks Babu Moger
Reinette Chatre
maintainerQuoted 39 lines · Babu
Quoted 30 lines · James Morse
Quoted 10 lines · Babu
Quoted 5 lines · Reinette Chatre
Quoted 4 lines · Babu
I retested the patches on a couple of AMD systems, and everything looks good.
Tested-by Babu Moger [email protected]Correction:
Tested-by Babu Moger <[email protected]>Thanks for re-testing it!
Quoted 15 lines
Quoted 5 lines
Thank you very much.
Quoted 3 lines
It's very likely that these patches will be merged before my ABMC series [1].
Quoted 7 lines
Quoted 5 lines
I'm currently working on v13 of the ABMC series and considering rebasing it on top of James' v9. That could potentially eliminate one review cycle during the merge process.
What are your thoughts on this approach?
Thanks for considering this. From my viewpoint this sounds like a good plan.
Welcome.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
I do not have insight into James's schedule to support this but from what I can tell this work is close to being ready for inclusion.
Sure. Lets wait for James or Martin's response.
I've got a v9 to post, rebased on top of the cpumask changes. My only question is whether to post it with the tail end of patches squashed together - to save Boris having to do it.
Quoted 7 lines
You have few comments to address in v9. I would say post v10 with all the comments addressed without squashing. Give the clear instructions about squashing.
Let the maintainer decide how they want to handle it. Pretty sure they have seen these cases already. Worst case you may have to spin another version. My 02 cents.
I agree. I also responded to same question with
https://lore.kernel.org/lkml/[email protected]/
Reinette
Hello James, Reinette,
I ran tools/tests/selftests/resctrl with the following patch on AMD EPYC 9454P 48-Core Processor, it looks good.
https://lore.kernel.org/lkml/[email protected]/#r
Quoted 3 lines
Quoted 1 line
It is strange that you needed to add this since it can be found in v6.10 and up.
Sorry, I made a mistake. This patch is in v6.10 and up.
Best regards,
Shaopeng TAN
James Morse
reviewerHello Shaopeng Tan,
Quoted 10 lines · Shaopeng Tan (Fujitsu)
I ran
tools/tests/selftests/resctrlwith the following patch on AMD EPYC 9454P 48-Core Processor, it looks good.
https://lore.kernel.org/lkml/[email protected]/#rQuoted 3 lines
Quoted 1 line
It is strange that you needed to add this since it can be found in v6.10 and up.
Sorry, I made a mistake. This patch is in v6.10 and up.
Tested-by Shaopeng Tan <[email protected]>
Thanks for re-testing this!
James