x86/resctrl : Support AMD Assignable Bandwidth Monitoring Counters (ABMC)
Subsystems (3)
Babu Moger
reviewerv9 cover x86/resctrl : Support AMD Assignable Bandwidth Monitoring Counters (ABMC)
This series adds the support for Assignable Bandwidth Monitoring Counters (ABMC). It is also called QoS RMID Pinning feature
Series is written such that it is easier to support other assignable features supported from different vendors.
The feature details are documented in the APM listed below [1].
[1] AMD64 Architecture Programmer's Manual Volume 2: System Programming Publication # 24593 Revision 3.41 section 19.3.3.3 Assignable Bandwidth Monitoring (ABMC). The documentation is available at
The patches are based on top of commitda99b80a7f5f1 (tip/master) Merge branch into tip/master: 'x86/sev'
# Introduction
Users can create as many monitor groups as RMIDs supported by the hardware. However, bandwidth monitoring feature on AMD system only guarantees that RMIDs currently assigned to a processor will be tracked by hardware. The counters of any other RMIDs which are no longer being tracked will be reset to zero. The MBM event counters return "Unavailable" for the RMIDs that are not tracked by hardware. So, there can be only limited number of groups that can give guaranteed monitoring numbers. With ever changing configurations there is no way to definitely know which of these groups are being tracked for certain point of time. Users do not have the option to monitor a group or set of groups for certain period of time without worrying about counter being reset in between.
The ABMC feature provides an option to the user to assign a hardware counter to an RMID, event pair and monitor the bandwidth as long as it is assigned. The assigned RMID will be tracked by the hardware until the user unassigns it manually. There is no need to worry about counters being reset during this period. Additionally, the user can specify a bitmask identifying the specific bandwidth types from the given source to track with the counter.
Without ABMC enabled, monitoring will work in current 'default' mode without assignment option.
# Linux Implementation
Create a generic interface aimed to support user space assignment of scarce counters used for monitoring. First usage of interface is by ABMC with option to expand usage to "soft-ABMC" and MPAM counters in future.
Feature adds following interface files:
/sys/fs/resctrl/info/L3_MON/mbm_assign_mode: Reports the list of assignable monitoring features supported. The enclosed brackets indicate which feature is enabled.
/sys/fs/resctrl/info/L3_MON/num_mbm_cntrs: Reports the number of monitoring counters available for assignment.
/sys/fs/resctrl/info/L3_MON/available_mbm_cntrs: Reports the number of monitoring counters free in each domain.
/sys/fs/resctrl/info/L3_MON/mbm_assign_control: Reports the resctrl group and monitor status of each group. Assignment state can be updated by writing to the interface.
# Examples
a. Check if ABMC support is available
#mount -t resctrl resctrl /sys/fs/resctrl/
#cat /sys/fs/resctrl/info/L3_MON/mbm_assign_mode [mbm_cntr_assign]
default
ABMC feature is detected and it is enabled.
b. Check how many ABMC counters are available.
#cat /sys/fs/resctrl/info/L3_MON/num_mbm_cntrs 32
c. Create few resctrl groups.
# mkdir /sys/fs/resctrl/mon_groups/child_default_mon_grp # mkdir /sys/fs/resctrl/non_default_ctrl_mon_grp # mkdir /sys/fs/resctrl/non_default_ctrl_mon_grp/mon_groups/child_non_default_mon_grp
d. This series adds a new interface file /sys/fs/resctrl/info/L3_MON/mbm_assign_control
to list and modify any group's monitoring states. File provides single place to list monitoring states of all the resctrl groups. It makes it easier for user space to learn about the used counters without needing to traverse all the groups thus reducing the number of file system calls.
The list follows the following format:
"<CTRL_MON group>/<MON group>/<domain_id>=<flags>"
Format for specific type of groups:
* Default CTRL_MON group:
"//<domain_id>=<flags>"
* Non-default CTRL_MON group:
"<CTRL_MON group>//<domain_id>=<flags>"
* Child MON group of default CTRL_MON group:
"/<MON group>/<domain_id>=<flags>"
* Child MON group of non-default CTRL_MON group:
"<CTRL_MON group>/<MON group>/<domain_id>=<flags>"
Flags can be one of the following:
t MBM total event is enabled.
l MBM local event is enabled.
tl Both total and local MBM events are enabled. _ None of the MBM events are enabled
Examples:
# cat /sys/fs/resctrl/info/L3_MON/mbm_assign_control non_default_ctrl_mon_grp//0=tl;1=tl; non_default_ctrl_mon_grp/child_non_default_mon_grp/0=tl;1=tl; //0=tl;1=tl;
/child_default_mon_grp/0=tl;1=tl;
There are four groups and all the groups have local and total event enabled on domain 0 and 1.
e. Update the group assignment states using the interface file /sys/fs/resctrl/info/L3_MON/mbm_assign_control.
The write format is similar to the above list format with addition of opcode for the assignment operation.
“<CTRL_MON group>/<MON group>/<domain_id><opcode><flags>”
* Default CTRL_MON group:
"//<domain_id><opcode><flags>"
* Non-default CTRL_MON group:
"<CTRL_MON group>//<domain_id><opcode><flags>"
* Child MON group of default CTRL_MON group:
"/<MON group>/<domain_id><opcode><flags>"
* Child MON group of non-default CTRL_MON group:
"<CTRL_MON group>/<MON group>/<domain_id><opcode><flags>"
Opcode can be one of the following:
= Update the assignment to match the flags.
+ Assign a new MBM event without impacting existing assignments.
- Unassign a MBM event from currently assigned events.
Flags can be one of the following:
t MBM total event.
l MBM local event.
tl Both total and local MBM events.
_ None of the MBM events. Only works with '=' opcode. This flag cannot be combined with other flags.
Initial group status:
# cat /sys/fs/resctrl/info/L3_MON/mbm_assign_control non_default_ctrl_mon_grp//0=tl;1=tl; non_default_ctrl_mon_grp/child_non_default_mon_grp/0=tl;1=tl; //0=tl;1=tl;
/child_default_mon_grp/0=tl;1=tl;
To update the default group to enable only total event on domain 0:
# echo "//0=t" > /sys/fs/resctrl/info/L3_MON/mbm_assign_control
Assignment status after the update:
# cat /sys/fs/resctrl/info/L3_MON/mbm_assign_control non_default_ctrl_mon_grp//0=tl;1=tl; non_default_ctrl_mon_grp/child_non_default_mon_grp/0=tl;1=tl; //0=t;1=tl;
/child_default_mon_grp/0=tl;1=tl;
To update the MON group child_default_mon_grp to remove total event on domain 1:
# echo "/child_default_mon_grp/1-t" > /sys/fs/resctrl/info/L3_MON/mbm_assign_control
Assignment status after the update:
$ cat /sys/fs/resctrl/info/L3_MON/mbm_assign_control non_default_ctrl_mon_grp//0=tl;1=tl; non_default_ctrl_mon_grp/child_non_default_mon_grp/0=tl;1=tl; //0=t;1=tl;
/child_default_mon_grp/0=tl;1=l;
To update the MON group non_default_ctrl_mon_grp/child_non_default_mon_grp to remove both local and total events on domain 1:
# echo "non_default_ctrl_mon_grp/child_non_default_mon_grp/1=_" >
/sys/fs/resctrl/info/L3_MON/mbm_assign_control
Assignment status after the update:
$ cat /sys/fs/resctrl/info/L3_MON/mbm_assign_control non_default_ctrl_mon_grp//0=tl;1=tl; non_default_ctrl_mon_grp/child_non_default_mon_grp/0=tl;1=_; //0=t;1=tl;
/child_default_mon_grp/0=tl;1=l;
To update the default group to add a local event domain 0. # echo "//0+l" > /sys/fs/resctrl/info/L3_MON/mbm_assign_control
Assignment status after the update:
# cat /sys/fs/resctrl/info/L3_MON/mbm_assign_control non_default_ctrl_mon_grp//0=tl;1=tl; non_default_ctrl_mon_grp/child_non_default_mon_grp/0=tl;1=_; //0=tl;1=tl;
/child_default_mon_grp/0=tl;1=l;
To update the non default CTRL_MON group non_default_ctrl_mon_grp to unassign all the MBM events on all the domains.
# echo "non_default_ctrl_mon_grp//*=_" > /sys/fs/resctrl/info/L3_MON/mbm_assign_control
Assignment status after the update:
# cat /sys/fs/resctrl/info/L3_MON/mbm_assign_control non_default_ctrl_mon_grp//0=_;1=_; non_default_ctrl_mon_grp/child_non_default_mon_grp/0=tl;1=_; //0=tl;1=tl;
/child_default_mon_grp/0=tl;1=l;
f. Read the event mbm_total_bytes and mbm_local_bytes of the default group.
There is no change in reading the events with ABMC. If the event is unassigned when reading, then the read will come back as "Unassigned".
# cat /sys/fs/resctrl/mon_data/mon_L3_00/mbm_total_bytes 779247936 # cat /sys/fs/resctrl/mon_data/mon_L3_00/mbm_local_bytes 765207488
g. Check the bandwidth configuration for the group. Note that bandwidth
configuration has a domain scope. Total event defaults to 0x7F (to count all the events) and local event defaults to 0x15 (to count all the local numa events). The event bitmap decoding is available at
https://www.kernel.org/doc/Documentation/x86/resctrl.rst
in section "mbm_total_bytes_config", "mbm_local_bytes_config":
#cat /sys/fs/resctrl/info/L3_MON/mbm_total_bytes_config 0=0x7f;1=0x7f #cat /sys/fs/resctrl/info/L3_MON/mbm_local_bytes_config 0=0x15;1=0x15
h. Change the bandwidth source for domain 0 for the total event to count only reads.
Note that this change effects total events on the domain 0.
#echo 0=0x33 > /sys/fs/resctrl/info/L3_MON/mbm_total_bytes_config #cat /sys/fs/resctrl/info/L3_MON/mbm_total_bytes_config 0=0x33;1=0x7F
i. Now read the total event again. The first read will come back with "Unavailable"
status. The subsequent read of mbm_total_bytes will display only the read events.
#cat /sys/fs/resctrl/mon_data/mon_L3_00/mbm_total_bytes Unavailable #cat /sys/fs/resctrl/mon_data/mon_L3_00/mbm_total_bytes 314101
j. Users will have the option to go back to 'default' mbm_assign_mode if required.
This can be done using the following command. Note that switching the mbm_assign_mode will reset all the MBM counters of all resctrl groups.
# echo "default" > /sys/fs/resctrl/info/L3_MON/mbm_assign_mode # cat /sys/fs/resctrl/info/L3_MON/mbm_assign_mode mbm_cntr_assign [default]
k. Unmount the resctrl
#umount /sys/fs/resctrl/
---
v9:
Patch 14 is a new addition.
Major change in patch 24.
Moved the fix patch to address __init attribute to begining of the series. Fixed all the call sequences. Added additional Fixed tags.
Added Reviewed-by where applicable.
Took care of couple of minor merge conflicts with latest code. Re-ordered the MSR in couple of instances.
Added available_mbm_cntrs (patch 14) to print the number of counter in a domain.
Used MBM_EVENT_ARRAY_INDEX macro to get the event index. Introduced rdtgroup_cntr_id_init() to initialize the cntr_id
Introduced new function resctrl_config_cntr to assign the counter, update the bitmap and reset the architectural state.
Taken care of error handling(freeing the counter) when assignment fails.
Changed rdtgroup_assign_cntrs() and rdtgroup_unassign_cntrs() to return void. Updated couple of rdtgroup_unassign_cntrs() calls properly.
Fixed problem changing the mode to mbm_cntr_assign mode when it is not supported. Added extra checks to detect if systems supports it.
https://lore.kernel.org/lkml/[email protected]/
As discussed in the above comment, introduced resctrl_mon_event_config_set to handle IPI. But sending another IPI inside IPI causes problem. Kernel reports SMP warning. So, introduced resctrl_arch_update_cntr() to send the command directly.
Fixed handling special case '//0=' and '//".
Removed extra strstr() call in rdtgroup_mbm_assign_control_write(). Added generic failure text when assignment operation fails. Corrected user documentation format texts.
v8:
Patches are getting into final stages.
Couple of changes Patch 8, Patch 19 and Patch 23.
Most of the other changes are related to rename and text message updates.
Details are in each patch. Here is the summary.
Added __init attribute to dom_data_init() in patch 8/25. Moved the mbm_cntrs_init() and mbm_cntrs_exit() functionality inside dom_data_init() and dom_data_exit() respectively.
Renamed resctrl_mbm_evt_config_init() to arch_mbm_evt_config_init() Renamed resctrl_arch_event_config_get() to resctrl_arch_mon_event_config_get().
resctrl_arch_event_config_set() to resctrl_arch_mon_event_config_set().
Rename resctrl_arch_assign_cntr to resctrl_arch_config_cntr. Renamed rdtgroup_assign_cntr() to rdtgroup_assign_cntr_event(). Added the code to return the error if rdtgroup_assign_cntr_event fails. Moved definition of MBM_EVENT_ARRAY_INDEX to resctrl/internal.h. Renamed rdtgroup_mbm_cntr_is_assigned to mbm_cntr_assigned_to_domain Added return error handling in resctrl_arch_config_cntr(). Renamed rdtgroup_assign_grp to rdtgroup_assign_cntrs.
Renamed rdtgroup_unassign_grp to rdtgroup_unassign_cntrs. Fixed the problem with unassigning the child MON groups of CTRL_MON group. Reset the internal counters after mbm_cntr_assign mode is changed. Renamed rdtgroup_mbm_cntr_reset() to mbm_cntr_reset()
Renamed resctrl_arch_mbm_cntr_assign_configure to
resctrl_arch_mbm_cntr_assign_set_one.
Used the same IPI as event update to modify the assignment. Could not do the way we discussed in the thread.
https://lore.kernel.org/lkml/[email protected]/
Needed to figure out event type to update the configuration.
Moved unassign first and assign during the assign modification. Assign none "_" takes priority. Cannot be mixed with other flags. Updated the documentation and .rst file format. htmldoc looks ok.
v7:
Major changes are related to FS and arch codes separation. Changed few interface names based on feedback.
Here are the summary and each patch contains changes specific the patch.
Removed WARN_ON for num_mbm_cntrs. Decided to dynamically allocate the bitmap. WARN_ON is not required anymore.
Renamed the function resctrl_arch_get_abmc_enabled() to resctrl_arch_mbm_cntr_assign_enabled().
Merged resctrl_arch_mbm_cntr_assign_disable, resctrl_arch_mbm_cntr_assign_disable and renamed to resctrl_arch_mbm_cntr_assign_set(). Passed the struct rdt_resource to these functions.
Removed resctrl_arch_reset_rmid_all() from arch code. This will be done from FS the caller.
Updated the descriptions/commit log in resctrl.rst to generic text. Removed ABMC references. Renamed mbm_mode to mbm_assign_mode.
Renamed mbm_control to mbm_assign_control.
Introduced mutex lock in rdtgroup_mbm_mode_show().
The 'legacy' mode is called 'default' mode.
Removed the static allocation and now allocating bitmap mbm_cntr_free_map dynamically.
Merged rdtgroup_assign_cntr(), rdtgroup_alloc_cntr() into one. Merged rdtgroup_unassign_cntr(), rdtgroup_free_cntr() into one.
Added struct rdt_resource to the interface functions resctrl_arch_assign_cntr () and resctrl_arch_unassign_cntr().
Rename rdtgroup_abmc_cfg() to resctrl_abmc_config_one_amd().
Added a new patch to fix counter assignment on event config changes.
Removed the references of ABMC from user interfaces.
Simplified the parsing (strsep(&token, "//") in rdtgroup_mbm_assign_control_write(). Added mutex lock in rdtgroup_mbm_assign_control_write() while processing.
Thomas Gleixner asked us to update https://gitlab.com/x86-cpuid.org/x86-cpuid-db.
It needs internal approval. We are working on it.
v6:
We still need to finalize few interface details on mbm_assign_mode and mbm_assign_control in case of ABMC and Soft-ABMC. We can continue the discussion with this series.
Added support for domain-id '*' to update all the domains at once. Fixed assign interface to allocate the counter if counter is not assigned.
Fixed unassign interface to free the counter if the counter is not assigned in any of the domains.
Renamed abmc_capable to mbm_cntr_assignable.
Renamed abmc_enabled to mbm_cntr_assign_enabled.
Used msr_set_bit and msr_clear_bit for msr updates.
Renamed resctrl_arch_abmc_enable() to resctrl_arch_mbm_cntr_assign_enable(). Renamed resctrl_arch_abmc_disable() to resctrl_arch_mbm_cntr_assign_disable().
Changed the display name from num_cntrs to num_mbm_cntrs.
Removed the variable mbm_cntrs_free_map_len. This is not required. Removed the call mbm_cntrs_init() in arch code. This needs to be done at higher level. Used DECLARE_BITMAP to initialize mbm_cntrs_free_map.
Removed unused config value definitions.
Introduced mbm_cntr_map to track counters at domain level. With this we dont need to send MSR read to read the counter configuration.
Separated all the counter id management to upper level in FS code.
Added checks to detect "Unassigned" before reading the RMID.
More details in each patch.
v5:
Rebase changes (because of SNC support)
Interface changes.
/sys/fs/resctrl/mbm_assign to /sys/fs/resctrl/mbm_assign_mode. /sys/fs/resctrl/mbm_assign_control to /sys/fs/resctrl/mbm_assign_control.
Added few arch specific routines.
resctrl_arch_get_abmc_enabled.
resctrl_arch_abmc_enable.
resctrl_arch_abmc_disable.
Few renames
num_cntrs_free_map -> mbm_cntrs_free_map num_cntrs_init -> mbm_cntrs_init arch_domain_mbm_evt_config -> resctrl_arch_mbm_evt_config
Introduced resctrl_arch_event_config_get and
resctrl_arch_event_config_set() to update event configuration.
Removed mon_state field mongroup. Added MON_CNTR_UNSET to initialize counters.
Renamed ctr_id to cntr_id for the hardware counter.
Report "Unassigned" in case the user attempts to read the events without assigning the counter.
ABMC is enabled during the boot up. Can be enabled or disabled later.
Fixed opcode and flags combination.
'=_" is valid.
"-_" amd "+_" is not valid.Added all the comments as far as I know. If I missed something, it is not intentional.
v4:
Main change is domain specific event assignment.
Kept the ABMC feature as a default.
Dynamcic switching between ABMC and mbm_legacy is still allowed. We are still not clear about mount option.
Moved the monitoring related data in resctrl_mon structure from rdt_resource. Fixed the display of legacy and ABMC mode.
Used bimap APIs when possible.
Removed event configuration read from MSRs. We can use the internal saved data.(patch 12)
Added more comments about L3_QOS_ABMC_CFG MSR.
Added IPIs to read the assignment status for each domain (patch 18 and 19) More details in each patch.
v3:
This series adds the support for global assignment mode discussed in the thread. https://lore.kernel.org/lkml/[email protected]/
Removed the individual assignment mode and included the global assignment interface. Added following interface files.
a. /sys/fs/resctrl/info/L3_MON/mbm_assign
Used for displaying the current assignment mode and switch between ABMC and legacy mode.
b. /sys/fs/resctrl/info/L3_MON/mbm_assign_control
Used for lising the groups assignment mode and modify the assignment states.
c. Most of the changes are related to the new interface.
d. Addressed the comments from Reinette, James and Peter.
e. Hope I have addressed most of the major feedbacks discussed. If I missed
something then it is not intentional. Please feel free to comment.
f. Sending this as an RFC as per Reinette's comment. So, this is still open
for discussion.
v2:
a. Major change is the way ABMC is enabled. Earlier, user needed to remount
with -o abmc to enable ABMC feature. Removed that option now.
Now users can enable ABMC by "$echo 1 to /sys/fs/resctrl/info/L3_MON/mbm_assign_enable".
b. Added new word 21 to x86/cpufeatures.h.
c. Display unsupported if user attempts to read the events when ABMC is enabled
and event is not assigned.
d. Display monitor_state as "Unsupported" when ABMC is disabled.
e. Text updates and rebase to latest tip tree (as of Jan 18).
f. This series is still work in progress. I am yet to hear from ARM developers.
v8: https://lore.kernel.org/lkml/[email protected]/
v7: https://lore.kernel.org/lkml/[email protected]/
v6: https://lore.kernel.org/lkml/[email protected]/
v5: https://lore.kernel.org/lkml/[email protected]/
v4: https://lore.kernel.org/lkml/[email protected]/
v3: https://lore.kernel.org/lkml/[email protected]/
v2: https://lore.kernel.org/lkml/[email protected]/
v1: https://lore.kernel.org/lkml/[email protected]/
Babu Moger (26):
x86/resctrl: Add __init attribute for the functions called in
resctrl_late_init
x86/cpufeatures: Add support for Assignable Bandwidth Monitoring
Counters (ABMC)
x86/resctrl: Add ABMC feature in the command line options x86/resctrl: Consolidate monitoring related data from rdt_resource x86/resctrl: Detect Assignable Bandwidth Monitoring feature details x86/resctrl: Introduce resctrl_file_fflags_init() to initialize fflags x86/resctrl: Add support to enable/disable AMD ABMC feature x86/resctrl: Introduce the interface to display monitor mode x86/resctrl: Introduce interface to display number of monitoring
counters
x86/resctrl: Introduce bitmap mbm_cntr_free_map to track assignable
counters
x86/resctrl: Introduce mbm_total_cfg and mbm_local_cfg in struct
rdt_hw_mon_domain
x86/resctrl: Remove MSR reading of event configuration value x86/resctrl: Introduce mbm_cntr_map to track assignable counters at
domain
x86/resctrl: Introduce interface to display number of free counters x86/resctrl: Add data structures and definitions for ABMC assignment x86/resctrl: Introduce cntr_id in mongroup for assignments x86/resctrl: Implement resctrl_arch_config_cntr() to assign a counter
with ABMC
x86/resctrl: Add the interface to assign/update counter assignment x86/resctrl: Add the interface to unassign a MBM counter x86/resctrl: Auto assign/unassign counters when mbm_cntr_assign is
enabled
x86/resctrl: Report "Unassigned" for MBM events in mbm_cntr_assign
mode
x86/resctrl: Introduce the interface to switch between monitor modes x86/resctrl: Configure mbm_cntr_assign mode if supported x86/resctrl: Update assignments on event configuration changes x86/resctrl: Introduce interface to list assignment states of all the
groups
x86/resctrl: Introduce interface to modify assignment states of the
groups
.../admin-guide/kernel-parameters.txt | 2 +- Documentation/arch/x86/resctrl.rst | 233 +++++ arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/include/asm/msr-index.h | 2 + arch/x86/kernel/cpu/cpuid-deps.c | 3 + arch/x86/kernel/cpu/resctrl/core.c | 27 +- arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 12 +- arch/x86/kernel/cpu/resctrl/internal.h | 91 +- arch/x86/kernel/cpu/resctrl/monitor.c | 113 +- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 967 ++++++++++++++++-- arch/x86/kernel/cpu/scattered.c | 1 + include/linux/resctrl.h | 32 +- 12 files changed, 1389 insertions(+), 95 deletions(-)
Signature · 1 line
2.34.1
Babu Moger
reviewerPATCH v9 1/26 x86/resctrl: Add __init attribute for the functions called in resctrl_late_init
The function resctrl_late_init() has the __init attribute, but some functions it calls do not. Add the __init attribute to all the functions to maintain consistency throughout the call sequence.
---
v9: Moved the patch to the begining of the series.
Fixed all the call sequences. Added additional Fixed tags.
v8: New patch.
--- arch/x86/kernel/cpu/resctrl/core.c | 8 ++++---- arch/x86/kernel/cpu/resctrl/internal.h | 2 +- arch/x86/kernel/cpu/resctrl/monitor.c | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-)
arch/x86/kernel/cpu/resctrl/core.c +4 -4
@@ -275,7 +275,7 @@ static __init bool __rdt_get_mem_config_amd(struct rdt_resource *r)return true; } -static void rdt_get_cache_alloc_cfg (int idx,struct rdt_resource *r) +static __init void rdt_get_cache_alloc_cfg (int idx,struct rdt_resource *r) {struct rdt_hw_resource *hw_res =resctrl_to_arch_res (r);union cpuid_0x10_1_eax eax;
@@ -294,7 +294,7 @@ static void rdt_get_cache_alloc_cfg(int idx, struct rdt_resource *r) r->alloc_capable = true; } -static void rdt_get_cdp_config (int level) +static __init void rdt_get_cdp_config (int level) {/* * By default, CDP is disabled. CDP can be enabled by mount parameter
@@ -304,12 +304,12 @@ static void rdt_get_cdp_config(int level) rdt_resources_all[level].r_resctrl.cdp_capable = true; } -static void rdt_get_cdp_l3_config (void ) +static __init void rdt_get_cdp_l3_config (void ) {rdt_get_cdp_config (RDT_RESOURCE_L3 ); } -static void rdt_get_cdp_l2_config (void ) +static __init void rdt_get_cdp_l2_config (void ) {rdt_get_cdp_config (RDT_RESOURCE_L2 ); }
arch/x86/kernel/cpu/resctrl/internal.h +1 -1
@@ -627,7 +627,7 @@ int closids_supported(void);void closid_free (int closid);int alloc_rmid (u32 closid);void free_rmid (u32 closid,u32 rmid); -int rdt_get_mon_l3_config (struct rdt_resource *r); +int __init rdt_get_mon_l3_config (struct rdt_resource *r); void __exit rdt_put_mon_l3_config(void);bool __init rdt_cpu_has (int flag);void mon_event_count (void *info);
arch/x86/kernel/cpu/resctrl/monitor.c +2 -2
@@ -983,7 +983,7 @@ void mbm_setup_overflow_handler(struct rdt_mon_domain *dom, unsigned long delay_schedule_delayed_work_on (cpu, &dom->mbm_over, delay); } -static int dom_data_init (struct rdt_resource *r) +static __init int dom_data_init (struct rdt_resource *r) {u32 idx_limit =resctrl_arch_system_num_rmid_idx ();u32 num_closid =resctrl_arch_get_num_closid (r);
@@ -1081,7 +1081,7 @@ static struct mon_evt mbm_local_event = {* because as per the SDM the total and local memory bandwidth * are enumerated as part of L3 monitoring. */ -static void l3_mon_evt_init (struct rdt_resource *r) +static void __init l3_mon_evt_init (struct rdt_resource *r) {INIT_LIST_HEAD (&r->evt_list);
Signature · 1 line
2.34.1
Reinette Chatre
maintainerRe: [PATCH v9 01/26] x86/resctrl: Add __init attribute for the functions called in resctrl_late_init
Hi Babu,
In subject please use () to indicate a function, writing resctrl_late_init()
Quoted 1 line · Babu Moger
The function
resctrl_late_init()has the__initattribute, but some
No need to say "The function" when using ().
Quoted 1 line
functions it calls do not. Add the
__initattribute to all the functions
None of the functions changed are actually called by resctrl_late_init(). If this is indeed the goal then I think cache_alloc_hsw_probe() was missed.
Quoted 82 lines
to maintain consistency throughout the call sequence.
Fixes 6a445edce657 ("x86/intel_rdt/cqm: Add RDT monitoring initialization")Fixes def10853930a ("x86/intel_rdt: Add two new resources for L2 Code and Data Prioritization (CDP)")Fixes bd334c86b5d7 ("x86/resctrl: Add __init attribute to rdt_get_mon_l3_config()")Suggested-by Reinette Chatre <[email protected]>Signed-off-by Babu Moger <[email protected]>---
v9: Moved the patch to the begining of the series.
Fixed all the call sequences. Added additional Fixed tags.v8: New patch.
--- arch/x86/kernel/cpu/resctrl/core.c | 8 ++++---- arch/x86/kernel/cpu/resctrl/internal.h | 2 +- arch/x86/kernel/cpu/resctrl/monitor.c | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-)arch/x86/kernel/cpu/resctrl/core.c +4
-4@@ -275,7 +275,7 @@ static __init bool __rdt_get_mem_config_amd(struct rdt_resource *r)return true; } -static void rdt_get_cache_alloc_cfg (int idx,struct rdt_resource *r) +static __init void rdt_get_cache_alloc_cfg (int idx,struct rdt_resource *r) {struct rdt_hw_resource *hw_res =resctrl_to_arch_res (r);union cpuid_0x10_1_eax eax;@@ -294,7 +294,7 @@ static void rdt_get_cache_alloc_cfg(int idx, struct rdt_resource *r) r->alloc_capable = true; } -static void rdt_get_cdp_config (int level) +static __init void rdt_get_cdp_config (int level) {/* * By default, CDP is disabled. CDP can be enabled by mount parameter @@ -304,12 +304,12 @@ static void rdt_get_cdp_config(int level) rdt_resources_all[level].r_resctrl.cdp_capable = true; } -static void rdt_get_cdp_l3_config (void ) +static __init void rdt_get_cdp_l3_config (void ) {rdt_get_cdp_config (RDT_RESOURCE_L3 ); } -static void rdt_get_cdp_l2_config (void ) +static __init void rdt_get_cdp_l2_config (void ) {rdt_get_cdp_config (RDT_RESOURCE_L2 ); }arch/x86/kernel/cpu/resctrl/internal.h +1
-1@@ -627,7 +627,7 @@ int closids_supported(void);void closid_free (int closid);int alloc_rmid (u32 closid);void free_rmid (u32 closid,u32 rmid); -int rdt_get_mon_l3_config (struct rdt_resource *r); +int __init rdt_get_mon_l3_config (struct rdt_resource *r); void __exit rdt_put_mon_l3_config(void);bool __init rdt_cpu_has (int flag);void mon_event_count (void *info);arch/x86/kernel/cpu/resctrl/monitor.c +1
-1@@ -983,7 +983,7 @@ void mbm_setup_overflow_handler(struct rdt_mon_domain *dom, unsigned long delay_schedule_delayed_work_on (cpu, &dom->mbm_over, delay); } -static int dom_data_init (struct rdt_resource *r) +static __init int dom_data_init (struct rdt_resource *r) {u32 idx_limit =resctrl_arch_system_num_rmid_idx ();u32 num_closid =resctrl_arch_get_num_closid (r);
arch/x86/kernel/cpu/resctrl/monitor.c static struct mon_evt mbm_local_event = { · line 1084
Quoted 5 lines
arch/x86/kernel/cpu/resctrl/monitor.c +1
-1@@ -1081,7 +1081,7 @@ static struct mon_evt mbm_local_event = {* because as per the SDM the total and local memory bandwidth * are enumerated as part of L3 monitoring. */ -static void l3_mon_evt_init (struct rdt_resource *r) +static void __init l3_mon_evt_init (struct rdt_resource *r)
This change follows a different order from the other changes in this patch. "Function prototypes" in Documentation/process/coding-style.rst indicates the preferred order is storage class before return type. I acknowledge that resctrl is not consistent in this regard but we can work towards the preferred order while keeping this patch consistent?
Reinette
Moger, Babu
reviewerRe: [PATCH v9 01/26] x86/resctrl: Add __init attribute for the functions called in resctrl_late_init
Hi Reinette,
Quoted 3 lines · Reinette Chatre
Hi Babu,
In subject please use () to indicate a function, writing
resctrl_late_init()
Will change it to
x86/resctrl: Add __init attribute for all the call sequences in resctrl_late_init()
Quoted 10 lines · Babu Moger
Quoted 1 line
The function
resctrl_late_init()has the__initattribute, but someNo need to say "The function" when using ().
Quoted 1 line
functions it calls do not. Add the
__initattribute to all the functionsNone of the functions changed are actually called by
resctrl_late_init(). If this is indeed the goal then I thinkcache_alloc_hsw_probe()was missed.
Will change the function to.
static inline __init void cache_alloc_hsw_probe(void)
How about this description?
"resctrl_late_init() has the __init attribute, but some of the call sequences of it do not have the __init attribute.
Add the __init attribute to all the functions in the call sequences to maintain consistency throughout."
Quoted 77 lines
Quoted 77 lines
to maintain consistency throughout the call sequence.
Fixes 6a445edce657 ("x86/intel_rdt/cqm: Add RDT monitoring initialization")Fixes def10853930a ("x86/intel_rdt: Add two new resources for L2 Code and Data Prioritization (CDP)")Fixes bd334c86b5d7 ("x86/resctrl: Add __init attribute to rdt_get_mon_l3_config()")Suggested-by Reinette Chatre <[email protected]>Signed-off-by Babu Moger <[email protected]>---
v9: Moved the patch to the begining of the series.
Fixed all the call sequences. Added additional Fixed tags.v8: New patch.
--- arch/x86/kernel/cpu/resctrl/core.c | 8 ++++---- arch/x86/kernel/cpu/resctrl/internal.h | 2 +- arch/x86/kernel/cpu/resctrl/monitor.c | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-)arch/x86/kernel/cpu/resctrl/core.c +4
-4@@ -275,7 +275,7 @@ static __init bool __rdt_get_mem_config_amd(struct rdt_resource *r)return true; } -static void rdt_get_cache_alloc_cfg (int idx,struct rdt_resource *r) +static __init void rdt_get_cache_alloc_cfg (int idx,struct rdt_resource *r) {struct rdt_hw_resource *hw_res =resctrl_to_arch_res (r);union cpuid_0x10_1_eax eax;@@ -294,7 +294,7 @@ static void rdt_get_cache_alloc_cfg(int idx, struct rdt_resource *r) r->alloc_capable = true; } -static void rdt_get_cdp_config (int level) +static __init void rdt_get_cdp_config (int level) {/* * By default, CDP is disabled. CDP can be enabled by mount parameter @@ -304,12 +304,12 @@ static void rdt_get_cdp_config(int level) rdt_resources_all[level].r_resctrl.cdp_capable = true; } -static void rdt_get_cdp_l3_config (void ) +static __init void rdt_get_cdp_l3_config (void ) {rdt_get_cdp_config (RDT_RESOURCE_L3 ); } -static void rdt_get_cdp_l2_config (void ) +static __init void rdt_get_cdp_l2_config (void ) {rdt_get_cdp_config (RDT_RESOURCE_L2 ); }arch/x86/kernel/cpu/resctrl/internal.h +1
-1@@ -627,7 +627,7 @@ int closids_supported(void);void closid_free (int closid);int alloc_rmid (u32 closid);void free_rmid (u32 closid,u32 rmid); -int rdt_get_mon_l3_config (struct rdt_resource *r); +int __init rdt_get_mon_l3_config (struct rdt_resource *r); void __exit rdt_put_mon_l3_config(void);bool __init rdt_cpu_has (int flag);void mon_event_count (void *info);arch/x86/kernel/cpu/resctrl/monitor.c +0
-0@@ -983,7 +983,7 @@ void mbm_setup_overflow_handler(struct rdt_mon_domain *dom, unsigned long delay_schedule_delayed_work_on (cpu, &dom->mbm_over, delay); }
Quoted 16 lines
arch/x86/kernel/cpu/resctrl/monitor.c static struct mon_evt mbm_local_event = { · line 1084
Quoted 11 lines
arch/x86/kernel/cpu/resctrl/monitor.c +2
-2-static int dom_data_init (struct rdt_resource *r) +static __init int dom_data_init (struct rdt_resource *r) {u32 idx_limit =resctrl_arch_system_num_rmid_idx ();u32 num_closid =resctrl_arch_get_num_closid (r);@@ -1081,7 +1081,7 @@ static struct mon_evt mbm_local_event = {* because as per the SDM the total and local memory bandwidth * are enumerated as part of L3 monitoring. */ -static void l3_mon_evt_init (struct rdt_resource *r) +static void __init l3_mon_evt_init (struct rdt_resource *r)This change follows a different order from the other changes in this patch. "Function prototypes" in
Documentation/process/coding-style.rstindicates the preferred order is storage class before return type. I acknowledge that resctrl is not consistent in this regard but we can work towards the preferred order while keeping this patch consistent?
Sure. Will change it to.
static __init void l3_mon_evt_init(struct rdt_resource *r)
Signature · 2 lines
Thanks Babu Moger
Reinette Chatre
maintainerRe: [PATCH v9 01/26] x86/resctrl: Add __init attribute for the functions called in resctrl_late_init
Hi Babu,
Quoted 11 lines · Babu
Hi Reinette,
Quoted 3 lines · Reinette Chatre
Hi Babu,
In subject please use () to indicate a function, writing
resctrl_late_init()Will change it to
x86/resctrl: Add
__initattribute for all the call sequences inresctrl_late_init()
I am not sure how to interpret "call sequences". The original is ok now that cache_alloc_hsw_probe() is also included. Specifically, this can be:
x86/resctrl: Add __init attribute to functions called from resctrl_late_init()
Quoted 12 lines
Quoted 11 lines · Babu Moger
Quoted 1 line
The function
resctrl_late_init()has the__initattribute, but someNo need to say "The function" when using ().
Quoted 1 line
functions it calls do not. Add the
__initattribute to all the functionsNone of the functions changed are actually called by
resctrl_late_init(). If this is indeed the goal then I thinkcache_alloc_hsw_probe()was missed.
Quoted 8 lines
Will change the function to.
static inline
__initvoidcache_alloc_hsw_probe(void)How about this description?
"
resctrl_late_init()has the__initattribute, but some of the call sequences of it do not have the__initattribute.
"some of the call sequences of it" sounds strange. It can be simplified with "some of the functions called from it"?
Quoted 3 lines
Add the
__initattribute to all the functions in the call sequences to maintain consistency throughout."
Sounds good, thank you.
Reinette
Moger, Babu
reviewerRe: [PATCH v9 01/26] x86/resctrl: Add __init attribute for the functions called in resctrl_late_init
Hi Reinette,
Quoted 12 lines · Reinette Chatre
Hi Babu,
Quoted 9 lines · Babu
Hi Reinette,
Quoted 3 lines · Reinette Chatre
Hi Babu,
In subject please use () to indicate a function, writing
resctrl_late_init()Will change it to
Quoted 7 lines
Quoted 2 lines
x86/resctrl: Add
__initattribute for all the call sequences inresctrl_late_init()I am not sure how to interpret "call sequences". The original is ok now that
cache_alloc_hsw_probe()is also included. Specifically, this can be:x86/resctrl: Add
__initattribute to functions called fromresctrl_late_init()
Sure.
Quoted 17 lines
Quoted 17 lines
Quoted 12 lines · Babu Moger
Quoted 1 line
The function
resctrl_late_init()has the__initattribute, but someNo need to say "The function" when using ().
Quoted 1 line
functions it calls do not. Add the
__initattribute to all the functionsNone of the functions changed are actually called by
resctrl_late_init(). If this is indeed the goal then I thinkcache_alloc_hsw_probe()was missed.Will change the function to.
static inline
__initvoidcache_alloc_hsw_probe(void)
Quoted 7 lines
Quoted 4 lines
How about this description?
"
resctrl_late_init()has the__initattribute, but some of the call sequences of it do not have the__initattribute."some of the call sequences of it" sounds strange. It can be simplified with "some of the functions called from it"?
Sure,
Quoted 6 lines
Quoted 4 lines
Add the
__initattribute to all the functions in the call sequences to maintain consistency throughout."Sounds good, thank you.
Signature · 2 lines
Thanks Babu Moger
Babu Moger
reviewerPATCH v9 2/26 x86/cpufeatures: Add support for Assignable Bandwidth Monitoring Counters (ABMC)
In reply to Babu MogerUsers can create as many monitor groups as RMIDs supported by the hardware. However, bandwidth monitoring feature on AMD system only guarantees that RMIDs currently assigned to a processor will be tracked by hardware. The counters of any other RMIDs which are no longer being tracked will be reset to zero. The MBM event counters return "Unavailable" for the RMIDs that are not tracked by hardware. So, there can be only limited number of groups that can give guaranteed monitoring numbers. With ever changing configurations there is no way to definitely know which of these groups are being tracked for certain point of time. Users do not have the option to monitor a group or set of groups for certain period of time without worrying about RMID being reset in between.
The ABMC feature provides an option to the user to assign a hardware counter to an RMID, event pair and monitor the bandwidth as long as it is assigned. The assigned RMID will be tracked by the hardware until the user unassigns it manually. There is no need to worry about counters being reset during this period. Additionally, the user can specify a bitmask identifying the specific bandwidth types from the given source to track with the counter.
Without ABMC enabled, monitoring will work in current mode without assignment option.
Linux resctrl subsystem provides the interface to count maximum of two memory bandwidth events per group, from a combination of available total and local events. Keeping the current interface, users can enable a maximum of 2 ABMC counters per group. User will also have the option to enable only one counter to the group. If the system runs out of assignable ABMC counters, kernel will display an error. Users need to disable an already enabled counter to make space for new assignments.
The feature can be detected via CPUID_Fn80000020_EBX_x00 bit 5. Bits Description
5 ABMC (Assignable Bandwidth Monitoring Counters)
The feature details are documented in APM listed below [1].
[1] AMD64 Architecture Programmer's Manual Volume 2: System Programming Publication # 24593 Revision 3.41 section 19.3.3.3 Assignable Bandwidth Monitoring (ABMC).
---
Note: Checkpatch checks/warnings are ignored to maintain coding style.
v9: Took care of couple of minor merge conflicts. No other changes.
v8: No changes.
v7: Removed "" from feature flags. Not required anymore.
https://lore.kernel.org/lkml/20240817145058.GCZsC40neU4wkPXeVR@fat_crate.local/
v6: Added Reinette's Reviewed-by. Moved the Checkpatch note below ---.
v5: Minor rebase change and subject line update.
v4: Changes because of rebase. Feature word 21 has few more additions now.
Changed the text to "tracked by hardware" instead of active.
v3: Change because of rebase. Actual patch did not change.
v2: Added dependency on X86_FEATURE_BMEC.
--- arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/kernel/cpu/cpuid-deps.c | 3 +++ arch/x86/kernel/cpu/scattered.c | 1 + 3 files changed, 5 insertions(+)
arch/x86/include/asm/cpufeatures.h +1 -0
@@ -476,6 +476,7 @@#define X86_FEATURE_AMD_FAST_CPPC (21*32 + 5)/* Fast CPPC */ #define X86_FEATURE_AMD_HETEROGENEOUS_CORES (21*32 + 6)/* Heterogeneous Core Topology */ #define X86_FEATURE_AMD_WORKLOAD_CLASS (21*32 + 7)/* Workload Classification */ +#define X86_FEATURE_ABMC (21*32 + 8)/* Assignable Bandwidth Monitoring Counters */ /* * BUG word(s)
arch/x86/kernel/cpu/cpuid-deps.c +3 -0
@@ -70,6 +70,9 @@ static const struct cpuid_dep cpuid_deps[] = { { X86_FEATURE_CQM_MBM_LOCAL, X86_FEATURE_CQM_LLC }, { X86_FEATURE_BMEC, X86_FEATURE_CQM_MBM_TOTAL }, { X86_FEATURE_BMEC, X86_FEATURE_CQM_MBM_LOCAL }, + { X86_FEATURE_ABMC, X86_FEATURE_CQM_MBM_TOTAL }, + { X86_FEATURE_ABMC, X86_FEATURE_CQM_MBM_LOCAL }, + { X86_FEATURE_ABMC, X86_FEATURE_BMEC }, { X86_FEATURE_AVX512_BF16, X86_FEATURE_AVX512VL }, { X86_FEATURE_AVX512_FP16, X86_FEATURE_AVX512BW }, { X86_FEATURE_ENQCMD, X86_FEATURE_XSAVES },
arch/x86/kernel/cpu/scattered.c +1 -0
@@ -49,6 +49,7 @@ static const struct cpuid_bit cpuid_bits[] = { { X86_FEATURE_MBA, CPUID_EBX, 6, 0x80000008, 0 }, { X86_FEATURE_SMBA, CPUID_EBX, 2, 0x80000020, 0 }, { X86_FEATURE_BMEC, CPUID_EBX, 3, 0x80000020, 0 }, + { X86_FEATURE_ABMC, CPUID_EBX, 5, 0x80000020, 0 }, { X86_FEATURE_AMD_WORKLOAD_CLASS, CPUID_EAX, 22, 0x80000021, 0 }, { X86_FEATURE_PERFMON_V2, CPUID_EAX, 0, 0x80000022, 0 }, { X86_FEATURE_AMD_LBR_V2, CPUID_EAX, 1, 0x80000022, 0 },
Signature · 1 line
2.34.1
Babu Moger
reviewerPATCH v9 3/26 x86/resctrl: Add ABMC feature in the command line options
In reply to Babu MogerAdd the command line option to enable or disable exposing the ABMC (Assignable Bandwidth Monitoring Counters) hardware feature to resctrl.
---
v9: No code changes. Added Reviewed-by.
v8: Commit message update.
v7: No changes
v6: No changes
v5: No changes
v4: No changes
v3: No changes
v2: No changes
--- Documentation/admin-guide/kernel-parameters.txt | 2 +- Documentation/arch/x86/resctrl.rst | 1 + arch/x86/kernel/cpu/resctrl/core.c | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-)
Documentation/admin-guide/kernel-parameters.txt +1 -1
@@ -5677,7 +5677,7 @@ rdt= [HW,X86,RDT] Turn on/off individual RDT features. List is: cmt, mbmtotal, mbmlocal, l3cat, l3cdp, l2cat, l2cdp, - mba, smba, bmec. + mba, smba, bmec, abmc. E.g. to turn on cmt and turn off mba use: rdt=cmt,!mba
Documentation/arch/x86/resctrl.rst +1 -0
@@ -26,6 +26,7 @@ MBM (Memory Bandwidth Monitoring) "cqm_mbm_total", "cqm_mbm_local" MBA (Memory Bandwidth Allocation) "mba" SMBA (Slow Memory Bandwidth Allocation) "" BMEC (Bandwidth Monitoring Event Configuration) "" +ABMC (Assignable Bandwidth Monitoring Counters) "" =============================================== ================================ Historically, new features were made visible by default in /proc/cpuinfo. This
arch/x86/kernel/cpu/resctrl/core.c +2 -0
@@ -809,6 +809,7 @@ enum {RDT_FLAG_MBA ,RDT_FLAG_SMBA ,RDT_FLAG_BMEC , + RDT_FLAG_ABMC, };#define RDT_OPT (idx, n, f) \
@@ -834,6 +835,7 @@ static struct rdt_options rdt_options[] __initdata = {RDT_OPT (RDT_FLAG_MBA ,"mba" ,X86_FEATURE_MBA ),RDT_OPT (RDT_FLAG_SMBA ,"smba" ,X86_FEATURE_SMBA ),RDT_OPT (RDT_FLAG_BMEC ,"bmec" ,X86_FEATURE_BMEC ), + RDT_OPT(RDT_FLAG_ABMC, "abmc", X86_FEATURE_ABMC), };#define NUM_RDT_OPTIONS ARRAY_SIZE(rdt_options)
Signature · 1 line
2.34.1
Babu Moger
reviewerPATCH v9 4/26 x86/resctrl: Consolidate monitoring related data from rdt_resource
In reply to Babu MogerThe cache allocation and memory bandwidth allocation feature properties are consolidated into struct resctrl_cache and struct resctrl_membw respectively.
In preparation for more monitoring properties that will clobber the existing resource struct more, re-organize the monitoring specific properties to also be in a separate structure.
---
v9: No changes.
v8: Added Reviewed-by from Reinette. No other changes.
v7: Added kernel doc for data structure. Minor text update.
v6: Update commit message and update kernel doc for rdt_resource.
v5: Commit message update.
Also changes related to data structure updates does to SNC support.
v4: New patch.
--- arch/x86/kernel/cpu/resctrl/core.c | 4 ++-- arch/x86/kernel/cpu/resctrl/monitor.c | 18 +++++++++--------- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 8 ++++---- include/linux/resctrl.h | 16 ++++++++++++---- 4 files changed, 27 insertions(+), 19 deletions(-)
arch/x86/kernel/cpu/resctrl/core.c +2 -2
@@ -124,7 +124,7 @@ u32 resctrl_arch_system_num_rmid_idx(void)struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3 ].r_resctrl;/* RMID are independent numbers for x86. num_rmid_idx == num_rmid */ -return r->num_rmid; +return r->mon.num_rmid; }/*
@@ -625,7 +625,7 @@ static void domain_add_cpu_mon(int cpu, struct rdt_resource *r)arch_mon_domain_online (r, d); -if (arch_domain_mbm_alloc (r->num_rmid, hw_dom)) { +if (arch_domain_mbm_alloc (r->mon.num_rmid, hw_dom)) {mon_domain_free (hw_dom);return ; }
arch/x86/kernel/cpu/resctrl/monitor.c +9 -9
@@ -222,7 +222,7 @@ static int logical_rmid_to_physical_rmid(int cpu, int lrmid)if (snc_nodes_per_l3_cache ==1 )return lrmid; -return lrmid + (cpu_to_node (cpu) % snc_nodes_per_l3_cache) * r->num_rmid; +return lrmid + (cpu_to_node (cpu) % snc_nodes_per_l3_cache) * r->mon.num_rmid; }static int __rmid_read_phys (u32 prmid,enum resctrl_event_id eventid,u64 *val)
@@ -297,11 +297,11 @@ void resctrl_arch_reset_rmid_all(struct rdt_resource *r, struct rdt_mon_domain *if (is_mbm_total_enabled ())memset (hw_dom->arch_mbm_total,0 , -sizeof (*hw_dom->arch_mbm_total) * r->num_rmid); +sizeof (*hw_dom->arch_mbm_total) * r->mon.num_rmid);if (is_mbm_local_enabled ())memset (hw_dom->arch_mbm_local,0 , -sizeof (*hw_dom->arch_mbm_local) * r->num_rmid); +sizeof (*hw_dom->arch_mbm_local) * r->mon.num_rmid); }static u64 mbm_overflow_count (u64 prev_msr,u64 cur_msr,unsigned int width)
@@ -1083,14 +1083,14 @@ static struct mon_evt mbm_local_event = {*/ static void __init l3_mon_evt_init (struct rdt_resource *r) { -INIT_LIST_HEAD (&r->evt_list); +INIT_LIST_HEAD (&r->mon.evt_list);if (is_llc_occupancy_enabled ()) -list_add_tail (&llc_occupancy_event.list, &r->evt_list); +list_add_tail (&llc_occupancy_event.list, &r->mon.evt_list);if (is_mbm_total_enabled ()) -list_add_tail (&mbm_total_event.list, &r->evt_list); +list_add_tail (&mbm_total_event.list, &r->mon.evt_list);if (is_mbm_local_enabled ()) -list_add_tail (&mbm_local_event.list, &r->evt_list); +list_add_tail (&mbm_local_event.list, &r->mon.evt_list); }/*
@@ -1186,7 +1186,7 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r) resctrl_rmid_realloc_limit = boot_cpu_data.x86_cache_size *1024 ; hw_res->mon_scale = boot_cpu_data.x86_cache_occ_scale / snc_nodes_per_l3_cache; - r->num_rmid = (boot_cpu_data.x86_cache_max_rmid +1 ) / snc_nodes_per_l3_cache; + r->mon.num_rmid = (boot_cpu_data.x86_cache_max_rmid +1 ) / snc_nodes_per_l3_cache; hw_res->mbm_width =MBM_CNTR_WIDTH_BASE ;if (mbm_offset >0 && mbm_offset <=MBM_CNTR_WIDTH_OFFSET_MAX )
@@ -1201,7 +1201,7 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r)* * For a 35MB LLC and 56 RMIDs, this is ~1.8% of the LLC. */ - threshold = resctrl_rmid_realloc_limit / r->num_rmid; + threshold = resctrl_rmid_realloc_limit / r->mon.num_rmid;/* * Because num_rmid may not be a power of two, round the value
arch/x86/kernel/cpu/resctrl/rdtgroup.c +4 -4
@@ -1097,7 +1097,7 @@ static int rdt_num_rmids_show(struct kernfs_open_file *of, {struct rdt_resource *r = of->kn->parent->priv; -seq_printf (seq,"%d\n" , r->num_rmid); +seq_printf (seq,"%d\n" , r->mon.num_rmid);return 0 ; }
@@ -1108,7 +1108,7 @@ static int rdt_mon_features_show(struct kernfs_open_file *of,struct rdt_resource *r = of->kn->parent->priv;struct mon_evt *mevt; -list_for_each_entry (mevt, &r->evt_list, list) { +list_for_each_entry (mevt, &r->mon.evt_list, list) {seq_printf (seq,"%s\n" , mevt->name);if (mevt->configurable)seq_printf (seq,"%s_config\n" , mevt->name);
@@ -3057,13 +3057,13 @@ static int mon_add_all_files(struct kernfs_node *kn, struct rdt_mon_domain *d,struct mon_evt *mevt;int ret; -if (WARN_ON (list_empty (&r->evt_list))) +if (WARN_ON (list_empty (&r->mon.evt_list)))return -EPERM ; priv.u.rid = r->rid; priv.u.domid = do_sum ? d->ci->id : d->hdr.id; priv.u.sum = do_sum; -list_for_each_entry (mevt, &r->evt_list, list) { +list_for_each_entry (mevt, &r->mon.evt_list, list) { priv.u.evtid = mevt->evtid; ret =mon_addfile (kn, mevt->name, priv.priv);if (ret)
include/linux/resctrl.h +12 -4
@@ -182,16 +182,26 @@ enum resctrl_scope { RESCTRL_L3_NODE, }; +/** +* struct resctrl_mon - Monitoring related data of a resctrl resource +* @num_rmid: Number of RMIDs available +* @evt_list: List of monitoring events +*/ +struct resctrl_mon { +int num_rmid; +struct list_head evt_list; +}; +/** * struct rdt_resource - attributes of a resctrl resource * @rid: The index of the resource * @alloc_capable: Is allocation available on this machine * @mon_capable: Is monitor feature available on this machine -* @num_rmid: Number of RMIDs available * @ctrl_scope: Scope of this resource for control functions * @mon_scope: Scope of this resource for monitor functions * @cache: Cache allocation related data * @membw: If the component has bandwidth controls, their properties. +* @mon: Monitoring related data. * @ctrl_domains: RCU list of all control domains for this resource * @mon_domains: RCU list of all monitor domains for this resource * @name: Name to use in "schemata" file.
@@ -199,7 +209,6 @@ enum resctrl_scope {* @default_ctrl: Specifies default cache cbm or memory B/W percent. * @format_str: Per resource format string to show domain value * @parse_ctrlval: Per resource function pointer to parse control values -* @evt_list: List of monitoring events * @fflags: flags to choose base and info files * @cdp_capable: Is the CDP feature available on this resource */
@@ -207,11 +216,11 @@ struct rdt_resource {int rid;bool alloc_capable;bool mon_capable; -int num_rmid;enum resctrl_scope ctrl_scope;enum resctrl_scope mon_scope;struct resctrl_cache cache;struct resctrl_membw membw; +struct resctrl_mon mon;struct list_head ctrl_domains;struct list_head mon_domains;char *name;
@@ -221,7 +230,6 @@ struct rdt_resource {int (*parse_ctrlval)(struct rdt_parse_data *data,struct resctrl_schema *s,struct rdt_ctrl_domain *d); -struct list_head evt_list;unsigned long fflags;bool cdp_capable; };
Signature · 1 line
2.34.1
Babu Moger
reviewerPATCH v9 5/26 x86/resctrl: Detect Assignable Bandwidth Monitoring feature details
In reply to Babu MogerABMC feature details are reported via CPUID Fn8000_0020_EBX_x5. Bits Description
15:0 MAX_ABMC Maximum Supported Assignable Bandwidth
Monitoring Counter ID + 1
The feature details are documented in APM listed below [1].
[1] AMD64 Architecture Programmer's Manual Volume 2: System Programming Publication # 24593 Revision 3.41 section 19.3.3.3 Assignable Bandwidth Monitoring (ABMC).
Detect the feature and number of assignable monitoring counters supported.
---
v9: Added Reviewed-by tag. No code changes
v8: Used GENMASK for the mask.
v7: Removed WARN_ON for num_mbm_cntrs. Decided to dynamically allocate the
bitmap. WARN_ON is not required anymore.
Removed redundant comments.
v6: Commit message update.
Renamed abmc_capable to mbm_cntr_assignable.
v5: Name change num_cntrs to num_mbm_cntrs.
Moved abmc_capable to resctrl_mon.
v4: Removed resctrl_arch_has_abmc(). Added all the code inline. We dont
need to separate this as arch code.
v3: Removed changes related to mon_features.
Moved rdt_cpu_has to core.c and added new function resctrl_arch_has_abmc. Also moved the fields mbm_assign_capable and mbm_assign_cntrs to rdt_resource. (James)
v2: Changed the field name to mbm_assign_capable from abmc_capable.
--- arch/x86/kernel/cpu/resctrl/monitor.c | 6 ++++++ include/linux/resctrl.h | 4 ++++ 2 files changed, 10 insertions(+)
arch/x86/kernel/cpu/resctrl/monitor.c +6 -0
@@ -1229,6 +1229,12 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r) mbm_local_event.configurable = true;mbm_config_rftype_init ("mbm_local_bytes_config" ); } + +if (rdt_cpu_has (X86_FEATURE_ABMC )) { + r->mon.mbm_cntr_assignable = true; +cpuid_count (0x80000020 ,5 , &eax, &ebx, &ecx, &edx); + r->mon.num_mbm_cntrs = (ebx &GENMASK (15 ,0 )) +1 ; + } }l3_mon_evt_init (r);
include/linux/resctrl.h +4 -0
@@ -185,10 +185,14 @@ enum resctrl_scope {/** * struct resctrl_mon - Monitoring related data of a resctrl resource * @num_rmid: Number of RMIDs available +* @num_mbm_cntrs: Number of assignable monitoring counters +* @mbm_cntr_assignable:Is system capable of supporting monitor assignment? * @evt_list: List of monitoring events */ struct resctrl_mon {int num_rmid; +int num_mbm_cntrs; +bool mbm_cntr_assignable;struct list_head evt_list; };
Signature · 1 line
2.34.1
Babu Moger
reviewerPATCH v9 6/26 x86/resctrl: Introduce resctrl_file_fflags_init() to initialize fflags
In reply to Babu Mogerthread_throttle_mode_init() and mbm_config_rftype_init() both initialize fflags for resctrl files.
Adding new files will involve adding another function to initialize the fflags. This can be simplified by adding a new function resctrl_file_fflags_init() and passing the file name and flags to be initialized.
Consolidate fflags initialization into resctrl_file_fflags_init() and remove thread_throttle_mode_init() and mbm_config_rftype_init().
---
v9: No changes.
v8: No changes.
v7: No changes.
v6: Added Reviewed-by from Reinette.
v5: Commit message update.
v4: Commit message update.
v3: New patch to display ABMC capability.
--- arch/x86/kernel/cpu/resctrl/core.c | 4 +++- arch/x86/kernel/cpu/resctrl/internal.h | 4 ++-- arch/x86/kernel/cpu/resctrl/monitor.c | 6 ++++-- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 16 +++------------- 4 files changed, 12 insertions(+), 18 deletions(-)
arch/x86/kernel/cpu/resctrl/core.c +3 -1
@@ -234,7 +234,9 @@ static __init bool __get_mem_config_intel(struct rdt_resource *r) r->membw.throttle_mode =THREAD_THROTTLE_PER_THREAD ; else r->membw.throttle_mode = THREAD_THROTTLE_MAX; -thread_throttle_mode_init (); + +resctrl_file_fflags_init ("thread_throttle_mode" , +RFTYPE_CTRL_INFO |RFTYPE_RES_MB ); r->alloc_capable = true;
arch/x86/kernel/cpu/resctrl/internal.h +2 -2
@@ -647,8 +647,8 @@ void cqm_handle_limbo(struct work_struct *work);bool has_busy_rmid (struct rdt_mon_domain *d);void __check_limbo (struct rdt_mon_domain *d,bool force_free);void rdt_domain_reconfigure_cdp (struct rdt_resource *r); -void __init thread_throttle_mode_init (void ); -void __init mbm_config_rftype_init (const char *config); +void __init resctrl_file_fflags_init (const char *config, +unsigned long fflags);void rdt_staged_configs_clear (void );bool closid_allocated (unsigned int closid);int resctrl_find_cleanest_closid (void );
arch/x86/kernel/cpu/resctrl/monitor.c +4 -2
@@ -1223,11 +1223,13 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r)if (rdt_cpu_has (X86_FEATURE_CQM_MBM_TOTAL )) { mbm_total_event.configurable = true; -mbm_config_rftype_init ("mbm_total_bytes_config" ); +resctrl_file_fflags_init ("mbm_total_bytes_config" , +RFTYPE_MON_INFO |RFTYPE_RES_CACHE ); }if (rdt_cpu_has (X86_FEATURE_CQM_MBM_LOCAL )) { mbm_local_event.configurable = true; -mbm_config_rftype_init ("mbm_local_bytes_config" ); +resctrl_file_fflags_init ("mbm_local_bytes_config" , +RFTYPE_MON_INFO |RFTYPE_RES_CACHE ); }if (rdt_cpu_has (X86_FEATURE_ABMC )) {
arch/x86/kernel/cpu/resctrl/rdtgroup.c +3 -13
@@ -2020,24 +2020,14 @@ static struct rftype *rdtgroup_get_rftype_by_name(const char *name)return NULL ; } -void __init thread_throttle_mode_init (void ) -{ -struct rftype *rft; - - rft =rdtgroup_get_rftype_by_name ("thread_throttle_mode" ); -if (!rft) -return ; - - rft->fflags =RFTYPE_CTRL_INFO |RFTYPE_RES_MB ; -} - -void __init mbm_config_rftype_init (const char *config) +void __init resctrl_file_fflags_init (const char *config, +unsigned long fflags) {struct rftype *rft; rft =rdtgroup_get_rftype_by_name (config);if (rft) - rft->fflags =RFTYPE_MON_INFO |RFTYPE_RES_CACHE ; + rft->fflags = fflags; }/**
Signature · 1 line
2.34.1
Babu Moger
reviewerPATCH v9 7/26 x86/resctrl: Add support to enable/disable AMD ABMC feature
In reply to Babu MogerAdd the functionality to enable/disable AMD ABMC feature.
AMD ABMC feature is enabled by setting enabled bit(0) in MSR L3_QOS_EXT_CFG. When the state of ABMC is changed, the MSR needs to be updated on all the logical processors in the QOS Domain.
Hardware counters will reset when ABMC state is changed.
The ABMC feature details are documented in APM listed below [1].
[1] AMD64 Architecture Programmer's Manual Volume 2: System Programming Publication # 24593 Revision 3.41 section 19.3.3.3 Assignable Bandwidth Monitoring (ABMC).
---
v9: Re-ordered the MSR and added Reviewed-by tag.
v8: Commit message update and moved around the comments about L3_QOS_EXT_CFG
to _resctrl_abmc_enable.
v7: Renamed the function
resctrl_arch_get_abmc_enabled() to resctrl_arch_mbm_cntr_assign_enabled().
Merged resctrl_arch_mbm_cntr_assign_disable, resctrl_arch_mbm_cntr_assign_disable and renamed to resctrl_arch_mbm_cntr_assign_set().
Moved the function definition to linux/resctrl.h.
Passed the struct rdt_resource to these functions.
Removed resctrl_arch_reset_rmid_all() from arch code. This will be done from the caller.
v6: Renamed abmc_enabled to mbm_cntr_assign_enabled.
Used msr_set_bit and msr_clear_bit for msr updates.
Renamed resctrl_arch_abmc_enable() to resctrl_arch_mbm_cntr_assign_enable(). Renamed resctrl_arch_abmc_disable() to resctrl_arch_mbm_cntr_assign_disable(). Made _resctrl_abmc_enable to return void.
v5: Renamed resctrl_abmc_enable to resctrl_arch_abmc_enable.
Renamed resctrl_abmc_disable to resctrl_arch_abmc_disable. Introduced resctrl_arch_get_abmc_enabled to get abmc state from non-arch code.
Renamed resctrl_abmc_set_all to _resctrl_abmc_enable(). Modified commit log to make it clear about AMD ABMC feature.
v3: No changes.
v2: Few text changes in commit message.
--- arch/x86/include/asm/msr-index.h | 1 + arch/x86/kernel/cpu/resctrl/core.c | 5 ++++ arch/x86/kernel/cpu/resctrl/internal.h | 5 ++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 36 ++++++++++++++++++++++++++ include/linux/resctrl.h | 3 +++ 5 files changed, 50 insertions(+)
arch/x86/include/asm/msr-index.h +1 -0
@@ -1194,6 +1194,7 @@/* - AMD: */ #define MSR_IA32_MBA_BW_BASE 0xc0000200#define MSR_IA32_SMBA_BW_BASE 0xc0000280 +#define MSR_IA32_L3_QOS_EXT_CFG 0xc00003ff#define MSR_IA32_EVT_CFG_BASE 0xc0000400/* AMD-V MSRs */
arch/x86/kernel/cpu/resctrl/core.c +5 -0
@@ -405,6 +405,11 @@ void rdt_ctrl_update(void *arg) hw_res->msr_update (m); } +bool resctrl_arch_mbm_cntr_assign_enabled (struct rdt_resource *r) +{ +return resctrl_to_arch_res (r)->mbm_cntr_assign_enabled; +} +/* * rdt_find_domain - Search for a domain id in a resource domain list. *
arch/x86/kernel/cpu/resctrl/internal.h +5 -0
@@ -56,6 +56,9 @@/* Max event bits supported */ #define MAX_EVT_CONFIG_BITS GENMASK(6, 0) +/* Setting bit 0 in L3_QOS_EXT_CFG enables the ABMC feature. */ +#define ABMC_ENABLE_BIT 0 +/** * cpumask_any_housekeeping() - Choose any CPU in @mask, preferring those that * aren't marked nohz_full
@@ -477,6 +480,7 @@ struct rdt_parse_data {* @mbm_cfg_mask: Bandwidth sources that can be tracked when Bandwidth * Monitoring Event Configuration (BMEC) is supported. * @cdp_enabled: CDP state of this resource +* @mbm_cntr_assign_enabled: ABMC feature is enabled * * Members of this structure are either private to the architecture * e.g. mbm_width, or accessed via helpers that provide abstraction. e.g.
@@ -491,6 +495,7 @@ struct rdt_hw_resource {unsigned int mbm_width;unsigned int mbm_cfg_mask;bool cdp_enabled; +bool mbm_cntr_assign_enabled; };static inline struct rdt_hw_resource *resctrl_to_arch_res (struct rdt_resource *r)
arch/x86/kernel/cpu/resctrl/rdtgroup.c +36 -0
@@ -2402,6 +2402,42 @@ int resctrl_arch_set_cdp_enabled(enum resctrl_res_level l, bool enable)return 0 ; } +static void resctrl_abmc_set_one_amd (void *arg) +{ +bool *enable = arg; + +if (*enable) +msr_set_bit (MSR_IA32_L3_QOS_EXT_CFG ,ABMC_ENABLE_BIT ); +else +msr_clear_bit (MSR_IA32_L3_QOS_EXT_CFG ,ABMC_ENABLE_BIT ); +} + +/* +* Update L3_QOS_EXT_CFG MSR on all the CPUs associated with the monitor +* domain. +*/ +static void _resctrl_abmc_enable (struct rdt_resource *r,bool enable) +{ +struct rdt_mon_domain *d; + +list_for_each_entry (d, &r->mon_domains, hdr.list) +on_each_cpu_mask (&d->hdr.cpu_mask, + resctrl_abmc_set_one_amd, &enable,1 ); +} + +int resctrl_arch_mbm_cntr_assign_set (struct rdt_resource *r,bool enable) +{ +struct rdt_hw_resource *hw_res =resctrl_to_arch_res (r); + +if (r->mon.mbm_cntr_assignable && + hw_res->mbm_cntr_assign_enabled != enable) { +_resctrl_abmc_enable (r, enable); + hw_res->mbm_cntr_assign_enabled = enable; + } + +return 0 ; +} +/* * 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
@@ -355,4 +355,7 @@ void resctrl_arch_reset_rmid_all(struct rdt_resource *r, struct rdt_mon_domain *extern unsigned int resctrl_rmid_realloc_threshold;extern unsigned int resctrl_rmid_realloc_limit; +int resctrl_arch_mbm_cntr_assign_set (struct rdt_resource *r,bool enable); +bool resctrl_arch_mbm_cntr_assign_enabled (struct rdt_resource *r); +#endif /* _RESCTRL_H */
Signature · 1 line
2.34.1
Babu Moger
reviewerPATCH v9 8/26 x86/resctrl: Introduce the interface to display monitor mode
In reply to Babu MogerIntroduce the interface file "mbm_assign_mode" to list monitor modes supported.
The "mbm_cntr_assign" mode provides the option to assign a counter to an RMID, event pair and monitor the bandwidth as long as it is assigned.
On AMD systems "mbm_cntr_assign" is backed by the ABMC (Assignable Bandwidth Monitoring Counters) hardware feature and is enabled by default.
The "default" mode is the existing monitoring mode that works without the explicit counter assignment, instead relying on dynamic counter assignment by hardware that may result in hardware not dedicating a counter resulting in monitoring data reads returning "Unavailable".
Provide an interface to display the monitor mode on the system.
$ cat /sys/fs/resctrl/info/L3_MON/mbm_assign_mode [mbm_cntr_assign] default
---
v9: Updated user documentation based on comments.
v8: Commit message update.
v7: Updated the descriptions/commit log in resctrl.rst to generic text.
Thanks to James and Reinette.
Rename mbm_mode to mbm_assign_mode.
Introduced mutex lock in rdtgroup_mbm_mode_show().
v6: Added documentation for mbm_cntr_assign and legacy mode.
Moved mbm_mode fflags initialization to static initialization.
v5: Changed interface name to mbm_mode.
It will be always available even if ABMC feature is not supported. Added description in resctrl.rst about ABMC mode.
Fixed display abmc and legacy consistantly.
v4: Fixed the checks for legacy and abmc mode. Default it ABMC.
v3: New patch to display ABMC capability.
--- Documentation/arch/x86/resctrl.rst | 33 ++++++++++++++++++++++++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 31 ++++++++++++++++++++++++ 2 files changed, 64 insertions(+)
Documentation/arch/x86/resctrl.rst +33 -0
@@ -257,6 +257,39 @@ with the following files: # cat /sys/fs/resctrl/info/L3_MON/mbm_local_bytes_config 0=0x30;1=0x30;3=0x15;4=0x15 +"mbm_assign_mode": + Reports the list of monitoring modes supported. The enclosed brackets + indicate which mode is enabled. + :: + + # cat /sys/fs/resctrl/info/L3_MON/mbm_assign_mode + [mbm_cntr_assign] + default + + "mbm_cntr_assign": + + In mbm_cntr_assign mode user-space is able to specify which of the + events in CTRL_MON or MON groups should have a counter assigned using the + "mbm_assign_control" file. The number of counters available is described + in the "num_mbm_cntrs" file. Changing the mode may cause all counters on + a resource to reset. + + The mode is useful on platforms which support more CTRL_MON and MON + groups than the hardware counters, meaning 'unassigned' events on CTRL_MON or + MON groups will report 'Unavailable' or count the traffic in an unpredictable + way. + + AMD Platforms with ABMC (Assignable Bandwidth Monitoring Counters) feature + enable this mode by default so that counters remain assigned even when the + corresponding RMID is not in use by any processor. + + "default": + + In default mode resctrl assumes there is a hardware counter for each + event within every CTRL_MON and MON group. Reading mbm_total_bytes or + mbm_local_bytes may report 'Unavailable' if there is no counter associated + with that event. + "max_threshold_occupancy": Read/write file provides the largest value (in bytes) at which a previously used LLC_occupancy
arch/x86/kernel/cpu/resctrl/rdtgroup.c +31 -0
@@ -845,6 +845,30 @@ static int rdtgroup_rmid_show(struct kernfs_open_file *of,return ret; } +static int rdtgroup_mbm_assign_mode_show (struct kernfs_open_file *of, +struct seq_file *s,void *v) +{ +struct rdt_resource *r = of->kn->parent->priv; + +mutex_lock (&rdtgroup_mutex); + +if (r->mon.mbm_cntr_assignable) { +if (resctrl_arch_mbm_cntr_assign_enabled (r)) { +seq_puts (s,"[mbm_cntr_assign]\n" ); +seq_puts (s,"default\n" ); + }else { +seq_puts (s,"mbm_cntr_assign\n" ); +seq_puts (s,"[default]\n" ); + } + }else { +seq_puts (s,"[default]\n" ); + } + +mutex_unlock (&rdtgroup_mutex); + +return 0 ; +} +#ifdef CONFIG_PROC_CPU_RESCTRL /*
@@ -1901,6 +1925,13 @@ static struct rftype res_common_files[] = { .seq_show = mbm_local_bytes_config_show, .write = mbm_local_bytes_config_write, }, + { + .name = "mbm_assign_mode", + .mode = 0444, + .kf_ops = &rdtgroup_kf_single_ops, + .seq_show = rdtgroup_mbm_assign_mode_show, + .fflags = RFTYPE_MON_INFO, + }, { .name = "cpus", .mode = 0644,
Signature · 1 line
2.34.1
Reinette Chatre
maintainerRe: [PATCH v9 08/26] x86/resctrl: Introduce the interface to display monitor mode
Hi Babu,
Quoted 63 lines · Babu Moger
Introduce the interface file "
mbm_assign_mode" to list monitor modes supported.The "
mbm_cntr_assign" mode provides the option to assign a counter to an RMID, event pair and monitor the bandwidth as long as it is assigned.On AMD systems "
mbm_cntr_assign" is backed by the ABMC (Assignable Bandwidth Monitoring Counters) hardware feature and is enabled by default.The "default" mode is the existing monitoring mode that works without the explicit counter assignment, instead relying on dynamic counter assignment by hardware that may result in hardware not dedicating a counter resulting in monitoring data reads returning "Unavailable".
Provide an interface to display the monitor mode on the system.
$ cat /sys/fs/resctrl/info/L3_MON/mbm_assign_mode [mbm_cntr_assign] defaultSigned-off-by Babu Moger <[email protected]>---
v9: Updated user documentation based on comments.v8: Commit message update.
v7: Updated the descriptions/commit log in
resctrl.rstto generic text.
Thanks to James and Reinette.
Renamembm_modetombm_assign_mode.
Introduced mutex lock inrdtgroup_mbm_mode_show().v6: Added documentation for
mbm_cntr_assignand legacy mode.
Movedmbm_modefflags initialization to static initialization.v5: Changed interface name to
mbm_mode.
It will be always available even if ABMC feature is not supported. Added description inresctrl.rstabout ABMC mode.
Fixed display abmc and legacy consistantly.v4: Fixed the checks for legacy and abmc mode. Default it ABMC.
v3: New patch to display ABMC capability.
--- Documentation/arch/x86/resctrl.rst | 33 ++++++++++++++++++++++++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 31 ++++++++++++++++++++++++ 2 files changed, 64 insertions(+)Documentation/arch/x86/resctrl.rst +9
-0@@ -257,6 +257,39 @@ with the following files: # cat /sys/fs/resctrl/info/L3_MON/mbm_local_bytes_config 0=0x30;1=0x30;3=0x15;4=0x15 +"mbm_assign_mode": + Reports the list of monitoring modes supported. The enclosed brackets + indicate which mode is enabled. + :: + + # cat /sys/fs/resctrl/info/L3_MON/mbm_assign_mode + [mbm_cntr_assign] + default +
Documentation/arch/x86/resctrl.rst with the following files: · line 278
Quoted 10 lines
Documentation/arch/x86/resctrl.rst +10
-0+ "mbm_cntr_assign": + + In mbm_cntr_assign mode user-space is able to specify which of the + events in CTRL_MON or MON groups should have a counter assigned using the + "mbm_assign_control" file. The number of counters available is described + in the "num_mbm_cntrs" file. Changing the mode may cause all counters on + a resource to reset. + + The mode is useful on platforms which support more CTRL_MON and MON + groups than the hardware counters, meaning 'unassigned' events on CTRL_MON or
" than the hardware counters" -> " than hardware counters"?
Documentation/arch/x86/resctrl.rst with the following files: · line 280
Quoted 2 lines
Documentation/arch/x86/resctrl.rst +2
-0+ MON groups will report 'Unavailable' or count the traffic in an unpredictable + way.
I think the above can be confusing to users. It mentioned "*will* report Unavailable" and then "*or* count the traffic in an unpredictable way". It is not possible for counter to report "Unavailable" while also reporting unpredictable data.
My concern is that there is no way for a user to know if the platform supports more CTRL_MON and MON groups than hardware counters and the above seems to imply that counters may be unreliable ... so how does a user know if counters are unreliable or not?
Can this be made specific to help users know if their platforms are impacted? From what I know all AMD platforms are impacted so perhaps a straight-forward:
"The mode is useful on AMD platforms which support more CTRL_MON and MON ..."
I'm concerned that users with Intel platforms may want to use the "mbm_cntr_assign" mode to make the event data "more predictable" and then be concerned when the mode does not exist.
As an alternative, is it possible to know the number of hardware counters on AMD systems without ABMC? I wonder if we could perhaps always expose num_mbm_cntrs as a way for users to know if their platform may be impacted by this type of "unpredictability" (by comparing num_mbm_cntrs to num_rmids).
Documentation/arch/x86/resctrl.rst with the following files: · line 291
Quoted 11 lines
Documentation/arch/x86/resctrl.rst +11
-0+ + AMD Platforms with ABMC (Assignable Bandwidth Monitoring Counters) feature + enable this mode by default so that counters remain assigned even when the + corresponding RMID is not in use by any processor. + + "default": + + In default mode resctrl assumes there is a hardware counter for each + event within every CTRL_MON and MON group. Reading mbm_total_bytes or + mbm_local_bytes may report 'Unavailable' if there is no counter associated + with that event.
If I understand correctly, on AMD platforms without ABMC the events only report "Unavailable" if there is no counter assigned at the time of the query. If a counter is unassigned and then reassigned then the event count will reset and the user will get some data back but it may thus be unpredictable (to match earlier language). Is this correct? Any AMD platform in "default" mode may thus be vulnerable to "unpredictable" event counts (not just "Unavailable") ... this gets complicated because users should be steered to avoid "default" mode if mbm_assign_mode is available, while not be made concerned to use "default" mode on Intel where mbm_assign_mode is not available.
Reinette
Moger, Babu
reviewerRe: [PATCH v9 08/26] x86/resctrl: Introduce the interface to display monitor mode
Hi Reinette,
Quoted 70 lines · Reinette Chatre
Hi Babu,
Quoted 67 lines · Babu Moger
Introduce the interface file "
mbm_assign_mode" to list monitor modes supported.The "
mbm_cntr_assign" mode provides the option to assign a counter to an RMID, event pair and monitor the bandwidth as long as it is assigned.On AMD systems "
mbm_cntr_assign" is backed by the ABMC (Assignable Bandwidth Monitoring Counters) hardware feature and is enabled by default.The "default" mode is the existing monitoring mode that works without the explicit counter assignment, instead relying on dynamic counter assignment by hardware that may result in hardware not dedicating a counter resulting in monitoring data reads returning "Unavailable".
Provide an interface to display the monitor mode on the system.
$ cat /sys/fs/resctrl/info/L3_MON/mbm_assign_mode [mbm_cntr_assign] defaultSigned-off-by Babu Moger <[email protected]>---
v9: Updated user documentation based on comments.v8: Commit message update.
v7: Updated the descriptions/commit log in
resctrl.rstto generic text.
Thanks to James and Reinette.
Renamembm_modetombm_assign_mode.
Introduced mutex lock inrdtgroup_mbm_mode_show().v6: Added documentation for
mbm_cntr_assignand legacy mode.
Movedmbm_modefflags initialization to static initialization.v5: Changed interface name to
mbm_mode.
It will be always available even if ABMC feature is not supported. Added description inresctrl.rstabout ABMC mode.
Fixed display abmc and legacy consistantly.v4: Fixed the checks for legacy and abmc mode. Default it ABMC.
v3: New patch to display ABMC capability.
--- Documentation/arch/x86/resctrl.rst | 33 ++++++++++++++++++++++++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 31 ++++++++++++++++++++++++ 2 files changed, 64 insertions(+)Documentation/arch/x86/resctrl.rst +13
-0@@ -257,6 +257,39 @@ with the following files: # cat /sys/fs/resctrl/info/L3_MON/mbm_local_bytes_config 0=0x30;1=0x30;3=0x15;4=0x15 +"mbm_assign_mode": + Reports the list of monitoring modes supported. The enclosed brackets + indicate which mode is enabled. + :: + + # cat /sys/fs/resctrl/info/L3_MON/mbm_assign_mode + [mbm_cntr_assign] + default + + "mbm_cntr_assign": + + In mbm_cntr_assign mode user-space is able to specify which of the + events in CTRL_MON or MON groups should have a counter assigned using the
Quoted 8 lines
Documentation/arch/x86/resctrl.rst with the following files: · line 278
Quoted 6 lines
Documentation/arch/x86/resctrl.rst +6
-0+ "mbm_assign_control" file. The number of counters available is described + in the "num_mbm_cntrs" file. Changing the mode may cause all counters on + a resource to reset. + + The mode is useful on platforms which support more CTRL_MON and MON + groups than the hardware counters, meaning 'unassigned' events on CTRL_MON or" than the hardware counters" -> " than hardware counters"?
Sure.
Quoted 11 lines
Documentation/arch/x86/resctrl.rst with the following files: · line 280
Quoted 3 lines
Documentation/arch/x86/resctrl.rst +2
-0+ MON groups will report 'Unavailable' or count the traffic in an unpredictable + way.I think the above can be confusing to users. It mentioned "*will* report Unavailable" and then "*or* count the traffic in an unpredictable way". It is not possible for counter to report "Unavailable" while also reporting unpredictable data.
My concern is that there is no way for a user to know if the platform supports more
CTRL_MONand MON groups than hardware counters and the above seems to imply that counters may be unreliable ... so how does a user know if counters are unreliable or not?
That is correct. There is no definite way to find out if the counters are unreliable.
Quoted 5 lines
Can this be made specific to help users know if their platforms are impacted? From what I know all AMD platforms are impacted so perhaps a straight-forward:
"The mode is useful on AMD platforms which support more
CTRL_MONand MON ..."
Sure.
Quoted 9 lines
I'm concerned that users with Intel platforms may want to use the "
mbm_cntr_assign" mode to make the event data "more predictable" and then be concerned when the mode does not exist.As an alternative, is it possible to know the number of hardware counters on AMD systems without ABMC? I wonder if we could perhaps always expose
num_mbm_cntrsas a way for users to know if their platform may be impacted by this type of "unpredictability" (by comparingnum_mbm_cntrstonum_rmids).
There is some round about(or hacky) way to find that out number of RMIDs that can be active.
Quoted 11 lines
Quoted 11 lines
Documentation/arch/x86/resctrl.rst +10
-0+ + AMD Platforms with ABMC (Assignable Bandwidth Monitoring Counters) feature + enable this mode by default so that counters remain assigned even when the + corresponding RMID is not in use by any processor. + + "default": + + In default mode resctrl assumes there is a hardware counter for each + event within every CTRL_MON and MON group. Reading mbm_total_bytes or + mbm_local_bytes may report 'Unavailable' if there is no counter associated
Quoted 8 lines
Documentation/arch/x86/resctrl.rst with the following files: · line 291
Quoted 1 line
Documentation/arch/x86/resctrl.rst +1
-0+ with that event.If I understand correctly, on AMD platforms without ABMC the events only report "Unavailable" if there is no counter assigned at the time of the query. If a counter is unassigned and then reassigned then the event count will reset and the user will get some data back but it may thus be unpredictable (to match earlier language). Is this correct? Any AMD platform in "default" mode may thus be vulnerable to "unpredictable" event counts (not just "Unavailable") ... this gets complicated
Yes. All the AMD systems without ABMC are affected by this problem.
Quoted 3 lines
because users should be steered to avoid "default" mode if
mbm_assign_modeis available, while not be made concerned to use "default" mode on Intel wherembm_assign_modeis not available.
Can we add text to clarify this?
Quoted 4 lines
Reinette
Signature · 2 lines
Thanks Babu Moger
Reinette Chatre
maintainerRe: [PATCH v9 08/26] x86/resctrl: Introduce the interface to display monitor mode
Hi Babu,
Quoted 27 lines · Babu
Hi Reinette,
Quoted 24 lines · Reinette Chatre
Hi Babu,
Quoted 21 lines · Babu Moger
Introduce the interface file "
mbm_assign_mode" to list monitor modes supported.The "
mbm_cntr_assign" mode provides the option to assign a counter to an RMID, event pair and monitor the bandwidth as long as it is assigned.On AMD systems "
mbm_cntr_assign" is backed by the ABMC (Assignable Bandwidth Monitoring Counters) hardware feature and is enabled by default.The "default" mode is the existing monitoring mode that works without the explicit counter assignment, instead relying on dynamic counter assignment by hardware that may result in hardware not dedicating a counter resulting in monitoring data reads returning "Unavailable".
Provide an interface to display the monitor mode on the system.
$ cat /sys/fs/resctrl/info/L3_MON/mbm_assign_mode [mbm_cntr_assign] defaultSigned-off-by Babu Moger <[email protected]>---
...
Quoted 11 lines
Quoted 8 lines
I'm concerned that users with Intel platforms may want to use the "
mbm_cntr_assign" mode to make the event data "more predictable" and then be concerned when the mode does not exist.As an alternative, is it possible to know the number of hardware counters on AMD systems without ABMC? I wonder if we could perhaps always expose
num_mbm_cntrsas a way for users to know if their platform may be impacted by this type of "unpredictability" (by comparingnum_mbm_cntrstonum_rmids).There is some round about(or hacky) way to find that out number of RMIDs that can be active.
Does this give consistent and accurate data? Is this something that can be added to resctrl? (Reading your other message [1] it does not sound as though it can produce an accurate number on boot.)
If not then it will be up to the documentation to be accurate.
Quoted 19 lines
Quoted 10 lines
Quoted 10 lines
Documentation/arch/x86/resctrl.rst +10
-0+ + AMD Platforms with ABMC (Assignable Bandwidth Monitoring Counters) feature + enable this mode by default so that counters remain assigned even when the + corresponding RMID is not in use by any processor. + + "default": + + In default mode resctrl assumes there is a hardware counter for each + event within every CTRL_MON and MON group. Reading mbm_total_bytes or + mbm_local_bytes may report 'Unavailable' if there is no counter associatedQuoted 8 lines
Documentation/arch/x86/resctrl.rst with the following files: · line 291
Quoted 1 line
Documentation/arch/x86/resctrl.rst +1
-0+ with that event.If I understand correctly, on AMD platforms without ABMC the events only report "Unavailable" if there is no counter assigned at the time of the query. If a counter is unassigned and then reassigned then the event count will reset and the user will get some data back but it may thus be unpredictable (to match earlier language). Is this correct? Any AMD platform in "default" mode may thus be vulnerable to "unpredictable" event counts (not just "Unavailable") ... this gets complicated
Quoted 7 lines
Yes. All the AMD systems without ABMC are affected by this problem.
Quoted 3 lines
because users should be steered to avoid "default" mode if
mbm_assign_modeis available, while not be made concerned to use "default" mode on Intel wherembm_assign_modeis not available.Can we add text to clarify this?
Please do.
Reinette
Re: [PATCH v9 08/26] x86/resctrl: Introduce the interface to display monitor mode
Hi Reinette,
Quoted 72 lines · Reinette Chatre
Hi Babu,
Quoted 27 lines · Babu
Hi Reinette,
Quoted 24 lines · Reinette Chatre
Hi Babu,
Quoted 21 lines · Babu Moger
Introduce the interface file "
mbm_assign_mode" to list monitor modes supported.The "
mbm_cntr_assign" mode provides the option to assign a counter to an RMID, event pair and monitor the bandwidth as long as it is assigned.On AMD systems "
mbm_cntr_assign" is backed by the ABMC (Assignable Bandwidth Monitoring Counters) hardware feature and is enabled by default.The "default" mode is the existing monitoring mode that works without the explicit counter assignment, instead relying on dynamic counter assignment by hardware that may result in hardware not dedicating a counter resulting in monitoring data reads returning "Unavailable".
Provide an interface to display the monitor mode on the system.
$ cat /sys/fs/resctrl/info/L3_MON/mbm_assign_mode [mbm_cntr_assign] defaultSigned-off-by Babu Moger <[email protected]>---
...
Quoted 11 lines
Quoted 8 lines
I'm concerned that users with Intel platforms may want to use the "
mbm_cntr_assign" mode to make the event data "more predictable" and then be concerned when the mode does not exist.As an alternative, is it possible to know the number of hardware counters on AMD systems without ABMC? I wonder if we could perhaps always expose
num_mbm_cntrsas a way for users to know if their platform may be impacted by this type of "unpredictability" (by comparingnum_mbm_cntrstonum_rmids).There is some round about(or hacky) way to find that out number of RMIDs that can be active.
Does this give consistent and accurate data? Is this something that can be added to resctrl? (Reading your other message [1] it does not sound as though it can produce an accurate number on boot.)
If not then it will be up to the documentation to be accurate.Quoted 21 lines
Quoted 10 lines
Quoted 10 lines
Documentation/arch/x86/resctrl.rst +10
-0+ + AMD Platforms with ABMC (Assignable Bandwidth Monitoring Counters) feature + enable this mode by default so that counters remain assigned even when the + corresponding RMID is not in use by any processor. + + "default": + + In default mode resctrl assumes there is a hardware counter for each + event within every CTRL_MON and MON group. Reading mbm_total_bytes or + mbm_local_bytes may report 'Unavailable' if there is no counter associatedQuoted 8 lines
Documentation/arch/x86/resctrl.rst with the following files: · line 291
Quoted 1 line
Documentation/arch/x86/resctrl.rst +1
-0+ with that event.If I understand correctly, on AMD platforms without ABMC the events only report "Unavailable" if there is no counter assigned at the time of the query. If a counter is unassigned and then reassigned then the event count will reset and the user will get some data back but it may thus be unpredictable (to match earlier language). Is this correct? Any AMD platform in "default" mode may thus be vulnerable to "unpredictable" event counts (not just "Unavailable") ... this gets complicated
Yes. All the AMD systems without ABMC are affected by this problem.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
because users should be steered to avoid "default" mode if
mbm_assign_modeis available, while not be made concerned to use "default" mode on Intel wherembm_assign_modeis not available.Can we add text to clarify this?
Please do.
I think we need to add text about AMD systems. How about this?
"default":
In default mode resctrl assumes there is a hardware counter for each
event within every CTRL_MON and MON group. On AMD systems with 16 more monitoring groups, reading mbm_total_bytes or mbm_local_bytes may report 'Unavailable' if there is no counter associated with that event. It is therefore recommended to use the 'mbm_cntr_assign' mode, if supported."
Quoted 5 lines
Reinette
Signature · 1 line
- Babu Moger
Reinette Chatre
maintainerRe: [PATCH v9 08/26] x86/resctrl: Introduce the interface to display monitor mode
Hi Babu,
Quoted 81 lines · Babu
Hi Reinette,
Quoted 78 lines · Reinette Chatre
Hi Babu,
Quoted 27 lines · Babu
Hi Reinette,
Quoted 24 lines · Reinette Chatre
Hi Babu,
Quoted 21 lines · Babu Moger
Introduce the interface file "
mbm_assign_mode" to list monitor modes supported.The "
mbm_cntr_assign" mode provides the option to assign a counter to an RMID, event pair and monitor the bandwidth as long as it is assigned.On AMD systems "
mbm_cntr_assign" is backed by the ABMC (Assignable Bandwidth Monitoring Counters) hardware feature and is enabled by default.The "default" mode is the existing monitoring mode that works without the explicit counter assignment, instead relying on dynamic counter assignment by hardware that may result in hardware not dedicating a counter resulting in monitoring data reads returning "Unavailable".
Provide an interface to display the monitor mode on the system.
$ cat /sys/fs/resctrl/info/L3_MON/mbm_assign_mode [mbm_cntr_assign] defaultSigned-off-by Babu Moger <[email protected]>---
...
Quoted 11 lines
Quoted 8 lines
I'm concerned that users with Intel platforms may want to use the "
mbm_cntr_assign" mode to make the event data "more predictable" and then be concerned when the mode does not exist.As an alternative, is it possible to know the number of hardware counters on AMD systems without ABMC? I wonder if we could perhaps always expose
num_mbm_cntrsas a way for users to know if their platform may be impacted by this type of "unpredictability" (by comparingnum_mbm_cntrstonum_rmids).There is some round about(or hacky) way to find that out number of RMIDs that can be active.
Does this give consistent and accurate data? Is this something that can be added to resctrl? (Reading your other message [1] it does not sound as though it can produce an accurate number on boot.)
If not then it will be up to the documentation to be accurate.Quoted 26 lines
Quoted 10 lines
Quoted 10 lines
Documentation/arch/x86/resctrl.rst +10
-0+ + AMD Platforms with ABMC (Assignable Bandwidth Monitoring Counters) feature + enable this mode by default so that counters remain assigned even when the + corresponding RMID is not in use by any processor. + + "default": + + In default mode resctrl assumes there is a hardware counter for each + event within every CTRL_MON and MON group. Reading mbm_total_bytes or + mbm_local_bytes may report 'Unavailable' if there is no counter associatedQuoted 8 lines
Quoted 1 line
+ with that event.
If I understand correctly, on AMD platforms without ABMC the events only report "Unavailable" if there is no counter assigned at the time of the query. If a counter is unassigned and then reassigned then the event count will reset and the user will get some data back but it may thus be unpredictable (to match earlier language). Is this correct? Any AMD platform in "default" mode may thus be vulnerable to "unpredictable" event counts (not just "Unavailable") ... this gets complicated
Yes. All the AMD systems without ABMC are affected by this problem.
Quoted 3 lines
because users should be steered to avoid "default" mode if
mbm_assign_modeis available, while not be made concerned to use "default" mode on Intel wherembm_assign_modeis not available.Can we add text to clarify this?
Quoted 7 lines
Quoted 1 line
Please do.
I think we need to add text about AMD systems. How about this?
"default":
In default mode resctrl assumes there is a hardware counter for each
event within everyCTRL_MONand MON group. On AMD systems with 16 more monitoring groups, readingmbm_total_bytesormbm_local_bytesmay report 'Unavailable' if there is no counter associated with that event. It is therefore recommended to use the 'mbm_cntr_assign' mode, if supported."
What is meant with "On AMD systems with 16 more monitoring groups"? First, the language is not clear, second, you mentioned earlier that there is just a "hacky" way to determine number of RMIDs that can be active but here "16" is made official in the documentation?
Reinette
Re: [PATCH v9 08/26] x86/resctrl: Introduce the interface to display monitor mode
Hi Reinette,
Quoted 88 lines · Reinette Chatre
Hi Babu,
Quoted 85 lines · Babu
Hi Reinette,
Quoted 72 lines · Reinette Chatre
Hi Babu,
Quoted 27 lines · Babu
Hi Reinette,
Quoted 24 lines · Reinette Chatre
Hi Babu,
Quoted 21 lines · Babu Moger
Introduce the interface file "
mbm_assign_mode" to list monitor modes supported.The "
mbm_cntr_assign" mode provides the option to assign a counter to an RMID, event pair and monitor the bandwidth as long as it is assigned.On AMD systems "
mbm_cntr_assign" is backed by the ABMC (Assignable Bandwidth Monitoring Counters) hardware feature and is enabled by default.The "default" mode is the existing monitoring mode that works without the explicit counter assignment, instead relying on dynamic counter assignment by hardware that may result in hardware not dedicating a counter resulting in monitoring data reads returning "Unavailable".
Provide an interface to display the monitor mode on the system.
$ cat /sys/fs/resctrl/info/L3_MON/mbm_assign_mode [mbm_cntr_assign] defaultSigned-off-by Babu Moger <[email protected]>---
...
Quoted 11 lines
Quoted 8 lines
I'm concerned that users with Intel platforms may want to use the "
mbm_cntr_assign" mode to make the event data "more predictable" and then be concerned when the mode does not exist.As an alternative, is it possible to know the number of hardware counters on AMD systems without ABMC? I wonder if we could perhaps always expose
num_mbm_cntrsas a way for users to know if their platform may be impacted by this type of "unpredictability" (by comparingnum_mbm_cntrstonum_rmids).There is some round about(or hacky) way to find that out number of RMIDs that can be active.
Does this give consistent and accurate data? Is this something that can be added to resctrl? (Reading your other message [1] it does not sound as though it can produce an accurate number on boot.)
If not then it will be up to the documentation to be accurate.Quoted 21 lines
Quoted 10 lines
Quoted 10 lines
Documentation/arch/x86/resctrl.rst +10
-0+ + AMD Platforms with ABMC (Assignable Bandwidth Monitoring Counters) feature + enable this mode by default so that counters remain assigned even when the + corresponding RMID is not in use by any processor. + + "default": + + In default mode resctrl assumes there is a hardware counter for each + event within every CTRL_MON and MON group. Reading mbm_total_bytes or + mbm_local_bytes may report 'Unavailable' if there is no counter associatedQuoted 8 lines
Quoted 1 line
+ with that event.
If I understand correctly, on AMD platforms without ABMC the events only report "Unavailable" if there is no counter assigned at the time of the query. If a counter is unassigned and then reassigned then the event count will reset and the user will get some data back but it may thus be unpredictable (to match earlier language). Is this correct? Any AMD platform in "default" mode may thus be vulnerable to "unpredictable" event counts (not just "Unavailable") ... this gets complicated
Yes. All the AMD systems without ABMC are affected by this problem.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
because users should be steered to avoid "default" mode if
mbm_assign_modeis available, while not be made concerned to use "default" mode on Intel wherembm_assign_modeis not available.Can we add text to clarify this?
Please do.
I think we need to add text about AMD systems. How about this?
Quoted 9 lines
Quoted 3 lines
"default":
In default mode resctrl assumes there is a hardware counter for each
event within everyCTRL_MONand MON group. On AMD systems with 16 more monitoring groups, readingmbm_total_bytesormbm_local_bytesmay report 'Unavailable' if there is no counter associated with that event. It is therefore recommended to use the 'mbm_cntr_assign' mode, if supported."What is meant with "On AMD systems with 16 more monitoring groups"? First, the language is not clear, second, you mentioned earlier that there is just a "hacky" way to determine number of RMIDs that can be active but here "16" is made official in the documentation?
The lowest active RMID is 16. I could not get it using the hacky way.
I have verified testing on all the previous generation of AMD systems by creating the monitoring groups until it reports "Unavailable". In recent systems it is 32. We can drop the exact number to be generic.
There is no clear documentation on that. Here is what the doc says.
A given implementation may have insufficient hardware to simultaneously track the bandwidth for all RMID values which the hardware supports. If an attempt is made to read a Bandwidth Count for an RMID that has been impacted by these hardware limitations, the “U” bit of the QM_CTR will be set when the counter is read. Subsequent QM_CTR reads for that RMID and Event may return a value with the "U" bit clear. Potential causes of the “U” bit being set include (but are not limited to)
• RMID is not currently tracked by the hardware.
• RMID was not tracked by the hardware at some time since it was last read.
• RMID has not been read since it started being tracked by the hardware.
All RMIDs which are currently in use by one or more processors in the QOS domain will be tracked. The hardware will always begin tracking a new RMID value when it gets written to the PQR_ASSOC register of any of the processors in the QOS domain and it is not already being tracked. When the hardware begins tracking an RMID that it was not previously tracking, it will clear the QM_CTR for all events in the new RMID
- Babu Moger
Reinette Chatre
maintainerRe: [PATCH v9 08/26] x86/resctrl: Introduce the interface to display monitor mode
Hi Babu,
Quoted 111 lines · Babu
Hi Reinette,
Quoted 88 lines · Reinette Chatre
Hi Babu,
Quoted 85 lines · Babu
Hi Reinette,
Quoted 72 lines · Reinette Chatre
Hi Babu,
Quoted 27 lines · Babu
Hi Reinette,
Quoted 24 lines · Reinette Chatre
Hi Babu,
Quoted 21 lines · Babu Moger
Introduce the interface file "
mbm_assign_mode" to list monitor modes supported.The "
mbm_cntr_assign" mode provides the option to assign a counter to an RMID, event pair and monitor the bandwidth as long as it is assigned.On AMD systems "
mbm_cntr_assign" is backed by the ABMC (Assignable Bandwidth Monitoring Counters) hardware feature and is enabled by default.The "default" mode is the existing monitoring mode that works without the explicit counter assignment, instead relying on dynamic counter assignment by hardware that may result in hardware not dedicating a counter resulting in monitoring data reads returning "Unavailable".
Provide an interface to display the monitor mode on the system.
$ cat /sys/fs/resctrl/info/L3_MON/mbm_assign_mode [mbm_cntr_assign] defaultSigned-off-by Babu Moger <[email protected]>---
...
Quoted 11 lines
Quoted 8 lines
I'm concerned that users with Intel platforms may want to use the "
mbm_cntr_assign" mode to make the event data "more predictable" and then be concerned when the mode does not exist.As an alternative, is it possible to know the number of hardware counters on AMD systems without ABMC? I wonder if we could perhaps always expose
num_mbm_cntrsas a way for users to know if their platform may be impacted by this type of "unpredictability" (by comparingnum_mbm_cntrstonum_rmids).There is some round about(or hacky) way to find that out number of RMIDs that can be active.
Does this give consistent and accurate data? Is this something that can be added to resctrl? (Reading your other message [1] it does not sound as though it can produce an accurate number on boot.)
If not then it will be up to the documentation to be accurate.Quoted 21 lines
Quoted 10 lines
Quoted 10 lines
(quoted diff) +10
-0+ + AMD Platforms with ABMC (Assignable Bandwidth Monitoring Counters) feature + enable this mode by default so that counters remain assigned even when the + corresponding RMID is not in use by any processor. + + "default": + + In default mode resctrl assumes there is a hardware counter for each + event within every CTRL_MON and MON group. Reading mbm_total_bytes or + mbm_local_bytes may report 'Unavailable' if there is no counter associatedQuoted 8 lines
Quoted 1 line
+ with that event.
If I understand correctly, on AMD platforms without ABMC the events only report "Unavailable" if there is no counter assigned at the time of the query. If a counter is unassigned and then reassigned then the event count will reset and the user will get some data back but it may thus be unpredictable (to match earlier language). Is this correct? Any AMD platform in "default" mode may thus be vulnerable to "unpredictable" event counts (not just "Unavailable") ... this gets complicated
Yes. All the AMD systems without ABMC are affected by this problem.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
because users should be steered to avoid "default" mode if
mbm_assign_modeis available, while not be made concerned to use "default" mode on Intel wherembm_assign_modeis not available.Can we add text to clarify this?
Please do.
I think we need to add text about AMD systems. How about this?
Quoted 9 lines
Quoted 3 lines
"default":
In default mode resctrl assumes there is a hardware counter for each
event within everyCTRL_MONand MON group. On AMD systems with 16 more monitoring groups, readingmbm_total_bytesormbm_local_bytesmay report 'Unavailable' if there is no counter associated with that event. It is therefore recommended to use the 'mbm_cntr_assign' mode, if supported."What is meant with "On AMD systems with 16 more monitoring groups"? First, the language is not clear, second, you mentioned earlier that there is just a "hacky" way to determine number of RMIDs that can be active but here "16" is made official in the documentation?
The lowest active RMID is 16. I could not get it using the hacky way.
I have verified testing on all the previous generation of AMD systems by creating the monitoring groups until it reports "Unavailable". In recent systems it is 32. We can drop the exact number to be generic.There is no clear documentation on that. Here is what the doc says.
A given implementation may have insufficient hardware to simultaneously track the bandwidth for all RMID values which the hardware supports. If an attempt is made to read a Bandwidth Count for an RMID that has been impacted by these hardware limitations, the “U” bit of the
QM_CTRwill be set when the counter is read. SubsequentQM_CTRreads for that RMID and Event may return a value with the "U" bit clear. Potential causes of the “U” bit being set include (but are not limited to)
Quoted 8 lines
• RMID is not currently tracked by the hardware.
• RMID was not tracked by the hardware at some time since it was last read.
• RMID has not been read since it started being tracked by the hardware.All RMIDs which are currently in use by one or more processors in the QOS domain will be tracked. The hardware will always begin tracking a new RMID value when it gets written to the
PQR_ASSOCregister of any of the processors in the QOS domain and it is not already being tracked. When the hardware begins tracking an RMID that it was not previously tracking, it will clear theQM_CTRfor all events in the new RMID- Babu Moger
I think I am starting to understand what is meant with the "count the traffic in an unpredictable way". From what I understand the hardware uses the "U" bit to indicate that an RMID was not tracked for a while, but it only sets this bit on the first read. After that the "U" bit may be cleared if a counter can be assigned to an RMID afterwards.
If it was only user space that reads the data then it should be clear to the user when the hardware limitation is encountered and thus hardware behavior can be "predictable", but since the overflow handler runs once per second it may indeed be the overflow handler that encounters the "U" bit and that bit is not currently handled. This could leave user space with impression that events are always returning data but that data may indeed be wrong.
In another thread [1] Tony confirmed that "U" bit is not returned by Intel systems so this issue only impacts AMD. As I understand the other scenarios in which AMD systems can return "U" (the first read after assigning an RMID and the first read after changing the memory config) are all scenarios that can be controlled by resctrl.
I do not see why unpredictable data should be addressed with documentation. Could this not be fixed instead? Essentially stating "AMD systems without ABMC count the traffic in an unpredictable way" seems like a poor user experience.
What if instead resctrl handles the "U" bit better? For example, when the overflow handler encounters the "U" bit the RMID can be permanently marked as "Unavailable"? Would that not be better than the counter behaving unpredictably with users never knowing if they can trust the event counters?
Reinette
[1] https://lore.kernel.org/all/ZzUvA2XE01U25A38@agluck-desk3/
Re: [PATCH v9 08/26] x86/resctrl: Introduce the interface to display monitor mode
Hi Reinette,
Quoted 139 lines · Reinette Chatre
Hi Babu,
Quoted 111 lines · Babu
Hi Reinette,
Quoted 88 lines · Reinette Chatre
Hi Babu,
Quoted 85 lines · Babu
Hi Reinette,
Quoted 72 lines · Reinette Chatre
Hi Babu,
Quoted 27 lines · Babu
Hi Reinette,
Quoted 24 lines · Reinette Chatre
Hi Babu,
Quoted 21 lines · Babu Moger
Introduce the interface file "
mbm_assign_mode" to list monitor modes supported.The "
mbm_cntr_assign" mode provides the option to assign a counter to an RMID, event pair and monitor the bandwidth as long as it is assigned.On AMD systems "
mbm_cntr_assign" is backed by the ABMC (Assignable Bandwidth Monitoring Counters) hardware feature and is enabled by default.The "default" mode is the existing monitoring mode that works without the explicit counter assignment, instead relying on dynamic counter assignment by hardware that may result in hardware not dedicating a counter resulting in monitoring data reads returning "Unavailable".
Provide an interface to display the monitor mode on the system.
$ cat /sys/fs/resctrl/info/L3_MON/mbm_assign_mode [mbm_cntr_assign] defaultSigned-off-by Babu Moger <[email protected]>---
...
Quoted 11 lines
Quoted 8 lines
I'm concerned that users with Intel platforms may want to use the "
mbm_cntr_assign" mode to make the event data "more predictable" and then be concerned when the mode does not exist.As an alternative, is it possible to know the number of hardware counters on AMD systems without ABMC? I wonder if we could perhaps always expose
num_mbm_cntrsas a way for users to know if their platform may be impacted by this type of "unpredictability" (by comparingnum_mbm_cntrstonum_rmids).There is some round about(or hacky) way to find that out number of RMIDs that can be active.
Does this give consistent and accurate data? Is this something that can be added to resctrl? (Reading your other message [1] it does not sound as though it can produce an accurate number on boot.)
If not then it will be up to the documentation to be accurate.Quoted 21 lines
Quoted 10 lines
Quoted 10 lines
(quoted diff) +10
-0+ + AMD Platforms with ABMC (Assignable Bandwidth Monitoring Counters) feature + enable this mode by default so that counters remain assigned even when the + corresponding RMID is not in use by any processor. + + "default": + + In default mode resctrl assumes there is a hardware counter for each + event within every CTRL_MON and MON group. Reading mbm_total_bytes or + mbm_local_bytes may report 'Unavailable' if there is no counter associatedQuoted 8 lines
Quoted 1 line
+ with that event.
If I understand correctly, on AMD platforms without ABMC the events only report "Unavailable" if there is no counter assigned at the time of the query. If a counter is unassigned and then reassigned then the event count will reset and the user will get some data back but it may thus be unpredictable (to match earlier language). Is this correct? Any AMD platform in "default" mode may thus be vulnerable to "unpredictable" event counts (not just "Unavailable") ... this gets complicated
Yes. All the AMD systems without ABMC are affected by this problem.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
because users should be steered to avoid "default" mode if
mbm_assign_modeis available, while not be made concerned to use "default" mode on Intel wherembm_assign_modeis not available.Can we add text to clarify this?
Please do.
I think we need to add text about AMD systems. How about this?
Quoted 9 lines
Quoted 3 lines
"default":
In default mode resctrl assumes there is a hardware counter for each
event within everyCTRL_MONand MON group. On AMD systems with 16 more monitoring groups, readingmbm_total_bytesormbm_local_bytesmay report 'Unavailable' if there is no counter associated with that event. It is therefore recommended to use the 'mbm_cntr_assign' mode, if supported."What is meant with "On AMD systems with 16 more monitoring groups"? First, the language is not clear, second, you mentioned earlier that there is just a "hacky" way to determine number of RMIDs that can be active but here "16" is made official in the documentation?
The lowest active RMID is 16. I could not get it using the hacky way.
I have verified testing on all the previous generation of AMD systems by creating the monitoring groups until it reports "Unavailable". In recent systems it is 32. We can drop the exact number to be generic.There is no clear documentation on that. Here is what the doc says.
A given implementation may have insufficient hardware to simultaneously track the bandwidth for all RMID values which the hardware supports. If an attempt is made to read a Bandwidth Count for an RMID that has been impacted by these hardware limitations, the “U” bit of the
QM_CTRwill be set when the counter is read. SubsequentQM_CTRreads for that RMID and Event may return a value with the "U" bit clear. Potential causes of the “U” bit being set include (but are not limited to)Quoted 8 lines
• RMID is not currently tracked by the hardware.
• RMID was not tracked by the hardware at some time since it was last read.
• RMID has not been read since it started being tracked by the hardware.All RMIDs which are currently in use by one or more processors in the QOS domain will be tracked. The hardware will always begin tracking a new RMID value when it gets written to the
PQR_ASSOCregister of any of the processors in the QOS domain and it is not already being tracked. When the hardware begins tracking an RMID that it was not previously tracking, it will clear theQM_CTRfor all events in the new RMID- Babu Moger
I think I am starting to understand what is meant with the "count the traffic in an unpredictable way". From what I understand the hardware uses the "U" bit to indicate that an RMID was not tracked for a while, but it only sets this bit on the first read. After that the "U" bit may be cleared if a counter can be assigned to an RMID afterwards.
If it was only user space that reads the data then it should be clear to the user when the hardware limitation is encountered and thus hardware behavior can be "predictable", but since the overflow handler runs once per second it may indeed be the overflow handler that encounters the "U" bit and that bit is not currently handled. This could leave user space with impression that events are always returning data but that data may indeed be wrong.In another thread [1] Tony confirmed that "U" bit is not returned by Intel systems so this issue only impacts AMD. As I understand the other scenarios in which AMD systems can return "U" (the first read after assigning an RMID and the first read after changing the memory config) are all scenarios that can be controlled by resctrl.
Quoted 7 lines
I do not see why unpredictable data should be addressed with documentation. Could this not be fixed instead? Essentially stating "AMD systems without ABMC count the traffic in an unpredictable way" seems like a poor user experience.
What if instead resctrl handles the "U" bit better? For example, when the overflow handler encounters the "U" bit the RMID can be permanently marked as "Unavailable"? Would that not be better than the counter behaving unpredictably with users never knowing if they can trust the event counters?
Actually, I was looking at handling "Unavailable" in little bit better way. Right now, I see it reports "Unavailable" first then it goes into overflow and stays in overflow forever.
Also setting the RMID Unavailable permanently is not a good option. We should have a way to reset it. At some later point the RMID can become active and report the correct numbers.
I was thinking of introducing a new arch state(in arch_mbm_state) to handle this case. Need to investigate more on this. What do you think?
Quoted 6 lines
Reinette
[1] https://lore.kernel.org/all/ZzUvA2XE01U25A38@agluck-desk3/
Signature · 1 line
- Babu Moger
Reinette Chatre
maintainerRe: [PATCH v9 08/26] x86/resctrl: Introduce the interface to display monitor mode
Hi Babu,
Quoted 111 lines · Babu
Quoted 102 lines · Reinette Chatre
Quoted 76 lines · Babu
Quoted 55 lines · Reinette Chatre
Quoted 54 lines · Babu
Quoted 43 lines · Reinette Chatre
Quoted 7 lines · Babu
Quoted 6 lines · Reinette Chatre
On 10/29/24 4:21 PM, Babu Moger wrote:
I'm concerned that users with Intel platforms may want to use the "
mbm_cntr_assign" mode to make the event data "more predictable" and then be concerned when the mode does not exist.Quoted 7 lines
Quoted 4 lines
As an alternative, is it possible to know the number of hardware counters on AMD systems without ABMC? I wonder if we could perhaps always expose
num_mbm_cntrsas a way for users to know if their platform may be impacted by this type of "unpredictability" (by comparingnum_mbm_cntrstonum_rmids).There is some round about(or hacky) way to find that out number of RMIDs that can be active.
Does this give consistent and accurate data? Is this something that can be added to resctrl? (Reading your other message [1] it does not sound as though it can produce an accurate number on boot.)
If not then it will be up to the documentation to be accurate.Quoted 21 lines
Quoted 10 lines
Quoted 10 lines
(quoted diff) +10
-0+ + AMD Platforms with ABMC (Assignable Bandwidth Monitoring Counters) feature + enable this mode by default so that counters remain assigned even when the + corresponding RMID is not in use by any processor. + + "default": + + In default mode resctrl assumes there is a hardware counter for each + event within every CTRL_MON and MON group. Reading mbm_total_bytes or + mbm_local_bytes may report 'Unavailable' if there is no counter associatedQuoted 8 lines
Quoted 1 line
+ with that event.
If I understand correctly, on AMD platforms without ABMC the events only report "Unavailable" if there is no counter assigned at the time of the query. If a counter is unassigned and then reassigned then the event count will reset and the user will get some data back but it may thus be unpredictable (to match earlier language). Is this correct? Any AMD platform in "default" mode may thus be vulnerable to "unpredictable" event counts (not just "Unavailable") ... this gets complicated
Yes. All the AMD systems without ABMC are affected by this problem.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
because users should be steered to avoid "default" mode if
mbm_assign_modeis available, while not be made concerned to use "default" mode on Intel wherembm_assign_modeis not available.Can we add text to clarify this?
Please do.
I think we need to add text about AMD systems. How about this?
Quoted 9 lines
Quoted 3 lines
"default":
In default mode resctrl assumes there is a hardware counter for each
event within everyCTRL_MONand MON group. On AMD systems with 16 more monitoring groups, readingmbm_total_bytesormbm_local_bytesmay report 'Unavailable' if there is no counter associated with that event. It is therefore recommended to use the 'mbm_cntr_assign' mode, if supported."What is meant with "On AMD systems with 16 more monitoring groups"? First, the language is not clear, second, you mentioned earlier that there is just a "hacky" way to determine number of RMIDs that can be active but here "16" is made official in the documentation?
The lowest active RMID is 16. I could not get it using the hacky way.
I have verified testing on all the previous generation of AMD systems by creating the monitoring groups until it reports "Unavailable". In recent systems it is 32. We can drop the exact number to be generic.There is no clear documentation on that. Here is what the doc says.
A given implementation may have insufficient hardware to simultaneously track the bandwidth for all RMID values which the hardware supports. If an attempt is made to read a Bandwidth Count for an RMID that has been impacted by these hardware limitations, the “U” bit of the
QM_CTRwill be set when the counter is read. SubsequentQM_CTRreads for that RMID and Event may return a value with the "U" bit clear. Potential causes of the “U” bit being set include (but are not limited to)Quoted 8 lines
• RMID is not currently tracked by the hardware.
• RMID was not tracked by the hardware at some time since it was last read.
• RMID has not been read since it started being tracked by the hardware.All RMIDs which are currently in use by one or more processors in the QOS domain will be tracked. The hardware will always begin tracking a new RMID value when it gets written to the
PQR_ASSOCregister of any of the processors in the QOS domain and it is not already being tracked. When the hardware begins tracking an RMID that it was not previously tracking, it will clear theQM_CTRfor all events in the new RMID- Babu Moger
I think I am starting to understand what is meant with the "count the traffic in an unpredictable way". From what I understand the hardware uses the "U" bit to indicate that an RMID was not tracked for a while, but it only sets this bit on the first read. After that the "U" bit may be cleared if a counter can be assigned to an RMID afterwards.
If it was only user space that reads the data then it should be clear to the user when the hardware limitation is encountered and thus hardware behavior can be "predictable", but since the overflow handler runs once per second it may indeed be the overflow handler that encounters the "U" bit and that bit is not currently handled. This could leave user space with impression that events are always returning data but that data may indeed be wrong.In another thread [1] Tony confirmed that "U" bit is not returned by Intel systems so this issue only impacts AMD. As I understand the other scenarios in which AMD systems can return "U" (the first read after assigning an RMID and the first read after changing the memory config) are all scenarios that can be controlled by resctrl.
Quoted 7 lines
I do not see why unpredictable data should be addressed with documentation. Could this not be fixed instead? Essentially stating "AMD systems without ABMC count the traffic in an unpredictable way" seems like a poor user experience.
What if instead resctrl handles the "U" bit better? For example, when the overflow handler encounters the "U" bit the RMID can be permanently marked as "Unavailable"? Would that not be better than the counter behaving unpredictably with users never knowing if they can trust the event counters?
Quoted 1 line
Actually, I was looking at handling "Unavailable" in little bit better way. Right now, I see it reports "Unavailable" first then it goes into overflow and stays in overflow forever.
Could you please elaborate what you mean with "stays in overflow forever"?
Quoted 2 lines
Also setting the RMID Unavailable permanently is not a good option. We should have a way to reset it. At some later point the RMID can become active and report the correct numbers.
I assume that when an RMID becomes active cannot be the trigger to reset it since user space cannot then be aware that a counter was not available for a while.
Quoted 2 lines
I was thinking of introducing a new arch
state(in arch_mbm_state)to handle this case. Need to investigate more on this. What do you think?
Some new state is surely needed to reflect that the RMID's data may be wrong. It is not clear to me how you envision the reset of the state. If it is driven from user space then I expect that resctrl needs to be taught something about this and it cannot just be buried in arch code.
Reinette
Re: [PATCH v9 08/26] x86/resctrl: Introduce the interface to display monitor mode
Hi Reinette,
Quoted 114 lines · Reinette Chatre
Hi Babu,
Quoted 111 lines · Babu
Quoted 109 lines · Reinette Chatre
Quoted 76 lines · Babu
Quoted 55 lines · Reinette Chatre
Quoted 54 lines · Babu
Quoted 43 lines · Reinette Chatre
Quoted 7 lines · Babu
Quoted 6 lines · Reinette Chatre
On 10/29/24 4:21 PM, Babu Moger wrote:
I'm concerned that users with Intel platforms may want to use the "
mbm_cntr_assign" mode to make the event data "more predictable" and then be concerned when the mode does not exist.Quoted 7 lines
Quoted 4 lines
As an alternative, is it possible to know the number of hardware counters on AMD systems without ABMC? I wonder if we could perhaps always expose
num_mbm_cntrsas a way for users to know if their platform may be impacted by this type of "unpredictability" (by comparingnum_mbm_cntrstonum_rmids).There is some round about(or hacky) way to find that out number of RMIDs that can be active.
Does this give consistent and accurate data? Is this something that can be added to resctrl? (Reading your other message [1] it does not sound as though it can produce an accurate number on boot.)
If not then it will be up to the documentation to be accurate.Quoted 21 lines
Quoted 10 lines
Quoted 10 lines
(quoted diff) +10
-0+ + AMD Platforms with ABMC (Assignable Bandwidth Monitoring Counters) feature + enable this mode by default so that counters remain assigned even when the + corresponding RMID is not in use by any processor. + + "default": + + In default mode resctrl assumes there is a hardware counter for each + event within every CTRL_MON and MON group. Reading mbm_total_bytes or + mbm_local_bytes may report 'Unavailable' if there is no counter associatedQuoted 8 lines
Quoted 1 line
+ with that event.
If I understand correctly, on AMD platforms without ABMC the events only report "Unavailable" if there is no counter assigned at the time of the query. If a counter is unassigned and then reassigned then the event count will reset and the user will get some data back but it may thus be unpredictable (to match earlier language). Is this correct? Any AMD platform in "default" mode may thus be vulnerable to "unpredictable" event counts (not just "Unavailable") ... this gets complicated
Yes. All the AMD systems without ABMC are affected by this problem.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
because users should be steered to avoid "default" mode if
mbm_assign_modeis available, while not be made concerned to use "default" mode on Intel wherembm_assign_modeis not available.Can we add text to clarify this?
Please do.
I think we need to add text about AMD systems. How about this?
Quoted 9 lines
Quoted 3 lines
"default":
In default mode resctrl assumes there is a hardware counter for each
event within everyCTRL_MONand MON group. On AMD systems with 16 more monitoring groups, readingmbm_total_bytesormbm_local_bytesmay report 'Unavailable' if there is no counter associated with that event. It is therefore recommended to use the 'mbm_cntr_assign' mode, if supported."What is meant with "On AMD systems with 16 more monitoring groups"? First, the language is not clear, second, you mentioned earlier that there is just a "hacky" way to determine number of RMIDs that can be active but here "16" is made official in the documentation?
The lowest active RMID is 16. I could not get it using the hacky way.
I have verified testing on all the previous generation of AMD systems by creating the monitoring groups until it reports "Unavailable". In recent systems it is 32. We can drop the exact number to be generic.There is no clear documentation on that. Here is what the doc says.
A given implementation may have insufficient hardware to simultaneously track the bandwidth for all RMID values which the hardware supports. If an attempt is made to read a Bandwidth Count for an RMID that has been impacted by these hardware limitations, the “U” bit of the
QM_CTRwill be set when the counter is read. SubsequentQM_CTRreads for that RMID and Event may return a value with the "U" bit clear. Potential causes of the “U” bit being set include (but are not limited to)Quoted 8 lines
• RMID is not currently tracked by the hardware.
• RMID was not tracked by the hardware at some time since it was last read.
• RMID has not been read since it started being tracked by the hardware.All RMIDs which are currently in use by one or more processors in the QOS domain will be tracked. The hardware will always begin tracking a new RMID value when it gets written to the
PQR_ASSOCregister of any of the processors in the QOS domain and it is not already being tracked. When the hardware begins tracking an RMID that it was not previously tracking, it will clear theQM_CTRfor all events in the new RMID- Babu Moger
I think I am starting to understand what is meant with the "count the traffic in an unpredictable way". From what I understand the hardware uses the "U" bit to indicate that an RMID was not tracked for a while, but it only sets this bit on the first read. After that the "U" bit may be cleared if a counter can be assigned to an RMID afterwards.
If it was only user space that reads the data then it should be clear to the user when the hardware limitation is encountered and thus hardware behavior can be "predictable", but since the overflow handler runs once per second it may indeed be the overflow handler that encounters the "U" bit and that bit is not currently handled. This could leave user space with impression that events are always returning data but that data may indeed be wrong.In another thread [1] Tony confirmed that "U" bit is not returned by Intel systems so this issue only impacts AMD. As I understand the other scenarios in which AMD systems can return "U" (the first read after assigning an RMID and the first read after changing the memory config) are all scenarios that can be controlled by resctrl.
I do not see why unpredictable data should be addressed with documentation. Could this not be fixed instead? Essentially stating "AMD systems without ABMC count the traffic in an unpredictable way" seems like a poor user experience.
What if instead resctrl handles the "U" bit better? For example, when the overflow handler encounters the "U" bit the RMID can be permanently marked as "Unavailable"? Would that not be better than the counter behaving unpredictably with users never knowing if they can trust the event counters?
Quoted 3 lines
Quoted 1 line
Actually, I was looking at handling "Unavailable" in little bit better way. Right now, I see it reports "Unavailable" first then it goes into overflow and stays in overflow forever.
Could you please elaborate what you mean with "stays in overflow forever"?
This may not an issue. Once overflow(large number) happens, it will stay in that state until there is another change. But we are only concerned about the delta. Delta is fine.
Quoted 6 lines
Quoted 3 lines
Also setting the RMID Unavailable permanently is not a good option. We should have a way to reset it. At some later point the RMID can become active and report the correct numbers.
I assume that when an RMID becomes active cannot be the trigger to reset it since user space cannot then be aware that a counter was not available for a while.
Yes. That is correct.
Quoted 8 lines
Quoted 3 lines
I was thinking of introducing a new arch
state(in arch_mbm_state)to handle this case. Need to investigate more on this. What do you think?Some new state is surely needed to reflect that the RMID's data may be wrong. It is not clear to me how you envision the reset of the state. If it is driven from user space then I expect that resctrl needs to be taught something about this and it cannot just be buried in arch code.
Yes. We need to take a hard look at this.
Signature · 1 line
- Babu Moger
Babu Moger
reviewerPATCH v9 9/26 x86/resctrl: Introduce interface to display number of monitoring counters
In reply to Babu MogerThe mbm_cntr_assign mode provides an option to the user to assign a counter to an RMID, event pair and monitor the bandwidth as long as the counter is assigned. Number of assignments depend on number of monitoring counters available.
Provide the interface to display the number of monitoring counters supported. The interface file 'num_mbm_cntrs' is available when an architecture supports mbm_cntr_assign mode.
---
v9: Updated user document based on the comments.
Will add a new file available_mbm_cntrs later in the series.
v8: Commit message update and documentation update.
v7: Minor commit log text changes.
v6: No changes.
v5: Changed the display name from num_cntrs to num_mbm_cntrs.
Updated the commit message.
Moved the patch after mbm_mode is introduced.
v4: Changed the counter name to num_cntrs. And few text changes.
v3: Changed the field name to mbm_assign_cntrs.
v2: Changed the field name to mbm_assignable_counters from abmc_counter.
--- Documentation/arch/x86/resctrl.rst | 12 ++++++++++++ arch/x86/kernel/cpu/resctrl/monitor.c | 1 + arch/x86/kernel/cpu/resctrl/rdtgroup.c | 16 ++++++++++++++++ 3 files changed, 29 insertions(+)
Documentation/arch/x86/resctrl.rst +12 -0
@@ -290,6 +290,18 @@ with the following files: mbm_local_bytes may report 'Unavailable' if there is no counter associated with that event. +"num_mbm_cntrs": + The number of monitoring counters available for assignment when the + architecture supports mbm_cntr_assign mode. + + The resctrl file system supports tracking up to two memory bandwidth + events per monitoring group: mbm_total_bytes and/or mbm_local_bytes. + Up to two counters can be assigned per monitoring group, one for each + memory bandwidth event. More monitoring groups can be tracked by + assigning one counter per monitoring group. However, doing so limits + memory bandwidth tracking to a single memory bandwidth event per + monitoring group. + "max_threshold_occupancy": Read/write file provides the largest value (in bytes) at which a previously used LLC_occupancy
arch/x86/kernel/cpu/resctrl/monitor.c +1 -0
@@ -1236,6 +1236,7 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r) r->mon.mbm_cntr_assignable = true;cpuid_count (0x80000020 ,5 , &eax, &ebx, &ecx, &edx); r->mon.num_mbm_cntrs = (ebx &GENMASK (15 ,0 )) +1 ; +resctrl_file_fflags_init ("num_mbm_cntrs" ,RFTYPE_MON_INFO ); } }
arch/x86/kernel/cpu/resctrl/rdtgroup.c +16 -0
@@ -869,6 +869,16 @@ static int rdtgroup_mbm_assign_mode_show(struct kernfs_open_file *of,return 0 ; } +static int rdtgroup_num_mbm_cntrs_show (struct kernfs_open_file *of, +struct seq_file *s,void *v) +{ +struct rdt_resource *r = of->kn->parent->priv; + +seq_printf (s,"%d\n" , r->mon.num_mbm_cntrs); + +return 0 ; +} +#ifdef CONFIG_PROC_CPU_RESCTRL /*
@@ -1940,6 +1950,12 @@ static struct rftype res_common_files[] = { .seq_show = rdtgroup_cpus_show, .fflags = RFTYPE_BASE, }, + { + .name = "num_mbm_cntrs", + .mode = 0444, + .kf_ops = &rdtgroup_kf_single_ops, + .seq_show = rdtgroup_num_mbm_cntrs_show, + }, { .name = "cpus_list", .mode = 0644,
Signature · 1 line
2.34.1
Reinette Chatre
maintainerRe: [PATCH v9 09/26] x86/resctrl: Introduce interface to display number of monitoring counters
Hi Babu,
Quoted 9 lines · Babu Moger
The
mbm_cntr_assignmode provides an option to the user to assign a counter to an RMID, event pair and monitor the bandwidth as long as the counter is assigned. Number of assignments depend on number of monitoring counters available.Provide the interface to display the number of monitoring counters supported. The interface file '
num_mbm_cntrs' is available when an architecture supportsmbm_cntr_assignmode.
As mentioned in previous patch, do you think it may be possible to have a value for num_mbm_cntrs for non-ABMC AMD systems? If that is available and always exposed to user space (irrespective of mbm_cntr_assign mode) then it would be clear to user space on benefits/risks of running a "default" mode.
Reinette
Moger, Babu
reviewerRe: [PATCH v9 09/26] x86/resctrl: Introduce interface to display number of monitoring counters
Hi Reinette,
Quoted 13 lines · Reinette Chatre
Hi Babu,
Quoted 9 lines · Babu Moger
The
mbm_cntr_assignmode provides an option to the user to assign a counter to an RMID, event pair and monitor the bandwidth as long as the counter is assigned. Number of assignments depend on number of monitoring counters available.Provide the interface to display the number of monitoring counters supported. The interface file '
num_mbm_cntrs' is available when an architecture supportsmbm_cntr_assignmode.
Quoted 5 lines
As mentioned in previous patch, do you think it may be possible to have a value for
num_mbm_cntrsfor non-ABMC AMD systems? If that is available and always exposed to user space (irrespective ofmbm_cntr_assignmode) then it would be clear to user space on benefits/risks of running a "default" mode.
I am trying the work-around to get the number of max active RMIDs in default mode. The method is to loop through all of the recently assigned RMID's to see if any of their QM_CTR.U bits transition from 0->1.
I am not successful in getting it to work so far. I remember Peter was trying this before in soft-ABMC. Peter, Any success with that?
If it does not work then our best option is to document it.
Signature · 2 lines
Thanks Babu Moger
Re: [PATCH v9 09/26] x86/resctrl: Introduce interface to display number of monitoring counters
Hi Babu,
Quoted 22 lines · Babu
Hi Reinette,
Quoted 13 lines · Reinette Chatre
Hi Babu,
Quoted 9 lines · Babu Moger
The
mbm_cntr_assignmode provides an option to the user to assign a counter to an RMID, event pair and monitor the bandwidth as long as the counter is assigned. Number of assignments depend on number of monitoring counters available.Provide the interface to display the number of monitoring counters supported. The interface file '
num_mbm_cntrs' is available when an architecture supportsmbm_cntr_assignmode.Quoted 5 lines
As mentioned in previous patch, do you think it may be possible to have a value for
num_mbm_cntrsfor non-ABMC AMD systems? If that is available and always exposed to user space (irrespective ofmbm_cntr_assignmode) then it would be clear to user space on benefits/risks of running a "default" mode.
Quoted 6 lines
I am trying the work-around to get the number of max active RMIDs in default mode. The method is to loop through all of the recently assigned RMID's to see if any of their QM_CTR.U bits transition from 0->1.
I am not successful in getting it to work so far. I remember Peter was trying this before in soft-ABMC. Peter, Any success with that?
Sorry I missed this question before. By now maybe you've already debugged your own implementation...
Here's what I've been using:
-- >8 --
Subject: [PATCH] x86/resctrl: Detect MBM counters on pre-ABMC AMD
implementations
This procedure is based on information provided directly by AMD which cannot currently be corroborated by any public documentation.
In particular, it assumes that deallocation of MBM counters for RMIDs is driven directly by writing a new RMID value into PQR_ASSOC.
--- arch/x86/kernel/cpu/resctrl/internal.h | 1 + arch/x86/kernel/cpu/resctrl/monitor.c | 83 ++++++++++++++++++++++++++ 2 files changed, 84 insertions(+)
arch/x86/kernel/cpu/resctrl/internal.h +1 -0
@@ -705,6 +705,7 @@ int closids_supported(void);void closid_free (int closid);int alloc_rmid (u32 closid);void free_rmid (u32 closid,u32 rmid); +int amd_detect_mbm_counters (void );int __init rdt_get_mon_l3_config (struct rdt_resource *r); void __exit rdt_put_mon_l3_config(void);bool __init rdt_cpu_has (int flag);
arch/x86/kernel/cpu/resctrl/monitor.c +83 -0
89 lines not on this page · raw message
Babu Moger
reviewerPATCH v9 10/26 x86/resctrl: Introduce bitmap mbm_cntr_free_map to track assignable counters
In reply to Babu MogerHardware provides a set of counters when mbm_assign_mode is supported. These counters are assigned to the MBM monitoring events of a CTRL_MON or MON group that needs to be tracked. The kernel must manage and track the available counters.
Introduce mbm_cntr_free_map bitmap to track available counters and set of routines to allocate and free the counters.
dom_data_init() requires mbm_cntr_assign state to initialize mbm_cntr_free_map bitmap. Move dom_data_init() after mbm_cntr_assign detection.
---
v9: Commit message update and kernel doc update.
v8: Moved the init and exit functionality inside dom_data_init()
and dom_data_exit() respectively.
v7: Removed the static allocation and now allocating bitmap mbm_cntr_free_map
dynamically.
Passed the struct rdt_resource mbm_cntr_alloc and mbm_cntr_free. Removed the reference of ABMC and changed it mbm_cntr_assign. Few other text changes.
v6: Removed the variable mbm_cntrs_free_map_len. This is not required.
Removed the call mbm_cntrs_init() in arch code. This needs to be done at higher level.
Used DECLARE_BITMAP to initialize mbm_cntrs_free_map. Moved all the counter interfaces mbm_cntr_alloc() and mbm_cntr_free() in here as part of separating arch and fs bits.
v5:
Updated the comments and commit log.
Few renames
num_cntrs_free_map -> mbm_cntrs_free_map num_cntrs_init -> mbm_cntrs_init
Added initialization in rdt_get_tree because the default ABMC enablement happens during the init.
v4: Changed the name to num_cntrs where applicable.
Used bitmap apis.
Added more comments for the globals.
v3: Changed the bitmap name to assign_cntrs_free_map. Removed abmc
from the name.
v2: Changed the bitmap name to assignable_counter_free_map from
abmc_counter_free_map.
--- arch/x86/kernel/cpu/resctrl/core.c | 2 +- arch/x86/kernel/cpu/resctrl/internal.h | 4 ++- arch/x86/kernel/cpu/resctrl/monitor.c | 49 ++++++++++++++++++++++---- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 19 ++++++++++ include/linux/resctrl.h | 2 ++ 5 files changed, 67 insertions(+), 9 deletions(-)
arch/x86/kernel/cpu/resctrl/core.c +1 -1
@@ -1140,7 +1140,7 @@ static void __exit resctrl_exit(void)rdtgroup_exit ();if (r->mon_capable) -rdt_put_mon_l3_config (); +rdt_put_mon_l3_config (r); }__exitcall (resctrl_exit);
arch/x86/kernel/cpu/resctrl/internal.h +3 -1
@@ -633,7 +633,7 @@ void closid_free(int closid);int alloc_rmid (u32 closid);void free_rmid (u32 closid,u32 rmid);int __init rdt_get_mon_l3_config (struct rdt_resource *r); -void __exit rdt_put_mon_l3_config(void); +void __exit rdt_put_mon_l3_config(struct rdt_resource *r);bool __init rdt_cpu_has (int flag);void mon_event_count (void *info);int rdtgroup_mondata_show (struct seq_file *m,void *arg);
@@ -654,6 +654,8 @@ void __check_limbo(struct rdt_mon_domain *d, bool force_free);void rdt_domain_reconfigure_cdp (struct rdt_resource *r);void __init resctrl_file_fflags_init (const char *config,unsigned long fflags); +int mbm_cntr_alloc (struct rdt_resource *r); +void mbm_cntr_free (struct rdt_resource *r,u32 cntr_id);void rdt_staged_configs_clear (void );bool closid_allocated (unsigned int closid);int resctrl_find_cleanest_closid (void );
arch/x86/kernel/cpu/resctrl/monitor.c +42 -7
92 lines not on this page · raw message
arch/x86/kernel/cpu/resctrl/rdtgroup.c +19 -0
@@ -185,6 +185,25 @@ bool closid_allocated(unsigned int closid)return !test_bit (closid, &closid_free_map); } +int mbm_cntr_alloc (struct rdt_resource *r) +{ +int cntr_id; + + cntr_id =find_first_bit (r->mon.mbm_cntr_free_map, + r->mon.num_mbm_cntrs); +if (cntr_id >= r->mon.num_mbm_cntrs) +return -ENOSPC ; + +__clear_bit (cntr_id, r->mon.mbm_cntr_free_map); + +return cntr_id; +} + +void mbm_cntr_free (struct rdt_resource *r,u32 cntr_id) +{ +__set_bit (cntr_id, r->mon.mbm_cntr_free_map); +} +/** * rdtgroup_mode_by_closid - Return mode of resource group with closid * @closid: closid if the resource group
include/linux/resctrl.h +2 -0
@@ -187,12 +187,14 @@ enum resctrl_scope {* @num_rmid: Number of RMIDs available * @num_mbm_cntrs: Number of assignable monitoring counters * @mbm_cntr_assignable:Is system capable of supporting monitor assignment? +* @mbm_cntr_free_map: Bitmap of free MBM counters * @evt_list: List of monitoring events */ struct resctrl_mon {int num_rmid;int num_mbm_cntrs;bool mbm_cntr_assignable; +unsigned long *mbm_cntr_free_map;struct list_head evt_list; };
Signature · 1 line
2.34.1
Re: [PATCH v9 10/26] x86/resctrl: Introduce bitmap mbm_cntr_free_map to track assignable counters
Hi Babu,
Quoted 8 lines · Babu Moger
Hardware provides a set of counters when
mbm_assign_modeis supported. These counters are assigned to the MBM monitoring events of aCTRL_MONor MON group that needs to be tracked. The kernel must manage and track the available counters.Introduce
mbm_cntr_free_mapbitmap to track available counters and set of routines to allocate and free the counters.
Quoted 6 lines
dom_data_init()requiresmbm_cntr_assignstate to initializembm_cntr_free_mapbitmap. Movedom_data_init()aftermbm_cntr_assigndetection.Signed-off-by Babu Moger <[email protected]>---
Reinette
Babu Moger
reviewerPATCH v9 11/26 x86/resctrl: Introduce mbm_total_cfg and mbm_local_cfg in struct rdt_hw_mon_domain
In reply to Babu MogerIf the BMEC (Bandwidth Monitoring Event Configuration) feature is supported, the bandwidth events can be configured to track specific events. The event configuration is domain specific. ABMC (Assignable Bandwidth Monitoring Counters) feature needs event configuration information to assign a hardware counter to an RMID. Event configurations are not stored in resctrl but instead always read from or written to hardware directly when prompted by user space.
Read the event configuration from the hardware during the domain initialization. Save the configuration value in struct rdt_hw_mon_domain, so it can be used for counter assignment.
---
v9: Added Reviewed-by tag. No other changes.
v8: Renamed resctrl_mbm_evt_config_init() to arch_mbm_evt_config_init()
Minor commit message update.
v7: Fixed initializing INVALID_CONFIG_VALUE to mbm_local_cfg in case of error.
v6: Renamed resctrl_arch_mbm_evt_config -> resctrl_mbm_evt_config_init
Initialized value to INVALID_CONFIG_VALUE if it is not configurable. Minor commit message update.
v5: Exported mon_event_config_index_get.
Renamed arch_domain_mbm_evt_config to resctrl_arch_mbm_evt_config.
v4: Read the configuration information from the hardware to initialize.
Added few commit messages.
Fixed the tab spaces.
v3: Minor changes related to rebase in mbm_config_write_domain.
v2: No changes.
--- arch/x86/kernel/cpu/resctrl/core.c | 2 ++ arch/x86/kernel/cpu/resctrl/internal.h | 9 +++++++++ arch/x86/kernel/cpu/resctrl/monitor.c | 26 ++++++++++++++++++++++++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 4 +--- 4 files changed, 38 insertions(+), 3 deletions(-)
arch/x86/kernel/cpu/resctrl/core.c +2 -0
@@ -632,6 +632,8 @@ static void domain_add_cpu_mon(int cpu, struct rdt_resource *r)arch_mon_domain_online (r, d); +arch_mbm_evt_config_init (hw_dom); +if (arch_domain_mbm_alloc (r->mon.num_rmid, hw_dom)) {mon_domain_free (hw_dom);return ;
arch/x86/kernel/cpu/resctrl/internal.h +9 -0
@@ -56,6 +56,9 @@/* Max event bits supported */ #define MAX_EVT_CONFIG_BITS GENMASK(6, 0) +#define INVALID_CONFIG_VALUE U32_MAX +#define INVALID_CONFIG_INDEX UINT_MAX +/* Setting bit 0 in L3_QOS_EXT_CFG enables the ABMC feature. */ #define ABMC_ENABLE_BIT 0
@@ -401,6 +404,8 @@ struct rdt_hw_ctrl_domain {* @d_resctrl: Properties exposed to the resctrl file system * @arch_mbm_total: arch private state for MBM total bandwidth * @arch_mbm_local: arch private state for MBM local bandwidth +* @mbm_total_cfg: MBM total bandwidth configuration +* @mbm_local_cfg: MBM local bandwidth configuration * * Members of this structure are accessed via helpers that provide abstraction. */
@@ -408,6 +413,8 @@ struct rdt_hw_mon_domain {struct rdt_mon_domain d_resctrl;struct arch_mbm_state *arch_mbm_total;struct arch_mbm_state *arch_mbm_local; +u32 mbm_total_cfg; +u32 mbm_local_cfg; };static inline struct rdt_hw_ctrl_domain *resctrl_to_arch_ctrl_dom (struct rdt_ctrl_domain *r)
@@ -656,6 +663,8 @@ void __init resctrl_file_fflags_init(const char *config, unsigned long fflags);int mbm_cntr_alloc (struct rdt_resource *r);void mbm_cntr_free (struct rdt_resource *r,u32 cntr_id); +void arch_mbm_evt_config_init (struct rdt_hw_mon_domain *hw_dom); +unsigned int mon_event_config_index_get (u32 evtid);void rdt_staged_configs_clear (void );bool closid_allocated (unsigned int closid);int resctrl_find_cleanest_closid (void );
arch/x86/kernel/cpu/resctrl/monitor.c +26 -0
@@ -1282,6 +1282,32 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r)return 0 ; } +void arch_mbm_evt_config_init (struct rdt_hw_mon_domain *hw_dom) +{ +unsigned int index; +u64 msrval; + +/* +* Read the configuration registers QOS_EVT_CFG_n, where <n> is +* the BMEC event number (EvtID). +*/ +if (mbm_total_event.configurable) { + index =mon_event_config_index_get (QOS_L3_MBM_TOTAL_EVENT_ID ); +rdmsrl (MSR_IA32_EVT_CFG_BASE + index, msrval); + hw_dom->mbm_total_cfg = msrval &MAX_EVT_CONFIG_BITS ; + }else { + hw_dom->mbm_total_cfg =INVALID_CONFIG_VALUE ; + } + +if (mbm_local_event.configurable) { + index =mon_event_config_index_get (QOS_L3_MBM_LOCAL_EVENT_ID ); +rdmsrl (MSR_IA32_EVT_CFG_BASE + index, msrval); + hw_dom->mbm_local_cfg = msrval &MAX_EVT_CONFIG_BITS ; + }else { + hw_dom->mbm_local_cfg =INVALID_CONFIG_VALUE ; + } +} + void __exit rdt_put_mon_l3_config(struct rdt_resource *r) {dom_data_exit (r);
arch/x86/kernel/cpu/resctrl/rdtgroup.c +1 -3
@@ -1601,8 +1601,6 @@ struct mon_config_info {u32 mon_config; }; -#define INVALID_CONFIG_INDEX UINT_MAX -/** * mon_event_config_index_get - get the hardware index for the * configurable event
@@ -1612,7 +1610,7 @@ struct mon_config_info {* 1 for evtid == QOS_L3_MBM_LOCAL_EVENT_ID * INVALID_CONFIG_INDEX for invalid evtid */ -static inline unsigned int mon_event_config_index_get (u32 evtid) +unsigned int mon_event_config_index_get (u32 evtid) {switch (evtid) {case QOS_L3_MBM_TOTAL_EVENT_ID :
Signature · 1 line
2.34.1
Babu Moger
reviewerPATCH v9 12/26 x86/resctrl: Remove MSR reading of event configuration value
In reply to Babu MogerThe event configuration is domain specific and initialized during domain initialization. The values are stored in struct rdt_hw_mon_domain.
It is not required to read the configuration register every time user asks for it. Use the value stored in struct rdt_hw_mon_domain instead.
Introduce resctrl_arch_mon_event_config_get() and resctrl_arch_mon_event_config_set() to get/set architecture domain specific mbm_total_cfg/mbm_local_cfg values.
---
v9: Removed QOS_L3_OCCUP_EVENT_ID switch case in resctrl_arch_mon_event_config_set.
Fixed a unnecessary space.
v8: Renamed
resctrl_arch_event_config_get() to resctrl_arch_mon_event_config_get(). resctrl_arch_event_config_set() to resctrl_arch_mon_event_config_set().
v7: Removed check if (val == INVALID_CONFIG_VALUE) as resctrl_arch_event_config_get
already prints warning.
Kept the Event config value definitions as is.
v6: Fixed inconstancy with types. Made all the types to u32 for config
value.
Removed few rdt_last_cmd_puts as it is not necessary. Removed unused config value definitions.
Few more updates to commit message.
v5: Introduced resctrl_arch_event_config_get and
resctrl_arch_event_config_get() based on our discussion.
https://lore.kernel.org/lkml/[email protected]/
v4: New patch.
--- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 101 ++++++++++++++----------- include/linux/resctrl.h | 4 + 2 files changed, 60 insertions(+), 45 deletions(-)
arch/x86/kernel/cpu/resctrl/rdtgroup.c +56 -45
@@ -1597,10 +1597,55 @@ static int rdtgroup_size_show(struct kernfs_open_file *of, }struct mon_config_info { +struct rdt_mon_domain *d;u32 evtid;u32 mon_config; }; +u32 resctrl_arch_mon_event_config_get (struct rdt_mon_domain *d, +enum resctrl_event_id eventid) +{ +struct rdt_hw_mon_domain *hw_dom =resctrl_to_arch_mon_dom (d); + +switch (eventid) { +case QOS_L3_OCCUP_EVENT_ID : +break ; +case QOS_L3_MBM_TOTAL_EVENT_ID : +return hw_dom->mbm_total_cfg; +case QOS_L3_MBM_LOCAL_EVENT_ID : +return hw_dom->mbm_local_cfg; + } + +/* Never expect to get here */ +WARN_ON_ONCE (1 ); + +return INVALID_CONFIG_VALUE ; +} + +void resctrl_arch_mon_event_config_set (void *info) +{ +struct mon_config_info *mon_info = info; +struct rdt_hw_mon_domain *hw_dom; +unsigned int index; + + index =mon_event_config_index_get (mon_info->evtid); +if (index ==INVALID_CONFIG_INDEX ) +return ; + +wrmsr (MSR_IA32_EVT_CFG_BASE + index, mon_info->mon_config,0 ); + + hw_dom =resctrl_to_arch_mon_dom (mon_info->d); + +switch (mon_info->evtid) { +case QOS_L3_MBM_TOTAL_EVENT_ID : + hw_dom->mbm_total_cfg = mon_info->mon_config; +break ; +case QOS_L3_MBM_LOCAL_EVENT_ID : + hw_dom->mbm_local_cfg = mon_info->mon_config; +break ; + } +} +/** * mon_event_config_index_get - get the hardware index for the * configurable event
@@ -1623,33 +1668,11 @@ unsigned int mon_event_config_index_get(u32 evtid) } } -static void mon_event_config_read (void *info) -{ -struct mon_config_info *mon_info = info; -unsigned int index; -u64 msrval; - - index =mon_event_config_index_get (mon_info->evtid); -if (index ==INVALID_CONFIG_INDEX ) { -pr_warn_once ("Invalid event id %d\n" , mon_info->evtid); -return ; - } -rdmsrl (MSR_IA32_EVT_CFG_BASE + index, msrval); - -/* Report only the valid event configuration bits */ - mon_info->mon_config = msrval &MAX_EVT_CONFIG_BITS ; -} - -static void mondata_config_read (struct rdt_mon_domain *d,struct mon_config_info *mon_info) -{ -smp_call_function_any (&d->hdr.cpu_mask, mon_event_config_read, mon_info,1 ); -} -static int mbm_config_show (struct seq_file *s,struct rdt_resource *r,u32 evtid) { -struct mon_config_info mon_info;struct rdt_mon_domain *dom;bool sep = false; +u32 val;cpus_read_lock ();mutex_lock (&rdtgroup_mutex);
@@ -1658,11 +1681,8 @@ static int mbm_config_show(struct seq_file *s, struct rdt_resource *r, u32 evtidif (sep)seq_puts (s,";" ); -memset (&mon_info,0 ,sizeof (struct mon_config_info )); - mon_info.evtid = evtid; -mondata_config_read (dom, &mon_info); - -seq_printf (s,"%d=0x%02x" , dom->hdr.id, mon_info.mon_config); + val =resctrl_arch_mon_event_config_get (dom, evtid); +seq_printf (s,"%d=0x%02x" , dom->hdr.id, val); sep = true; }seq_puts (s,"\n" );
@@ -1693,33 +1713,23 @@ static int mbm_local_bytes_config_show(struct kernfs_open_file *of,return 0 ; } -static void mon_event_config_write (void *info) -{ -struct mon_config_info *mon_info = info; -unsigned int index; - - index =mon_event_config_index_get (mon_info->evtid); -if (index ==INVALID_CONFIG_INDEX ) { -pr_warn_once ("Invalid event id %d\n" , mon_info->evtid); -return ; - } -wrmsr (MSR_IA32_EVT_CFG_BASE + index, mon_info->mon_config,0 ); -}static void mbm_config_write_domain (struct rdt_resource *r,struct rdt_mon_domain *d,u32 evtid,u32 val) {struct mon_config_info mon_info = {0 }; +u32 config_val;/* -* Read the current config value first. If both are the same then +* Check the current config value first. If both are the same then * no need to write it again. */ - mon_info.evtid = evtid; -mondata_config_read (d, &mon_info); -if (mon_info.mon_config == val) + config_val =resctrl_arch_mon_event_config_get (d, evtid); +if (config_val ==INVALID_CONFIG_VALUE || config_val == val)return ; + mon_info.d = d; + mon_info.evtid = evtid; mon_info.mon_config = val;/*
@@ -1728,7 +1738,8 @@ static void mbm_config_write_domain(struct rdt_resource *r,* are scoped at the domain level. Writing any of these MSRs * on one CPU is observed by all the CPUs in the domain. */ -smp_call_function_any (&d->hdr.cpu_mask, mon_event_config_write, +smp_call_function_any (&d->hdr.cpu_mask, + resctrl_arch_mon_event_config_set, &mon_info,1 );/*
include/linux/resctrl.h +4 -0
@@ -354,6 +354,10 @@ void resctrl_arch_reset_rmid(struct rdt_resource *r, struct rdt_mon_domain *d,*/ void resctrl_arch_reset_rmid_all (struct rdt_resource *r,struct rdt_mon_domain *d); +void resctrl_arch_mon_event_config_set (void *info); +u32 resctrl_arch_mon_event_config_get (struct rdt_mon_domain *d, +enum resctrl_event_id eventid); +extern unsigned int resctrl_rmid_realloc_threshold;extern unsigned int resctrl_rmid_realloc_limit;
Signature · 1 line
2.34.1
Reinette Chatre
maintainerRe: [PATCH v9 12/26] x86/resctrl: Remove MSR reading of event configuration value
Hi Babu,
include/linux/resctrl.h void resctrl_arch_reset_rmid(struct rdt_resource *r, struct rdt_mon_domain *d, · line 357
Quoted 7 lines · Babu Moger
include/linux/resctrl.h +1
-0@@ -354,6 +354,10 @@ void resctrl_arch_reset_rmid(struct rdt_resource *r, struct rdt_mon_domain *d,*/ void resctrl_arch_reset_rmid_all (struct rdt_resource *r,struct rdt_mon_domain *d); +void resctrl_arch_mon_event_config_set (void *info);
An architecture that may want to use this would need to know how to interpret the info passed. For an API I thus expect the struct it points to to also be available in this header file.
include/linux/resctrl.h void resctrl_arch_reset_rmid(struct rdt_resource *r, struct rdt_mon_domain *d, · line 363
Quoted 6 lines
include/linux/resctrl.h +3
-0+u32 resctrl_arch_mon_event_config_get (struct rdt_mon_domain *d, +enum resctrl_event_id eventid); +extern unsigned int resctrl_rmid_realloc_threshold;extern unsigned int resctrl_rmid_realloc_limit;
Reinette
Moger, Babu
reviewerRe: [PATCH v9 12/26] x86/resctrl: Remove MSR reading of event configuration value
Hi Reinette,
Quoted 9 lines · Reinette Chatre
Hi Babu,
Quoted 6 lines · Babu Moger
include/linux/resctrl.h +0
-0@@ -354,6 +354,10 @@ void resctrl_arch_reset_rmid(struct rdt_resource *r, struct rdt_mon_domain *d,*/ void resctrl_arch_reset_rmid_all (struct rdt_resource *r,struct rdt_mon_domain *d);
Quoted 5 lines
include/linux/resctrl.h void resctrl_arch_reset_rmid(struct rdt_resource *r, struct rdt_mon_domain *d, · line 357
Quoted 1 line
include/linux/resctrl.h +1
-0+void resctrl_arch_mon_event_config_set (void *info);An architecture that may want to use this would need to know how to interpret the info passed. For an API I thus expect the struct it points to to also be available in this header file.
Sure, I will move structure mon_config_info to resctrl.h.
Quoted 11 lines
include/linux/resctrl.h void resctrl_arch_reset_rmid(struct rdt_resource *r, struct rdt_mon_domain *d, · line 363
Quoted 8 lines
include/linux/resctrl.h +3
-0+u32 resctrl_arch_mon_event_config_get (struct rdt_mon_domain *d, +enum resctrl_event_id eventid); +extern unsigned int resctrl_rmid_realloc_threshold;extern unsigned int resctrl_rmid_realloc_limit;Reinette
Signature · 2 lines
Thanks Babu Moger
Babu Moger
reviewerPATCH v9 13/26 x86/resctrl: Introduce mbm_cntr_map to track assignable counters at domain
In reply to Babu MogerThe MBM counters are allocated globally and assigned to an RMID, event pair in a resctrl group. It is tracked by mbm_cntr_free_map. Counters are assigned to the domain based on the user input. It needs to be tracked at domain level also.
Add the mbm_cntr_map bitmap in struct rdt_mon_domain to keep track of assignment at domain level. The global counter at mbm_cntr_free_map can be released when assignment at all the domains are cleared.
---
v9: Added Reviewed-by tag. No other changes.
v8: Minor commit message changes.
v7: Added check mbm_cntr_assignable for allocating bitmap mbm_cntr_map
v6: New patch to add domain level assignment.
--- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 10 ++++++++++ include/linux/resctrl.h | 2 ++ 2 files changed, 12 insertions(+)
arch/x86/kernel/cpu/resctrl/rdtgroup.c +10 -0
@@ -4091,6 +4091,7 @@ static void __init rdtgroup_setup_default(void)static void domain_destroy_mon_state (struct rdt_mon_domain *d) { +bitmap_free (d->mbm_cntr_map);bitmap_free (d->rmid_busy_llc);kfree (d->mbm_total);kfree (d->mbm_local);
@@ -4164,6 +4165,15 @@ static int domain_setup_mon_state(struct rdt_resource *r, struct rdt_mon_domainreturn -ENOMEM ; } } +if (is_mbm_enabled () && r->mon.mbm_cntr_assignable) { + d->mbm_cntr_map =bitmap_zalloc (r->mon.num_mbm_cntrs,GFP_KERNEL ); +if (!d->mbm_cntr_map) { +bitmap_free (d->rmid_busy_llc); +kfree (d->mbm_total); +kfree (d->mbm_local); +return -ENOMEM ; + } + }return 0 ; }
include/linux/resctrl.h +2 -0
@@ -105,6 +105,7 @@ struct rdt_ctrl_domain {* @cqm_limbo: worker to periodically read CQM h/w counters * @mbm_work_cpu: worker CPU for MBM h/w counters * @cqm_work_cpu: worker CPU for CQM h/w counters +* @mbm_cntr_map: bitmap to track domain counter assignment */ struct rdt_mon_domain {struct rdt_domain_hdr hdr;
@@ -116,6 +117,7 @@ struct rdt_mon_domain {struct delayed_work cqm_limbo;int mbm_work_cpu;int cqm_work_cpu; +unsigned long *mbm_cntr_map; };/**
Signature · 1 line
2.34.1
Babu Moger
reviewerPATCH v9 14/26 x86/resctrl: Introduce interface to display number of free counters
In reply to Babu MogerProvide the interface to display the number of free monitoring counters available for assignment in each doamin when mbm_cntr_assign is supported.
---
v9: New patch.
--- Documentation/arch/x86/resctrl.rst | 4 ++++ arch/x86/kernel/cpu/resctrl/monitor.c | 1 + arch/x86/kernel/cpu/resctrl/rdtgroup.c | 33 ++++++++++++++++++++++++++ 3 files changed, 38 insertions(+)
Documentation/arch/x86/resctrl.rst +4 -0
@@ -302,6 +302,10 @@ with the following files: memory bandwidth tracking to a single memory bandwidth event per monitoring group. +"available_mbm_cntrs": + The number of free monitoring counters available assignment in each domain + when the architecture supports mbm_cntr_assign mode. + "max_threshold_occupancy": Read/write file provides the largest value (in bytes) at which a previously used LLC_occupancy
arch/x86/kernel/cpu/resctrl/monitor.c +1 -0
@@ -1268,6 +1268,7 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r)cpuid_count (0x80000020 ,5 , &eax, &ebx, &ecx, &edx); r->mon.num_mbm_cntrs = (ebx &GENMASK (15 ,0 )) +1 ;resctrl_file_fflags_init ("num_mbm_cntrs" ,RFTYPE_MON_INFO ); +resctrl_file_fflags_init ("available_mbm_cntrs" ,RFTYPE_MON_INFO ); } }
arch/x86/kernel/cpu/resctrl/rdtgroup.c +33 -0
@@ -898,6 +898,33 @@ static int rdtgroup_num_mbm_cntrs_show(struct kernfs_open_file *of,return 0 ; } +static int rdtgroup_available_mbm_cntrs_show (struct kernfs_open_file *of, +struct seq_file *s,void *v) +{ +struct rdt_resource *r = of->kn->parent->priv; +struct rdt_mon_domain *dom; +bool sep = false; +u32 val; + +cpus_read_lock (); +mutex_lock (&rdtgroup_mutex); + +list_for_each_entry (dom, &r->mon_domains, hdr.list) { +if (sep) +seq_puts (s,";" ); + + val = r->mon.num_mbm_cntrs -hweight64 (*dom->mbm_cntr_map); +seq_printf (s,"%d=%d" , dom->hdr.id, val); + sep = true; + } +seq_puts (s,"\n" ); + +mutex_unlock (&rdtgroup_mutex); +cpus_read_unlock (); + +return 0 ; +} +#ifdef CONFIG_PROC_CPU_RESCTRL /*
@@ -1984,6 +2011,12 @@ static struct rftype res_common_files[] = { .kf_ops = &rdtgroup_kf_single_ops, .seq_show = rdtgroup_num_mbm_cntrs_show, }, + { + .name = "available_mbm_cntrs", + .mode = 0444, + .kf_ops = &rdtgroup_kf_single_ops, + .seq_show = rdtgroup_available_mbm_cntrs_show, + }, { .name = "cpus_list", .mode = 0644,
Signature · 1 line
2.34.1
Luck, Tony
maintainerRE: [PATCH v9 14/26] x86/resctrl: Introduce interface to display number of free counters
Quoted 2 lines
Provide the interface to display the number of free monitoring counters available for assignment in each doamin when
mbm_cntr_assignis supported.
s/doamin/domain/
-Tony
Moger, Babu
reviewerRe: RE: [PATCH v9 14/26] x86/resctrl: Introduce interface to display number of free counters
Quoted 5 lines · Tony
Quoted 2 lines
Provide the interface to display the number of free monitoring counters available for assignment in each doamin when
mbm_cntr_assignis supported.s/doamin/domain/
Sure. Thanks
Signature · 2 lines
Thanks Babu Moger
Re: [PATCH v9 14/26] x86/resctrl: Introduce interface to display number of free counters
In reply to Babu MogerHi Babu,
Quoted 18 lines · Babu Moger
Provide the interface to display the number of free monitoring counters available for assignment in each doamin when
mbm_cntr_assignis supported.Signed-off-by Babu Moger <[email protected]>---
v9: New patch.--- Documentation/arch/x86/resctrl.rst | 4 ++++ arch/x86/kernel/cpu/resctrl/monitor.c | 1 + arch/x86/kernel/cpu/resctrl/rdtgroup.c | 33 ++++++++++++++++++++++++++ 3 files changed, 38 insertions(+)Documentation/arch/x86/resctrl.rst +0
-0
Documentation/arch/x86/resctrl.rst with the following files: · line 307
Quoted 6 lines
Documentation/arch/x86/resctrl.rst +3
-0@@ -302,6 +302,10 @@ with the following files: memory bandwidth tracking to a single memory bandwidth event per monitoring group. +"available_mbm_cntrs": + The number of free monitoring counters available assignment in each domain + when the architecture supports mbm_cntr_assign mode.
It seems you need to clarify that counters are only available to a domain when they're available in all domains:
resctrl# for i in seq 100; do
Quoted 2 lines
Documentation/arch/x86/resctrl.rst +0
-0mkdir mon_groups/m${i}done
resctrl# cat info/L3_MON/available_mbm_cntrs 0=0;1=0;2=0;3=0;4=0;5=0;6=0;7=0;8=0;9=0;10=0;11=0;12=0;16=0;17=0;18=0;19=0;20=0;21=0;22=0;23=0;24=0;25=0;26=0;27=0;28=0
resctrl# cd info/L3_MON/
L3_MON# echo '/m1/0=_' > mbm_assign_control
L3_MON# cat available_mbm_cntrs 0=2;1=0;2=0;3=0;4=0;5=0;6=0;7=0;8=0;9=0;10=0;11=0;12=0;16=0;17=0;18=0;19=0;20=0;21=0;22=0;23=0;24=0;25=0;26=0;27=0;28=0 L3_MON# echo '/m16/0+t' > mbm_assign_control
-bash: echo: write error: Invalid argument
L3_MON# cat ../last_cmd_status
Out of MBM assignable counters
Assign operation '+t' failed on the group /m16/
L3_MON# rmdir ../../mon_groups/m1
L3_MON# cat available_mbm_cntrs 0=2;1=2;2=2;3=2;4=2;5=2;6=2;7=2;8=2;9=2;10=2;11=2;12=2;16=2;17=2;18=2;19=2;20=2;21=2;22=2;23=2;24=2;25=2;26=2;27=2;28=2 L3_MON# echo '/m16/0+t' > mbm_assign_control
L3_MON#
-Peter
Moger, Babu
reviewerRe: [PATCH v9 14/26] x86/resctrl: Introduce interface to display number of free counters
Hi Peter,
Quoted 24 lines · Peter Newman
Hi Babu,
Quoted 21 lines · Babu Moger
Provide the interface to display the number of free monitoring counters available for assignment in each doamin when
mbm_cntr_assignis supported.Signed-off-by Babu Moger <[email protected]>---
v9: New patch.--- Documentation/arch/x86/resctrl.rst | 4 ++++ arch/x86/kernel/cpu/resctrl/monitor.c | 1 + arch/x86/kernel/cpu/resctrl/rdtgroup.c | 33 ++++++++++++++++++++++++++ 3 files changed, 38 insertions(+)Documentation/arch/x86/resctrl.rst +0
-0@@ -302,6 +302,10 @@ with the following files: memory bandwidth tracking to a single memory bandwidth event per monitoring group.
Quoted 6 lines
Documentation/arch/x86/resctrl.rst with the following files: · line 307
Quoted 3 lines
Documentation/arch/x86/resctrl.rst +3
-0+"available_mbm_cntrs": + The number of free monitoring counters available assignment in each domain + when the architecture supports mbm_cntr_assign mode.It seems you need to clarify that counters are only available to a domain when they're available in all domains:
Yes. Makes sense.
Quoted 17 lines
resctrl# for i in
seq 100; doQuoted 2 lines
Documentation/arch/x86/resctrl.rst +0
-0mkdir mon_groups/m${i}done
resctrl# cat info/L3_MON/available_mbm_cntrs 0=0;1=0;2=0;3=0;4=0;5=0;6=0;7=0;8=0;9=0;10=0;11=0;12=0;16=0;17=0;18=0;19=0;20=0;21=0;22=0;23=0;24=0;25=0;26=0;27=0;28=0
resctrl# cd info/L3_MON/
L3_MON# echo '/m1/0=_' >mbm_assign_control
L3_MON# catavailable_mbm_cntrs0=2;1=0;2=0;3=0;4=0;5=0;6=0;7=0;8=0;9=0;10=0;11=0;12=0;16=0;17=0;18=0;19=0;20=0;21=0;22=0;23=0;24=0;25=0;26=0;27=0;28=0 L3_MON# echo '/m16/0+t' >mbm_assign_control
-bash: echo: write error: Invalid argument
L3_MON# cat ../last_cmd_status
Out of MBM assignable counters
Assign operation '+t' failed on the group /m16/
Quoted 6 lines
L3_MON# rmdir ../../mon_groups/m1
L3_MON# catavailable_mbm_cntrs0=2;1=2;2=2;3=2;4=2;5=2;6=2;7=2;8=2;9=2;10=2;11=2;12=2;16=2;17=2;18=2;19=2;20=2;21=2;22=2;23=2;24=2;25=2;26=2;27=2;28=2 L3_MON# echo '/m16/0+t' >mbm_assign_control
L3_MON#
Test case looks good to me. Thanks for trying out.
Signature · 2 lines
Thanks Babu Moger
Reinette Chatre
maintainerRe: [PATCH v9 14/26] x86/resctrl: Introduce interface to display number of free counters
In reply to Babu MogerHi Babu,
Quoted 17 lines · Babu Moger
Provide the interface to display the number of free monitoring counters available for assignment in each doamin when
mbm_cntr_assignis supported.Signed-off-by Babu Moger <[email protected]>---
v9: New patch.--- Documentation/arch/x86/resctrl.rst | 4 ++++ arch/x86/kernel/cpu/resctrl/monitor.c | 1 + arch/x86/kernel/cpu/resctrl/rdtgroup.c | 33 ++++++++++++++++++++++++++ 3 files changed, 38 insertions(+)Documentation/arch/x86/resctrl.rst +0
-0
Documentation/arch/x86/resctrl.rst with the following files: · line 306
Quoted 5 lines
Documentation/arch/x86/resctrl.rst +2
-0@@ -302,6 +302,10 @@ with the following files: memory bandwidth tracking to a single memory bandwidth event per monitoring group. +"available_mbm_cntrs": + The number of free monitoring counters available assignment in each domain
"The number of free monitoring counters available assignment" -> "The number of monitoring counters available for assignment"?
(not taking into account how text may change after addressing Peter's feedback)
Quoted 31 lines
Documentation/arch/x86/resctrl.rst +2
-0+ when the architecture supports mbm_cntr_assign mode. + "max_threshold_occupancy": Read/write file provides the largest value (in bytes) at which a previously used LLC_occupancyarch/x86/kernel/cpu/resctrl/monitor.c +1
-0@@ -1268,6 +1268,7 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r)cpuid_count (0x80000020 ,5 , &eax, &ebx, &ecx, &edx); r->mon.num_mbm_cntrs = (ebx &GENMASK (15 ,0 )) +1 ;resctrl_file_fflags_init ("num_mbm_cntrs" ,RFTYPE_MON_INFO ); +resctrl_file_fflags_init ("available_mbm_cntrs" ,RFTYPE_MON_INFO ); } }arch/x86/kernel/cpu/resctrl/rdtgroup.c +6
-0@@ -898,6 +898,33 @@ static int rdtgroup_num_mbm_cntrs_show(struct kernfs_open_file *of,return 0 ; } +static int rdtgroup_available_mbm_cntrs_show (struct kernfs_open_file *of, +struct seq_file *s,void *v) +{ +struct rdt_resource *r = of->kn->parent->priv; +struct rdt_mon_domain *dom; +bool sep = false;
arch/x86/kernel/cpu/resctrl/rdtgroup.c static int rdtgroup_num_mbm_cntrs_show(struct kernfs_open_file *of, · line 916
Quoted 10 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +10
-0+u32 val; + +cpus_read_lock (); +mutex_lock (&rdtgroup_mutex); + +list_for_each_entry (dom, &r->mon_domains, hdr.list) { +if (sep) +seq_puts (s,";" ); + + val = r->mon.num_mbm_cntrs -hweight64 (*dom->mbm_cntr_map);
This should probably be bitmap_weight() to address warnings like below that are encountered by build testing with various configs (32bit in this case). 0day does not seem to automatically pick up patches just based on submission but it sure will when these are merged to tip so this needs a clean slate.
Quoted 1 line
Quoted 1 line
arch/x86/kernel/cpu/resctrl/rdtgroup.c:916:32: warning: shift count >= width of type [-Wshift-count-overflow]
916 | val = r->mon.num_mbm_cntrs - hweight64(*dom->mbm_cntr_map);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/asm-generic/bitops/const_hweight.h:29:49: note: expanded from macro 'hweight64'
29 | #define hweight64(w) (__builtin_constant_p(w) ? __const_hweight64(w) : __arch_hweight64(w))
| ^~~~~~~~~~~~~~~~~~~~
include/asm-generic/bitops/const_hweight.h:21:76: note: expanded from macro '__const_hweight64'
21 | #define __const_hweight64(w) (__const_hweight32(w) + __const_hweight32((w) >> 32))
| ^ ~~
include/asm-generic/bitops/const_hweight.h:20:49: note: expanded from macro '__const_hweight32'
20 | #define __const_hweight32(w) (__const_hweight16(w) + __const_hweight16((w) >> 16))
| ^
include/asm-generic/bitops/const_hweight.h:19:48: note: expanded from macro '__const_hweight16'
19 | #define __const_hweight16(w) (__const_hweight8(w) + __const_hweight8((w) >> 8 ))
| ^
include/asm-generic/bitops/const_hweight.h:10:9: note: expanded from macro '__const_hweight8'
10 | ((!!((w) & (1ULL << 0))) + \
| ^Reinette
Moger, Babu
reviewerRe: [PATCH v9 14/26] x86/resctrl: Introduce interface to display number of free counters
Hi Reinette,
Quoted 23 lines · Reinette Chatre
Hi Babu,
Quoted 20 lines · Babu Moger
Provide the interface to display the number of free monitoring counters available for assignment in each doamin when
mbm_cntr_assignis supported.Signed-off-by Babu Moger <[email protected]>---
v9: New patch.--- Documentation/arch/x86/resctrl.rst | 4 ++++ arch/x86/kernel/cpu/resctrl/monitor.c | 1 + arch/x86/kernel/cpu/resctrl/rdtgroup.c | 33 ++++++++++++++++++++++++++ 3 files changed, 38 insertions(+)Documentation/arch/x86/resctrl.rst +0
-0@@ -302,6 +302,10 @@ with the following files: memory bandwidth tracking to a single memory bandwidth event per monitoring group.
Quoted 7 lines
Documentation/arch/x86/resctrl.rst with the following files: · line 306
Quoted 2 lines
Documentation/arch/x86/resctrl.rst +2
-0+"available_mbm_cntrs": + The number of free monitoring counters available assignment in each domain"The number of free monitoring counters available assignment" -> "The number of monitoring counters available for assignment"?
(not taking into account how text may change after addressing Peter's feedback)
How about this?
"The number of monitoring counters available for assignment in each domain when the architecture supports mbm_cntr_assign mode. There are a total of "num_mbm_cntrs" counters are available for assignment. Counters can be assigned or unassigned individually in each domain. A counter is available for new assignment if it is unassigned in all domains."
Quoted 39 lines
Quoted 39 lines
Documentation/arch/x86/resctrl.rst +2
-0+ when the architecture supports mbm_cntr_assign mode. + "max_threshold_occupancy": Read/write file provides the largest value (in bytes) at which a previously used LLC_occupancyarch/x86/kernel/cpu/resctrl/monitor.c +1
-0@@ -1268,6 +1268,7 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r)cpuid_count (0x80000020 ,5 , &eax, &ebx, &ecx, &edx); r->mon.num_mbm_cntrs = (ebx &GENMASK (15 ,0 )) +1 ;resctrl_file_fflags_init ("num_mbm_cntrs" ,RFTYPE_MON_INFO ); +resctrl_file_fflags_init ("available_mbm_cntrs" ,RFTYPE_MON_INFO ); } }arch/x86/kernel/cpu/resctrl/rdtgroup.c +13
-0@@ -898,6 +898,33 @@ static int rdtgroup_num_mbm_cntrs_show(struct kernfs_open_file *of,return 0 ; } +static int rdtgroup_available_mbm_cntrs_show (struct kernfs_open_file *of, +struct seq_file *s,void *v) +{ +struct rdt_resource *r = of->kn->parent->priv; +struct rdt_mon_domain *dom; +bool sep = false; +u32 val; + +cpus_read_lock (); +mutex_lock (&rdtgroup_mutex); + +list_for_each_entry (dom, &r->mon_domains, hdr.list) { +if (sep)
Quoted 8 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c static int rdtgroup_num_mbm_cntrs_show(struct kernfs_open_file *of, · line 916
Quoted 3 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +3
-0+seq_puts (s,";" ); + + val = r->mon.num_mbm_cntrs -hweight64 (*dom->mbm_cntr_map);This should probably be
bitmap_weight()to address warnings like below that are encountered by build testing with various configs (32bit in this case). 0day does not seem to automatically pick up patches just based on submission but it sure will when these are merged to tip so this needs a clean slate.
Sure.
Quoted 25 lines
Quoted 2 lines
Quoted 2 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c:916:32: warning: shift count >= width of type [-Wshift-count-overflow]916 | val = r->mon.num_mbm_cntrs - hweight64(*dom->mbm_cntr_map); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/asm-generic/bitops/const_hweight.h:29:49: note: expanded from macro 'hweight64' 29 | #define hweight64(w) (__builtin_constant_p(w) ? __const_hweight64(w) : __arch_hweight64(w)) | ^~~~~~~~~~~~~~~~~~~~ include/asm-generic/bitops/const_hweight.h:21:76: note: expanded from macro '__const_hweight64' 21 | #define __const_hweight64(w) (__const_hweight32(w) + __const_hweight32((w) >> 32)) | ^ ~~ include/asm-generic/bitops/const_hweight.h:20:49: note: expanded from macro '__const_hweight32' 20 | #define __const_hweight32(w) (__const_hweight16(w) + __const_hweight16((w) >> 16)) | ^ include/asm-generic/bitops/const_hweight.h:19:48: note: expanded from macro '__const_hweight16' 19 | #define __const_hweight16(w) (__const_hweight8(w) + __const_hweight8((w) >> 8 )) | ^ include/asm-generic/bitops/const_hweight.h:10:9: note: expanded from macro '__const_hweight8' 10 | ((!!((w) & (1ULL << 0))) + \ | ^Reinette
Signature · 2 lines
Thanks Babu Moger
Reinette Chatre
maintainerRe: [PATCH v9 14/26] x86/resctrl: Introduce interface to display number of free counters
Hi Babu,
Quoted 34 lines · Babu
Hi Reinette,
Quoted 23 lines · Reinette Chatre
Hi Babu,
Quoted 20 lines · Babu Moger
Provide the interface to display the number of free monitoring counters available for assignment in each doamin when
mbm_cntr_assignis supported.Signed-off-by Babu Moger <[email protected]>---
v9: New patch.--- Documentation/arch/x86/resctrl.rst | 4 ++++ arch/x86/kernel/cpu/resctrl/monitor.c | 1 + arch/x86/kernel/cpu/resctrl/rdtgroup.c | 33 ++++++++++++++++++++++++++ 3 files changed, 38 insertions(+)Documentation/arch/x86/resctrl.rst +0
-0@@ -302,6 +302,10 @@ with the following files: memory bandwidth tracking to a single memory bandwidth event per monitoring group.Quoted 7 lines
Documentation/arch/x86/resctrl.rst with the following files: · line 306
Quoted 2 lines
Documentation/arch/x86/resctrl.rst +2
-0+"available_mbm_cntrs": + The number of free monitoring counters available assignment in each domain"The number of free monitoring counters available assignment" -> "The number of monitoring counters available for assignment"?
(not taking into account how text may change after addressing Peter's feedback)
Quoted 7 lines
How about this?
"The number of monitoring counters available for assignment in each domain when the architecture supports
mbm_cntr_assignmode. There are a total of "num_mbm_cntrs" counters are available for assignment. Counters can be assigned or unassigned individually in each domain. A counter is available for new assignment if it is unassigned in all domains."
Please consider the context of this paragraph. It follows right after the description of "num_mbm_cntrs" that states "Up to two counters can be assigned per monitoring group". I think it is confusing to follow that with a paragraph that states "Counters can be assigned or unassigned individually in each domain." I wonder if it may be helpful to use a different term ... for example a counter is *assigned* to an event of a monitoring group but this assignment may be to specified (not yet supported) or all (this work) domains while it is only *programmed*/*activated* to specified domains. Of course, all of this documentation needs to remain coherent if future work decides to indeed support per-domain assignment.
Reinette
Re: [PATCH v9 14/26] x86/resctrl: Introduce interface to display number of free counters
Hi Reinette,
Quoted 45 lines · Reinette Chatre
Hi Babu,
Quoted 34 lines · Babu
Hi Reinette,
Quoted 23 lines · Reinette Chatre
Hi Babu,
Quoted 20 lines · Babu Moger
Provide the interface to display the number of free monitoring counters available for assignment in each doamin when
mbm_cntr_assignis supported.Signed-off-by Babu Moger <[email protected]>---
v9: New patch.--- Documentation/arch/x86/resctrl.rst | 4 ++++ arch/x86/kernel/cpu/resctrl/monitor.c | 1 + arch/x86/kernel/cpu/resctrl/rdtgroup.c | 33 ++++++++++++++++++++++++++ 3 files changed, 38 insertions(+)Documentation/arch/x86/resctrl.rst +0
-0@@ -302,6 +302,10 @@ with the following files: memory bandwidth tracking to a single memory bandwidth event per monitoring group.Quoted 7 lines
Documentation/arch/x86/resctrl.rst with the following files: · line 306
Quoted 2 lines
Documentation/arch/x86/resctrl.rst +2
-0+"available_mbm_cntrs": + The number of free monitoring counters available assignment in each domain"The number of free monitoring counters available assignment" -> "The number of monitoring counters available for assignment"?
(not taking into account how text may change after addressing Peter's feedback)
Quoted 7 lines
How about this?
"The number of monitoring counters available for assignment in each domain when the architecture supports
mbm_cntr_assignmode. There are a total of "num_mbm_cntrs" counters are available for assignment. Counters can be assigned or unassigned individually in each domain. A counter is available for new assignment if it is unassigned in all domains."
Quoted 9 lines
Please consider the context of this paragraph. It follows right after the description of "
num_mbm_cntrs" that states "Up to two counters can be assigned per monitoring group". I think it is confusing to follow that with a paragraph that states "Counters can be assigned or unassigned individually in each domain." I wonder if it may be helpful to use a different term ... for example a counter is *assigned* to an event of a monitoring group but this assignment may be to specified (not yet supported) or all (this work) domains while it is only *programmed*/*activated* to specified domains. Of course, all of this documentation needs to remain coherent if future work decides to indeed support per-domain assignment.
Little bit lost here. Please help me.
"available_mbm_cntrs":
"The number of monitoring counters available for assignment in each domain when the architecture supports "mbm_cntr_assign" mode. There are a total of "num_mbm_cntrs" counters are available for assignment. A counter is assigned to an event within a monitoring group and is available for activation across all domains. Users have the flexibility to activate it selectively within specific domains."
Thanks
- Babu Moger
Reinette Chatre
maintainerRe: [PATCH v9 14/26] x86/resctrl: Introduce interface to display number of free counters
Hi Babu,
Quoted 57 lines · Babu
Hi Reinette,
Quoted 44 lines · Reinette Chatre
Hi Babu,
Quoted 33 lines · Babu
Hi Reinette,
Quoted 28 lines · Reinette Chatre
Hi Babu,
Quoted 17 lines · Babu Moger
Provide the interface to display the number of free monitoring counters available for assignment in each doamin when
mbm_cntr_assignis supported.Signed-off-by Babu Moger <[email protected]>---
v9: New patch.
---
Documentation/arch/x86/resctrl.rst | 4 ++++ arch/x86/kernel/cpu/resctrl/monitor.c | 1 +arch/x86/kernel/cpu/resctrl/rdtgroup.c| 33 ++++++++++++++++++++++++++3 files changed, 38 insertions(+)Documentation/arch/x86/resctrl.rst +0
-0@@ -302,6 +302,10 @@ with the following files:Quoted 4 lines
memory bandwidth tracking to a single memory bandwidth event per monitoring group.
+"available_mbm_cntrs":
+ The number of free monitoring counters available assignment in each domain"The number of free monitoring counters available assignment" -> "The number of monitoring counters available for assignment"?
Quoted 1 line
(not taking into account how text may change after addressing Peter's feedback)
Quoted 7 lines
How about this?
"The number of monitoring counters available for assignment in each domain when the architecture supports
mbm_cntr_assignmode. There are a total of "num_mbm_cntrs" counters are available for assignment. Counters can be assigned or unassigned individually in each domain. A counter is available for new assignment if it is unassigned in all domains."Quoted 9 lines
Please consider the context of this paragraph. It follows right after the description of "
num_mbm_cntrs" that states "Up to two counters can be assigned per monitoring group". I think it is confusing to follow that with a paragraph that states "Counters can be assigned or unassigned individually in each domain." I wonder if it may be helpful to use a different term ... for example a counter is *assigned* to an event of a monitoring group but this assignment may be to specified (not yet supported) or all (this work) domains while it is only *programmed*/*activated* to specified domains. Of course, all of this documentation needs to remain coherent if future work decides to indeed support per-domain assignment.
Quoted 1 line
Little bit lost here. Please help me.
I think this highlights the uncertainty this interface brings. How do you expect users to use this interface? At this time I think this interface can create a lot of confusion. For example, consider a hypothetical system with three domains and four counters that has the following state per mbm_assign_control:
//0=tl;1=_;2=l #default group uses counters 0 and 1 to monitor total and local MBM /m1/0=_;1=t;2=t #monitor group m1 uses counter 2, just for total MBM /m2/0=l;1=_;2=l #monitor group m2 uses counter 3, just for local MBM /m3/0=_;1=_;2=_
Since, in this system there are only four counters available, and they have all been assigned, then there are no new counters available for assignment.
If I understand correctly, available_mbm_cntrs will read:
0=1;1=3;2=1
How is a user to interpret the above numbers? It does not reflect that no counter can be assigned to m3, instead it reflects which of the already assigned counters still need to be activated on domains. If, for example, a user is expected to use this file to know how many counters can still be assigned, should it not reflect the actual available counters. In the above scenario it will then be:
0=0;1=0;2=0
Of course, when doing the above the user may get impression that a counter that has already been assigned, just not activated, is no longer available for use.
Quoted 4 lines
"
available_mbm_cntrs":
"The number of monitoring counters available for assignment in each domain when the architecture supports "mbm_cntr_assign" mode. There are a total of "num_mbm_cntrs" counters are available for assignment. A counter is assigned to an event within a monitoring group and is available for activation across all domains. Users have the flexibility to activate it selectively within specific domains."
Once we understand how users are to use this file the documentation should be easier to create.
Reinette
Re: [PATCH v9 14/26] x86/resctrl: Introduce interface to display number of free counters
Hi Reinette,
Quoted 72 lines · Reinette Chatre
Hi Babu,
Quoted 57 lines · Babu
Hi Reinette,
Quoted 44 lines · Reinette Chatre
Hi Babu,
Quoted 33 lines · Babu
Hi Reinette,
Quoted 28 lines · Reinette Chatre
Hi Babu,
Quoted 17 lines · Babu Moger
Provide the interface to display the number of free monitoring counters available for assignment in each doamin when
mbm_cntr_assignis supported.Signed-off-by Babu Moger <[email protected]>---
v9: New patch.--- Documentation/arch/x86/resctrl.rst | 4 ++++ arch/x86/kernel/cpu/resctrl/monitor.c | 1 + arch/x86/kernel/cpu/resctrl/rdtgroup.c | 33 ++++++++++++++++++++++++++ 3 files changed, 38 insertions(+)Documentation/arch/x86/resctrl.rst +0
-0Documentation/arch/x86/resctrl.rst with the following files: · line 305
Quoted 4 lines
Documentation/arch/x86/resctrl.rst +1
-0@@ -302,6 +302,10 @@ with the following files: memory bandwidth tracking to a single memory bandwidth event per monitoring group. +"available_mbm_cntrs": + The number of free monitoring counters available assignment in each domain"The number of free monitoring counters available assignment" -> "The number of monitoring counters available for assignment"?
Quoted 1 line
(not taking into account how text may change after addressing Peter's feedback)
Quoted 7 lines
How about this?
"The number of monitoring counters available for assignment in each domain when the architecture supports
mbm_cntr_assignmode. There are a total of "num_mbm_cntrs" counters are available for assignment. Counters can be assigned or unassigned individually in each domain. A counter is available for new assignment if it is unassigned in all domains."Quoted 9 lines
Please consider the context of this paragraph. It follows right after the description of "
num_mbm_cntrs" that states "Up to two counters can be assigned per monitoring group". I think it is confusing to follow that with a paragraph that states "Counters can be assigned or unassigned individually in each domain." I wonder if it may be helpful to use a different term ... for example a counter is *assigned* to an event of a monitoring group but this assignment may be to specified (not yet supported) or all (this work) domains while it is only *programmed*/*activated* to specified domains. Of course, all of this documentation needs to remain coherent if future work decides to indeed support per-domain assignment.Quoted 1 line
Little bit lost here. Please help me.
I think this highlights the uncertainty this interface brings. How do you expect users to use this interface? At this time I think this interface can create a lot of confusion. For example, consider a hypothetical system with three domains and four counters that has the following state per
mbm_assign_control://0=tl;1=_;2=l #default group uses counters 0 and 1 to monitor total and local MBM /m1/0=_;1=t;2=t #monitor group m1 uses counter 2, just for total MBM /m2/0=l;1=_;2=l #monitor group m2 uses counter 3, just for local MBM /m3/0=_;1=_;2=_
Quoted 6 lines
Since, in this system there are only four counters available, and they have all been assigned, then there are no new counters available for assignment.
If I understand correctly,
available_mbm_cntrswill read:
0=1;1=3;2=1
Yes. Exactly. This causes confusion to the user.
Quoted 8 lines
How is a user to interpret the above numbers? It does not reflect that no counter can be assigned to m3, instead it reflects which of the already assigned counters still need to be activated on domains. If, for example, a user is expected to use this file to know how many counters can still be assigned, should it not reflect the actual available counters. In the above scenario it will then be:
0=0;1=0;2=0
We can also just print
#cat available_mbm_cntrs
0
The domain specific information is not important here.
That was my original idea. We can go back to that definition. That is more clear to the user.
Quoted 17 lines
Of course, when doing the above the user may get impression that a counter that has already been assigned, just not activated, is no longer available for use.
Quoted 4 lines
"
available_mbm_cntrs":
"The number of monitoring counters available for assignment in each domain when the architecture supports "mbm_cntr_assign" mode. There are a total of "num_mbm_cntrs" counters are available for assignment. A counter is assigned to an event within a monitoring group and is available for activation across all domains. Users have the flexibility to activate it selectively within specific domains."Once we understand how users are to use this file the documentation should be easier to create.
Reinette
Signature · 1 line
- Babu Moger
Reinette Chatre
maintainerRe: [PATCH v9 14/26] x86/resctrl: Introduce interface to display number of free counters
Hi Babu,
Quoted 80 lines · Babu
Quoted 62 lines · Reinette Chatre
Quoted 49 lines · Babu
Quoted 38 lines · Reinette Chatre
Quoted 29 lines · Babu
Quoted 26 lines · Reinette Chatre
Quoted 17 lines · Babu Moger
Provide the interface to display the number of free monitoring counters available for assignment in each doamin when
mbm_cntr_assignis supported.Signed-off-by Babu Moger <[email protected]>---
v9: New patch.
---
Documentation/arch/x86/resctrl.rst | 4 ++++ arch/x86/kernel/cpu/resctrl/monitor.c | 1 +arch/x86/kernel/cpu/resctrl/rdtgroup.c| 33 ++++++++++++++++++++++++++3 files changed, 38 insertions(+)Documentation/arch/x86/resctrl.rst +0
-0@@ -302,6 +302,10 @@ with the following files:Quoted 4 lines
memory bandwidth tracking to a single memory bandwidth event per monitoring group.
+"available_mbm_cntrs":
+ The number of free monitoring counters available assignment in each domain"The number of free monitoring counters available assignment" -> "The number of monitoring counters available for assignment"?
Quoted 1 line
(not taking into account how text may change after addressing Peter's feedback)
Quoted 7 lines
How about this?
"The number of monitoring counters available for assignment in each domain when the architecture supports
mbm_cntr_assignmode. There are a total of "num_mbm_cntrs" counters are available for assignment. Counters can be assigned or unassigned individually in each domain. A counter is available for new assignment if it is unassigned in all domains."Quoted 9 lines
Please consider the context of this paragraph. It follows right after the description of "
num_mbm_cntrs" that states "Up to two counters can be assigned per monitoring group". I think it is confusing to follow that with a paragraph that states "Counters can be assigned or unassigned individually in each domain." I wonder if it may be helpful to use a different term ... for example a counter is *assigned* to an event of a monitoring group but this assignment may be to specified (not yet supported) or all (this work) domains while it is only *programmed*/*activated* to specified domains. Of course, all of this documentation needs to remain coherent if future work decides to indeed support per-domain assignment.Quoted 1 line
Little bit lost here. Please help me.
I think this highlights the uncertainty this interface brings. How do you expect users to use this interface? At this time I think this interface can create a lot of confusion. For example, consider a hypothetical system with three domains and four counters that has the following state per
mbm_assign_control://0=tl;1=_;2=l #default group uses counters 0 and 1 to monitor total and local MBM /m1/0=_;1=t;2=t #monitor group m1 uses counter 2, just for total MBM /m2/0=l;1=_;2=l #monitor group m2 uses counter 3, just for local MBM /m3/0=_;1=_;2=_
Quoted 6 lines
Since, in this system there are only four counters available, and they have all been assigned, then there are no new counters available for assignment.
If I understand correctly,
available_mbm_cntrswill read:
0=1;1=3;2=1Yes. Exactly. This causes confusion to the user.
Quoted 8 lines
How is a user to interpret the above numbers? It does not reflect that no counter can be assigned to m3, instead it reflects which of the already assigned counters still need to be activated on domains. If, for example, a user is expected to use this file to know how many counters can still be assigned, should it not reflect the actual available counters. In the above scenario it will then be:
0=0;1=0;2=0
Quoted 6 lines
We can also just print
#catavailable_mbm_cntrs
0The domain specific information is not important here.
That was my original idea. We can go back to that definition. That is more clear to the user.
Tony's response [1] still applies.
I believe Tony's suggestion [2] considered that the available counters will be the same for every domain for this implementation. That is why my example noted:
"0=0;1=0;2=0"
The confusion surrounding the global allocator seems to be prevalent ([3], [4]) as folks familiar with resctrl attempt to digest the work. The struggle to make this documentation clear makes me more concerned how this feature will be perceived by users who are not as familiar with resctrl internals. I think that it may be worth it to take a moment and investigate what it will take to implement a per-domain counter allocator. The hardware supports it and I suspect that the upfront work to do the enabling will make it easier for users to adopt and understand the feature.
What do you think?
Reinette
[1] https://lore.kernel.org/all/SJ1PR11MB6083DC9EA6D323356E957A87FC4E2@SJ1PR11MB6083.namprd11.prod.outlook.com/
[2] https://lore.kernel.org/all/SJ1PR11MB6083583A24FA3B3B7C2DCD64FC442@SJ1PR11MB6083.namprd11.prod.outlook.com/
[3] https://lore.kernel.org/all/[email protected]/
[4] https://lore.kernel.org/all/CALPaoCh1BWdWww8Kztd13GBaY9mMeZX268fOQgECRytiKm-nPQ@mail.gmail.com/
Re: [PATCH v9 14/26] x86/resctrl: Introduce interface to display number of free counters
Hi Reinette,
Quoted 87 lines · Reinette Chatre
Hi Babu,
Quoted 84 lines · Babu
Quoted 62 lines · Reinette Chatre
Quoted 49 lines · Babu
Quoted 38 lines · Reinette Chatre
Quoted 29 lines · Babu
Quoted 26 lines · Reinette Chatre
Quoted 17 lines · Babu Moger
Provide the interface to display the number of free monitoring counters available for assignment in each doamin when
mbm_cntr_assignis supported.Signed-off-by Babu Moger <[email protected]>---
v9: New patch.--- Documentation/arch/x86/resctrl.rst | 4 ++++ arch/x86/kernel/cpu/resctrl/monitor.c | 1 + arch/x86/kernel/cpu/resctrl/rdtgroup.c | 33 ++++++++++++++++++++++++++ 3 files changed, 38 insertions(+)Documentation/arch/x86/resctrl.rst +0
-0Documentation/arch/x86/resctrl.rst with the following files: · line 305
Quoted 4 lines
Documentation/arch/x86/resctrl.rst +1
-0@@ -302,6 +302,10 @@ with the following files: memory bandwidth tracking to a single memory bandwidth event per monitoring group. +"available_mbm_cntrs": + The number of free monitoring counters available assignment in each domain"The number of free monitoring counters available assignment" -> "The number of monitoring counters available for assignment"?
Quoted 1 line
(not taking into account how text may change after addressing Peter's feedback)
Quoted 7 lines
How about this?
"The number of monitoring counters available for assignment in each domain when the architecture supports
mbm_cntr_assignmode. There are a total of "num_mbm_cntrs" counters are available for assignment. Counters can be assigned or unassigned individually in each domain. A counter is available for new assignment if it is unassigned in all domains."Quoted 9 lines
Please consider the context of this paragraph. It follows right after the description of "
num_mbm_cntrs" that states "Up to two counters can be assigned per monitoring group". I think it is confusing to follow that with a paragraph that states "Counters can be assigned or unassigned individually in each domain." I wonder if it may be helpful to use a different term ... for example a counter is *assigned* to an event of a monitoring group but this assignment may be to specified (not yet supported) or all (this work) domains while it is only *programmed*/*activated* to specified domains. Of course, all of this documentation needs to remain coherent if future work decides to indeed support per-domain assignment.Quoted 1 line
Little bit lost here. Please help me.
I think this highlights the uncertainty this interface brings. How do you expect users to use this interface? At this time I think this interface can create a lot of confusion. For example, consider a hypothetical system with three domains and four counters that has the following state per
mbm_assign_control://0=tl;1=_;2=l #default group uses counters 0 and 1 to monitor total and local MBM /m1/0=_;1=t;2=t #monitor group m1 uses counter 2, just for total MBM /m2/0=l;1=_;2=l #monitor group m2 uses counter 3, just for local MBM /m3/0=_;1=_;2=_
Quoted 6 lines
Since, in this system there are only four counters available, and they have all been assigned, then there are no new counters available for assignment.
If I understand correctly,
available_mbm_cntrswill read:
0=1;1=3;2=1Yes. Exactly. This causes confusion to the user.
Quoted 8 lines
How is a user to interpret the above numbers? It does not reflect that no counter can be assigned to m3, instead it reflects which of the already assigned counters still need to be activated on domains. If, for example, a user is expected to use this file to know how many counters can still be assigned, should it not reflect the actual available counters. In the above scenario it will then be:
0=0;1=0;2=0We can also just print
#catavailable_mbm_cntrs
0
Quoted 8 lines
Quoted 2 lines
The domain specific information is not important here.
That was my original idea. We can go back to that definition. That is more clear to the user.Tony's response [1] still applies.
I believe Tony's suggestion [2] considered that the available counters will be the same for every domain for this implementation. That is why my example noted:
"0=0;1=0;2=0"
yes. We can keep it like this.
Quoted 9 lines
The confusion surrounding the global allocator seems to be prevalent ([3], [4]) as folks familiar with resctrl attempt to digest the work. The struggle to make this documentation clear makes me more concerned how this feature will be perceived by users who are not as familiar with resctrl internals. I think that it may be worth it to take a moment and investigate what it will take to implement a per-domain counter allocator. The hardware supports it and I suspect that the upfront work to do the enabling will make it easier for users to adopt and understand the feature.
What do you think?
It adds more complexity for sure.
1. Each group needs to remember counter ids in each domain for each event. For example:
Resctrl group mon1
Total event
dom 0 cntr_id 1,
dom 1 cntr_id 10
dom 2 cntr_id 11
Local event
dom 0 cntr_id 2,
dom 1 cntr_id 15
dom 2 cntr_id 10
2. We should have a bitmap of "available counters" in each domain. We have this already. But allocation method changes.
3. Dynamic allocation/free of the counters
There could be some more things which I can't think right now. It might come up when we start working on it.
It is doable. But, is it worth adding this complexity? I am not sure.
Peter mentioned earlier that he was not interested in domain specific assignments. He was only interested in all domain ("*") implementation.
We can add the support but not sure if it is going to drastically help the user.
Yes, We should keep the options open for supporting domain level allocation for future.
For now, we can go ahead with the current implementation.
Quoted 8 lines
Reinette
[1] https://lore.kernel.org/all/SJ1PR11MB6083DC9EA6D323356E957A87FC4E2@SJ1PR11MB6083.namprd11.prod.outlook.com/
[2] https://lore.kernel.org/all/SJ1PR11MB6083583A24FA3B3B7C2DCD64FC442@SJ1PR11MB6083.namprd11.prod.outlook.com/
[3] https://lore.kernel.org/all/[email protected]/
[4] https://lore.kernel.org/all/CALPaoCh1BWdWww8Kztd13GBaY9mMeZX268fOQgECRytiKm-nPQ@mail.gmail.com/
Signature · 1 line
- Babu Moger
Reinette Chatre
maintainerRe: [PATCH v9 14/26] x86/resctrl: Introduce interface to display number of free counters
Hi Babu,
Quoted 109 lines · Babu
Hi Reinette,
Quoted 87 lines · Reinette Chatre
Hi Babu,
Quoted 84 lines · Babu
Quoted 62 lines · Reinette Chatre
Quoted 49 lines · Babu
Quoted 38 lines · Reinette Chatre
Quoted 29 lines · Babu
Quoted 26 lines · Reinette Chatre
Quoted 17 lines · Babu Moger
Provide the interface to display the number of free monitoring counters available for assignment in each doamin when
mbm_cntr_assignis supported.Signed-off-by Babu Moger <[email protected]>---
v9: New patch.--- Documentation/arch/x86/resctrl.rst | 4 ++++ arch/x86/kernel/cpu/resctrl/monitor.c | 1 + arch/x86/kernel/cpu/resctrl/rdtgroup.c | 33 ++++++++++++++++++++++++++ 3 files changed, 38 insertions(+)Documentation/arch/x86/resctrl.rst +0
-0Documentation/arch/x86/resctrl.rst with the following files: · line 305
Quoted 4 lines
Documentation/arch/x86/resctrl.rst +1
-0@@ -302,6 +302,10 @@ with the following files: memory bandwidth tracking to a single memory bandwidth event per monitoring group. +"available_mbm_cntrs": + The number of free monitoring counters available assignment in each domain"The number of free monitoring counters available assignment" -> "The number of monitoring counters available for assignment"?
Quoted 1 line
(not taking into account how text may change after addressing Peter's feedback)
Quoted 7 lines
How about this?
"The number of monitoring counters available for assignment in each domain when the architecture supports
mbm_cntr_assignmode. There are a total of "num_mbm_cntrs" counters are available for assignment. Counters can be assigned or unassigned individually in each domain. A counter is available for new assignment if it is unassigned in all domains."Quoted 9 lines
Please consider the context of this paragraph. It follows right after the description of "
num_mbm_cntrs" that states "Up to two counters can be assigned per monitoring group". I think it is confusing to follow that with a paragraph that states "Counters can be assigned or unassigned individually in each domain." I wonder if it may be helpful to use a different term ... for example a counter is *assigned* to an event of a monitoring group but this assignment may be to specified (not yet supported) or all (this work) domains while it is only *programmed*/*activated* to specified domains. Of course, all of this documentation needs to remain coherent if future work decides to indeed support per-domain assignment.Quoted 1 line
Little bit lost here. Please help me.
I think this highlights the uncertainty this interface brings. How do you expect users to use this interface? At this time I think this interface can create a lot of confusion. For example, consider a hypothetical system with three domains and four counters that has the following state per
mbm_assign_control://0=tl;1=_;2=l #default group uses counters 0 and 1 to monitor total and local MBM /m1/0=_;1=t;2=t #monitor group m1 uses counter 2, just for total MBM /m2/0=l;1=_;2=l #monitor group m2 uses counter 3, just for local MBM /m3/0=_;1=_;2=_
Quoted 6 lines
Since, in this system there are only four counters available, and they have all been assigned, then there are no new counters available for assignment.
If I understand correctly,
available_mbm_cntrswill read:
0=1;1=3;2=1Yes. Exactly. This causes confusion to the user.
Quoted 8 lines
How is a user to interpret the above numbers? It does not reflect that no counter can be assigned to m3, instead it reflects which of the already assigned counters still need to be activated on domains. If, for example, a user is expected to use this file to know how many counters can still be assigned, should it not reflect the actual available counters. In the above scenario it will then be:
0=0;1=0;2=0We can also just print
#catavailable_mbm_cntrs
0Quoted 8 lines
Quoted 2 lines
The domain specific information is not important here.
That was my original idea. We can go back to that definition. That is more clear to the user.Tony's response [1] still applies.
I believe Tony's suggestion [2] considered that the available counters will be the same for every domain for this implementation. That is why my example noted:
"0=0;1=0;2=0"yes. We can keep it like this.
Quoted 8 lines
The confusion surrounding the global allocator seems to be prevalent ([3], [4]) as folks familiar with resctrl attempt to digest the work. The struggle to make this documentation clear makes me more concerned how this feature will be perceived by users who are not as familiar with resctrl internals. I think that it may be worth it to take a moment and investigate what it will take to implement a per-domain counter allocator. The hardware supports it and I suspect that the upfront work to do the enabling will make it easier for users to adopt and understand the feature.
Quoted 3 lines
Quoted 1 line
What do you think?
It adds more complexity for sure.
I do see a difference in data structures used but the additional complexity is not obvious to me. It seems like there will be one fewer data structure, the global bitmap, and I think that will actually bring with it some simplification since there is no longer the need to coordinate between the per-domain and global counters, for example the logic that only frees a global counter if it is no longer used by a domain.
This may also simplify the update of the monitor event config (BMEC) since it can be done directly on counters of the domain instead of needing to go back and forth between global and per-domain counters.
Quoted 9 lines
1. Each group needs to remember counter ids in each domain for each event. For example:
Resctrl group mon1
Total event
dom 0cntr_id1,
dom 1cntr_id10
dom 2cntr_id11
Quoted 4 lines
Local event
dom 0cntr_id2,
dom 1cntr_id15
dom 2cntr_id10
Indeed. The challenge here is that domains may come and go so it cannot be a simple static array. As an alternative it can be an xarray indexed by the domain ID with pointers to a struct like below to contain the counters associated with the monitor group:
struct cntr_id {
u32 mbm_total;
u32 mbm_local;
}Thinking more about how this array needs to be managed made me wonder how the current implementation deals with domains that come and go. I do not think this is currently handled. For example, if a new domain comes online and monitoring groups had counters dynamically assigned, then these counters are not configured to the newly online domain.
Quoted 4 lines
2. We should have a bitmap of "available counters" in each domain. We have this already. But allocation method changes.
Would allocation/free not be simpler with only the per-domain bitmap needing to be consulted?
One implementation change I can think of is the dynamic assign of counters when a monitor group is created. Now a free counter needs to be found in each domain. Here it can be discussed if it should be an "all or nothing" assignment but the handling does not seem to be complex and would need to be solved eventually anyway.
Quoted 6 lines
3. Dynamic allocation/free of the counters
There could be some more things which I can't think right now. It might come up when we start working on it.
It is doable. But, is it worth adding this complexity? I am not sure.
Please elaborate where you see that this is too complex.
Quoted 3 lines
Peter mentioned earlier that he was not interested in domain specific assignments. He was only interested in all domain ("*") implementation.
Peter's most recent message indicates otherwise:
https://lore.kernel.org/all/CALPaoCgiHEaY_cDbCo=537JJ7mkYZDFFDs9heYvtQ80fXuuvWQ@mail.gmail.com/
Quoted 6 lines
We can add the support but not sure if it is going to drastically help the user.
Yes, We should keep the options open for supporting domain level allocation for future.
The current interface supports domain level allocation with this support in mind. The complication is that the interface is not behaving in an intuitive way when backing it with global allocation. So far I have seen a lot of confusion from knowledgeable users and I'm afraid this will worsen when more users are exposed to this work.
Quoted 3 lines
For now, we can go ahead with the current implementation.
As I see it this will require detailed documentation to explain the interface peculiarities. This documentation is made more complicated knowing that the peculiarities will be temporary since Peter already indicated that he will need to fix this to support his work.
Putting this all together I do think it may really just avoid a lot of confusion and extra unnecessary work if this is done now.
Reinette
Re: [PATCH v9 14/26] x86/resctrl: Introduce interface to display number of free counters
Hi Babu, Reinette,
Quoted 151 lines · Reinette Chatre
Hi Babu,
Quoted 109 lines · Babu
Hi Reinette,
Quoted 87 lines · Reinette Chatre
Hi Babu,
Quoted 84 lines · Babu
Quoted 62 lines · Reinette Chatre
Quoted 49 lines · Babu
Quoted 38 lines · Reinette Chatre
Quoted 29 lines · Babu
Quoted 26 lines · Reinette Chatre
Quoted 17 lines · Babu Moger
Provide the interface to display the number of free monitoring counters available for assignment in each doamin when
mbm_cntr_assignis supported.Signed-off-by Babu Moger <[email protected]>---
v9: New patch.--- Documentation/arch/x86/resctrl.rst | 4 ++++ arch/x86/kernel/cpu/resctrl/monitor.c | 1 + arch/x86/kernel/cpu/resctrl/rdtgroup.c | 33 ++++++++++++++++++++++++++ 3 files changed, 38 insertions(+)Documentation/arch/x86/resctrl.rst +0
-0Documentation/arch/x86/resctrl.rst with the following files: · line 305
Quoted 4 lines
Documentation/arch/x86/resctrl.rst +1
-0@@ -302,6 +302,10 @@ with the following files: memory bandwidth tracking to a single memory bandwidth event per monitoring group. +"available_mbm_cntrs": + The number of free monitoring counters available assignment in each domain"The number of free monitoring counters available assignment" -> "The number of monitoring counters available for assignment"?
Quoted 1 line
(not taking into account how text may change after addressing Peter's feedback)
Quoted 7 lines
How about this?
"The number of monitoring counters available for assignment in each domain when the architecture supports
mbm_cntr_assignmode. There are a total of "num_mbm_cntrs" counters are available for assignment. Counters can be assigned or unassigned individually in each domain. A counter is available for new assignment if it is unassigned in all domains."Quoted 9 lines
Please consider the context of this paragraph. It follows right after the description of "
num_mbm_cntrs" that states "Up to two counters can be assigned per monitoring group". I think it is confusing to follow that with a paragraph that states "Counters can be assigned or unassigned individually in each domain." I wonder if it may be helpful to use a different term ... for example a counter is *assigned* to an event of a monitoring group but this assignment may be to specified (not yet supported) or all (this work) domains while it is only *programmed*/*activated* to specified domains. Of course, all of this documentation needs to remain coherent if future work decides to indeed support per-domain assignment.Quoted 1 line
Little bit lost here. Please help me.
I think this highlights the uncertainty this interface brings. How do you expect users to use this interface? At this time I think this interface can create a lot of confusion. For example, consider a hypothetical system with three domains and four counters that has the following state per
mbm_assign_control://0=tl;1=_;2=l #default group uses counters 0 and 1 to monitor total and local MBM /m1/0=_;1=t;2=t #monitor group m1 uses counter 2, just for total MBM /m2/0=l;1=_;2=l #monitor group m2 uses counter 3, just for local MBM /m3/0=_;1=_;2=_
Quoted 6 lines
Since, in this system there are only four counters available, and they have all been assigned, then there are no new counters available for assignment.
If I understand correctly,
available_mbm_cntrswill read:
0=1;1=3;2=1Yes. Exactly. This causes confusion to the user.
Quoted 8 lines
How is a user to interpret the above numbers? It does not reflect that no counter can be assigned to m3, instead it reflects which of the already assigned counters still need to be activated on domains. If, for example, a user is expected to use this file to know how many counters can still be assigned, should it not reflect the actual available counters. In the above scenario it will then be:
0=0;1=0;2=0We can also just print
#catavailable_mbm_cntrs
0Quoted 8 lines
Quoted 2 lines
The domain specific information is not important here.
That was my original idea. We can go back to that definition. That is more clear to the user.Tony's response [1] still applies.
I believe Tony's suggestion [2] considered that the available counters will be the same for every domain for this implementation. That is why my example noted:
"0=0;1=0;2=0"yes. We can keep it like this.
Quoted 8 lines
The confusion surrounding the global allocator seems to be prevalent ([3], [4]) as folks familiar with resctrl attempt to digest the work. The struggle to make this documentation clear makes me more concerned how this feature will be perceived by users who are not as familiar with resctrl internals. I think that it may be worth it to take a moment and investigate what it will take to implement a per-domain counter allocator. The hardware supports it and I suspect that the upfront work to do the enabling will make it easier for users to adopt and understand the feature.
Quoted 3 lines
Quoted 1 line
What do you think?
It adds more complexity for sure.
I do see a difference in data structures used but the additional complexity is not obvious to me. It seems like there will be one fewer data structure, the global bitmap, and I think that will actually bring with it some simplification since there is no longer the need to coordinate between the per-domain and global counters, for example the logic that only frees a global counter if it is no longer used by a domain.
This may also simplify the update of the monitor event config (BMEC) since it can be done directly on counters of the domain instead of needing to go back and forth between global and per-domain counters.
Quoted 9 lines
1. Each group needs to remember counter ids in each domain for each event. For example:
Resctrl group mon1
Total event
dom 0cntr_id1,
dom 1cntr_id10
dom 2cntr_id11Quoted 4 lines
Local event
dom 0cntr_id2,
dom 1cntr_id15
dom 2cntr_id10Indeed. The challenge here is that domains may come and go so it cannot be a simple static array. As an alternative it can be an xarray indexed by the domain ID with pointers to a struct like below to contain the counters associated with the monitor group:
struct cntr_id { u32 mbm_total; u32 mbm_local; }
Quoted 5 lines
Thinking more about how this array needs to be managed made me wonder how the current implementation deals with domains that come and go. I do not think this is currently handled. For example, if a new domain comes online and monitoring groups had counters dynamically assigned, then these counters are not configured to the newly online domain.
In my prototype, I allocated a counter id-indexed array to each monitoring domain structure for tracking the counter allocations, because the hardware counters are all domain-scoped. That way the tracking data goes away when the hardware does.
I was focused on allowing all pending counter updates to a domain resulting from a single mbm_assign_control write to be batched and processed in a single IPI, so I structured the counter tracker something like this:
struct resctrl_monitor_cfg {
int closid;
int rmid;
int evtid;
bool dirty;
};This mirrors the info needed in whatever register configures the counter, plus a dirty flag to skip over the ones that don't need to be updated.
For the benefit of displaying mbm_assign_control, I put a pointer back to any counter array entry allocated in the mbm_state struct only because it's an existing structure that exists for every rmid-domain combination.
I didn't need to change the rdtgroup structure.
Quoted 22 lines
Quoted 5 lines
2. We should have a bitmap of "available counters" in each domain. We have this already. But allocation method changes.
Would allocation/free not be simpler with only the per-domain bitmap needing to be consulted?
One implementation change I can think of is the dynamic assign of counters when a monitor group is created. Now a free counter needs to be found in each domain. Here it can be discussed if it should be an "all or nothing" assignment but the handling does not seem to be complex and would need to be solved eventually anyway.
Quoted 6 lines
3. Dynamic allocation/free of the counters
There could be some more things which I can't think right now. It might come up when we start working on it.
It is doable. But, is it worth adding this complexity? I am not sure.
Quoted 8 lines
Please elaborate where you see that this is too complex.
Quoted 3 lines
Peter mentioned earlier that he was not interested in domain specific assignments. He was only interested in all domain ("*") implementation.
Peter's most recent message indicates otherwise:
https://lore.kernel.org/all/CALPaoCgiHEaY_cDbCo=537JJ7mkYZDFFDs9heYvtQ80fXuuvWQ@mail.gmail.com/
For now, I'm focused on managing the domains locally whenever possible to avoid all IPIs, as this gives me the least overhead.
I'm also prototyping the 'T' vs 't' approach that Reinette suggested[1], as this may take a lot of performance pressure off the mbm_assign_control interface, as most of the routine updates to counter assignments would be automated.
-Peter
Re: [PATCH v9 14/26] x86/resctrl: Introduce interface to display number of free counters
Hi Peter,
Quoted 160 lines · Peter Newman
Hi Babu, Reinette,
Quoted 156 lines · Reinette Chatre
Hi Babu,
Quoted 109 lines · Babu
Hi Reinette,
Quoted 87 lines · Reinette Chatre
Hi Babu,
Quoted 84 lines · Babu
Quoted 62 lines · Reinette Chatre
Quoted 49 lines · Babu
Quoted 38 lines · Reinette Chatre
Quoted 29 lines · Babu
Quoted 26 lines · Reinette Chatre
Quoted 17 lines · Babu Moger
Provide the interface to display the number of free monitoring counters available for assignment in each doamin when
mbm_cntr_assignis supported.Signed-off-by Babu Moger <[email protected]>---
v9: New patch.--- Documentation/arch/x86/resctrl.rst | 4 ++++ arch/x86/kernel/cpu/resctrl/monitor.c | 1 + arch/x86/kernel/cpu/resctrl/rdtgroup.c | 33 ++++++++++++++++++++++++++ 3 files changed, 38 insertions(+)Documentation/arch/x86/resctrl.rst +0
-0Documentation/arch/x86/resctrl.rst with the following files: · line 305
Quoted 4 lines
Documentation/arch/x86/resctrl.rst +1
-0@@ -302,6 +302,10 @@ with the following files: memory bandwidth tracking to a single memory bandwidth event per monitoring group. +"available_mbm_cntrs": + The number of free monitoring counters available assignment in each domain"The number of free monitoring counters available assignment" -> "The number of monitoring counters available for assignment"?
Quoted 1 line
(not taking into account how text may change after addressing Peter's feedback)
Quoted 7 lines
How about this?
"The number of monitoring counters available for assignment in each domain when the architecture supports
mbm_cntr_assignmode. There are a total of "num_mbm_cntrs" counters are available for assignment. Counters can be assigned or unassigned individually in each domain. A counter is available for new assignment if it is unassigned in all domains."Quoted 9 lines
Please consider the context of this paragraph. It follows right after the description of "
num_mbm_cntrs" that states "Up to two counters can be assigned per monitoring group". I think it is confusing to follow that with a paragraph that states "Counters can be assigned or unassigned individually in each domain." I wonder if it may be helpful to use a different term ... for example a counter is *assigned* to an event of a monitoring group but this assignment may be to specified (not yet supported) or all (this work) domains while it is only *programmed*/*activated* to specified domains. Of course, all of this documentation needs to remain coherent if future work decides to indeed support per-domain assignment.Quoted 1 line
Little bit lost here. Please help me.
I think this highlights the uncertainty this interface brings. How do you expect users to use this interface? At this time I think this interface can create a lot of confusion. For example, consider a hypothetical system with three domains and four counters that has the following state per
mbm_assign_control://0=tl;1=_;2=l #default group uses counters 0 and 1 to monitor total and local MBM /m1/0=_;1=t;2=t #monitor group m1 uses counter 2, just for total MBM /m2/0=l;1=_;2=l #monitor group m2 uses counter 3, just for local MBM /m3/0=_;1=_;2=_
Quoted 6 lines
Since, in this system there are only four counters available, and they have all been assigned, then there are no new counters available for assignment.
If I understand correctly,
available_mbm_cntrswill read:
0=1;1=3;2=1Yes. Exactly. This causes confusion to the user.
Quoted 8 lines
How is a user to interpret the above numbers? It does not reflect that no counter can be assigned to m3, instead it reflects which of the already assigned counters still need to be activated on domains. If, for example, a user is expected to use this file to know how many counters can still be assigned, should it not reflect the actual available counters. In the above scenario it will then be:
0=0;1=0;2=0We can also just print
#catavailable_mbm_cntrs
0Quoted 8 lines
Quoted 2 lines
The domain specific information is not important here.
That was my original idea. We can go back to that definition. That is more clear to the user.Tony's response [1] still applies.
I believe Tony's suggestion [2] considered that the available counters will be the same for every domain for this implementation. That is why my example noted:
"0=0;1=0;2=0"yes. We can keep it like this.
Quoted 8 lines
The confusion surrounding the global allocator seems to be prevalent ([3], [4]) as folks familiar with resctrl attempt to digest the work. The struggle to make this documentation clear makes me more concerned how this feature will be perceived by users who are not as familiar with resctrl internals. I think that it may be worth it to take a moment and investigate what it will take to implement a per-domain counter allocator. The hardware supports it and I suspect that the upfront work to do the enabling will make it easier for users to adopt and understand the feature.
Quoted 3 lines
Quoted 1 line
What do you think?
It adds more complexity for sure.
I do see a difference in data structures used but the additional complexity is not obvious to me. It seems like there will be one fewer data structure, the global bitmap, and I think that will actually bring with it some simplification since there is no longer the need to coordinate between the per-domain and global counters, for example the logic that only frees a global counter if it is no longer used by a domain.
This may also simplify the update of the monitor event config (BMEC) since it can be done directly on counters of the domain instead of needing to go back and forth between global and per-domain counters.
Quoted 9 lines
1. Each group needs to remember counter ids in each domain for each event. For example:
Resctrl group mon1
Total event
dom 0cntr_id1,
dom 1cntr_id10
dom 2cntr_id11Quoted 4 lines
Local event
dom 0cntr_id2,
dom 1cntr_id15
dom 2cntr_id10Indeed. The challenge here is that domains may come and go so it cannot be a simple static array. As an alternative it can be an xarray indexed by the domain ID with pointers to a struct like below to contain the counters associated with the monitor group:
struct cntr_id { u32 mbm_total; u32 mbm_local; }Thinking more about how this array needs to be managed made me wonder how the current implementation deals with domains that come and go. I do not think this is currently handled. For example, if a new domain comes online and monitoring groups had counters dynamically assigned, then these counters are not configured to the newly online domain.
I am trying to understand the details of your approach here.
Quoted 10 lines
In my prototype, I allocated a counter id-indexed array to each monitoring domain structure for tracking the counter allocations, because the hardware counters are all domain-scoped. That way the tracking data goes away when the hardware does.
I was focused on allowing all pending counter updates to a domain resulting from a single
mbm_assign_controlwrite to be batched and processed in a single IPI, so I structured the counter tracker something like this:
Not sure what you meant here. How are you batching two IPIs for two domains?
#echo "//0=t;1=t" > /sys/fs/resctrl/info/L3_MON/mbm_assign_control
This is still a single write. Two IPIs are sent separately, one for each domain.
Are you doing something different?
Quoted 11 lines
struct resctrl_monitor_cfg { int closid; int rmid; int evtid; bool dirty; };This mirrors the info needed in whatever register configures the counter, plus a dirty flag to skip over the ones that don't need to be updated.
This is what my understanding of your implementation.
include/linux/resctrl.h +7 -0
@@ -94,6 +94,13 @@ struct rdt_ctrl_domain {u32 *mbps_val; }; +struct resctrl_monitor_cfg { +int closid; +int rmid; +int evtid; +bool dirty; +}; +/** * struct rdt_mon_domain - group of CPUs sharing a resctrl monitor
resource
* @hdr: common header for different domain types
@@ -116,6 +123,7 @@ struct rdt_mon_domain {
struct delayed_work cqm_limbo;
int mbm_work_cpu;
int cqm_work_cpu;+ /* Allocate num_mbm_cntrs entries in each domain */
+ struct resctrl_monitor_cfg *mon_cfg;
};
When a user requests an assignment for total event to the default group for domain 0, you go search in rdt_mon_domain(dom 0) for empty mon_cfg entry.
If there is an empty entry, then use that entry for assignment and update closid, rmid, evtid and dirty = 1. We can get all these information from default group here.
Does this make sense?
Quoted 5 lines
For the benefit of displaying
mbm_assign_control, I put a pointer back to any counter array entry allocated in thembm_statestruct only because it's an existing structure that exists for every rmid-domain combination.
Pointer in mbm_state may not be required here.
We are going to loop over resctrl groups. We can search the rdt_mon_domain to see if specific closid, rmid, evtid is already assigned or not in that domain.
Quoted 2 lines
I didn't need to change the rdtgroup structure.
Ok. That is good.
Quoted 44 lines
Quoted 23 lines
Quoted 6 lines
2. We should have a bitmap of "available counters" in each domain. We have this already. But allocation method changes.
Would allocation/free not be simpler with only the per-domain bitmap needing to be consulted?
One implementation change I can think of is the dynamic assign of counters when a monitor group is created. Now a free counter needs to be found in each domain. Here it can be discussed if it should be an "all or nothing" assignment but the handling does not seem to be complex and would need to be solved eventually anyway.
Quoted 6 lines
3. Dynamic allocation/free of the counters
There could be some more things which I can't think right now. It might come up when we start working on it.
It is doable. But, is it worth adding this complexity? I am not sure.
Quoted 8 lines
Please elaborate where you see that this is too complex.
Quoted 3 lines
Peter mentioned earlier that he was not interested in domain specific assignments. He was only interested in all domain ("*") implementation.
Peter's most recent message indicates otherwise:
https://lore.kernel.org/all/CALPaoCgiHEaY_cDbCo=537JJ7mkYZDFFDs9heYvtQ80fXuuvWQ@mail.gmail.com/For now, I'm focused on managing the domains locally whenever possible to avoid all IPIs, as this gives me the least overhead.
I'm also prototyping the 'T' vs 't' approach that Reinette suggested[1], as this may take a lot of performance pressure off the
mbm_assign_controlinterface, as most of the routine updates to counter assignments would be automated.-Peter
Signature · 1 line
- Babu Moger
Re: [PATCH v9 14/26] x86/resctrl: Introduce interface to display number of free counters
Hi Babu,
Quoted 54 lines · Babu
Hi Peter,
Quoted 37 lines · Peter Newman
Hi Babu, Reinette,
Quoted 33 lines · Reinette Chatre
Hi Babu,
Quoted 8 lines · Babu
1. Each group needs to remember counter ids in each domain for each event. For example:
Resctrl group mon1
Total event
dom 0cntr_id1,
dom 1cntr_id10
dom 2cntr_id11Quoted 4 lines
Local event
dom 0cntr_id2,
dom 1cntr_id15
dom 2cntr_id10Indeed. The challenge here is that domains may come and go so it cannot be a simple static array. As an alternative it can be an xarray indexed by the domain ID with pointers to a struct like below to contain the counters associated with the monitor group:
struct cntr_id { u32 mbm_total; u32 mbm_local; }Thinking more about how this array needs to be managed made me wonder how the current implementation deals with domains that come and go. I do not think this is currently handled. For example, if a new domain comes online and monitoring groups had counters dynamically assigned, then these counters are not configured to the newly online domain.
I am trying to understand the details of your approach here.
Quoted 10 lines
In my prototype, I allocated a counter id-indexed array to each monitoring domain structure for tracking the counter allocations, because the hardware counters are all domain-scoped. That way the tracking data goes away when the hardware does.
I was focused on allowing all pending counter updates to a domain resulting from a single
mbm_assign_controlwrite to be batched and processed in a single IPI, so I structured the counter tracker something like this:
Quoted 8 lines
Not sure what you meant here. How are you batching two IPIs for two domains?
#echo "//0=t;1=t" >
/sys/fs/resctrl/info/L3_MON/mbm_assign_controlThis is still a single write. Two IPIs are sent separately, one for each domain.
Are you doing something different?
I said "all pending counter updates to a domain", whereby I meant targeting a single domain.
Depending on the CPU of the caller, your example write requires 1 or 2 IPIs.
What is important is that the following write also requires 1 or 2 IPIs:
(assuming /sys/fs/resctrl/mon_groups/[g1-g31] exist, line breaks added for readability)
echo $'//0=t;1=t\n
/g1/0=t;1=t\n
/g2/0=t;1=t\n
/g3/0=t;1=t\n
/g4/0=t;1=t\n
/g5/0=t;1=t\n
/g6/0=t;1=t\n
/g7/0=t;1=t\n
/g8/0=t;1=t\n
/g9/0=t;1=t\n
/g10/0=t;1=t\n
/g11/0=t;1=t\n
/g12/0=t;1=t\n
/g13/0=t;1=t\n
/g14/0=t;1=t\n
/g15/0=t;1=t\n
/g16/0=t;1=t\n
/g17/0=t;1=t\n
/g18/0=t;1=t\n
/g19/0=t;1=t\n
/g20/0=t;1=t\n
/g21/0=t;1=t\n
/g22/0=t;1=t\n
/g23/0=t;1=t\n
/g24/0=t;1=t\n
/g25/0=t;1=t\n
/g26/0=t;1=t\n
/g27/0=t;1=t\n
/g28/0=t;1=t\n
/g29/0=t;1=t\n
/g30/0=t;1=t\n
/g31/0=t;1=t\n'
My ultimate goal is for a thread bound to a particular domain to be able to unassign and reassign the local domain's 32 counters in a single write() with no IPIs at all. And when IPIs are required, then no more than one per domain, regardless of the number of groups updated.
Quoted 47 lines
Quoted 9 lines
struct resctrl_monitor_cfg { int closid; int rmid; int evtid; bool dirty; };Quoted 3 lines
This mirrors the info needed in whatever register configures the counter, plus a dirty flag to skip over the ones that don't need to be updated.
This is what my understanding of your implementation.
include/linux/resctrl.h +7
-0@@ -94,6 +94,13 @@ struct rdt_ctrl_domain {u32 *mbps_val; }; +struct resctrl_monitor_cfg { +int closid; +int rmid; +int evtid; +bool dirty; +}; +/** * struct rdt_mon_domain - group of CPUs sharing a resctrl monitor resource
* @hdr: common header for different domain typesinclude/linux/resctrl.h +2
-0@@ -116,6 +123,7 @@ struct rdt_mon_domain {struct delayed_work cqm_limbo;int mbm_work_cpu;int cqm_work_cpu; +/* Allocate num_mbm_cntrs entries in each domain */ +struct resctrl_monitor_cfg *mon_cfg; };When a user requests an assignment for total event to the default group for domain 0, you go search in
rdt_mon_domain(dom 0)for emptymon_cfgentry.
Quoted 5 lines
If there is an empty entry, then use that entry for assignment and update closid, rmid, evtid and dirty = 1. We can get all these information from default group here.
Does this make sense?
Yes, sounds correct.
Quoted 7 lines
Quoted 6 lines
For the benefit of displaying
mbm_assign_control, I put a pointer back to any counter array entry allocated in thembm_statestruct only because it's an existing structure that exists for every rmid-domain combination.
Quoted 5 lines
Pointer in
mbm_statemay not be required here.We are going to loop over resctrl groups. We can search the
rdt_mon_domainto see if specific closid, rmid, evtid is already assigned or not in that domain.
No, not required I guess. High-performance CPUs can probably search a 32-entry array very quickly.
-Peter
Re: [PATCH v9 14/26] x86/resctrl: Introduce interface to display number of free counters
Hi Peter, Reinette,
Quoted 109 lines · Peter Newman
Hi Babu,
Quoted 54 lines · Babu
Hi Peter,
Quoted 37 lines · Peter Newman
Hi Babu, Reinette,
Quoted 33 lines · Reinette Chatre
Hi Babu,
Quoted 8 lines · Babu
1. Each group needs to remember counter ids in each domain for each event. For example:
Resctrl group mon1
Total event
dom 0cntr_id1,
dom 1cntr_id10
dom 2cntr_id11Quoted 4 lines
Local event
dom 0cntr_id2,
dom 1cntr_id15
dom 2cntr_id10Indeed. The challenge here is that domains may come and go so it cannot be a simple static array. As an alternative it can be an xarray indexed by the domain ID with pointers to a struct like below to contain the counters associated with the monitor group:
struct cntr_id { u32 mbm_total; u32 mbm_local; }Thinking more about how this array needs to be managed made me wonder how the current implementation deals with domains that come and go. I do not think this is currently handled. For example, if a new domain comes online and monitoring groups had counters dynamically assigned, then these counters are not configured to the newly online domain.
I am trying to understand the details of your approach here.
Quoted 10 lines
In my prototype, I allocated a counter id-indexed array to each monitoring domain structure for tracking the counter allocations, because the hardware counters are all domain-scoped. That way the tracking data goes away when the hardware does.
I was focused on allowing all pending counter updates to a domain resulting from a single
mbm_assign_controlwrite to be batched and processed in a single IPI, so I structured the counter tracker something like this:Quoted 8 lines
Not sure what you meant here. How are you batching two IPIs for two domains?
#echo "//0=t;1=t" >
/sys/fs/resctrl/info/L3_MON/mbm_assign_controlThis is still a single write. Two IPIs are sent separately, one for each domain.
Are you doing something different?
I said "all pending counter updates to a domain", whereby I meant targeting a single domain.
Depending on the CPU of the caller, your example write requires 1 or 2 IPIs.
What is important is that the following write also requires 1 or 2 IPIs:
(assuming /sys/fs/resctrl/mon_groups/[g1-g31] exist, line breaks added for readability)
echo $'//0=t;1=t\n
/g1/0=t;1=t\n
/g2/0=t;1=t\n
/g3/0=t;1=t\n
/g4/0=t;1=t\n
/g5/0=t;1=t\n
/g6/0=t;1=t\n
/g7/0=t;1=t\n
/g8/0=t;1=t\n
/g9/0=t;1=t\n
/g10/0=t;1=t\n
/g11/0=t;1=t\n
/g12/0=t;1=t\n
/g13/0=t;1=t\n
/g14/0=t;1=t\n
/g15/0=t;1=t\n
/g16/0=t;1=t\n
/g17/0=t;1=t\n
/g18/0=t;1=t\n
/g19/0=t;1=t\n
/g20/0=t;1=t\n
/g21/0=t;1=t\n
/g22/0=t;1=t\n
/g23/0=t;1=t\n
/g24/0=t;1=t\n
/g25/0=t;1=t\n
/g26/0=t;1=t\n
/g27/0=t;1=t\n
/g28/0=t;1=t\n
/g29/0=t;1=t\n
/g30/0=t;1=t\n
/g31/0=t;1=t\n'
Quoted 6 lines
My ultimate goal is for a thread bound to a particular domain to be able to unassign and reassign the local domain's 32 counters in a single
write()with no IPIs at all. And when IPIs are required, then no more than one per domain, regardless of the number of groups updated.
Yes. I think I got the idea. Thanks.
Quoted 48 lines
Quoted 48 lines
Quoted 10 lines
struct resctrl_monitor_cfg { int closid; int rmid; int evtid; bool dirty; };Quoted 3 lines
This mirrors the info needed in whatever register configures the counter, plus a dirty flag to skip over the ones that don't need to be updated.
This is what my understanding of your implementation.
include/linux/resctrl.h +7
-0@@ -94,6 +94,13 @@ struct rdt_ctrl_domain {u32 *mbps_val; }; +struct resctrl_monitor_cfg { +int closid; +int rmid; +int evtid; +bool dirty; +}; +/** * struct rdt_mon_domain - group of CPUs sharing a resctrl monitor resource
* @hdr: common header for different domain typesinclude/linux/resctrl.h +2
-0@@ -116,6 +123,7 @@ struct rdt_mon_domain {struct delayed_work cqm_limbo;int mbm_work_cpu;int cqm_work_cpu; +/* Allocate num_mbm_cntrs entries in each domain */ +struct resctrl_monitor_cfg *mon_cfg; };When a user requests an assignment for total event to the default group for domain 0, you go search in
rdt_mon_domain(dom 0)for emptymon_cfgentry.
Quoted 7 lines
Quoted 5 lines
If there is an empty entry, then use that entry for assignment and update closid, rmid, evtid and dirty = 1. We can get all these information from default group here.
Does this make sense?
Yes, sounds correct.
I will probably add cntr_id in resctrl_monitor_cfg structure and initialize during the allocation. And rename the field 'dirty' to 'active'(or something similar) to hold the assign state for that entry. That way we have all the information required for assignment at one place. We don't need to update the rdtgroup structure.
Reinette, What do you think about this approach?
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
For the benefit of displaying
mbm_assign_control, I put a pointer back to any counter array entry allocated in thembm_statestruct only because it's an existing structure that exists for every rmid-domain combination.
Quoted 8 lines
Quoted 5 lines
Pointer in
mbm_statemay not be required here.We are going to loop over resctrl groups. We can search the
rdt_mon_domainto see if specific closid, rmid, evtid is already assigned or not in that domain.No, not required I guess. High-performance CPUs can probably search a 32-entry array very quickly.
Ok.
Signature · 1 line
- Babu Moger
Re: [PATCH v9 14/26] x86/resctrl: Introduce interface to display number of free counters
Hi Babu,
Quoted 139 lines · Babu
Hi Peter, Reinette,
Quoted 70 lines · Peter Newman
Hi Babu,
Quoted 15 lines · Babu
Hi Peter,
Quoted 9 lines · Peter Newman
In my prototype, I allocated a counter id-indexed array to each monitoring domain structure for tracking the counter allocations, because the hardware counters are all domain-scoped. That way the tracking data goes away when the hardware does.
I was focused on allowing all pending counter updates to a domain resulting from a single
mbm_assign_controlwrite to be batched and processed in a single IPI, so I structured the counter tracker something like this:Quoted 8 lines
Not sure what you meant here. How are you batching two IPIs for two domains?
#echo "//0=t;1=t" >
/sys/fs/resctrl/info/L3_MON/mbm_assign_controlThis is still a single write. Two IPIs are sent separately, one for each domain.
Are you doing something different?
I said "all pending counter updates to a domain", whereby I meant targeting a single domain.
Depending on the CPU of the caller, your example write requires 1 or 2 IPIs.
What is important is that the following write also requires 1 or 2 IPIs:
(assuming /sys/fs/resctrl/mon_groups/[g1-g31] exist, line breaks added for readability)
echo $'//0=t;1=t\n
/g1/0=t;1=t\n
/g2/0=t;1=t\n
/g3/0=t;1=t\n
/g4/0=t;1=t\n
/g5/0=t;1=t\n
/g6/0=t;1=t\n
/g7/0=t;1=t\n
/g8/0=t;1=t\n
/g9/0=t;1=t\n
/g10/0=t;1=t\n
/g11/0=t;1=t\n
/g12/0=t;1=t\n
/g13/0=t;1=t\n
/g14/0=t;1=t\n
/g15/0=t;1=t\n
/g16/0=t;1=t\n
/g17/0=t;1=t\n
/g18/0=t;1=t\n
/g19/0=t;1=t\n
/g20/0=t;1=t\n
/g21/0=t;1=t\n
/g22/0=t;1=t\n
/g23/0=t;1=t\n
/g24/0=t;1=t\n
/g25/0=t;1=t\n
/g26/0=t;1=t\n
/g27/0=t;1=t\n
/g28/0=t;1=t\n
/g29/0=t;1=t\n
/g30/0=t;1=t\n
/g31/0=t;1=t\n'Quoted 6 lines
My ultimate goal is for a thread bound to a particular domain to be able to unassign and reassign the local domain's 32 counters in a single
write()with no IPIs at all. And when IPIs are required, then no more than one per domain, regardless of the number of groups updated.Yes. I think I got the idea. Thanks.
Quoted 48 lines
Quoted 48 lines
Quoted 10 lines
struct resctrl_monitor_cfg { int closid; int rmid; int evtid; bool dirty; };Quoted 3 lines
This mirrors the info needed in whatever register configures the counter, plus a dirty flag to skip over the ones that don't need to be updated.
This is what my understanding of your implementation.
include/linux/resctrl.h +7
-0@@ -94,6 +94,13 @@ struct rdt_ctrl_domain {u32 *mbps_val; }; +struct resctrl_monitor_cfg { +int closid; +int rmid; +int evtid; +bool dirty; +}; +/** * struct rdt_mon_domain - group of CPUs sharing a resctrl monitor resource
* @hdr: common header for different domain typesinclude/linux/resctrl.h +2
-0@@ -116,6 +123,7 @@ struct rdt_mon_domain {struct delayed_work cqm_limbo;int mbm_work_cpu;int cqm_work_cpu; +/* Allocate num_mbm_cntrs entries in each domain */ +struct resctrl_monitor_cfg *mon_cfg; };When a user requests an assignment for total event to the default group for domain 0, you go search in
rdt_mon_domain(dom 0)for emptymon_cfgentry.Quoted 7 lines
Quoted 5 lines
If there is an empty entry, then use that entry for assignment and update closid, rmid, evtid and dirty = 1. We can get all these information from default group here.
Does this make sense?
Yes, sounds correct.
Quoted 5 lines
I will probably add
cntr_idinresctrl_monitor_cfgstructure and initialize during the allocation. And rename the field 'dirty' to 'active'(or something similar) to hold the assign state for that entry. That way we have all the information required for assignment at one place. We don't need to update the rdtgroup structure.
It concerns me that you want to say "active" instead of "dirty". What I'm proposing is a write-back cache of the config values so that a series of remote updates to many groups can be written back to hardware all at once.
Therefore we want to track which entries are "dirty", implying that they differ from what was last written to the registers and therefore need to be flushed by the remote domain. Whether the counter is enabled or not is already implicit in the configuration values (evtid != 0).
-Peter
Moger, Babu
reviewerRe: [PATCH v9 14/26] x86/resctrl: Introduce interface to display number of free counters
Hi Peter,
Quoted 153 lines · Peter Newman
Hi Babu,
Quoted 139 lines · Babu
Hi Peter, Reinette,
Quoted 70 lines · Peter Newman
Hi Babu,
Quoted 15 lines · Babu
Hi Peter,
Quoted 9 lines · Peter Newman
In my prototype, I allocated a counter id-indexed array to each monitoring domain structure for tracking the counter allocations, because the hardware counters are all domain-scoped. That way the tracking data goes away when the hardware does.
I was focused on allowing all pending counter updates to a domain resulting from a single
mbm_assign_controlwrite to be batched and processed in a single IPI, so I structured the counter tracker something like this:Quoted 8 lines
Not sure what you meant here. How are you batching two IPIs for two domains?
#echo "//0=t;1=t" >
/sys/fs/resctrl/info/L3_MON/mbm_assign_controlThis is still a single write. Two IPIs are sent separately, one for each domain.
Are you doing something different?
I said "all pending counter updates to a domain", whereby I meant targeting a single domain.
Depending on the CPU of the caller, your example write requires 1 or 2 IPIs.
What is important is that the following write also requires 1 or 2 IPIs:
(assuming /sys/fs/resctrl/mon_groups/[g1-g31] exist, line breaks added for readability)
echo $'//0=t;1=t\n
/g1/0=t;1=t\n
/g2/0=t;1=t\n
/g3/0=t;1=t\n
/g4/0=t;1=t\n
/g5/0=t;1=t\n
/g6/0=t;1=t\n
/g7/0=t;1=t\n
/g8/0=t;1=t\n
/g9/0=t;1=t\n
/g10/0=t;1=t\n
/g11/0=t;1=t\n
/g12/0=t;1=t\n
/g13/0=t;1=t\n
/g14/0=t;1=t\n
/g15/0=t;1=t\n
/g16/0=t;1=t\n
/g17/0=t;1=t\n
/g18/0=t;1=t\n
/g19/0=t;1=t\n
/g20/0=t;1=t\n
/g21/0=t;1=t\n
/g22/0=t;1=t\n
/g23/0=t;1=t\n
/g24/0=t;1=t\n
/g25/0=t;1=t\n
/g26/0=t;1=t\n
/g27/0=t;1=t\n
/g28/0=t;1=t\n
/g29/0=t;1=t\n
/g30/0=t;1=t\n
/g31/0=t;1=t\n'Quoted 6 lines
My ultimate goal is for a thread bound to a particular domain to be able to unassign and reassign the local domain's 32 counters in a single
write()with no IPIs at all. And when IPIs are required, then no more than one per domain, regardless of the number of groups updated.Yes. I think I got the idea. Thanks.
Quoted 48 lines
Quoted 48 lines
Quoted 10 lines
struct resctrl_monitor_cfg { int closid; int rmid; int evtid; bool dirty; };Quoted 3 lines
This mirrors the info needed in whatever register configures the counter, plus a dirty flag to skip over the ones that don't need to be updated.
This is what my understanding of your implementation.
include/linux/resctrl.h +7
-0@@ -94,6 +94,13 @@ struct rdt_ctrl_domain {u32 *mbps_val; }; +struct resctrl_monitor_cfg { +int closid; +int rmid; +int evtid; +bool dirty; +}; +/** * struct rdt_mon_domain - group of CPUs sharing a resctrl monitor resource
* @hdr: common header for different domain typesinclude/linux/resctrl.h +2
-0@@ -116,6 +123,7 @@ struct rdt_mon_domain {struct delayed_work cqm_limbo;int mbm_work_cpu;int cqm_work_cpu; +/* Allocate num_mbm_cntrs entries in each domain */ +struct resctrl_monitor_cfg *mon_cfg; };When a user requests an assignment for total event to the default group for domain 0, you go search in
rdt_mon_domain(dom 0)for emptymon_cfgentry.Quoted 7 lines
Quoted 5 lines
If there is an empty entry, then use that entry for assignment and update closid, rmid, evtid and dirty = 1. We can get all these information from default group here.
Does this make sense?
Yes, sounds correct.
Quoted 5 lines
I will probably add
cntr_idinresctrl_monitor_cfgstructure and initialize during the allocation. And rename the field 'dirty' to 'active'(or something similar) to hold the assign state for that entry. That way we have all the information required for assignment at one place. We don't need to update the rdtgroup structure.It concerns me that you want to say "active" instead of "dirty". What I'm proposing is a write-back cache of the config values so that a series of remote updates to many groups can be written back to hardware all at once.
Quoted 6 lines
Therefore we want to track which entries are "dirty", implying that they differ from what was last written to the registers and therefore need to be flushed by the remote domain. Whether the counter is enabled or not is already implicit in the configuration values (evtid != 0).
That is correct. But I wanted to add the "state" explicitly. Makes it easy to search. We can overload it if you want both.
int state;
#define ASSIGN_STATE_ACTIVE BIT(0)
#define ASSIGN_STATE_DIRTY BIT(1)
Signature · 2 lines
Thanks Babu Moger
Reinette Chatre
maintainerRe: [PATCH v9 14/26] x86/resctrl: Introduce interface to display number of free counters
In reply to Moger, BabuHi Babu and Peter,
Quoted 177 lines · Babu
Hi Peter, Reinette,
Quoted 109 lines · Peter Newman
Hi Babu,
Quoted 54 lines · Babu
Hi Peter,
Quoted 37 lines · Peter Newman
Hi Babu, Reinette,
Quoted 33 lines · Reinette Chatre
Hi Babu,
Quoted 8 lines · Babu
1. Each group needs to remember counter ids in each domain for each event. For example:
Resctrl group mon1
Total event
dom 0cntr_id1,
dom 1cntr_id10
dom 2cntr_id11Quoted 4 lines
Local event
dom 0cntr_id2,
dom 1cntr_id15
dom 2cntr_id10Indeed. The challenge here is that domains may come and go so it cannot be a simple static array. As an alternative it can be an xarray indexed by the domain ID with pointers to a struct like below to contain the counters associated with the monitor group:
structcntr_id{
u32mbm_total;
u32mbm_local;
}Thinking more about how this array needs to be managed made me wonder how the current implementation deals with domains that come and go. I do not think this is currently handled. For example, if a new domain comes online and monitoring groups had counters dynamically assigned, then these counters are not configured to the newly online domain.
I am trying to understand the details of your approach here.
Quoted 10 lines
In my prototype, I allocated a counter id-indexed array to each monitoring domain structure for tracking the counter allocations, because the hardware counters are all domain-scoped. That way the tracking data goes away when the hardware does.
I was focused on allowing all pending counter updates to a domain resulting from a single
mbm_assign_controlwrite to be batched and processed in a single IPI, so I structured the counter tracker something like this:Quoted 8 lines
Not sure what you meant here. How are you batching two IPIs for two domains?
#echo "//0=t;1=t" >
/sys/fs/resctrl/info/L3_MON/mbm_assign_controlThis is still a single write. Two IPIs are sent separately, one for each domain.
Are you doing something different?
I said "all pending counter updates to a domain", whereby I meant targeting a single domain.
Depending on the CPU of the caller, your example write requires 1 or 2 IPIs.
What is important is that the following write also requires 1 or 2 IPIs:
(assuming /sys/fs/resctrl/mon_groups/[g1-g31] exist, line breaks added for readability)
echo $'//0=t;1=t\n
/g1/0=t;1=t\n
/g2/0=t;1=t\n
/g3/0=t;1=t\n
/g4/0=t;1=t\n
/g5/0=t;1=t\n
/g6/0=t;1=t\n
/g7/0=t;1=t\n
/g8/0=t;1=t\n
/g9/0=t;1=t\n
/g10/0=t;1=t\n
/g11/0=t;1=t\n
/g12/0=t;1=t\n
/g13/0=t;1=t\n
/g14/0=t;1=t\n
/g15/0=t;1=t\n
/g16/0=t;1=t\n
/g17/0=t;1=t\n
/g18/0=t;1=t\n
/g19/0=t;1=t\n
/g20/0=t;1=t\n
/g21/0=t;1=t\n
/g22/0=t;1=t\n
/g23/0=t;1=t\n
/g24/0=t;1=t\n
/g25/0=t;1=t\n
/g26/0=t;1=t\n
/g27/0=t;1=t\n
/g28/0=t;1=t\n
/g29/0=t;1=t\n
/g30/0=t;1=t\n
/g31/0=t;1=t\n'Quoted 6 lines
My ultimate goal is for a thread bound to a particular domain to be able to unassign and reassign the local domain's 32 counters in a single
write()with no IPIs at all. And when IPIs are required, then no more than one per domain, regardless of the number of groups updated.Yes. I think I got the idea. Thanks.
Quoted 48 lines
Quoted 48 lines
Quoted 10 lines
struct
resctrl_monitor_cfg{
int closid;
int rmid;
int evtid;
bool dirty;
};Quoted 3 lines
This mirrors the info needed in whatever register configures the counter, plus a dirty flag to skip over the ones that don't need to be updated.
This is what my understanding of your implementation.
include/linux/resctrl.h +7
-0@@ -94,6 +94,13 @@ struct rdt_ctrl_domain { u32 *mbps_val; }; +struct resctrl_monitor_cfg { + int closid; + int rmid; + int evtid; + bool dirty; +}; + /*** struct rdt_mon_domain - group of CPUs sharing a resctrl monitor resource
* @hdr: common header for different domain typesinclude/linux/resctrl.h +2
-0@@ -116,6 +123,7 @@ struct rdt_mon_domain { struct delayed_work cqm_limbo; int mbm_work_cpu; int cqm_work_cpu; + /* Allocate num_mbm_cntrs entries in each domain */ + struct resctrl_monitor_cfg *mon_cfg; };When a user requests an assignment for total event to the default group for domain 0, you go search in
rdt_mon_domain(dom 0)for emptymon_cfgentry.Quoted 7 lines
Quoted 5 lines
If there is an empty entry, then use that entry for assignment and update closid, rmid, evtid and dirty = 1. We can get all these information from default group here.
Does this make sense?
Yes, sounds correct.
Quoted 7 lines
I will probably add
cntr_idinresctrl_monitor_cfgstructure and initialize during the allocation. And rename the field 'dirty' to 'active'(or something similar) to hold the assign state for that entry. That way we have all the information required for assignment at one place. We don't need to update the rdtgroup structure.Reinette, What do you think about this approach?
I think this approach is in the right direction. Thanks to Peter for the guidance here.
I do not think that it is necessary to add cntr_id to resctrl_monitor_cfg though, I think the cntr_id would be the index to the array instead?
It may also be worthwhile to consider using a pointer to the resource group instead of storing closid and rmid directly. If used to indicate initialization then an initialized pointer is easier to distinguish than the closid/rmid that may have zero as valid values.
I expect evtid will be enum resctrl_event_id and that raises the question of whether "0" can indeed be used as an "uninitialized" value since doing so would change the meaning of the enum. It may indeed keep things separated by maintaining evtid as an enum resctrl_event_id and note the initialization differently ... either via a pointer to a resource group or entirely separately as Babu indicates later.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
For the benefit of displaying
mbm_assign_control, I put a pointer back to any counter array entry allocated in thembm_statestruct only because it's an existing structure that exists for every rmid-domain combination.Pointer in
mbm_statemay not be required here.
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
We are going to loop over resctrl groups. We can search the
rdt_mon_domainto see if specific closid, rmid, evtid is already assigned or not in that domain.No, not required I guess. High-performance CPUs can probably search a 32-entry array very quickly.
Ok.
This is not so clear to me. I am wondering about the scenario when a resource group is removed and its counters need to be freed. Searching which counters need to be freed would then require a search of the array within every domain, of which I understand there can be many? Having a pointer from the mbm_state may help here.
Reinette
Moger, Babu
reviewerRe: [PATCH v9 14/26] x86/resctrl: Introduce interface to display number of free counters
Hi Reinette,
Quoted 186 lines · Reinette Chatre
Hi Babu and Peter,
Quoted 183 lines · Babu
Hi Peter, Reinette,
Quoted 109 lines · Peter Newman
Hi Babu,
Quoted 54 lines · Babu
Hi Peter,
Quoted 37 lines · Peter Newman
Hi Babu, Reinette,
Quoted 33 lines · Reinette Chatre
Hi Babu,
Quoted 8 lines · Babu
1. Each group needs to remember counter ids in each domain for each event. For example:
Resctrl group mon1
Total event
dom 0cntr_id1,
dom 1cntr_id10
dom 2cntr_id11Quoted 4 lines
Local event
dom 0cntr_id2,
dom 1cntr_id15
dom 2cntr_id10Indeed. The challenge here is that domains may come and go so it cannot be a simple static array. As an alternative it can be an xarray indexed by the domain ID with pointers to a struct like below to contain the counters associated with the monitor group:
structcntr_id{
u32mbm_total;
u32mbm_local;
}Thinking more about how this array needs to be managed made me wonder how the current implementation deals with domains that come and go. I do not think this is currently handled. For example, if a new domain comes online and monitoring groups had counters dynamically assigned, then these counters are not configured to the newly online domain.
I am trying to understand the details of your approach here.
Quoted 10 lines
In my prototype, I allocated a counter id-indexed array to each monitoring domain structure for tracking the counter allocations, because the hardware counters are all domain-scoped. That way the tracking data goes away when the hardware does.
I was focused on allowing all pending counter updates to a domain resulting from a single
mbm_assign_controlwrite to be batched and processed in a single IPI, so I structured the counter tracker something like this:Quoted 8 lines
Not sure what you meant here. How are you batching two IPIs for two domains?
#echo "//0=t;1=t" >
/sys/fs/resctrl/info/L3_MON/mbm_assign_controlThis is still a single write. Two IPIs are sent separately, one for each domain.
Are you doing something different?
I said "all pending counter updates to a domain", whereby I meant targeting a single domain.
Depending on the CPU of the caller, your example write requires 1 or 2 IPIs.
What is important is that the following write also requires 1 or 2 IPIs:
(assuming /sys/fs/resctrl/mon_groups/[g1-g31] exist, line breaks added for readability)
echo $'//0=t;1=t\n
/g1/0=t;1=t\n
/g2/0=t;1=t\n
/g3/0=t;1=t\n
/g4/0=t;1=t\n
/g5/0=t;1=t\n
/g6/0=t;1=t\n
/g7/0=t;1=t\n
/g8/0=t;1=t\n
/g9/0=t;1=t\n
/g10/0=t;1=t\n
/g11/0=t;1=t\n
/g12/0=t;1=t\n
/g13/0=t;1=t\n
/g14/0=t;1=t\n
/g15/0=t;1=t\n
/g16/0=t;1=t\n
/g17/0=t;1=t\n
/g18/0=t;1=t\n
/g19/0=t;1=t\n
/g20/0=t;1=t\n
/g21/0=t;1=t\n
/g22/0=t;1=t\n
/g23/0=t;1=t\n
/g24/0=t;1=t\n
/g25/0=t;1=t\n
/g26/0=t;1=t\n
/g27/0=t;1=t\n
/g28/0=t;1=t\n
/g29/0=t;1=t\n
/g30/0=t;1=t\n
/g31/0=t;1=t\n'Quoted 6 lines
My ultimate goal is for a thread bound to a particular domain to be able to unassign and reassign the local domain's 32 counters in a single
write()with no IPIs at all. And when IPIs are required, then no more than one per domain, regardless of the number of groups updated.Yes. I think I got the idea. Thanks.
Quoted 48 lines
Quoted 48 lines
Quoted 10 lines
struct
resctrl_monitor_cfg{
int closid;
int rmid;
int evtid;
bool dirty;
};Quoted 3 lines
This mirrors the info needed in whatever register configures the counter, plus a dirty flag to skip over the ones that don't need to be updated.
This is what my understanding of your implementation.
include/linux/resctrl.h +7
-0@@ -94,6 +94,13 @@ struct rdt_ctrl_domain { u32 *mbps_val; }; +struct resctrl_monitor_cfg { + int closid; + int rmid; + int evtid; + bool dirty; +}; + /*** struct rdt_mon_domain - group of CPUs sharing a resctrl monitor resource
* @hdr: common header for different domain typesinclude/linux/resctrl.h +2
-0@@ -116,6 +123,7 @@ struct rdt_mon_domain { struct delayed_work cqm_limbo; int mbm_work_cpu; int cqm_work_cpu; + /* Allocate num_mbm_cntrs entries in each domain */ + struct resctrl_monitor_cfg *mon_cfg; };When a user requests an assignment for total event to the default group for domain 0, you go search in
rdt_mon_domain(dom 0)for emptymon_cfgentry.Quoted 7 lines
Quoted 5 lines
If there is an empty entry, then use that entry for assignment and update closid, rmid, evtid and dirty = 1. We can get all these information from default group here.
Does this make sense?
Yes, sounds correct.
I will probably add
cntr_idinresctrl_monitor_cfgstructure and initialize during the allocation. And rename the field 'dirty' to 'active'(or something similar) to hold the assign state for that entry. That way we have all the information required for assignment at one place. We don't need to update the rdtgroup structure.
Quoted 6 lines
Quoted 1 line
Reinette, What do you think about this approach?
I think this approach is in the right direction. Thanks to Peter for the guidance here.
I do not think that it is necessary to addcntr_idtoresctrl_monitor_cfgthough, I think thecntr_idwould be the index to the array instead?
Yes. I think We can use the index as cntn_id. Will let you know otherwise.
Quoted 5 lines
It may also be worthwhile to consider using a pointer to the resource group instead of storing closid and rmid directly. If used to indicate initialization then an initialized pointer is easier to distinguish than the closid/rmid that may have zero as valid values.
Sure. Sounds good.
Quoted 7 lines
I expect evtid will be enum
resctrl_event_idand that raises the question of whether "0" can indeed be used as an "uninitialized" value since doing so would change the meaning of the enum. It may indeed keep things separated by maintaining evtid as an enumresctrl_event_idand note the initialization differently ... either via a pointer to a resource group or entirely separately as Babu indicates later.
Sure. Will add evtid as enum resctrl_event_id and use the "state" to indicate assign/unassign/dirty status.
Quoted 15 lines
Quoted 15 lines
Quoted 14 lines
Quoted 11 lines
Quoted 5 lines
For the benefit of displaying
mbm_assign_control, I put a pointer back to any counter array entry allocated in thembm_statestruct only because it's an existing structure that exists for every rmid-domain combination.Pointer in
mbm_statemay not be required here.We are going to loop over resctrl groups. We can search the
rdt_mon_domainto see if specific closid, rmid, evtid is already assigned or not in that domain.No, not required I guess. High-performance CPUs can probably search a 32-entry array very quickly.
Quoted 8 lines
Quoted 2 lines
Ok.
This is not so clear to me. I am wondering about the scenario when a resource group is removed and its counters need to be freed. Searching which counters need to be freed would then require a search of the array within every domain, of which I understand there can be many? Having a pointer from the
mbm_statemay help here.
Sure. Will add the allocated entry pointer in mbm_state.
Quoted 4 lines
Reinette
Signature · 2 lines
Thanks Babu Moger
Reinette Chatre
maintainerRe: [PATCH v9 14/26] x86/resctrl: Introduce interface to display number of free counters
Hi Babu,
Quoted 202 lines · Babu
Quoted 175 lines · Reinette Chatre
Quoted 174 lines · Babu
Quoted 102 lines · Peter Newman
Quoted 49 lines · Babu
Quoted 30 lines · Peter Newman
Quoted 28 lines · Reinette Chatre
Hi Babu,
Quoted 8 lines · Babu
1. Each group needs to remember counter ids in each domain for each event. For example:
Resctrl group mon1
Total event
dom 0cntr_id1,
dom 1cntr_id10
dom 2cntr_id11Quoted 4 lines
Local event
dom 0cntr_id2,
dom 1cntr_id15
dom 2cntr_id10Indeed. The challenge here is that domains may come and go so it cannot be a simple static array. As an alternative it can be an xarray indexed by the domain ID with pointers to a struct like below to contain the counters associated with the monitor group:
structcntr_id{
u32mbm_total;
u32mbm_local;
}Quoted 5 lines
Quoted 5 lines
Thinking more about how this array needs to be managed made me wonder how the current implementation deals with domains that come and go. I do not think this is currently handled. For example, if a new domain comes online and monitoring groups had counters dynamically assigned, then these counters are not configured to the newly online domain.
I am trying to understand the details of your approach here.
Quoted 10 lines
In my prototype, I allocated a counter id-indexed array to each monitoring domain structure for tracking the counter allocations, because the hardware counters are all domain-scoped. That way the tracking data goes away when the hardware does.
I was focused on allowing all pending counter updates to a domain resulting from a single
mbm_assign_controlwrite to be batched and processed in a single IPI, so I structured the counter tracker something like this:Quoted 8 lines
Not sure what you meant here. How are you batching two IPIs for two domains?
#echo "//0=t;1=t" >
/sys/fs/resctrl/info/L3_MON/mbm_assign_controlThis is still a single write. Two IPIs are sent separately, one for each domain.
Are you doing something different?
I said "all pending counter updates to a domain", whereby I meant targeting a single domain.
Depending on the CPU of the caller, your example write requires 1 or 2 IPIs.
What is important is that the following write also requires 1 or 2 IPIs:
(assuming /sys/fs/resctrl/mon_groups/[g1-g31] exist, line breaks added for readability)
echo $'//0=t;1=t\n
/g1/0=t;1=t\n
/g2/0=t;1=t\n
/g3/0=t;1=t\n
/g4/0=t;1=t\n
/g5/0=t;1=t\n
/g6/0=t;1=t\n
/g7/0=t;1=t\n
/g8/0=t;1=t\n
/g9/0=t;1=t\n
/g10/0=t;1=t\n
/g11/0=t;1=t\n
/g12/0=t;1=t\n
/g13/0=t;1=t\n
/g14/0=t;1=t\n
/g15/0=t;1=t\n
/g16/0=t;1=t\n
/g17/0=t;1=t\n
/g18/0=t;1=t\n
/g19/0=t;1=t\n
/g20/0=t;1=t\n
/g21/0=t;1=t\n
/g22/0=t;1=t\n
/g23/0=t;1=t\n
/g24/0=t;1=t\n
/g25/0=t;1=t\n
/g26/0=t;1=t\n
/g27/0=t;1=t\n
/g28/0=t;1=t\n
/g29/0=t;1=t\n
/g30/0=t;1=t\n
/g31/0=t;1=t\n'Quoted 6 lines
My ultimate goal is for a thread bound to a particular domain to be able to unassign and reassign the local domain's 32 counters in a single
write()with no IPIs at all. And when IPIs are required, then no more than one per domain, regardless of the number of groups updated.Yes. I think I got the idea. Thanks.
Quoted 48 lines
Quoted 48 lines
Quoted 10 lines
struct
resctrl_monitor_cfg{
int closid;
int rmid;
int evtid;
bool dirty;
};Quoted 3 lines
This mirrors the info needed in whatever register configures the counter, plus a dirty flag to skip over the ones that don't need to be updated.
This is what my understanding of your implementation.
include/linux/resctrl.h +7
-0@@ -94,6 +94,13 @@ struct rdt_ctrl_domain { u32 *mbps_val; }; +struct resctrl_monitor_cfg { + int closid; + int rmid; + int evtid; + bool dirty; +}; + /*** struct rdt_mon_domain - group of CPUs sharing a resctrl monitor resource
* @hdr: common header for different domain typesinclude/linux/resctrl.h +2
-0@@ -116,6 +123,7 @@ struct rdt_mon_domain { struct delayed_work cqm_limbo; int mbm_work_cpu; int cqm_work_cpu; + /* Allocate num_mbm_cntrs entries in each domain */ + struct resctrl_monitor_cfg *mon_cfg; };When a user requests an assignment for total event to the default group for domain 0, you go search in
rdt_mon_domain(dom 0)for emptymon_cfgentry.Quoted 7 lines
Quoted 5 lines
If there is an empty entry, then use that entry for assignment and update closid, rmid, evtid and dirty = 1. We can get all these information from default group here.
Does this make sense?
Yes, sounds correct.
I will probably add
cntr_idinresctrl_monitor_cfgstructure and initialize during the allocation. And rename the field 'dirty' to 'active'(or something similar) to hold the assign state for that entry. That way we have all the information required for assignment at one place. We don't need to update the rdtgroup structure.Quoted 6 lines
Quoted 1 line
Reinette, What do you think about this approach?
I think this approach is in the right direction. Thanks to Peter for the guidance here.
I do not think that it is necessary to addcntr_idtoresctrl_monitor_cfgthough, I think thecntr_idwould be the index to the array instead?Yes. I think We can use the index as
cntn_id. Will let you know otherwise.Quoted 5 lines
It may also be worthwhile to consider using a pointer to the resource group instead of storing closid and rmid directly. If used to indicate initialization then an initialized pointer is easier to distinguish than the closid/rmid that may have zero as valid values.
Sure. Sounds good.
Quoted 7 lines
I expect evtid will be enum
resctrl_event_idand that raises the question of whether "0" can indeed be used as an "uninitialized" value since doing so would change the meaning of the enum. It may indeed keep things separated by maintaining evtid as an enumresctrl_event_idand note the initialization differently ... either via a pointer to a resource group or entirely separately as Babu indicates later.
Quoted 2 lines
Sure. Will add evtid as enum
resctrl_event_idand use the "state" to indicate assign/unassign/dirty status.
Is "assign/unassign" state needed? If resctrl_monitor_cfg contains a pointer to the resource group to which the counter has been assigned then I expect NULL means unassigned and a value means assigned?
Reinette
Moger, Babu
reviewerRe: [PATCH v9 14/26] x86/resctrl: Introduce interface to display number of free counters
Hi Reinette,
Quoted 205 lines · Reinette Chatre
Hi Babu,
Quoted 202 lines · Babu
Quoted 175 lines · Reinette Chatre
Quoted 174 lines · Babu
Quoted 102 lines · Peter Newman
Quoted 49 lines · Babu
Quoted 30 lines · Peter Newman
Quoted 28 lines · Reinette Chatre
Hi Babu,
Quoted 8 lines · Babu
1. Each group needs to remember counter ids in each domain for each event. For example:
Resctrl group mon1
Total event
dom 0cntr_id1,
dom 1cntr_id10
dom 2cntr_id11Quoted 4 lines
Local event
dom 0cntr_id2,
dom 1cntr_id15
dom 2cntr_id10Indeed. The challenge here is that domains may come and go so it cannot be a simple static array. As an alternative it can be an xarray indexed by the domain ID with pointers to a struct like below to contain the counters associated with the monitor group:
structcntr_id{
u32mbm_total;
u32mbm_local;
}Quoted 5 lines
Quoted 5 lines
Thinking more about how this array needs to be managed made me wonder how the current implementation deals with domains that come and go. I do not think this is currently handled. For example, if a new domain comes online and monitoring groups had counters dynamically assigned, then these counters are not configured to the newly online domain.
I am trying to understand the details of your approach here.
Quoted 10 lines
In my prototype, I allocated a counter id-indexed array to each monitoring domain structure for tracking the counter allocations, because the hardware counters are all domain-scoped. That way the tracking data goes away when the hardware does.
I was focused on allowing all pending counter updates to a domain resulting from a single
mbm_assign_controlwrite to be batched and processed in a single IPI, so I structured the counter tracker something like this:Quoted 8 lines
Not sure what you meant here. How are you batching two IPIs for two domains?
#echo "//0=t;1=t" >
/sys/fs/resctrl/info/L3_MON/mbm_assign_controlThis is still a single write. Two IPIs are sent separately, one for each domain.
Are you doing something different?
I said "all pending counter updates to a domain", whereby I meant targeting a single domain.
Depending on the CPU of the caller, your example write requires 1 or 2 IPIs.
What is important is that the following write also requires 1 or 2 IPIs:
(assuming /sys/fs/resctrl/mon_groups/[g1-g31] exist, line breaks added for readability)
echo $'//0=t;1=t\n
/g1/0=t;1=t\n
/g2/0=t;1=t\n
/g3/0=t;1=t\n
/g4/0=t;1=t\n
/g5/0=t;1=t\n
/g6/0=t;1=t\n
/g7/0=t;1=t\n
/g8/0=t;1=t\n
/g9/0=t;1=t\n
/g10/0=t;1=t\n
/g11/0=t;1=t\n
/g12/0=t;1=t\n
/g13/0=t;1=t\n
/g14/0=t;1=t\n
/g15/0=t;1=t\n
/g16/0=t;1=t\n
/g17/0=t;1=t\n
/g18/0=t;1=t\n
/g19/0=t;1=t\n
/g20/0=t;1=t\n
/g21/0=t;1=t\n
/g22/0=t;1=t\n
/g23/0=t;1=t\n
/g24/0=t;1=t\n
/g25/0=t;1=t\n
/g26/0=t;1=t\n
/g27/0=t;1=t\n
/g28/0=t;1=t\n
/g29/0=t;1=t\n
/g30/0=t;1=t\n
/g31/0=t;1=t\n'Quoted 6 lines
My ultimate goal is for a thread bound to a particular domain to be able to unassign and reassign the local domain's 32 counters in a single
write()with no IPIs at all. And when IPIs are required, then no more than one per domain, regardless of the number of groups updated.Yes. I think I got the idea. Thanks.
Quoted 48 lines
Quoted 48 lines
Quoted 10 lines
struct
resctrl_monitor_cfg{
int closid;
int rmid;
int evtid;
bool dirty;
};Quoted 3 lines
This mirrors the info needed in whatever register configures the counter, plus a dirty flag to skip over the ones that don't need to be updated.
This is what my understanding of your implementation.
include/linux/resctrl.h +7
-0@@ -94,6 +94,13 @@ struct rdt_ctrl_domain { u32 *mbps_val; }; +struct resctrl_monitor_cfg { + int closid; + int rmid; + int evtid; + bool dirty; +}; + /*** struct rdt_mon_domain - group of CPUs sharing a resctrl monitor resource
* @hdr: common header for different domain typesinclude/linux/resctrl.h +2
-0@@ -116,6 +123,7 @@ struct rdt_mon_domain { struct delayed_work cqm_limbo; int mbm_work_cpu; int cqm_work_cpu; + /* Allocate num_mbm_cntrs entries in each domain */ + struct resctrl_monitor_cfg *mon_cfg; };When a user requests an assignment for total event to the default group for domain 0, you go search in
rdt_mon_domain(dom 0)for emptymon_cfgentry.Quoted 7 lines
Quoted 5 lines
If there is an empty entry, then use that entry for assignment and update closid, rmid, evtid and dirty = 1. We can get all these information from default group here.
Does this make sense?
Yes, sounds correct.
I will probably add
cntr_idinresctrl_monitor_cfgstructure and initialize during the allocation. And rename the field 'dirty' to 'active'(or something similar) to hold the assign state for that entry. That way we have all the information required for assignment at one place. We don't need to update the rdtgroup structure.Quoted 6 lines
Quoted 1 line
Reinette, What do you think about this approach?
I think this approach is in the right direction. Thanks to Peter for the guidance here.
I do not think that it is necessary to addcntr_idtoresctrl_monitor_cfgthough, I think thecntr_idwould be the index to the array instead?Yes. I think We can use the index as
cntn_id. Will let you know otherwise.Quoted 5 lines
It may also be worthwhile to consider using a pointer to the resource group instead of storing closid and rmid directly. If used to indicate initialization then an initialized pointer is easier to distinguish than the closid/rmid that may have zero as valid values.
Sure. Sounds good.
Quoted 7 lines
I expect evtid will be enum
resctrl_event_idand that raises the question of whether "0" can indeed be used as an "uninitialized" value since doing so would change the meaning of the enum. It may indeed keep things separated by maintaining evtid as an enumresctrl_event_idand note the initialization differently ... either via a pointer to a resource group or entirely separately as Babu indicates later.
Quoted 6 lines
Quoted 2 lines
Sure. Will add evtid as enum
resctrl_event_idand use the "state" to indicate assign/unassign/dirty status.Is "assign/unassign" state needed? If
resctrl_monitor_cfgcontains a pointer to the resource group to which the counter has been assigned then I expect NULL means unassigned and a value means assigned?
Yes. We use the rdtgroup pointer to check the assign/unassign state.
I will drop the 'state' field. Peter can add state when he wants use it for optimization later.
I think we need to have the 'cntr_id" field here in resctrl_monitor_cfg. When we access the pointer from mbm_state, we wont know what is cntr_id index it came from.
Signature · 2 lines
Thanks Babu Moger
Reinette Chatre
maintainerRe: [PATCH v9 14/26] x86/resctrl: Introduce interface to display number of free counters
Hi Babu,
Quoted 215 lines · Babu
Hi Reinette,
Quoted 205 lines · Reinette Chatre
Hi Babu,
Quoted 202 lines · Babu
Quoted 175 lines · Reinette Chatre
Quoted 174 lines · Babu
Quoted 102 lines · Peter Newman
Quoted 49 lines · Babu
Quoted 30 lines · Peter Newman
Quoted 28 lines · Reinette Chatre
Hi Babu,
Quoted 8 lines · Babu
1. Each group needs to remember counter ids in each domain for each event. For example:
Resctrl group mon1
Total event
dom 0cntr_id1,
dom 1cntr_id10
dom 2cntr_id11Quoted 4 lines
Local event
dom 0cntr_id2,
dom 1cntr_id15
dom 2cntr_id10Indeed. The challenge here is that domains may come and go so it cannot be a simple static array. As an alternative it can be an xarray indexed by the domain ID with pointers to a struct like below to contain the counters associated with the monitor group:
structcntr_id{
u32mbm_total;
u32mbm_local;
}Quoted 5 lines
Quoted 5 lines
Thinking more about how this array needs to be managed made me wonder how the current implementation deals with domains that come and go. I do not think this is currently handled. For example, if a new domain comes online and monitoring groups had counters dynamically assigned, then these counters are not configured to the newly online domain.
I am trying to understand the details of your approach here.
Quoted 10 lines
In my prototype, I allocated a counter id-indexed array to each monitoring domain structure for tracking the counter allocations, because the hardware counters are all domain-scoped. That way the tracking data goes away when the hardware does.
I was focused on allowing all pending counter updates to a domain resulting from a single
mbm_assign_controlwrite to be batched and processed in a single IPI, so I structured the counter tracker something like this:Quoted 8 lines
Not sure what you meant here. How are you batching two IPIs for two domains?
#echo "//0=t;1=t" >
/sys/fs/resctrl/info/L3_MON/mbm_assign_controlThis is still a single write. Two IPIs are sent separately, one for each domain.
Are you doing something different?
I said "all pending counter updates to a domain", whereby I meant targeting a single domain.
Depending on the CPU of the caller, your example write requires 1 or 2 IPIs.
What is important is that the following write also requires 1 or 2 IPIs:
(assuming /sys/fs/resctrl/mon_groups/[g1-g31] exist, line breaks added for readability)
echo $'//0=t;1=t\n
/g1/0=t;1=t\n
/g2/0=t;1=t\n
/g3/0=t;1=t\n
/g4/0=t;1=t\n
/g5/0=t;1=t\n
/g6/0=t;1=t\n
/g7/0=t;1=t\n
/g8/0=t;1=t\n
/g9/0=t;1=t\n
/g10/0=t;1=t\n
/g11/0=t;1=t\n
/g12/0=t;1=t\n
/g13/0=t;1=t\n
/g14/0=t;1=t\n
/g15/0=t;1=t\n
/g16/0=t;1=t\n
/g17/0=t;1=t\n
/g18/0=t;1=t\n
/g19/0=t;1=t\n
/g20/0=t;1=t\n
/g21/0=t;1=t\n
/g22/0=t;1=t\n
/g23/0=t;1=t\n
/g24/0=t;1=t\n
/g25/0=t;1=t\n
/g26/0=t;1=t\n
/g27/0=t;1=t\n
/g28/0=t;1=t\n
/g29/0=t;1=t\n
/g30/0=t;1=t\n
/g31/0=t;1=t\n'Quoted 6 lines
My ultimate goal is for a thread bound to a particular domain to be able to unassign and reassign the local domain's 32 counters in a single
write()with no IPIs at all. And when IPIs are required, then no more than one per domain, regardless of the number of groups updated.Yes. I think I got the idea. Thanks.
Quoted 48 lines
Quoted 48 lines
Quoted 10 lines
struct
resctrl_monitor_cfg{
int closid;
int rmid;
int evtid;
bool dirty;
};Quoted 3 lines
This mirrors the info needed in whatever register configures the counter, plus a dirty flag to skip over the ones that don't need to be updated.
This is what my understanding of your implementation.
include/linux/resctrl.h +7
-0@@ -94,6 +94,13 @@ struct rdt_ctrl_domain { u32 *mbps_val; }; +struct resctrl_monitor_cfg { + int closid; + int rmid; + int evtid; + bool dirty; +}; + /*** struct rdt_mon_domain - group of CPUs sharing a resctrl monitor resource
* @hdr: common header for different domain typesinclude/linux/resctrl.h +2
-0@@ -116,6 +123,7 @@ struct rdt_mon_domain { struct delayed_work cqm_limbo; int mbm_work_cpu; int cqm_work_cpu; + /* Allocate num_mbm_cntrs entries in each domain */ + struct resctrl_monitor_cfg *mon_cfg; };When a user requests an assignment for total event to the default group for domain 0, you go search in
rdt_mon_domain(dom 0)for emptymon_cfgentry.Quoted 7 lines
Quoted 5 lines
If there is an empty entry, then use that entry for assignment and update closid, rmid, evtid and dirty = 1. We can get all these information from default group here.
Does this make sense?
Yes, sounds correct.
I will probably add
cntr_idinresctrl_monitor_cfgstructure and initialize during the allocation. And rename the field 'dirty' to 'active'(or something similar) to hold the assign state for that entry. That way we have all the information required for assignment at one place. We don't need to update the rdtgroup structure.Quoted 6 lines
Quoted 1 line
Reinette, What do you think about this approach?
I think this approach is in the right direction. Thanks to Peter for the guidance here.
I do not think that it is necessary to addcntr_idtoresctrl_monitor_cfgthough, I think thecntr_idwould be the index to the array instead?Yes. I think We can use the index as
cntn_id. Will let you know otherwise.Quoted 5 lines
It may also be worthwhile to consider using a pointer to the resource group instead of storing closid and rmid directly. If used to indicate initialization then an initialized pointer is easier to distinguish than the closid/rmid that may have zero as valid values.
Sure. Sounds good.
Quoted 7 lines
I expect evtid will be enum
resctrl_event_idand that raises the question of whether "0" can indeed be used as an "uninitialized" value since doing so would change the meaning of the enum. It may indeed keep things separated by maintaining evtid as an enumresctrl_event_idand note the initialization differently ... either via a pointer to a resource group or entirely separately as Babu indicates later.Quoted 6 lines
Quoted 2 lines
Sure. Will add evtid as enum
resctrl_event_idand use the "state" to indicate assign/unassign/dirty status.Is "assign/unassign" state needed? If
resctrl_monitor_cfgcontains a pointer to the resource group to which the counter has been assigned then I expect NULL means unassigned and a value means assigned?
Quoted 9 lines
Yes. We use the rdtgroup pointer to check the assign/unassign state.
I will drop the 'state' field. Peter can add state when he wants use it for optimization later.
I think we need to have the '
cntr_id" field here inresctrl_monitor_cfg. When we access the pointer frommbm_state, we wont know what iscntr_idindex it came from.
oh, good point. I wonder how Peter addressed this in his PoC. As an alternative, could the cntr_id be used in mbm_state instead of a pointer?
Reinette
Moger, Babu
reviewerRe: [PATCH v9 14/26] x86/resctrl: Introduce interface to display number of free counters
Hi Reinette,
Quoted 223 lines · Reinette Chatre
Hi Babu,
Quoted 220 lines · Babu
Hi Reinette,
Quoted 205 lines · Reinette Chatre
Hi Babu,
Quoted 202 lines · Babu
Quoted 175 lines · Reinette Chatre
Quoted 174 lines · Babu
Quoted 102 lines · Peter Newman
Quoted 49 lines · Babu
Quoted 30 lines · Peter Newman
Quoted 28 lines · Reinette Chatre
Hi Babu,
Quoted 8 lines · Babu
1. Each group needs to remember counter ids in each domain for each event. For example:
Resctrl group mon1
Total event
dom 0cntr_id1,
dom 1cntr_id10
dom 2cntr_id11Quoted 4 lines
Local event
dom 0cntr_id2,
dom 1cntr_id15
dom 2cntr_id10Indeed. The challenge here is that domains may come and go so it cannot be a simple static array. As an alternative it can be an xarray indexed by the domain ID with pointers to a struct like below to contain the counters associated with the monitor group:
structcntr_id{
u32mbm_total;
u32mbm_local;
}Quoted 5 lines
Quoted 5 lines
Thinking more about how this array needs to be managed made me wonder how the current implementation deals with domains that come and go. I do not think this is currently handled. For example, if a new domain comes online and monitoring groups had counters dynamically assigned, then these counters are not configured to the newly online domain.
I am trying to understand the details of your approach here.
Quoted 10 lines
In my prototype, I allocated a counter id-indexed array to each monitoring domain structure for tracking the counter allocations, because the hardware counters are all domain-scoped. That way the tracking data goes away when the hardware does.
I was focused on allowing all pending counter updates to a domain resulting from a single
mbm_assign_controlwrite to be batched and processed in a single IPI, so I structured the counter tracker something like this:Quoted 8 lines
Not sure what you meant here. How are you batching two IPIs for two domains?
#echo "//0=t;1=t" >
/sys/fs/resctrl/info/L3_MON/mbm_assign_controlThis is still a single write. Two IPIs are sent separately, one for each domain.
Are you doing something different?
I said "all pending counter updates to a domain", whereby I meant targeting a single domain.
Depending on the CPU of the caller, your example write requires 1 or 2 IPIs.
What is important is that the following write also requires 1 or 2 IPIs:
(assuming /sys/fs/resctrl/mon_groups/[g1-g31] exist, line breaks added for readability)
echo $'//0=t;1=t\n
/g1/0=t;1=t\n
/g2/0=t;1=t\n
/g3/0=t;1=t\n
/g4/0=t;1=t\n
/g5/0=t;1=t\n
/g6/0=t;1=t\n
/g7/0=t;1=t\n
/g8/0=t;1=t\n
/g9/0=t;1=t\n
/g10/0=t;1=t\n
/g11/0=t;1=t\n
/g12/0=t;1=t\n
/g13/0=t;1=t\n
/g14/0=t;1=t\n
/g15/0=t;1=t\n
/g16/0=t;1=t\n
/g17/0=t;1=t\n
/g18/0=t;1=t\n
/g19/0=t;1=t\n
/g20/0=t;1=t\n
/g21/0=t;1=t\n
/g22/0=t;1=t\n
/g23/0=t;1=t\n
/g24/0=t;1=t\n
/g25/0=t;1=t\n
/g26/0=t;1=t\n
/g27/0=t;1=t\n
/g28/0=t;1=t\n
/g29/0=t;1=t\n
/g30/0=t;1=t\n
/g31/0=t;1=t\n'Quoted 6 lines
My ultimate goal is for a thread bound to a particular domain to be able to unassign and reassign the local domain's 32 counters in a single
write()with no IPIs at all. And when IPIs are required, then no more than one per domain, regardless of the number of groups updated.Yes. I think I got the idea. Thanks.
Quoted 48 lines
Quoted 48 lines
Quoted 10 lines
struct
resctrl_monitor_cfg{
int closid;
int rmid;
int evtid;
bool dirty;
};Quoted 3 lines
This mirrors the info needed in whatever register configures the counter, plus a dirty flag to skip over the ones that don't need to be updated.
This is what my understanding of your implementation.
include/linux/resctrl.h +7
-0@@ -94,6 +94,13 @@ struct rdt_ctrl_domain { u32 *mbps_val; }; +struct resctrl_monitor_cfg { + int closid; + int rmid; + int evtid; + bool dirty; +}; + /*** struct rdt_mon_domain - group of CPUs sharing a resctrl monitor resource
* @hdr: common header for different domain typesinclude/linux/resctrl.h +2
-0@@ -116,6 +123,7 @@ struct rdt_mon_domain { struct delayed_work cqm_limbo; int mbm_work_cpu; int cqm_work_cpu; + /* Allocate num_mbm_cntrs entries in each domain */ + struct resctrl_monitor_cfg *mon_cfg; };When a user requests an assignment for total event to the default group for domain 0, you go search in
rdt_mon_domain(dom 0)for emptymon_cfgentry.Quoted 7 lines
Quoted 5 lines
If there is an empty entry, then use that entry for assignment and update closid, rmid, evtid and dirty = 1. We can get all these information from default group here.
Does this make sense?
Yes, sounds correct.
I will probably add
cntr_idinresctrl_monitor_cfgstructure and initialize during the allocation. And rename the field 'dirty' to 'active'(or something similar) to hold the assign state for that entry. That way we have all the information required for assignment at one place. We don't need to update the rdtgroup structure.Quoted 6 lines
Quoted 1 line
Reinette, What do you think about this approach?
I think this approach is in the right direction. Thanks to Peter for the guidance here.
I do not think that it is necessary to addcntr_idtoresctrl_monitor_cfgthough, I think thecntr_idwould be the index to the array instead?Yes. I think We can use the index as
cntn_id. Will let you know otherwise.Quoted 5 lines
It may also be worthwhile to consider using a pointer to the resource group instead of storing closid and rmid directly. If used to indicate initialization then an initialized pointer is easier to distinguish than the closid/rmid that may have zero as valid values.
Sure. Sounds good.
Quoted 7 lines
I expect evtid will be enum
resctrl_event_idand that raises the question of whether "0" can indeed be used as an "uninitialized" value since doing so would change the meaning of the enum. It may indeed keep things separated by maintaining evtid as an enumresctrl_event_idand note the initialization differently ... either via a pointer to a resource group or entirely separately as Babu indicates later.Quoted 6 lines
Quoted 2 lines
Sure. Will add evtid as enum
resctrl_event_idand use the "state" to indicate assign/unassign/dirty status.Is "assign/unassign" state needed? If
resctrl_monitor_cfgcontains a pointer to the resource group to which the counter has been assigned then I expect NULL means unassigned and a value means assigned?Yes. We use the rdtgroup pointer to check the assign/unassign state.
I will drop the 'state' field. Peter can add state when he wants use it for optimization later.
Quoted 8 lines
Quoted 4 lines
I think we need to have the '
cntr_id" field here inresctrl_monitor_cfg. When we access the pointer frommbm_state, we wont know what iscntr_idindex it came from.oh, good point. I wonder how Peter addressed this in his PoC. As an alternative, could the
cntr_idbe used inmbm_stateinstead of a pointer?
Yes. It can be done.
I thought it would be better to have everything at once place.
struct resctrl_monitor_cfg {
unsigned int cntr_id; enum resctrl_event_id evtid; struct rdtgroup *rgtgrp;
};
This will have everything required to assign/unassign the event.
Thanks
Babu Moger
Reinette Chatre
maintainerRe: [PATCH v9 14/26] x86/resctrl: Introduce interface to display number of free counters
Hi Babu,
Quoted 239 lines · Babu
Hi Reinette,
Quoted 223 lines · Reinette Chatre
Hi Babu,
Quoted 220 lines · Babu
Hi Reinette,
Quoted 205 lines · Reinette Chatre
Hi Babu,
Quoted 202 lines · Babu
Quoted 175 lines · Reinette Chatre
Quoted 174 lines · Babu
Quoted 102 lines · Peter Newman
Quoted 49 lines · Babu
Quoted 30 lines · Peter Newman
Quoted 28 lines · Reinette Chatre
Hi Babu,
Quoted 8 lines · Babu
1. Each group needs to remember counter ids in each domain for each event. For example:
Resctrl group mon1
Total event
dom 0cntr_id1,
dom 1cntr_id10
dom 2cntr_id11Quoted 4 lines
Local event
dom 0cntr_id2,
dom 1cntr_id15
dom 2cntr_id10Indeed. The challenge here is that domains may come and go so it cannot be a simple static array. As an alternative it can be an xarray indexed by the domain ID with pointers to a struct like below to contain the counters associated with the monitor group:
structcntr_id{
u32mbm_total;
u32mbm_local;
}Quoted 5 lines
Quoted 5 lines
Thinking more about how this array needs to be managed made me wonder how the current implementation deals with domains that come and go. I do not think this is currently handled. For example, if a new domain comes online and monitoring groups had counters dynamically assigned, then these counters are not configured to the newly online domain.
I am trying to understand the details of your approach here.
Quoted 10 lines
In my prototype, I allocated a counter id-indexed array to each monitoring domain structure for tracking the counter allocations, because the hardware counters are all domain-scoped. That way the tracking data goes away when the hardware does.
I was focused on allowing all pending counter updates to a domain resulting from a single
mbm_assign_controlwrite to be batched and processed in a single IPI, so I structured the counter tracker something like this:Quoted 8 lines
Not sure what you meant here. How are you batching two IPIs for two domains?
#echo "//0=t;1=t" >
/sys/fs/resctrl/info/L3_MON/mbm_assign_controlThis is still a single write. Two IPIs are sent separately, one for each domain.
Are you doing something different?
I said "all pending counter updates to a domain", whereby I meant targeting a single domain.
Depending on the CPU of the caller, your example write requires 1 or 2 IPIs.
What is important is that the following write also requires 1 or 2 IPIs:
(assuming /sys/fs/resctrl/mon_groups/[g1-g31] exist, line breaks added for readability)
echo $'//0=t;1=t\n
/g1/0=t;1=t\n
/g2/0=t;1=t\n
/g3/0=t;1=t\n
/g4/0=t;1=t\n
/g5/0=t;1=t\n
/g6/0=t;1=t\n
/g7/0=t;1=t\n
/g8/0=t;1=t\n
/g9/0=t;1=t\n
/g10/0=t;1=t\n
/g11/0=t;1=t\n
/g12/0=t;1=t\n
/g13/0=t;1=t\n
/g14/0=t;1=t\n
/g15/0=t;1=t\n
/g16/0=t;1=t\n
/g17/0=t;1=t\n
/g18/0=t;1=t\n
/g19/0=t;1=t\n
/g20/0=t;1=t\n
/g21/0=t;1=t\n
/g22/0=t;1=t\n
/g23/0=t;1=t\n
/g24/0=t;1=t\n
/g25/0=t;1=t\n
/g26/0=t;1=t\n
/g27/0=t;1=t\n
/g28/0=t;1=t\n
/g29/0=t;1=t\n
/g30/0=t;1=t\n
/g31/0=t;1=t\n'Quoted 6 lines
My ultimate goal is for a thread bound to a particular domain to be able to unassign and reassign the local domain's 32 counters in a single
write()with no IPIs at all. And when IPIs are required, then no more than one per domain, regardless of the number of groups updated.Yes. I think I got the idea. Thanks.
Quoted 48 lines
Quoted 48 lines
Quoted 10 lines
struct
resctrl_monitor_cfg{
int closid;
int rmid;
int evtid;
bool dirty;
};Quoted 3 lines
This mirrors the info needed in whatever register configures the counter, plus a dirty flag to skip over the ones that don't need to be updated.
This is what my understanding of your implementation.
include/linux/resctrl.h +7
-0@@ -94,6 +94,13 @@ struct rdt_ctrl_domain { u32 *mbps_val; }; +struct resctrl_monitor_cfg { + int closid; + int rmid; + int evtid; + bool dirty; +}; + /*** struct rdt_mon_domain - group of CPUs sharing a resctrl monitor resource
* @hdr: common header for different domain typesinclude/linux/resctrl.h +2
-0@@ -116,6 +123,7 @@ struct rdt_mon_domain { struct delayed_work cqm_limbo; int mbm_work_cpu; int cqm_work_cpu; + /* Allocate num_mbm_cntrs entries in each domain */ + struct resctrl_monitor_cfg *mon_cfg; };When a user requests an assignment for total event to the default group for domain 0, you go search in
rdt_mon_domain(dom 0)for emptymon_cfgentry.Quoted 7 lines
Quoted 5 lines
If there is an empty entry, then use that entry for assignment and update closid, rmid, evtid and dirty = 1. We can get all these information from default group here.
Does this make sense?
Yes, sounds correct.
I will probably add
cntr_idinresctrl_monitor_cfgstructure and initialize during the allocation. And rename the field 'dirty' to 'active'(or something similar) to hold the assign state for that entry. That way we have all the information required for assignment at one place. We don't need to update the rdtgroup structure.Quoted 6 lines
Quoted 1 line
Reinette, What do you think about this approach?
I think this approach is in the right direction. Thanks to Peter for the guidance here.
I do not think that it is necessary to addcntr_idtoresctrl_monitor_cfgthough, I think thecntr_idwould be the index to the array instead?Yes. I think We can use the index as
cntn_id. Will let you know otherwise.Quoted 5 lines
It may also be worthwhile to consider using a pointer to the resource group instead of storing closid and rmid directly. If used to indicate initialization then an initialized pointer is easier to distinguish than the closid/rmid that may have zero as valid values.
Sure. Sounds good.
Quoted 7 lines
I expect evtid will be enum
resctrl_event_idand that raises the question of whether "0" can indeed be used as an "uninitialized" value since doing so would change the meaning of the enum. It may indeed keep things separated by maintaining evtid as an enumresctrl_event_idand note the initialization differently ... either via a pointer to a resource group or entirely separately as Babu indicates later.Quoted 6 lines
Quoted 2 lines
Sure. Will add evtid as enum
resctrl_event_idand use the "state" to indicate assign/unassign/dirty status.Is "assign/unassign" state needed? If
resctrl_monitor_cfgcontains a pointer to the resource group to which the counter has been assigned then I expect NULL means unassigned and a value means assigned?Yes. We use the rdtgroup pointer to check the assign/unassign state.
I will drop the 'state' field. Peter can add state when he wants use it for optimization later.
Quoted 8 lines
Quoted 4 lines
I think we need to have the '
cntr_id" field here inresctrl_monitor_cfg. When we access the pointer frommbm_state, we wont know what iscntr_idindex it came from.oh, good point. I wonder how Peter addressed this in his PoC. As an alternative, could the
cntr_idbe used inmbm_stateinstead of a pointer?Yes. It can be done.
I thought it would be better to have everything at once place.
Quoted 8 lines
struct
resctrl_monitor_cfg{unsigned int cntr_id; enum resctrl_event_id evtid; struct rdtgroup *rgtgrp;};
This will have everything required to assign/unassign the event.
The "everything in one place" argument is not clear to me since the cntr_id is indeed present already as the index to the array that stores this structure. Including the cntr_id seems redundant to me. This is similar to several other data structures in resctrl that are indexed either by closid or rmid, without needing to store closid/rmid in these data structures self.
Reinette
Moger, Babu
reviewerRe: [PATCH v9 14/26] x86/resctrl: Introduce interface to display number of free counters
Hi Reinette,
Quoted 248 lines · Reinette Chatre
Hi Babu,
Quoted 245 lines · Babu
Hi Reinette,
Quoted 223 lines · Reinette Chatre
Hi Babu,
Quoted 220 lines · Babu
Hi Reinette,
Quoted 205 lines · Reinette Chatre
Hi Babu,
Quoted 202 lines · Babu
Quoted 175 lines · Reinette Chatre
Quoted 174 lines · Babu
Quoted 102 lines · Peter Newman
Quoted 49 lines · Babu
Quoted 30 lines · Peter Newman
Quoted 28 lines · Reinette Chatre
Hi Babu,
Quoted 12 lines · Babu
1. Each group needs to remember counter ids in each domain for each event.
For example:
Resctrl group mon1
Total event
dom 0 cntr_id 1,
dom 1 cntr_id 10
dom 2 cntr_id 11Local event
dom 0 cntr_id 2,
dom 1 cntr_id 15
dom 2 cntr_id 10Indeed. The challenge here is that domains may come and go so it cannot be a simple static array. As an alternative it can be an xarray indexed by the domain ID with pointers to a struct like below to contain the counters associated with the monitor group:
structcntr_id{
u32mbm_total;
u32mbm_local;
}Quoted 5 lines
Quoted 5 lines
Thinking more about how this array needs to be managed made me wonder how the current implementation deals with domains that come and go. I do not think this is currently handled. For example, if a new domain comes online and monitoring groups had counters dynamically assigned, then these counters are not configured to the newly online domain.
I am trying to understand the details of your approach here.
Quoted 10 lines
In my prototype, I allocated a counter id-indexed array to each monitoring domain structure for tracking the counter allocations, because the hardware counters are all domain-scoped. That way the tracking data goes away when the hardware does.
I was focused on allowing all pending counter updates to a domain resulting from a single
mbm_assign_controlwrite to be batched and processed in a single IPI, so I structured the counter tracker something like this:Quoted 8 lines
Not sure what you meant here. How are you batching two IPIs for two domains?
#echo "//0=t;1=t" >
/sys/fs/resctrl/info/L3_MON/mbm_assign_controlThis is still a single write. Two IPIs are sent separately, one for each domain.
Are you doing something different?
I said "all pending counter updates to a domain", whereby I meant targeting a single domain.
Depending on the CPU of the caller, your example write requires 1 or 2 IPIs.
What is important is that the following write also requires 1 or 2 IPIs:
(assuming /sys/fs/resctrl/mon_groups/[g1-g31] exist, line breaks added for readability)
echo $'//0=t;1=t\n
/g1/0=t;1=t\n
/g2/0=t;1=t\n
/g3/0=t;1=t\n
/g4/0=t;1=t\n
/g5/0=t;1=t\n
/g6/0=t;1=t\n
/g7/0=t;1=t\n
/g8/0=t;1=t\n
/g9/0=t;1=t\n
/g10/0=t;1=t\n
/g11/0=t;1=t\n
/g12/0=t;1=t\n
/g13/0=t;1=t\n
/g14/0=t;1=t\n
/g15/0=t;1=t\n
/g16/0=t;1=t\n
/g17/0=t;1=t\n
/g18/0=t;1=t\n
/g19/0=t;1=t\n
/g20/0=t;1=t\n
/g21/0=t;1=t\n
/g22/0=t;1=t\n
/g23/0=t;1=t\n
/g24/0=t;1=t\n
/g25/0=t;1=t\n
/g26/0=t;1=t\n
/g27/0=t;1=t\n
/g28/0=t;1=t\n
/g29/0=t;1=t\n
/g30/0=t;1=t\n
/g31/0=t;1=t\n'Quoted 6 lines
My ultimate goal is for a thread bound to a particular domain to be able to unassign and reassign the local domain's 32 counters in a single
write()with no IPIs at all. And when IPIs are required, then no more than one per domain, regardless of the number of groups updated.Yes. I think I got the idea. Thanks.
Quoted 48 lines
Quoted 48 lines
Quoted 10 lines
struct
resctrl_monitor_cfg{
int closid;
int rmid;
int evtid;
bool dirty;
};Quoted 3 lines
This mirrors the info needed in whatever register configures the counter, plus a dirty flag to skip over the ones that don't need to be updated.
This is what my understanding of your implementation.
include/linux/resctrl.h +7
-0@@ -94,6 +94,13 @@ struct rdt_ctrl_domain { u32 *mbps_val; }; +struct resctrl_monitor_cfg { + int closid; + int rmid; + int evtid; + bool dirty; +}; + /*** struct rdt_mon_domain - group of CPUs sharing a resctrl monitor resource
* @hdr: common header for different domain typesinclude/linux/resctrl.h +2
-0@@ -116,6 +123,7 @@ struct rdt_mon_domain { struct delayed_work cqm_limbo; int mbm_work_cpu; int cqm_work_cpu; + /* Allocate num_mbm_cntrs entries in each domain */ + struct resctrl_monitor_cfg *mon_cfg; };When a user requests an assignment for total event to the default group for domain 0, you go search in
rdt_mon_domain(dom 0)for emptymon_cfgentry.Quoted 7 lines
Quoted 5 lines
If there is an empty entry, then use that entry for assignment and update closid, rmid, evtid and dirty = 1. We can get all these information from default group here.
Does this make sense?
Yes, sounds correct.
I will probably add
cntr_idinresctrl_monitor_cfgstructure and initialize during the allocation. And rename the field 'dirty' to 'active'(or something similar) to hold the assign state for that entry. That way we have all the information required for assignment at one place. We don't need to update the rdtgroup structure.Quoted 6 lines
Quoted 1 line
Reinette, What do you think about this approach?
I think this approach is in the right direction. Thanks to Peter for the guidance here.
I do not think that it is necessary to addcntr_idtoresctrl_monitor_cfgthough, I think thecntr_idwould be the index to the array instead?Yes. I think We can use the index as
cntn_id. Will let you know otherwise.Quoted 5 lines
It may also be worthwhile to consider using a pointer to the resource group instead of storing closid and rmid directly. If used to indicate initialization then an initialized pointer is easier to distinguish than the closid/rmid that may have zero as valid values.
Sure. Sounds good.
Quoted 7 lines
I expect evtid will be enum
resctrl_event_idand that raises the question of whether "0" can indeed be used as an "uninitialized" value since doing so would change the meaning of the enum. It may indeed keep things separated by maintaining evtid as an enumresctrl_event_idand note the initialization differently ... either via a pointer to a resource group or entirely separately as Babu indicates later.Quoted 6 lines
Quoted 2 lines
Sure. Will add evtid as enum
resctrl_event_idand use the "state" to indicate assign/unassign/dirty status.Is "assign/unassign" state needed? If
resctrl_monitor_cfgcontains a pointer to the resource group to which the counter has been assigned then I expect NULL means unassigned and a value means assigned?Yes. We use the rdtgroup pointer to check the assign/unassign state.
I will drop the 'state' field. Peter can add state when he wants use it for optimization later.
Quoted 8 lines
Quoted 4 lines
I think we need to have the '
cntr_id" field here inresctrl_monitor_cfg. When we access the pointer frommbm_state, we wont know what iscntr_idindex it came from.oh, good point. I wonder how Peter addressed this in his PoC. As an alternative, could the
cntr_idbe used inmbm_stateinstead of a pointer?Yes. It can be done.
I thought it would be better to have everything at once place.
struct
resctrl_monitor_cfg{unsigned int cntr_id; enum resctrl_event_id evtid; struct rdtgroup *rgtgrp;};
Quoted 9 lines
Quoted 2 lines
This will have everything required to assign/unassign the event.
The "everything in one place" argument is not clear to me since the
cntr_idis indeed present already as the index to the array that stores this structure. Including thecntr_idseems redundant to me. This is similar to several other data structures in resctrl that are indexed either by closid or rmid, without needing to store closid/rmid in these data structures self.
Ok. That is fine. Will remove cntr_id index from resctrl_monitor_cfg. Will add it in mbm_state. That should be good.
Signature · 2 lines
Thanks Babu Moger
Babu Moger
reviewerPATCH v9 15/26 x86/resctrl: Add data structures and definitions for ABMC assignment
In reply to Babu MogerThe ABMC feature provides an option to the user to assign a hardware counter to an RMID, event pair and monitor the bandwidth as long as the counter is assigned. The bandwidth events will be tracked by the hardware until the user changes the configuration. Each resctrl group can configure maximum two counters, one for total event and one for local event.
The ABMC feature implements an MSR L3_QOS_ABMC_CFG (C000_03FDh). Configuration is done by setting the counter id, bandwidth source (RMID) and bandwidth configuration supported by BMEC (Bandwidth Monitoring Event Configuration).
Attempts to read or write the MSR when ABMC is not enabled will result in a #GP(0) exception.
Introduce the data structures and definitions for MSR L3_QOS_ABMC_CFG (0xC000_03FDh):
=========================================================================
Bits Mnemonic Description Access Reset
Type Value
=========================================================================
63 CfgEn Configuration Enable R/W 0
62 CtrEn Enable/disable counting R/W 0
61:53 – Reserved MBZ 0
52:48 CtrID Counter Identifier R/W 0
47 IsCOS BwSrc field is a CLOSID R/W 0
(not an RMID)
46:44 – Reserved MBZ 0
43:32 BwSrc Bandwidth Source R/W 0
(RMID or CLOSID)
31:0 BwType Bandwidth configuration R/W 0
to track for this counter
==========================================================================
The feature details are documented in the APM listed below [1].
[1] AMD64 Architecture Programmer's Manual Volume 2: System Programming Publication # 24593 Revision 3.41 section 19.3.3.3 Assignable Bandwidth Monitoring (ABMC).
---
v9: Removed the references of L3_QOS_ABMC_DSC.
Text changes about configuration in kernel doc.
v8: Update the configuration notes in kernel_doc.
Few commit message update.
v7: Removed the reference of L3_QOS_ABMC_DSC as it is not used anymore.
Moved the configuration notes to kernel_doc.
Adjusted the tabs for l3_qos_abmc_cfg and checkpatch seems happy.
v6: Removed all the fs related changes.
Added note on CfgEn,CtrEn.
Removed the definitions which are not used.
Removed cntr_id initialization.
v5: Moved assignment flags here (path 10/19 of v4).
Added MON_CNTR_UNSET definition to initialize cntr_id's. More details in commit log.
Renamed few fields in l3_qos_abmc_cfg for readability.
v4: Added more descriptions.
Changed the name abmc_ctr_id to ctr_id.
Added L3_QOS_ABMC_DSC. Used for reading the configuration.
v3: No changes.
v2: No changes.
--- arch/x86/include/asm/msr-index.h | 1 + arch/x86/kernel/cpu/resctrl/internal.h | 35 ++++++++++++++++++++++++++ 2 files changed, 36 insertions(+)
arch/x86/include/asm/msr-index.h +1 -0
@@ -1194,6 +1194,7 @@/* - AMD: */ #define MSR_IA32_MBA_BW_BASE 0xc0000200#define MSR_IA32_SMBA_BW_BASE 0xc0000280 +#define MSR_IA32_L3_QOS_ABMC_CFG 0xc00003fd#define MSR_IA32_L3_QOS_EXT_CFG 0xc00003ff#define MSR_IA32_EVT_CFG_BASE 0xc0000400
arch/x86/kernel/cpu/resctrl/internal.h +35 -0
@@ -602,6 +602,41 @@ union cpuid_0x10_x_edx {unsigned int full; }; +/* +* ABMC counters are configured by writing to L3_QOS_ABMC_CFG. +* @bw_type : Bandwidth configuration (supported by BMEC) +* tracked by the @cntr_id. +* @bw_src : Bandwidth source (RMID or CLOSID). +* @reserved1 : Reserved. +* @is_clos : @bw_src field is a CLOSID (not an RMID). +* @cntr_id : Counter identifier. +* @reserved : Reserved. +* @cntr_en : Counting enable bit. +* @cfg_en : Configuration enable bit. +* +* Configuration and counting: +* Counter can be configured across multiple writes to MSR. Configuration +* is applied only when @cfg_en = 1. Counter @cntr_id is reset when the +* configuration is applied. +* @cfg_en = 1, @cntr_en = 0 : Apply @cntr_id configuration but do not +* count events. +* @cfg_en = 1, @cntr_en = 1 : Apply @cntr_id configuration and start +* counting events. +*/ +union l3_qos_abmc_cfg { +struct { +unsigned long bw_type :32 , + bw_src :12 , + reserved1:3 , + is_clos :1 , + cntr_id :5 , + reserved :9 , + cntr_en :1 , + cfg_en :1 ; + } split; +unsigned long full; +}; +void rdt_last_cmd_clear (void );void rdt_last_cmd_puts (const char *s);__printf (1 ,2 )
Signature · 1 line
2.34.1
Re: [PATCH v9 15/26] x86/resctrl: Add data structures and definitions for ABMC assignment
Hi Babu,
Quoted 40 lines · Babu Moger
The ABMC feature provides an option to the user to assign a hardware counter to an RMID, event pair and monitor the bandwidth as long as the counter is assigned. The bandwidth events will be tracked by the hardware until the user changes the configuration. Each resctrl group can configure maximum two counters, one for total event and one for local event.
The ABMC feature implements an MSR
L3_QOS_ABMC_CFG(C000_03FDh). Configuration is done by setting the counter id, bandwidth source (RMID) and bandwidth configuration supported by BMEC (Bandwidth Monitoring Event Configuration).Attempts to read or write the MSR when ABMC is not enabled will result in a #GP(0) exception.
Introduce the data structures and definitions for MSR
L3_QOS_ABMC_CFG(0xC000_03FDh):
=========================================================================
Bits Mnemonic Description Access Reset
Type Value
=========================================================================
63 CfgEn Configuration Enable R/W 062 CtrEn Enable/disable counting R/W 0
61:53 – Reserved MBZ 0
52:48 CtrID Counter Identifier R/W 0
47 IsCOS BwSrc field is a CLOSID R/W 0
(not an RMID)46:44 – Reserved MBZ 0
43:32 BwSrc Bandwidth Source R/W 0
(RMID or CLOSID)31:0 BwType Bandwidth configuration R/W 0
to track for this counter
==========================================================================
Quoted 8 lines
The feature details are documented in the APM listed below [1].
[1] AMD64 Architecture Programmer's Manual Volume 2: System Programming Publication # 24593 Revision 3.41 section 19.3.3.3 Assignable Bandwidth Monitoring (ABMC).---
Reinette
Babu Moger
reviewerPATCH v9 16/26 x86/resctrl: Introduce cntr_id in mongroup for assignments
In reply to Babu Mogermbm_cntr_assign feature provides an option to the user to assign a counter to an RMID, event pair and monitor the bandwidth as long as the counter is assigned. There can be two counters per monitor group, one for MBM total event and another for MBM local event.
Introduce cntr_id to manage the assignments.
---
v9: Used MBM_EVENT_ARRAY_INDEX macro to get the event index.
Introduced rdtgroup_cntr_id_init() to initialize the cntr_id.
v8: Minor commit message update.
v7: Minor comment update for cntr_id.
v6: New patch.
Separated FS and arch bits.
--- arch/x86/kernel/cpu/resctrl/internal.h | 14 ++++++++++++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 15 +++++++++++++++ 2 files changed, 29 insertions(+)
arch/x86/kernel/cpu/resctrl/internal.h +14 -0
@@ -62,6 +62,18 @@/* Setting bit 0 in L3_QOS_EXT_CFG enables the ABMC feature. */ #define ABMC_ENABLE_BIT 0 +/* Maximum assignable counters per resctrl group */ +#define MAX_CNTRS 2 + +#define MON_CNTR_UNSET U32_MAX + +/* +* Get the counter index for the assignable counter +* 0 for evtid == QOS_L3_MBM_TOTAL_EVENT_ID +* 1 for evtid == QOS_L3_MBM_LOCAL_EVENT_ID +*/ +#define MBM_EVENT_ARRAY_INDEX (_event) ((_event) - 2) +/** * cpumask_any_housekeeping() - Choose any CPU in @mask, preferring those that * aren't marked nohz_full
@@ -231,12 +243,14 @@ enum rdtgrp_mode {* @parent: parent rdtgrp * @crdtgrp_list: child rdtgroup node list * @rmid: rmid for this rdtgroup +* @cntr_id: IDs of hardware counters assigned to monitor group */ struct mongroup {struct kernfs_node *mon_data_kn;struct rdtgroup *parent;struct list_head crdtgrp_list;u32 rmid; +u32 cntr_id[MAX_CNTRS ]; };/**
arch/x86/kernel/cpu/resctrl/rdtgroup.c +15 -0
@@ -925,6 +925,14 @@ static int rdtgroup_available_mbm_cntrs_show(struct kernfs_open_file *of,return 0 ; } +static void rdtgroup_cntr_id_init (struct rdtgroup *rdtgrp, +enum resctrl_event_id evtid) +{ +int index =MBM_EVENT_ARRAY_INDEX (evtid); + + rdtgrp->mon.cntr_id[index] =MON_CNTR_UNSET ; +} +#ifdef CONFIG_PROC_CPU_RESCTRL /*
@@ -3561,6 +3569,9 @@ static int mkdir_rdt_prepare_rmid_alloc(struct rdtgroup *rdtgrp) } rdtgrp->mon.rmid = ret; +rdtgroup_cntr_id_init (rdtgrp,QOS_L3_MBM_TOTAL_EVENT_ID ); +rdtgroup_cntr_id_init (rdtgrp,QOS_L3_MBM_LOCAL_EVENT_ID ); + ret =mkdir_mondata_all (rdtgrp->kn, rdtgrp, &rdtgrp->mon.mon_data_kn);if (ret) {rdt_last_cmd_puts ("kernfs subdir error\n" );
@@ -4115,6 +4126,10 @@ static void __init rdtgroup_setup_default(void) rdtgroup_default.closid =RESCTRL_RESERVED_CLOSID ; rdtgroup_default.mon.rmid =RESCTRL_RESERVED_RMID ; rdtgroup_default.type =RDTCTRL_GROUP ; + +rdtgroup_cntr_id_init (&rdtgroup_default,QOS_L3_MBM_TOTAL_EVENT_ID ); +rdtgroup_cntr_id_init (&rdtgroup_default,QOS_L3_MBM_LOCAL_EVENT_ID ); +INIT_LIST_HEAD (&rdtgroup_default.mon.crdtgrp_list);list_add (&rdtgroup_default.rdtgroup_list, &rdt_all_groups);
Signature · 1 line
2.34.1
Reinette Chatre
maintainerRe: [PATCH v9 16/26] x86/resctrl: Introduce cntr_id in mongroup for assignments
Hi Babu,
Quoted 1 line · Babu Moger
mbm_cntr_assignfeature provides an option to the user to assign a counter
nit for consistency: "mbm_cntr_assign feature" -> "mbm_cntr_assign mode"
Quoted 8 lines
to an RMID, event pair and monitor the bandwidth as long as the counter is assigned. There can be two counters per monitor group, one for MBM total event and another for MBM local event.
Introduce
cntr_idto manage the assignments.Signed-off-by Babu Moger <[email protected]>---
| Reviewed-by: Reinette Chatre <[email protected]>
Reinette
Moger, Babu
reviewerRe: [PATCH v9 16/26] x86/resctrl: Introduce cntr_id in mongroup for assignments
Hi Reinette,
Quoted 6 lines · Reinette Chatre
Hi Babu,
Quoted 1 line · Babu Moger
mbm_cntr_assignfeature provides an option to the user to assign a counternit for consistency: "
mbm_cntr_assignfeature" -> "mbm_cntr_assignmode"
Sure.
Quoted 11 lines
Quoted 9 lines
to an RMID, event pair and monitor the bandwidth as long as the counter is assigned. There can be two counters per monitor group, one for MBM total event and another for MBM local event.
Introduce
cntr_idto manage the assignments.Signed-off-by Babu Moger <[email protected]>---
| Reviewed-by: Reinette Chatre <[email protected]>
Signature · 2 lines
Thanks Babu Moger
Babu Moger
reviewerPATCH v9 17/26 x86/resctrl: Implement resctrl_arch_config_cntr() to assign a counter with ABMC
In reply to Babu MogerThe ABMC feature provides an option to the user to assign a hardware counter to an RMID, event pair and monitor the bandwidth as long as it is assigned. The assigned RMID will be tracked by the hardware until the user unassigns it manually.
Counters are configured by writing to L3_QOS_ABMC_CFG MSR and specifying the counter id, bandwidth source, and bandwidth types.
Provide the interface to assign the counter ids to RMID.
The feature details are documented in the APM listed below [1].
[1] AMD64 Architecture Programmer's Manual Volume 2: System Programming
Publication # 24593 Revision 3.41 section 19.3.3.3 Assignable Bandwidth
Monitoring (ABMC).---
v9: Removed the code to reset the architectural state. It will done
in another patch.
v8: Rename resctrl_arch_assign_cntr to resctrl_arch_config_cntr.
v7: Separated arch and fs functions. This patch only has arch implementation.
Added struct rdt_resource to the interface resctrl_arch_assign_cntr. Rename rdtgroup_abmc_cfg() to resctrl_abmc_config_one_amd().
v6: Removed mbm_cntr_alloc() from this patch to keep fs and arch code
separate.
Added code to update the counter assignment at domain level.
v5: Few name changes to match cntr_id.
Changed the function names to
rdtgroup_assign_cntr
resctr_arch_assign_cntr
More comments on commit log.
Added function summary.
v4: Commit message update.
User bitmap APIs where applicable. Changed the interfaces considering MPAM(arm). Added domain specific assignment.
v3: Removed the static from the prototype of rdtgroup_assign_abmc.
The function is not called directly from user anymore. These changes are related to global assignment interface.
v2: Minor text changes in commit message.
--- arch/x86/kernel/cpu/resctrl/internal.h | 3 ++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 38 ++++++++++++++++++++++++++ 2 files changed, 41 insertions(+)
arch/x86/kernel/cpu/resctrl/internal.h +3 -0
@@ -714,6 +714,9 @@ int mbm_cntr_alloc(struct rdt_resource *r);void mbm_cntr_free (struct rdt_resource *r,u32 cntr_id);void arch_mbm_evt_config_init (struct rdt_hw_mon_domain *hw_dom);unsigned int mon_event_config_index_get (u32 evtid); +int resctrl_arch_config_cntr (struct rdt_resource *r,struct rdt_mon_domain *d, +enum resctrl_event_id evtid,u32 rmid,u32 closid, +u32 cntr_id,bool assign);void rdt_staged_configs_clear (void );bool closid_allocated (unsigned int closid);int resctrl_find_cleanest_closid (void );
arch/x86/kernel/cpu/resctrl/rdtgroup.c +38 -0
@@ -1886,6 +1886,44 @@ static ssize_t mbm_local_bytes_config_write(struct kernfs_open_file *of,return ret ?: nbytes; } +static void resctrl_abmc_config_one_amd (void *info) +{ +u64 *msrval = info; + +wrmsrl (MSR_IA32_L3_QOS_ABMC_CFG , *msrval); +} + +/* +* Send an IPI to the domain to assign the counter to RMID, event pair. +*/ +int resctrl_arch_config_cntr (struct rdt_resource *r,struct rdt_mon_domain *d, +enum resctrl_event_id evtid,u32 rmid,u32 closid, +u32 cntr_id,bool assign) +{ +struct rdt_hw_mon_domain *hw_dom =resctrl_to_arch_mon_dom (d); +union l3_qos_abmc_cfg abmc_cfg = {0 }; +struct arch_mbm_state *arch_mbm; + + abmc_cfg.split.cfg_en =1 ; + abmc_cfg.split.cntr_en = assign ?1 :0 ; + abmc_cfg.split.cntr_id = cntr_id; + abmc_cfg.split.bw_src = rmid; + +/* Update the event configuration from the domain */ +if (evtid ==QOS_L3_MBM_TOTAL_EVENT_ID ) { + abmc_cfg.split.bw_type = hw_dom->mbm_total_cfg; + arch_mbm = &hw_dom->arch_mbm_total[rmid]; + }else { + abmc_cfg.split.bw_type = hw_dom->mbm_local_cfg; + arch_mbm = &hw_dom->arch_mbm_local[rmid]; + } + +smp_call_function_any (&d->hdr.cpu_mask, resctrl_abmc_config_one_amd, + &abmc_cfg,1 ); + +return 0 ; +} +/* rdtgroup information files for one cache resource. */ static struct rftype res_common_files[] = { {
Signature · 1 line
2.34.1
Luck, Tony
maintainerRE: [PATCH v9 17/26] x86/resctrl: Implement resctrl_arch_config_cntr() to assign a counter with ABMC
Quoted 17 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +17
-0+int resctrl_arch_config_cntr (struct rdt_resource *r,struct rdt_mon_domain *d, +enum resctrl_event_id evtid,u32 rmid,u32 closid, +u32 cntr_id,bool assign) +{ +struct rdt_hw_mon_domain *hw_dom =resctrl_to_arch_mon_dom (d); +union l3_qos_abmc_cfg abmc_cfg = {0 }; +struct arch_mbm_state *arch_mbm; + + abmc_cfg.split.cfg_en =1 ; + abmc_cfg.split.cntr_en = assign ?1 :0 ; + abmc_cfg.split.cntr_id = cntr_id; + abmc_cfg.split.bw_src = rmid; + +/* Update the event configuration from the domain */ +if (evtid ==QOS_L3_MBM_TOTAL_EVENT_ID ) { + abmc_cfg.split.bw_type = hw_dom->mbm_total_cfg; + arch_mbm = &hw_dom->arch_mbm_total[rmid];
arch/x86/kernel/cpu/resctrl/rdtgroup.c static ssize_t mbm_local_bytes_config_write(struct kernfs_open_file *of, · line 1925
Quoted 10 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +10
-0+ }else { + abmc_cfg.split.bw_type = hw_dom->mbm_local_cfg; + arch_mbm = &hw_dom->arch_mbm_local[rmid]; + } + +smp_call_function_any (&d->hdr.cpu_mask, resctrl_abmc_config_one_amd, + &abmc_cfg,1 ); + +return 0 ; +}
Compiling with W=1:
warning: variable 'arch_mbm' set but not used [-Wunused-but-set-variable]
[still not used by patch 26]
-Tony
Moger, Babu
reviewerRe: RE: [PATCH v9 17/26] x86/resctrl: Implement resctrl_arch_config_cntr() to assign a counter with ABMC
Hi Tony,
Quoted 30 lines · Tony
Quoted 17 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +17
-0+int resctrl_arch_config_cntr (struct rdt_resource *r,struct rdt_mon_domain *d, +enum resctrl_event_id evtid,u32 rmid,u32 closid, +u32 cntr_id,bool assign) +{ +struct rdt_hw_mon_domain *hw_dom =resctrl_to_arch_mon_dom (d); +union l3_qos_abmc_cfg abmc_cfg = {0 }; +struct arch_mbm_state *arch_mbm; + + abmc_cfg.split.cfg_en =1 ; + abmc_cfg.split.cntr_en = assign ?1 :0 ; + abmc_cfg.split.cntr_id = cntr_id; + abmc_cfg.split.bw_src = rmid; + +/* Update the event configuration from the domain */ +if (evtid ==QOS_L3_MBM_TOTAL_EVENT_ID ) { + abmc_cfg.split.bw_type = hw_dom->mbm_total_cfg; + arch_mbm = &hw_dom->arch_mbm_total[rmid];arch/x86/kernel/cpu/resctrl/rdtgroup.c static ssize_t mbm_local_bytes_config_write(struct kernfs_open_file *of, · line 1925
Quoted 10 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +10
-0+ }else { + abmc_cfg.split.bw_type = hw_dom->mbm_local_cfg; + arch_mbm = &hw_dom->arch_mbm_local[rmid]; + } + +smp_call_function_any (&d->hdr.cpu_mask, resctrl_abmc_config_one_amd, + &abmc_cfg,1 ); + +return 0 ; +}Compiling with W=1:
Quoted 3 lines
warning: variable '
arch_mbm' set but not used [-Wunused-but-set-variable][still not used by patch 26]
I knew I am going to miss something like this. Thanks. Will fix it.
Signature · 2 lines
Thanks Babu Moger
kernel test robot
build botRe: [PATCH v9 17/26] x86/resctrl: Implement resctrl_arch_config_cntr() to assign a counter with ABMC
In reply to Babu Mogerkernel test robot noticed the following build warnings:
Hi Babu,
kernel test robot noticed the following build warnings:
[auto build test WARNING on next-20241029]
[cannot apply to linus/master tip/x86/core v6.12-rc5 v6.12-rc4 v6.12-rc3 v6.12-rc5] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Babu-Moger/x86-resctrl-Add-__init-attribute-for-the-functions-called-in-resctrl_late_init/20241030-073059 base: next-20241029 patch link: https://lore.kernel.org/r/a3c2bdf2153882cc955b80b7d0fcdf7af3d09eb3.1730244116.git.babu.moger%40amd.com patch subject: [PATCH v9 17/26] x86/resctrl: Implement resctrl_arch_config_cntr() to assign a counter with ABMC config: x86_64-rhel-8.3-kselftests (https://download.01.org/0day-ci/archive/20241031/[email protected]/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241031/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
arch/x86/kernel/cpu/resctrl/rdtgroup.c: In function 'resctrl_arch_config_cntr':
>> arch/x86/kernel/cpu/resctrl/rdtgroup.c:1905:32: warning: variable 'arch_mbm' set but not used [-Wunused-but-set-variable]
1905 | struct arch_mbm_state *arch_mbm;
| ^~~~~~~~vim +/arch_mbm +1905 arch/x86/kernel/cpu/resctrl/rdtgroup.c
1895
1896 /*
1897 * Send an IPI to the domain to assign the counter to RMID, event pair.
1898 */
1899 int resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_mon_domain *d,
1900 enum resctrl_event_id evtid, u32 rmid, u32 closid,
1901 u32 cntr_id, bool assign)
1902 {
1903 struct rdt_hw_mon_domain *hw_dom = resctrl_to_arch_mon_dom(d);
1904 union l3_qos_abmc_cfg abmc_cfg = { 0 };
> 1905 struct arch_mbm_state *arch_mbm;
1906
1907 abmc_cfg.split.cfg_en = 1;
1908 abmc_cfg.split.cntr_en = assign ? 1 : 0;
1909 abmc_cfg.split.cntr_id = cntr_id;
1910 abmc_cfg.split.bw_src = rmid;
1911
1912 /* Update the event configuration from the domain */
1913 if (evtid == QOS_L3_MBM_TOTAL_EVENT_ID) {
1914 abmc_cfg.split.bw_type = hw_dom->mbm_total_cfg;
1915 arch_mbm = &hw_dom->arch_mbm_total[rmid];
1916 } else {
1917 abmc_cfg.split.bw_type = hw_dom->mbm_local_cfg;
1918 arch_mbm = &hw_dom->arch_mbm_local[rmid];
1919 }
1920
1921 smp_call_function_any(&d->hdr.cpu_mask, resctrl_abmc_config_one_amd,
1922 &abmc_cfg, 1);
1923
1924 return 0;
1925 }
1926
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Moger, Babu
reviewerRe: [PATCH v9 17/26] x86/resctrl: Implement resctrl_arch_config_cntr() to assign a counter with ABMC
Thanks. Will fix it next revision.
Quoted 66 lines · kernel test robot
Hi Babu,
kernel test robot noticed the following build warnings:
[auto build test WARNING on next-20241029]
[cannot apply to linus/master tip/x86/core v6.12-rc5 v6.12-rc4 v6.12-rc3 v6.12-rc5] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]url: https://github.com/intel-lab-lkp/linux/commits/Babu-Moger/x86-resctrl-Add-__init-attribute-for-the-functions-called-in-resctrl_late_init/20241030-073059 base: next-20241029 patch link: https://lore.kernel.org/r/a3c2bdf2153882cc955b80b7d0fcdf7af3d09eb3.1730244116.git.babu.moger%40amd.com patch subject: [PATCH v9 17/26] x86/resctrl: Implement resctrl_arch_config_cntr() to assign a counter with ABMC config: x86_64-rhel-8.3-kselftests (https://download.01.org/0day-ci/archive/20241031/[email protected]/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241031/[email protected]/reproduce)If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/All warnings (new ones prefixed by >>):
arch/x86/kernel/cpu/resctrl/rdtgroup.c: In function 'resctrl_arch_config_cntr':Quoted 1 line
Quoted 1 line
arch/x86/kernel/cpu/resctrl/rdtgroup.c:1905:32: warning: variable 'arch_mbm' set but not used [-Wunused-but-set-variable]1905 | struct arch_mbm_state *arch_mbm; | ^~~~~~~~vim +/arch_mbm +1905
arch/x86/kernel/cpu/resctrl/rdtgroup.c1895
1896 /*
1897 * Send an IPI to the domain to assign the counter to RMID, event pair.
1898 */
1899 int resctrl_arch_config_cntr(structrdt_resource*r, structrdt_mon_domain*d,
1900 enumresctrl_event_idevtid, u32 rmid, u32 closid,
1901 u32cntr_id, bool assign)
1902 {
1903 structrdt_hw_mon_domain*hw_dom=resctrl_to_arch_mon_dom(d);
1904 unionl3_qos_abmc_cfgabmc_cfg= { 0 };Quoted 1 line
1905 struct
arch_mbm_state*arch_mbm;1906
1907 abmc_cfg.split.cfg_en = 1;
1908 abmc_cfg.split.cntr_en = assign ? 1 : 0;
1909 abmc_cfg.split.cntr_id =cntr_id;
1910 abmc_cfg.split.bw_src = rmid;
1911
1912 /* Update the event configuration from the domain */
1913 if (evtid ==QOS_L3_MBM_TOTAL_EVENT_ID) {
1914 abmc_cfg.split.bw_type =hw_dom->mbm_total_cfg;
1915arch_mbm= &hw_dom->arch_mbm_total[rmid];
1916 } else {
1917 abmc_cfg.split.bw_type =hw_dom->mbm_local_cfg;
1918arch_mbm= &hw_dom->arch_mbm_local[rmid];
1919 }
1920
1921 smp_call_function_any(&d->hdr.cpu_mask,resctrl_abmc_config_one_amd,
1922&abmc_cfg, 1);
1923
1924 return 0;
1925 }
1926
Signature · 2 lines
Thanks Babu Moger
Reinette Chatre
maintainerRe: [PATCH v9 17/26] x86/resctrl: Implement resctrl_arch_config_cntr() to assign a counter with ABMC
In reply to Babu MogerHi Babu,
Quoted 7 lines · Babu Moger
The ABMC feature provides an option to the user to assign a hardware counter to an RMID, event pair and monitor the bandwidth as long as it is assigned. The assigned RMID will be tracked by the hardware until the user unassigns it manually.
Counters are configured by writing to
L3_QOS_ABMC_CFGMSR and specifying the counter id, bandwidth source, and bandwidth types.
needs imperative tone
Quoted 10 lines
Provide the interface to assign the counter ids to RMID.
The feature details are documented in the APM listed below [1].
[1] AMD64 Architecture Programmer's Manual Volume 2: System ProgrammingPublication # 24593 Revision 3.41 section 19.3.3.3 Assignable Bandwidth Monitoring (ABMC).
Reinette
Moger, Babu
reviewerRe: [PATCH v9 17/26] x86/resctrl: Implement resctrl_arch_config_cntr() to assign a counter with ABMC
Hi Reinette,
Quoted 8 lines · Reinette Chatre
Hi Babu,
Quoted 5 lines · Babu Moger
The ABMC feature provides an option to the user to assign a hardware counter to an RMID, event pair and monitor the bandwidth as long as it is assigned. The assigned RMID will be tracked by the hardware until the user unassigns it manually.
Quoted 4 lines
Quoted 2 lines
Counters are configured by writing to
L3_QOS_ABMC_CFGMSR and specifying the counter id, bandwidth source, and bandwidth types.needs imperative tone
How about this?
Configure the counters by writing to the L3_QOS_ABMC_CFG MSR and specifying the counter ID, bandwidth source, and bandwidth types.
Quoted 14 lines
Quoted 11 lines
Provide the interface to assign the counter ids to RMID.
The feature details are documented in the APM listed below [1].
[1] AMD64 Architecture Programmer's Manual Volume 2: System ProgrammingPublication # 24593 Revision 3.41 section 19.3.3.3 Assignable Bandwidth Monitoring (ABMC).Reinette
Signature · 2 lines
Thanks Babu Moger
Reinette Chatre
maintainerRe: [PATCH v9 17/26] x86/resctrl: Implement resctrl_arch_config_cntr() to assign a counter with ABMC
Hi Babu,
Quoted 14 lines · Babu
Hi Reinette,
Quoted 11 lines · Reinette Chatre
Hi Babu,
Quoted 7 lines · Babu Moger
The ABMC feature provides an option to the user to assign a hardware counter to an RMID, event pair and monitor the bandwidth as long as it is assigned. The assigned RMID will be tracked by the hardware until the user unassigns it manually.
Counters are configured by writing to
L3_QOS_ABMC_CFGMSR and specifying the counter id, bandwidth source, and bandwidth types.
Quoted 7 lines
Quoted 1 line
needs imperative tone
How about this?
Configure the counters by writing to the
L3_QOS_ABMC_CFGMSR and specifying the counter ID, bandwidth source, and bandwidth types.
ok with me. Exactly what ChatGPT suggests.
Please do note that that first paragraph informs reader that
a counter is assigned by user to "an RMID, event pair" while the hardware is configured with "the counter ID, bandwidth source, and bandwidth types". There thus does not seem to be a clear connection between what user assigns and what is programmed to hardware.
Reinette
Re: [PATCH v9 17/26] x86/resctrl: Implement resctrl_arch_config_cntr() to assign a counter with ABMC
Hi Reinette,
Quoted 19 lines · Reinette Chatre
Hi Babu,
Quoted 16 lines · Babu
Hi Reinette,
Quoted 12 lines · Reinette Chatre
Hi Babu,
Quoted 7 lines · Babu Moger
The ABMC feature provides an option to the user to assign a hardware counter to an RMID, event pair and monitor the bandwidth as long as it is assigned. The assigned RMID will be tracked by the hardware until the user unassigns it manually.
Counters are configured by writing to
L3_QOS_ABMC_CFGMSR and specifying the counter id, bandwidth source, and bandwidth types.needs imperative tone
Quoted 7 lines
Quoted 5 lines
How about this?
Configure the counters by writing to the
L3_QOS_ABMC_CFGMSR and specifying the counter ID, bandwidth source, and bandwidth types.ok with me. Exactly what ChatGPT suggests.
Hmm. ):
Quoted 6 lines
Please do note that that first paragraph informs reader that
a counter is assigned by user to "an RMID, event pair" while the hardware is configured with "the counter ID, bandwidth source, and bandwidth types". There thus does not seem to be a clear connection between what user assigns and what is programmed to hardware.
Adding RMID in the text might help.
Configure the counters by writing to the L3_QOS_ABMC_CFG MSR and specifying the counter ID, RMID, bandwidth source, and bandwidth types.
Signature · 1 line
- Babu Moger
Reinette Chatre
maintainerRe: [PATCH v9 17/26] x86/resctrl: Implement resctrl_arch_config_cntr() to assign a counter with ABMC
Hi Babu,
Quoted 39 lines · Babu
Hi Reinette,
Quoted 19 lines · Reinette Chatre
Hi Babu,
Quoted 16 lines · Babu
Hi Reinette,
Quoted 12 lines · Reinette Chatre
Hi Babu,
Quoted 7 lines · Babu Moger
The ABMC feature provides an option to the user to assign a hardware counter to an RMID, event pair and monitor the bandwidth as long as it is assigned. The assigned RMID will be tracked by the hardware until the user unassigns it manually.
Counters are configured by writing to
L3_QOS_ABMC_CFGMSR and specifying the counter id, bandwidth source, and bandwidth types.needs imperative tone
Quoted 7 lines
Quoted 5 lines
How about this?
Configure the counters by writing to the
L3_QOS_ABMC_CFGMSR and specifying the counter ID, bandwidth source, and bandwidth types.ok with me. Exactly what ChatGPT suggests.
Hmm. ):
Quoted 6 lines
Please do note that that first paragraph informs reader that
a counter is assigned by user to "an RMID, event pair" while the hardware is configured with "the counter ID, bandwidth source, and bandwidth types". There thus does not seem to be a clear connection between what user assigns and what is programmed to hardware.
Quoted 4 lines
Adding RMID in the text might help.
Configure the counters by writing to the
L3_QOS_ABMC_CFGMSR and specifying the counter ID, RMID, bandwidth source, and bandwidth types.
Isn't the bandwidth source and the RMID the same thing? How about something like:
"Configure the counters by writing to the L3_QOS_ABMC_CFG MSR and specifying
the counter ID, bandwidth source (RMID), and bandwidth event configuration."
Please feel free to improve.
Reinette
Re: [PATCH v9 17/26] x86/resctrl: Implement resctrl_arch_config_cntr() to assign a counter with ABMC
Hi Reinette,
Quoted 44 lines · Reinette Chatre
Hi Babu,
Quoted 41 lines · Babu
Hi Reinette,
Quoted 19 lines · Reinette Chatre
Hi Babu,
Quoted 16 lines · Babu
Hi Reinette,
Quoted 12 lines · Reinette Chatre
Hi Babu,
Quoted 7 lines · Babu Moger
The ABMC feature provides an option to the user to assign a hardware counter to an RMID, event pair and monitor the bandwidth as long as it is assigned. The assigned RMID will be tracked by the hardware until the user unassigns it manually.
Counters are configured by writing to
L3_QOS_ABMC_CFGMSR and specifying the counter id, bandwidth source, and bandwidth types.needs imperative tone
Quoted 7 lines
Quoted 5 lines
How about this?
Configure the counters by writing to the
L3_QOS_ABMC_CFGMSR and specifying the counter ID, bandwidth source, and bandwidth types.ok with me. Exactly what ChatGPT suggests.
Hmm. ):
Quoted 6 lines
Please do note that that first paragraph informs reader that
a counter is assigned by user to "an RMID, event pair" while the hardware is configured with "the counter ID, bandwidth source, and bandwidth types". There thus does not seem to be a clear connection between what user assigns and what is programmed to hardware.Adding RMID in the text might help.
Quoted 8 lines
Quoted 2 lines
Configure the counters by writing to the
L3_QOS_ABMC_CFGMSR and specifying the counter ID, RMID, bandwidth source, and bandwidth types.Isn't the bandwidth source and the RMID the same thing? How about something like:
"Configure the counters by writing to theL3_QOS_ABMC_CFGMSR and specifying
the counter ID, bandwidth source (RMID), and bandwidth event configuration."Please feel free to improve.
Looks good. Thanks
Signature · 1 line
- Babu Moger
Babu Moger
reviewerPATCH v9 18/26 x86/resctrl: Add the interface to assign/update counter assignment
In reply to Babu MogerThe mbm_cntr_assign mode offers several hardware counters that can be assigned to an RMID, event pair and monitor the bandwidth as long as it is assigned.
Counters are managed at two levels. The global assignment is tracked using the mbm_cntr_free_map field in the struct resctrl_mon, while domain-specific assignments are tracked using the mbm_cntr_map field in the struct rdt_mon_domain. Allocation begins at the global level and is then applied individually to each domain.
Introduce an interface to allocate these counters and update the corresponding domains accordingly.
---
v9: Introduced new function resctrl_config_cntr to assign the counter, update
the bitmap and reset the architectural state.
Taken care of error handling(freeing the counter) when assignment fails. Moved mbm_cntr_assigned_to_domain here as it used in this patch. Minor text changes.
v8: Renamed rdtgroup_assign_cntr() to rdtgroup_assign_cntr_event().
Added the code to return the error if rdtgroup_assign_cntr_event fails. Moved definition of MBM_EVENT_ARRAY_INDEX to resctrl/internal.h. Updated typo in the comments.
v7: New patch. Moved all the FS code here.
Merged rdtgroup_assign_cntr and rdtgroup_alloc_cntr. Adde new #define MBM_EVENT_ARRAY_INDEX.
--- arch/x86/kernel/cpu/resctrl/internal.h | 2 + arch/x86/kernel/cpu/resctrl/rdtgroup.c | 87 ++++++++++++++++++++++++++ 2 files changed, 89 insertions(+)
arch/x86/kernel/cpu/resctrl/internal.h +2 -0
@@ -717,6 +717,8 @@ unsigned int mon_event_config_index_get(u32 evtid);int resctrl_arch_config_cntr (struct rdt_resource *r,struct rdt_mon_domain *d,enum resctrl_event_id evtid,u32 rmid,u32 closid,u32 cntr_id,bool assign); +int rdtgroup_assign_cntr_event (struct rdt_resource *r,struct rdtgroup *rdtgrp, +struct rdt_mon_domain *d,enum resctrl_event_id evtid);void rdt_staged_configs_clear (void );bool closid_allocated (unsigned int closid);int resctrl_find_cleanest_closid (void );
arch/x86/kernel/cpu/resctrl/rdtgroup.c +87 -0
93 lines not on this page · raw message
Signature · 1 line
2.34.1
Reinette Chatre
maintainerRe: [PATCH v9 18/26] x86/resctrl: Add the interface to assign/update counter assignment
Hi Babu,
Quoted 15 lines · Babu Moger
The
mbm_cntr_assignmode offers several hardware counters that can be assigned to an RMID, event pair and monitor the bandwidth as long as it is assigned.Counters are managed at two levels. The global assignment is tracked using the
mbm_cntr_free_mapfield in the structresctrl_mon, while domain-specific assignments are tracked using thembm_cntr_mapfield in the structrdt_mon_domain. Allocation begins at the global level and is then applied individually to each domain.Introduce an interface to allocate these counters and update the corresponding domains accordingly.
Signed-off-by Babu Moger <[email protected]>---
...
Quoted 35 lines
arch/x86/kernel/cpu/resctrl/internal.h +2
-0@@ -717,6 +717,8 @@ unsigned int mon_event_config_index_get(u32 evtid);int resctrl_arch_config_cntr (struct rdt_resource *r,struct rdt_mon_domain *d,enum resctrl_event_id evtid,u32 rmid,u32 closid,u32 cntr_id,bool assign); +int rdtgroup_assign_cntr_event (struct rdt_resource *r,struct rdtgroup *rdtgrp, +struct rdt_mon_domain *d,enum resctrl_event_id evtid);void rdt_staged_configs_clear (void );bool closid_allocated (unsigned int closid);int resctrl_find_cleanest_closid (void );arch/x86/kernel/cpu/resctrl/rdtgroup.c +14
-0@@ -1924,6 +1924,93 @@ int resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_mon_domain *d,return 0 ; } +/* +* Configure the counter for the event, RMID pair for the domain. +* Update the bitmap and reset the architectural state. +*/ +static int resctrl_config_cntr (struct rdt_resource *r,struct rdt_mon_domain *d, +enum resctrl_event_id evtid,u32 rmid,u32 closid, +u32 cntr_id,bool assign) +{ +int ret; + + ret =resctrl_arch_config_cntr (r, d, evtid, rmid, closid, cntr_id, assign); +if (ret) +return ret; +
arch/x86/kernel/cpu/resctrl/rdtgroup.c int resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_mon_domain *d, · line 1950
Quoted 10 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +10
-0+if (assign) +__set_bit (cntr_id, d->mbm_cntr_map); +else +__clear_bit (cntr_id, d->mbm_cntr_map); + +/* +* Reset the architectural state so that reading of hardware +* counter is not considered as an overflow in next update. +*/ +resctrl_arch_reset_rmid (r, d, closid, rmid, evtid);
resctrl_arch_reset_rmid() expects to be run on a CPU that is in the domain @d ... note that after the architectural state is reset it initializes the state by reading the event on the current CPU. By running it here it is run on a random CPU that may not be in the right domain.
Quoted 36 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +36
-0+ +return ret; +} + +static bool mbm_cntr_assigned_to_domain (struct rdt_resource *r,u32 cntr_id) +{ +struct rdt_mon_domain *d; + +list_for_each_entry (d, &r->mon_domains, hdr.list) +if (test_bit (cntr_id, d->mbm_cntr_map)) +return 1 ; + +return 0 ; +} + +/* +* Assign a hardware counter to event @evtid of group @rdtgrp. +* Counter will be assigned to all the domains if rdt_mon_domain is NULL +* else the counter will be assigned to specific domain. +*/ +int rdtgroup_assign_cntr_event (struct rdt_resource *r,struct rdtgroup *rdtgrp, +struct rdt_mon_domain *d,enum resctrl_event_id evtid) +{ +int index =MBM_EVENT_ARRAY_INDEX (evtid); +int cntr_id = rdtgrp->mon.cntr_id[index]; +int ret; + +/* +* Allocate a new counter id to the event if the counter is not +* assigned already. +*/ +if (cntr_id ==MON_CNTR_UNSET ) { + cntr_id =mbm_cntr_alloc (r); +if (cntr_id <0 ) { +rdt_last_cmd_puts ("Out of MBM assignable counters\n" ); +return -ENOSPC ;
arch/x86/kernel/cpu/resctrl/rdtgroup.c int resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_mon_domain *d, · line 1996
Quoted 10 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +10
-0+ } + rdtgrp->mon.cntr_id[index] = cntr_id; + } + +if (!d) { +list_for_each_entry (d, &r->mon_domains, hdr.list) { + ret =resctrl_config_cntr (r, d, evtid, rdtgrp->mon.rmid, + rdtgrp->closid, cntr_id, true); +if (ret) + goto out_done_assign;
This may not be what users expect. What if, for example, domain #1 has a counter assigned to "total" event and then user wants to change that to assign a counter to "total" event of all domains. Would this not reconfigure the counter associated with domain #1 and unnecessarily reset it? Could this be made a bit smarter to only configure a counter on a domain if it is not already configured? This could perhaps form part of resctrl_config_cntr() to not scatter the duplicate check everywhere. What do you think?
Also, looks like this can do partial assignment. For example, if one of the domains encounter a failure then domains already configured are not undone. This matches other similar flows but is not documented and left to reader to decipher.
arch/x86/kernel/cpu/resctrl/rdtgroup.c int resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_mon_domain *d, · line 2000
Quoted 4 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +4
-0+ } + }else { + ret =resctrl_config_cntr (r, d, evtid, rdtgrp->mon.rmid, + rdtgrp->closid, cntr_id, true);
Looking at flows calling rdtgroup_assign_cntr_event() I do not see a check if counter is already assigned. So, if a user makes a loop of assigning a counter to the same event over and over it will result in an IPI every time. This seems unnecessary, what do you think?
Quoted 6 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +6
-0+if (ret) + goto out_done_assign; + } + +out_done_assign: +if (ret && !mbm_cntr_assigned_to_domain (r, cntr_id)) {
arch/x86/kernel/cpu/resctrl/rdtgroup.c int resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_mon_domain *d, · line 2016
Quoted 10 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +7
-0+mbm_cntr_free (r, cntr_id); +rdtgroup_cntr_id_init (rdtgrp, evtid); + } + +return ret; +} +/* rdtgroup information files for one cache resource. */ static struct rftype res_common_files[] = { {
Reinette
Moger, Babu
reviewerRe: [PATCH v9 18/26] x86/resctrl: Add the interface to assign/update counter assignment
Hi Reinette,
Quoted 63 lines · Reinette Chatre
Hi Babu,
Quoted 15 lines · Babu Moger
The
mbm_cntr_assignmode offers several hardware counters that can be assigned to an RMID, event pair and monitor the bandwidth as long as it is assigned.Counters are managed at two levels. The global assignment is tracked using the
mbm_cntr_free_mapfield in the structresctrl_mon, while domain-specific assignments are tracked using thembm_cntr_mapfield in the structrdt_mon_domain. Allocation begins at the global level and is then applied individually to each domain.Introduce an interface to allocate these counters and update the corresponding domains accordingly.
Signed-off-by Babu Moger <[email protected]>---
...
Quoted 42 lines
arch/x86/kernel/cpu/resctrl/internal.h +2
-0@@ -717,6 +717,8 @@ unsigned int mon_event_config_index_get(u32 evtid);int resctrl_arch_config_cntr (struct rdt_resource *r,struct rdt_mon_domain *d,enum resctrl_event_id evtid,u32 rmid,u32 closid,u32 cntr_id,bool assign); +int rdtgroup_assign_cntr_event (struct rdt_resource *r,struct rdtgroup *rdtgrp, +struct rdt_mon_domain *d,enum resctrl_event_id evtid);void rdt_staged_configs_clear (void );bool closid_allocated (unsigned int closid);int resctrl_find_cleanest_closid (void );arch/x86/kernel/cpu/resctrl/rdtgroup.c +21
-0@@ -1924,6 +1924,93 @@ int resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_mon_domain *d,return 0 ; } +/* +* Configure the counter for the event, RMID pair for the domain. +* Update the bitmap and reset the architectural state. +*/ +static int resctrl_config_cntr (struct rdt_resource *r,struct rdt_mon_domain *d, +enum resctrl_event_id evtid,u32 rmid,u32 closid, +u32 cntr_id,bool assign) +{ +int ret; + + ret =resctrl_arch_config_cntr (r, d, evtid, rmid, closid, cntr_id, assign); +if (ret) +return ret; + +if (assign) +__set_bit (cntr_id, d->mbm_cntr_map); +else +__clear_bit (cntr_id, d->mbm_cntr_map); + +/* +* Reset the architectural state so that reading of hardware
Quoted 8 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c int resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_mon_domain *d, · line 1950
Quoted 3 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +3
-0+* counter is not considered as an overflow in next update. +*/ +resctrl_arch_reset_rmid (r, d, closid, rmid, evtid);
resctrl_arch_reset_rmid()expects to be run on a CPU that is in the domain @d ... note that after the architectural state is reset it initializes the state by reading the event on the current CPU. By running it here it is run on a random CPU that may not be in the right domain.
Yes. That is correct. We can move this part to our earlier implementation. We dont need to read the RMID. We just have to reset the counter.
(quoted diff) +0 -0
b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
index 9fe419d0c536..bc3654ec3a08 100644
arch/x86/kernel/cpu/resctrl/rdtgroup.c +0 -0
@@ -2371,6 +2371,13 @@ int resctrl_arch_config_cntr(struct rdt_resource
*r, struct rdt_mon_domain *d,
smp_call_function_any(&d->hdr.cpu_mask, resctrl_abmc_config_one_amd,
&abmc_cfg, 1);+ /*
+ * Reset the architectural state so that reading of hardware
+ * counter is not considered as an overflow in next update.
+ */
+ if (arch_mbm)
+ memset(arch_mbm, 0, sizeof(struct arch_mbm_state));
+
return 0;}
Quoted 48 lines
Quoted 37 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +36
-0+ +return ret; +} + +static bool mbm_cntr_assigned_to_domain (struct rdt_resource *r,u32 cntr_id) +{ +struct rdt_mon_domain *d; + +list_for_each_entry (d, &r->mon_domains, hdr.list) +if (test_bit (cntr_id, d->mbm_cntr_map)) +return 1 ; + +return 0 ; +} + +/* +* Assign a hardware counter to event @evtid of group @rdtgrp. +* Counter will be assigned to all the domains if rdt_mon_domain is NULL +* else the counter will be assigned to specific domain. +*/ +int rdtgroup_assign_cntr_event (struct rdt_resource *r,struct rdtgroup *rdtgrp, +struct rdt_mon_domain *d,enum resctrl_event_id evtid) +{ +int index =MBM_EVENT_ARRAY_INDEX (evtid); +int cntr_id = rdtgrp->mon.cntr_id[index]; +int ret; + +/* +* Allocate a new counter id to the event if the counter is not +* assigned already. +*/ +if (cntr_id ==MON_CNTR_UNSET ) { + cntr_id =mbm_cntr_alloc (r); +if (cntr_id <0 ) { +rdt_last_cmd_puts ("Out of MBM assignable counters\n" ); +return -ENOSPC ;arch/x86/kernel/cpu/resctrl/rdtgroup.c int resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_mon_domain *d, · line 1996
Quoted 10 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +10
-0+ } + rdtgrp->mon.cntr_id[index] = cntr_id; + } + +if (!d) { +list_for_each_entry (d, &r->mon_domains, hdr.list) { + ret =resctrl_config_cntr (r, d, evtid, rdtgrp->mon.rmid, + rdtgrp->closid, cntr_id, true); +if (ret) + goto out_done_assign;
Quoted 7 lines
This may not be what users expect. What if, for example, domain #1 has a counter assigned to "total" event and then user wants to change that to assign a counter to "total" event of all domains. Would this not reconfigure the counter associated with domain #1 and unnecessarily reset it? Could this be made a bit smarter to only configure a counter on a domain if it is not already configured? This could perhaps form part of
resctrl_config_cntr()to not scatter the duplicate check everywhere. What do you think?
Yes. that is correct. We can add a check in resctrl_config_cntr().
(quoted diff) +0 -0
b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
index 9fe419d0c536..bc3654ec3a08 100644
--- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
+++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
@@ -2384,6 +2391,10 @@ static int resctrl_config_cntr(struct rdt_resource *r, struct rdt_mon_domain *d,
{
int ret;+ /* Return success if the domain is in expected assign state already */
+ if (assign == test_bit(cntr_id, d->mbm_cntr_map))
+ return 0;
+
ret = resctrl_arch_config_cntr(r, d, evtid, rmid, closid, cntr_id,
assign);
if (ret)
return ret;Quoted 4 lines
Also, looks like this can do partial assignment. For example, if one of the domains encounter a failure then domains already configured are not undone. This matches other similar flows but is not documented and left to reader to decipher.
I will add the text in patch 26
(x86/resctrl: Introduce interface to modify assignment states of the groups).
Quoted 11 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c int resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_mon_domain *d, · line 2000
Quoted 6 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +4
-0+ } + }else { + ret =resctrl_config_cntr (r, d, evtid, rdtgrp->mon.rmid, + rdtgrp->closid, cntr_id, true);Looking at flows calling
rdtgroup_assign_cntr_event()I do not see a check if counter is already assigned. So, if a user makes a loop of assigning a counter to the same event over and over it will result in an IPI every time. This seems unnecessary, what do you think?
This will be taken care by the above check in resctrl_config_cntr().
Quoted 21 lines
Quoted 7 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +6
-0+if (ret) + goto out_done_assign; + } + +out_done_assign: +if (ret && !mbm_cntr_assigned_to_domain (r, cntr_id)) {arch/x86/kernel/cpu/resctrl/rdtgroup.c int resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_mon_domain *d, · line 2016
Quoted 10 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +7
-0+mbm_cntr_free (r, cntr_id); +rdtgroup_cntr_id_init (rdtgrp, evtid); + } + +return ret; +} +/* rdtgroup information files for one cache resource. */ static struct rftype res_common_files[] = { {Reinette
Signature · 2 lines
Thanks Babu Moger
Reinette Chatre
maintainerRe: [PATCH v9 18/26] x86/resctrl: Add the interface to assign/update counter assignment
Hi Babu,
Quoted 92 lines · Babu
Hi Reinette,
Quoted 63 lines · Reinette Chatre
Hi Babu,
Quoted 15 lines · Babu Moger
The
mbm_cntr_assignmode offers several hardware counters that can be assigned to an RMID, event pair and monitor the bandwidth as long as it is assigned.Counters are managed at two levels. The global assignment is tracked using the
mbm_cntr_free_mapfield in the structresctrl_mon, while domain-specific assignments are tracked using thembm_cntr_mapfield in the structrdt_mon_domain. Allocation begins at the global level and is then applied individually to each domain.Introduce an interface to allocate these counters and update the corresponding domains accordingly.
Signed-off-by Babu Moger <[email protected]>---
...
Quoted 42 lines
arch/x86/kernel/cpu/resctrl/internal.h +2
-0@@ -717,6 +717,8 @@ unsigned int mon_event_config_index_get(u32 evtid);int resctrl_arch_config_cntr (struct rdt_resource *r,struct rdt_mon_domain *d,enum resctrl_event_id evtid,u32 rmid,u32 closid,u32 cntr_id,bool assign); +int rdtgroup_assign_cntr_event (struct rdt_resource *r,struct rdtgroup *rdtgrp, +struct rdt_mon_domain *d,enum resctrl_event_id evtid);void rdt_staged_configs_clear (void );bool closid_allocated (unsigned int closid);int resctrl_find_cleanest_closid (void );arch/x86/kernel/cpu/resctrl/rdtgroup.c +21
-0@@ -1924,6 +1924,93 @@ int resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_mon_domain *d,return 0 ; } +/* +* Configure the counter for the event, RMID pair for the domain. +* Update the bitmap and reset the architectural state. +*/ +static int resctrl_config_cntr (struct rdt_resource *r,struct rdt_mon_domain *d, +enum resctrl_event_id evtid,u32 rmid,u32 closid, +u32 cntr_id,bool assign) +{ +int ret; + + ret =resctrl_arch_config_cntr (r, d, evtid, rmid, closid, cntr_id, assign); +if (ret) +return ret; + +if (assign) +__set_bit (cntr_id, d->mbm_cntr_map); +else +__clear_bit (cntr_id, d->mbm_cntr_map); + +/* +* Reset the architectural state so that reading of hardware Quoted 8 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c int resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_mon_domain *d, · line 1950
Quoted 3 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +3
-0+* counter is not considered as an overflow in next update. +*/ +resctrl_arch_reset_rmid (r, d, closid, rmid, evtid);
resctrl_arch_reset_rmid()expects to be run on a CPU that is in the domain @d ... note that after the architectural state is reset it initializes the state by reading the event on the current CPU. By running it here it is run on a random CPU that may not be in the right domain.Yes. That is correct. We can move this part to our earlier implementation. We dont need to read the RMID. We just have to reset the counter.
arch/x86/kernel/cpu/resctrl/rdtgroup.c +0
-0@@ -2371,6 +2371,13 @@ int resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_mon_domain *d,smp_call_function_any (&d->hdr.cpu_mask, resctrl_abmc_config_one_amd, &abmc_cfg,1 );
arch/x86/kernel/cpu/resctrl/rdtgroup.c int resctrl_arch_config_cntr(struct rdt_resource · line 2383
Quoted 10 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +7
-0+/* +* Reset the architectural state so that reading of hardware +* counter is not considered as an overflow in next update. +*/ +if (arch_mbm) +memset (arch_mbm,0 ,sizeof (struct arch_mbm_state )); +return 0 ; }
I am not sure what you envision here. One motivation for the move out of resctrl_arch_config_cntr() was to avoid architectural state being reset twice. For reference, mbm_config_write_domain()->resctrl_arch_reset_rmid_all(). Will architectural state be reset twice again?
One thing that I did not notice before is that the non-architectural MBM state is not reset. Care should be taken to reset this also when considering that there is a plan to use that MBM state to build a generic rate event for all platforms:
https://lore.kernel.org/all/CALPaoCgFRFgQqG00Uc0GhMHK47bsbtFw6Bxy5O9A_HeYmGa5sA@mail.gmail.com/
Reinette
Re: [PATCH v9 18/26] x86/resctrl: Add the interface to assign/update counter assignment
Hi Reinette,
Quoted 94 lines · Reinette Chatre
Hi Babu,
Quoted 91 lines · Babu
Hi Reinette,
Quoted 63 lines · Reinette Chatre
Hi Babu,
Quoted 15 lines · Babu Moger
The
mbm_cntr_assignmode offers several hardware counters that can be assigned to an RMID, event pair and monitor the bandwidth as long as it is assigned.Counters are managed at two levels. The global assignment is tracked using the
mbm_cntr_free_mapfield in the structresctrl_mon, while domain-specific assignments are tracked using thembm_cntr_mapfield in the structrdt_mon_domain. Allocation begins at the global level and is then applied individually to each domain.Introduce an interface to allocate these counters and update the corresponding domains accordingly.
Signed-off-by Babu Moger <[email protected]>---
...
Quoted 42 lines
arch/x86/kernel/cpu/resctrl/internal.h +2
-0@@ -717,6 +717,8 @@ unsigned int mon_event_config_index_get(u32 evtid);int resctrl_arch_config_cntr (struct rdt_resource *r,struct rdt_mon_domain *d,enum resctrl_event_id evtid,u32 rmid,u32 closid,u32 cntr_id,bool assign); +int rdtgroup_assign_cntr_event (struct rdt_resource *r,struct rdtgroup *rdtgrp, +struct rdt_mon_domain *d,enum resctrl_event_id evtid);void rdt_staged_configs_clear (void );bool closid_allocated (unsigned int closid);int resctrl_find_cleanest_closid (void );arch/x86/kernel/cpu/resctrl/rdtgroup.c +21
-0@@ -1924,6 +1924,93 @@ int resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_mon_domain *d,return 0 ; } +/* +* Configure the counter for the event, RMID pair for the domain. +* Update the bitmap and reset the architectural state. +*/ +static int resctrl_config_cntr (struct rdt_resource *r,struct rdt_mon_domain *d, +enum resctrl_event_id evtid,u32 rmid,u32 closid, +u32 cntr_id,bool assign) +{ +int ret; + + ret =resctrl_arch_config_cntr (r, d, evtid, rmid, closid, cntr_id, assign); +if (ret) +return ret; + +if (assign) +__set_bit (cntr_id, d->mbm_cntr_map); +else +__clear_bit (cntr_id, d->mbm_cntr_map); + +/* +* Reset the architectural state so that reading of hardware Quoted 8 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c int resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_mon_domain *d, · line 1950
Quoted 3 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +3
-0+* counter is not considered as an overflow in next update. +*/ +resctrl_arch_reset_rmid (r, d, closid, rmid, evtid);
resctrl_arch_reset_rmid()expects to be run on a CPU that is in the domain @d ... note that after the architectural state is reset it initializes the state by reading the event on the current CPU. By running it here it is run on a random CPU that may not be in the right domain.Yes. That is correct. We can move this part to our earlier implementation. We dont need to read the RMID. We just have to reset the counter.
arch/x86/kernel/cpu/resctrl/rdtgroup.c +0
-0@@ -2371,6 +2371,13 @@ int resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_mon_domain *d,smp_call_function_any (&d->hdr.cpu_mask, resctrl_abmc_config_one_amd, &abmc_cfg,1 );
Quoted 16 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c int resctrl_arch_config_cntr(struct rdt_resource · line 2383
Quoted 11 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +7
-0+/* +* Reset the architectural state so that reading of hardware +* counter is not considered as an overflow in next update. +*/ +if (arch_mbm) +memset (arch_mbm,0 ,sizeof (struct arch_mbm_state )); +return 0 ; }I am not sure what you envision here. One motivation for the move out of
resctrl_arch_config_cntr()was to avoid architectural state being reset twice. For reference, mbm_config_write_domain()->resctrl_arch_reset_rmid_all(). Will architectural state be reset twice again?
That is good point. We don't have to do it twice.
We can move the whole reset(arch_mbm) in resctrl_arch_config_cntr().
Quoted 4 lines
One thing that I did not notice before is that the non-architectural MBM state is not reset. Care should be taken to reset this also when considering that there is a plan to use that MBM state to build a generic rate event for all platforms:
https://lore.kernel.org/all/CALPaoCgFRFgQqG00Uc0GhMHK47bsbtFw6Bxy5O9A_HeYmGa5sA@mail.gmail.com/
Did you mean we should add the following code in resctrl_arch_config_cntr()?
m = get_mbm_state(d, closid, rmid, evtid);
if (m)
memset(m, 0, sizeof(struct mbm_state));
- Babu Moger
Reinette Chatre
maintainerRe: [PATCH v9 18/26] x86/resctrl: Add the interface to assign/update counter assignment
Hi Babu,
Quoted 113 lines · Babu
Hi Reinette,
Quoted 93 lines · Reinette Chatre
Hi Babu,
Quoted 90 lines · Babu
Hi Reinette,
Quoted 62 lines · Reinette Chatre
Hi Babu,
Quoted 15 lines · Babu Moger
The
mbm_cntr_assignmode offers several hardware counters that can be assigned to an RMID, event pair and monitor the bandwidth as long as it is assigned.Counters are managed at two levels. The global assignment is tracked using the
mbm_cntr_free_mapfield in the structresctrl_mon, while domain-specific assignments are tracked using thembm_cntr_mapfield in the structrdt_mon_domain. Allocation begins at the global level and is then applied individually to each domain.Introduce an interface to allocate these counters and update the corresponding domains accordingly.
Signed-off-by Babu Moger <[email protected]>---
...
Quoted 41 lines
arch/x86/kernel/cpu/resctrl/internal.h +2
-0@@ -717,6 +717,8 @@ unsigned int mon_event_config_index_get(u32 evtid); int resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_mon_domain *d, enum resctrl_event_id evtid, u32 rmid, u32 closid, u32 cntr_id, bool assign); +int rdtgroup_assign_cntr_event (struct rdt_resource *r,struct rdtgroup *rdtgrp, + struct rdt_mon_domain *d, enum resctrl_event_id evtid); void rdt_staged_configs_clear(void); bool closid_allocated(unsigned int closid); int resctrl_find_cleanest_closid(void);arch/x86/kernel/cpu/resctrl/rdtgroup.c +0
-0@@ -1924,6 +1924,93 @@ int resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_mon_domain *d, return 0; }+/*
+ * Configure the counter for the event, RMID pair for the domain.
+ * Update the bitmap and reset the architectural state.
+ */arch/x86/kernel/cpu/resctrl/rdtgroup.c +17
-0+static int resctrl_config_cntr (struct rdt_resource *r,struct rdt_mon_domain *d, + enum resctrl_event_id evtid, u32 rmid, u32 closid, + u32 cntr_id, bool assign) +{ + int ret; + + ret = resctrl_arch_config_cntr(r, d, evtid, rmid, closid, cntr_id, assign); + if (ret) + return ret; + + if (assign) + __set_bit(cntr_id, d->mbm_cntr_map); + else + __clear_bit(cntr_id, d->mbm_cntr_map); + + /* +* Reset the architectural state so that reading of hardware Quoted 8 lines
Quoted 3 lines
+ * counter is not considered as an overflow in next update. + */
+resctrl_arch_reset_rmid(r, d, closid, rmid, evtid);
resctrl_arch_reset_rmid()expects to be run on a CPU that is in the domain @d ... note that after the architectural state is reset it initializes the state by reading the event on the current CPU. By running it here it is run on a random CPU that may not be in the right domain.Yes. That is correct. We can move this part to our earlier implementation. We dont need to read the RMID. We just have to reset the counter.
arch/x86/kernel/cpu/resctrl/rdtgroup.c +0
-0@@ -2371,6 +2371,13 @@ int resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_mon_domain *d, smp_call_function_any(&d->hdr.cpu_mask, resctrl_abmc_config_one_amd, &abmc_cfg, 1);Quoted 16 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c int resctrl_arch_config_cntr(struct rdt_resource · line 2383
Quoted 11 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +7
-0+ /* + * Reset the architectural state so that reading of hardware + * counter is not considered as an overflow in next update. + */ + if (arch_mbm) + memset(arch_mbm, 0, sizeof(struct arch_mbm_state)); + return 0; }I am not sure what you envision here. One motivation for the move out of
resctrl_arch_config_cntr()was to avoid architectural state being reset twice. For reference, mbm_config_write_domain()->resctrl_arch_reset_rmid_all(). Will architectural state be reset twice again?
Quoted 3 lines
That is good point. We don't have to do it twice.
We can move the whole
reset(arch_mbm)inresctrl_arch_config_cntr().
This is not clear to me. The architectural state needs to be reset on MBM config write even when assignable mode is not supported and/or enabled. Moving it to resctrl_arch_config_cntr() will break this, no?
I wonder if it may not simplify things to call resctrl_arch_reset_rmid() from resctrl_abmc_config_one_amd()?
Quoted 10 lines
Quoted 4 lines
One thing that I did not notice before is that the non-architectural MBM state is not reset. Care should be taken to reset this also when considering that there is a plan to use that MBM state to build a generic rate event for all platforms:
https://lore.kernel.org/all/CALPaoCgFRFgQqG00Uc0GhMHK47bsbtFw6Bxy5O9A_HeYmGa5sA@mail.gmail.com/Did you mean we should add the following code in
resctrl_arch_config_cntr()?m =
get_mbm_state(d, closid, rmid, evtid);
if (m)
memset(m, 0, sizeof(struct mbm_state));
This is not arch code but instead resctrl fs, so resctrl_config_cntr() may be more appropriate?
Reinette
Re: [PATCH v9 18/26] x86/resctrl: Add the interface to assign/update counter assignment
Hi Reinette,
Quoted 116 lines · Reinette Chatre
Hi Babu,
Quoted 113 lines · Babu
Hi Reinette,
Quoted 109 lines · Reinette Chatre
Hi Babu,
Quoted 91 lines · Babu
Hi Reinette,
Quoted 62 lines · Reinette Chatre
Hi Babu,
Quoted 15 lines · Babu Moger
The
mbm_cntr_assignmode offers several hardware counters that can be assigned to an RMID, event pair and monitor the bandwidth as long as it is assigned.Counters are managed at two levels. The global assignment is tracked using the
mbm_cntr_free_mapfield in the structresctrl_mon, while domain-specific assignments are tracked using thembm_cntr_mapfield in the structrdt_mon_domain. Allocation begins at the global level and is then applied individually to each domain.Introduce an interface to allocate these counters and update the corresponding domains accordingly.
Signed-off-by Babu Moger <[email protected]>---
...
Quoted 41 lines
arch/x86/kernel/cpu/resctrl/internal.h +2
-0@@ -717,6 +717,8 @@ unsigned int mon_event_config_index_get(u32 evtid); int resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_mon_domain *d, enum resctrl_event_id evtid, u32 rmid, u32 closid, u32 cntr_id, bool assign); +int rdtgroup_assign_cntr_event (struct rdt_resource *r,struct rdtgroup *rdtgrp, + struct rdt_mon_domain *d, enum resctrl_event_id evtid); void rdt_staged_configs_clear(void); bool closid_allocated(unsigned int closid); int resctrl_find_cleanest_closid(void);arch/x86/kernel/cpu/resctrl/rdtgroup.c +20
-0@@ -1924,6 +1924,93 @@ int resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_mon_domain *d, return 0; } +/* +* Configure the counter for the event, RMID pair for the domain. +* Update the bitmap and reset the architectural state. +*/ +static int resctrl_config_cntr(struct rdt_resource *r, struct rdt_mon_domain *d, + enum resctrl_event_id evtid, u32 rmid, u32 closid, + u32 cntr_id, bool assign) +{ + int ret; + + ret = resctrl_arch_config_cntr(r, d, evtid, rmid, closid, cntr_id, assign); + if (ret) + return ret; + + if (assign) + __set_bit(cntr_id, d->mbm_cntr_map); + else + __clear_bit(cntr_id, d->mbm_cntr_map); + + /* +* Reset the architectural state so that reading of hardware Quoted 8 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c int resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_mon_domain *d, · line 1949
Quoted 3 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +3
-0+* counter is not considered as an overflow in next update. +*/ + resctrl_arch_reset_rmid(r, d, closid, rmid, evtid);
resctrl_arch_reset_rmid()expects to be run on a CPU that is in the domain @d ... note that after the architectural state is reset it initializes the state by reading the event on the current CPU. By running it here it is run on a random CPU that may not be in the right domain.Yes. That is correct. We can move this part to our earlier implementation. We dont need to read the RMID. We just have to reset the counter.
arch/x86/kernel/cpu/resctrl/rdtgroup.c +0
-0@@ -2371,6 +2371,13 @@ int resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_mon_domain *d, smp_call_function_any(&d->hdr.cpu_mask, resctrl_abmc_config_one_amd, &abmc_cfg, 1);arch/x86/kernel/cpu/resctrl/rdtgroup.c int resctrl_arch_config_cntr(struct rdt_resource · line 2383
Quoted 10 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +7
-0+ /* + * Reset the architectural state so that reading of hardware + * counter is not considered as an overflow in next update. + */ + if (arch_mbm) + memset(arch_mbm, 0, sizeof(struct arch_mbm_state)); + return 0; }I am not sure what you envision here. One motivation for the move out of
resctrl_arch_config_cntr()was to avoid architectural state being reset twice. For reference, mbm_config_write_domain()->resctrl_arch_reset_rmid_all(). Will architectural state be reset twice again?
Quoted 7 lines
Quoted 3 lines
That is good point. We don't have to do it twice.
We can move the whole
reset(arch_mbm)inresctrl_arch_config_cntr().This is not clear to me. The architectural state needs to be reset on MBM config write even when assignable mode is not supported and/or enabled. Moving it to
resctrl_arch_config_cntr()will break this, no?
Yes. The architectural state needs to be reset if ABMC is enabled or not enabled on MBM config write.
Quoted 3 lines
I wonder if it may not simplify things to call
resctrl_arch_reset_rmid()fromresctrl_abmc_config_one_amd()?
Yes. That is is an option. I can try.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
One thing that I did not notice before is that the non-architectural MBM state is not reset. Care should be taken to reset this also when considering that there is a plan to use that MBM state to build a generic rate event for all platforms:
https://lore.kernel.org/all/CALPaoCgFRFgQqG00Uc0GhMHK47bsbtFw6Bxy5O9A_HeYmGa5sA@mail.gmail.com/
Quoted 7 lines
Quoted 5 lines
Did you mean we should add the following code in
resctrl_arch_config_cntr()?m =
get_mbm_state(d, closid, rmid, evtid);
if (m)
memset(m, 0, sizeof(struct mbm_state));This is not arch code but instead resctrl fs, so
resctrl_config_cntr()may be more appropriate?
Sure. We can do that.
Quoted 4 lines
Reinette
Signature · 1 line
- Babu Moger
Re: [PATCH v9 18/26] x86/resctrl: Add the interface to assign/update counter assignment
In reply to Babu MogerHi, Babu,
Quoted 110 lines · Babu Moger
The
mbm_cntr_assignmode offers several hardware counters that can be assigned to an RMID, event pair and monitor the bandwidth as long as it is assigned.Counters are managed at two levels. The global assignment is tracked using the
mbm_cntr_free_mapfield in the structresctrl_mon, while domain-specific assignments are tracked using thembm_cntr_mapfield in the structrdt_mon_domain. Allocation begins at the global level and is then applied individually to each domain.Introduce an interface to allocate these counters and update the corresponding domains accordingly.
Signed-off-by Babu Moger <[email protected]>---
v9: Introduced new functionresctrl_config_cntrto assign the counter, update
the bitmap and reset the architectural state.
Taken care of error handling(freeing the counter) when assignment fails. Movedmbm_cntr_assigned_to_domainhere as it used in this patch. Minor text changes.v8: Renamed
rdtgroup_assign_cntr()tordtgroup_assign_cntr_event().
Added the code to return the error ifrdtgroup_assign_cntr_eventfails. Moved definition ofMBM_EVENT_ARRAY_INDEXtoresctrl/internal.h. Updated typo in the comments.v7: New patch. Moved all the FS code here.
Mergedrdtgroup_assign_cntrandrdtgroup_alloc_cntr. Adde new #defineMBM_EVENT_ARRAY_INDEX.--- arch/x86/kernel/cpu/resctrl/internal.h | 2 + arch/x86/kernel/cpu/resctrl/rdtgroup.c | 87 ++++++++++++++++++++++++++ 2 files changed, 89 insertions(+)arch/x86/kernel/cpu/resctrl/internal.h +2
-0@@ -717,6 +717,8 @@ unsigned int mon_event_config_index_get(u32 evtid);int resctrl_arch_config_cntr (struct rdt_resource *r,struct rdt_mon_domain *d,enum resctrl_event_id evtid,u32 rmid,u32 closid,u32 cntr_id,bool assign); +int rdtgroup_assign_cntr_event (struct rdt_resource *r,struct rdtgroup *rdtgrp, +struct rdt_mon_domain *d,enum resctrl_event_id evtid);void rdt_staged_configs_clear (void );bool closid_allocated (unsigned int closid);int resctrl_find_cleanest_closid (void );arch/x86/kernel/cpu/resctrl/rdtgroup.c +55
-0@@ -1924,6 +1924,93 @@ int resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_mon_domain *d,return 0 ; } +/* +* Configure the counter for the event, RMID pair for the domain. +* Update the bitmap and reset the architectural state. +*/ +static int resctrl_config_cntr (struct rdt_resource *r,struct rdt_mon_domain *d, +enum resctrl_event_id evtid,u32 rmid,u32 closid, +u32 cntr_id,bool assign) +{ +int ret; + + ret =resctrl_arch_config_cntr (r, d, evtid, rmid, closid, cntr_id, assign); +if (ret) +return ret; + +if (assign) +__set_bit (cntr_id, d->mbm_cntr_map); +else +__clear_bit (cntr_id, d->mbm_cntr_map); + +/* +* Reset the architectural state so that reading of hardware +* counter is not considered as an overflow in next update. +*/ +resctrl_arch_reset_rmid (r, d, closid, rmid, evtid); + +return ret; +} + +static bool mbm_cntr_assigned_to_domain (struct rdt_resource *r,u32 cntr_id) +{ +struct rdt_mon_domain *d; + +list_for_each_entry (d, &r->mon_domains, hdr.list) +if (test_bit (cntr_id, d->mbm_cntr_map)) +return 1 ; + +return 0 ; +} + +/* +* Assign a hardware counter to event @evtid of group @rdtgrp. +* Counter will be assigned to all the domains if rdt_mon_domain is NULL +* else the counter will be assigned to specific domain. +*/ +int rdtgroup_assign_cntr_event (struct rdt_resource *r,struct rdtgroup *rdtgrp, +struct rdt_mon_domain *d,enum resctrl_event_id evtid) +{ +int index =MBM_EVENT_ARRAY_INDEX (evtid); +int cntr_id = rdtgrp->mon.cntr_id[index]; +int ret; + +/* +* Allocate a new counter id to the event if the counter is not +* assigned already. +*/
arch/x86/kernel/cpu/resctrl/rdtgroup.c int resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_mon_domain *d, · line 1991
Quoted 10 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +10
-0+if (cntr_id ==MON_CNTR_UNSET ) { + cntr_id =mbm_cntr_alloc (r); +if (cntr_id <0 ) { +rdt_last_cmd_puts ("Out of MBM assignable counters\n" ); +return -ENOSPC ; + } + rdtgrp->mon.cntr_id[index] = cntr_id; + } + +if (!d) {
Should assert cpus are locked here?
/* Walking r->domains, ensure it can't race with cpuhp */
lockdep_assert_cpus_held();Please see more comments on patch #20.
Quoted 15 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +15
-0+list_for_each_entry (d, &r->mon_domains, hdr.list) { + ret =resctrl_config_cntr (r, d, evtid, rdtgrp->mon.rmid, + rdtgrp->closid, cntr_id, true); +if (ret) + goto out_done_assign; + } + }else { + ret =resctrl_config_cntr (r, d, evtid, rdtgrp->mon.rmid, + rdtgrp->closid, cntr_id, true); +if (ret) + goto out_done_assign; + } + +out_done_assign: +if (ret && !mbm_cntr_assigned_to_domain (r, cntr_id)) {
arch/x86/kernel/cpu/resctrl/rdtgroup.c int resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_mon_domain *d, · line 2016
Quoted 10 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +7
-0+mbm_cntr_free (r, cntr_id); +rdtgroup_cntr_id_init (rdtgrp, evtid); + } + +return ret; +} +/* rdtgroup information files for one cache resource. */ static struct rftype res_common_files[] = { {
Thanks.
-Fenghua
Babu Moger
reviewerPATCH v9 19/26 x86/resctrl: Add the interface to unassign a MBM counter
In reply to Babu MogerThe mbm_cntr_assign mode provides a limited number of hardware counters that can be assigned to an RMID, event pair to monitor bandwidth while assigned. If all counters are in use, the kernel will show an error
message: "Out of MBM assignable counters" when a new assignment is requested. To make space for a new assignment, users must unassign an already assigned counter.
Introduce an interface that allows for the unassignment of counter IDs from both the group and the domain. Additionally, ensure that the global counter is released if it is no longer assigned to any domains.
---
v9: Changes related to addition of new function resctrl_config_cntr().
The removed rdtgroup_mbm_cntr_is_assigned() as it was introduced already.
Text changes to take care comments.
v8: Renamed rdtgroup_mbm_cntr_is_assigned to mbm_cntr_assigned_to_domain
Added return error handling in resctrl_arch_config_cntr().
v7: Merged rdtgroup_unassign_cntr and rdtgroup_free_cntr functions.
Renamed rdtgroup_mbm_cntr_test() to rdtgroup_mbm_cntr_is_assigned(). Reworded the commit log little bit.
v6: Removed mbm_cntr_free from this patch.
Added counter test in all the domains and free if it is not assigned to any domains.
v5: Few name changes to match cntr_id.
Changed the function names to rdtgroup_unassign_cntr More comments on commit log.
v4: Added domain specific unassign feature.
Few name changes.
v3: Removed the static from the prototype of rdtgroup_unassign_abmc.
The function is not called directly from user anymore. These changes are related to global assignment interface.
v2: No changes.
--- arch/x86/kernel/cpu/resctrl/internal.h | 2 ++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 41 ++++++++++++++++++++++++++ 2 files changed, 43 insertions(+)
arch/x86/kernel/cpu/resctrl/internal.h +2 -0
@@ -719,6 +719,8 @@ int resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_mon_domain *d, u32 cntr_id, bool assign);int rdtgroup_assign_cntr_event (struct rdt_resource *r,struct rdtgroup *rdtgrp,struct rdt_mon_domain *d,enum resctrl_event_id evtid); +int rdtgroup_unassign_cntr_event (struct rdt_resource *r,struct rdtgroup *rdtgrp, +struct rdt_mon_domain *d,enum resctrl_event_id evtid);void rdt_staged_configs_clear (void );bool closid_allocated (unsigned int closid);int resctrl_find_cleanest_closid (void );
arch/x86/kernel/cpu/resctrl/rdtgroup.c +41 -0
47 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v9 19/26] x86/resctrl: Add the interface to unassign a MBM counter
Hi Babu,
Quoted 11 lines · Babu Moger
The
mbm_cntr_assignmode provides a limited number of hardware counters that can be assigned to an RMID, event pair to monitor bandwidth while assigned. If all counters are in use, the kernel will show an error
message: "Out of MBM assignable counters" when a new assignment is requested. To make space for a new assignment, users must unassign an already assigned counter.Introduce an interface that allows for the unassignment of counter IDs from both the group and the domain. Additionally, ensure that the global counter is released if it is no longer assigned to any domains.
This seems unnecessarily restrictive. What's wrong with monitoring different groups in different domains?
-Peter
Moger, Babu
reviewerRe: [PATCH v9 19/26] x86/resctrl: Add the interface to unassign a MBM counter
Hi Peter,
Quoted 11 lines · Peter Newman
Hi Babu,
Quoted 8 lines · Babu Moger
The
mbm_cntr_assignmode provides a limited number of hardware counters that can be assigned to an RMID, event pair to monitor bandwidth while assigned. If all counters are in use, the kernel will show an error
message: "Out of MBM assignable counters" when a new assignment is requested. To make space for a new assignment, users must unassign an already assigned counter.
Quoted 6 lines
Quoted 3 lines
Introduce an interface that allows for the unassignment of counter IDs from both the group and the domain. Additionally, ensure that the global counter is released if it is no longer assigned to any domains.
This seems unnecessarily restrictive. What's wrong with monitoring different groups in different domains?
Yes. User can monitor different groups in different domains. But, they will have to use different global counter for each group.
Here is an example.
#cat /sys/fs/resctrl/info/L3_MON/mbm_assign_control groupA//0=t;1=_;
groupB//0=_;1=l;
Group A - counter 0 (Assigned to total event in Domain 0) Group B - counter 1 (Assigned to local event in Domain 1)
We allocate two different counters here. Now we are left with 30 counters (max 32).
This is similar to CLOSID management we follow in resctrl. This is not a new restriction,
Signature · 2 lines
Thanks Babu Moger
Re: [PATCH v9 19/26] x86/resctrl: Add the interface to unassign a MBM counter
Hi Babu,
Quoted 19 lines · Babu
Hi Peter,
Quoted 15 lines · Peter Newman
Hi Babu,
Quoted 11 lines · Babu Moger
The
mbm_cntr_assignmode provides a limited number of hardware counters that can be assigned to an RMID, event pair to monitor bandwidth while assigned. If all counters are in use, the kernel will show an error
message: "Out of MBM assignable counters" when a new assignment is requested. To make space for a new assignment, users must unassign an already assigned counter.Introduce an interface that allows for the unassignment of counter IDs from both the group and the domain. Additionally, ensure that the global counter is released if it is no longer assigned to any domains.
Quoted 5 lines
Quoted 2 lines
This seems unnecessarily restrictive. What's wrong with monitoring different groups in different domains?
Yes. User can monitor different groups in different domains. But, they will have to use different global counter for each group.
What is a global counter anyways? It sounds like an artifact of an earlier revision. This concept does not sound intuitive to the user.
Quoted 10 lines
Here is an example.
#cat
/sys/fs/resctrl/info/L3_MON/mbm_assign_controlgroupA//0=t;1=_;
groupB//0=_;1=l;Group A - counter 0 (Assigned to total event in Domain 0) Group B - counter 1 (Assigned to local event in Domain 1)
Quoted 6 lines
We allocate two different counters here. Now we are left with 30 counters (max 32).
This is similar to CLOSID management we follow in resctrl. This is not a new restriction,
It is a restriction in a new feature that resembles a restriction in an existing feature.
I don't see what function the global allocator serves now that there is already a per-domain allocator. My best guess is that it avoids the case of an mbm_assign_control write that succeeds in some domains but fails in others.
I admit I said earlier that I was only planning to allocate globally, but now that I'm evaluating how to make resctrl's monitoring functionality scale on large systems, I'm being forced to reconsider.
As long as this is only a limitation I can fix later, I don't see it as an obstacle. There would just need to be better documentation of what sort of internal data structures the user needs to visualize in order to use this feature successfully.
-Peter
Moger, Babu
reviewerRe: [PATCH v9 19/26] x86/resctrl: Add the interface to unassign a MBM counter
Hi Peter,
Quoted 22 lines · Peter Newman
Hi Babu,
Quoted 19 lines · Babu
Hi Peter,
Quoted 15 lines · Peter Newman
Hi Babu,
Quoted 11 lines · Babu Moger
The
mbm_cntr_assignmode provides a limited number of hardware counters that can be assigned to an RMID, event pair to monitor bandwidth while assigned. If all counters are in use, the kernel will show an error
message: "Out of MBM assignable counters" when a new assignment is requested. To make space for a new assignment, users must unassign an already assigned counter.Introduce an interface that allows for the unassignment of counter IDs from both the group and the domain. Additionally, ensure that the global counter is released if it is no longer assigned to any domains.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
This seems unnecessarily restrictive. What's wrong with monitoring different groups in different domains?
Yes. User can monitor different groups in different domains. But, they will have to use different global counter for each group.
What is a global counter anyways? It sounds like an artifact of an earlier revision. This concept does not sound intuitive to the user.
# cat /sys/fs/resctrl/info/L3_MON/num_mbm_cntrs 32
This is a global counter. We have totally 32 hardware counters.
This is tracked by the bitmap mbm_cntr_free_map.
Quoted 26 lines
Quoted 11 lines
Here is an example.
#cat
/sys/fs/resctrl/info/L3_MON/mbm_assign_controlgroupA//0=t;1=_;
groupB//0=_;1=l;Group A - counter 0 (Assigned to total event in Domain 0) Group B - counter 1 (Assigned to local event in Domain 1)
Quoted 6 lines
We allocate two different counters here. Now we are left with 30 counters (max 32).
This is similar to CLOSID management we follow in resctrl. This is not a new restriction,
It is a restriction in a new feature that resembles a restriction in an existing feature.
I don't see what function the global allocator serves now that there is already a per-domain allocator. My best guess is that it avoids the case of an
mbm_assign_controlwrite that succeeds in some domains but fails in others.
Quoted 8 lines
I admit I said earlier that I was only planning to allocate globally, but now that I'm evaluating how to make resctrl's monitoring functionality scale on large systems, I'm being forced to reconsider.
As long as this is only a limitation I can fix later, I don't see it as an obstacle. There would just need to be better documentation of what sort of internal data structures the user needs to visualize in order to use this feature successfully.
We have totally 32 global counters. That means we can assign up to 32 events.
Assigning events requires sending an IPI to write the MSR (MSR_IA32_L3_QOS_ABMC_CFG) on every domain affected.
So, we wanted another bitmap to track if status of the assignment on each domain. This is tracked by mbm_cntr_map. This bit is updated when we send the IPI on that domain.
I dont consider this as a limitation. This helps to avoid sending unnecessary IPIs to all the domains when user wants to assign an event. This is kind of improvement I would say.
We still have the option to applying the assignment to all the domains by setting "*" for the domain.
Signature · 2 lines
Thanks Babu Moger
Babu Moger
reviewerPATCH v9 20/26 x86/resctrl: Auto assign/unassign counters when mbm_cntr_assign is enabled
In reply to Babu MogerAssign/unassign counters on resctrl group creation/deletion. Two counters are required per group, one for MBM total event and one for MBM local event.
There are a limited number of counters available for assignment. If these counters are exhausted, the kernel will display the error message: "Out of MBM assignable counters". However, it is not necessary to fail the creation of a group due to assignment failures. Users have the flexibility to modify the assignments at a later time.
---
v9: Changed rdtgroup_assign_cntrs() and rdtgroup_unassign_cntrs() to return void.
Updated couple of rdtgroup_unassign_cntrs() calls properly. Updated function comments.
v8: Renamed rdtgroup_assign_grp to rdtgroup_assign_cntrs.
Renamed rdtgroup_unassign_grp to rdtgroup_unassign_cntrs. Fixed the problem with unassigning the child MON groups of CTRL_MON group.
v7: Reworded the commit message.
Removed the reference of ABMC with mbm_cntr_assign. Renamed the function rdtgroup_assign_cntrs to rdtgroup_assign_grp.
v6: Removed the redundant comments on all the calls of
rdtgroup_assign_cntrs. Updated the commit message.
Dropped printing error message on every call of rdtgroup_assign_cntrs.
v5: Removed the code to enable/disable ABMC during the mount.
That will be another patch.
Added arch callers to get the arch specific data. Renamed fuctions to match the other abmc function. Added code comments for assignment failures.
v4: Few name changes based on the upstream discussion.
Commit message update.
v3: This is a new patch. Patch addresses the upstream comment to enable
ABMC feature by default if the feature is available.
--- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 61 +++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/resctrl/rdtgroup.c +60 -1
@@ -2932,6 +2932,46 @@ static void schemata_list_destroy(void) } } +/* +* Called when a new group is created. If "mbm_cntr_assign" mode is enabled, +* counters are automatically assigned. Each group can accommodate two counters: +* one for the total event and one for the local event. Assignments may fail +* due to the limited number of counters. However, it is not necessary to fail +* the group creation and thus no failure is returned. Users have the option +* to modify the counter assignments after the group has been created. +*/ +static void rdtgroup_assign_cntrs (struct rdtgroup *rdtgrp) +{ +struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3 ].r_resctrl; + +if (!resctrl_arch_mbm_cntr_assign_enabled (r)) +return ; + +if (is_mbm_total_enabled ()) +rdtgroup_assign_cntr_event (r, rdtgrp,NULL ,QOS_L3_MBM_TOTAL_EVENT_ID ); + +if (is_mbm_local_enabled ()) +rdtgroup_assign_cntr_event (r, rdtgrp,NULL ,QOS_L3_MBM_LOCAL_EVENT_ID ); +} + +/* +* Called when a group is deleted. Counters are unassigned if it was in +* assigned state. +*/ +static void rdtgroup_unassign_cntrs (struct rdtgroup *rdtgrp) +{ +struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3 ].r_resctrl; + +if (!resctrl_arch_mbm_cntr_assign_enabled (r)) +return ; + +if (is_mbm_total_enabled ()) +rdtgroup_unassign_cntr_event (r, rdtgrp,NULL ,QOS_L3_MBM_TOTAL_EVENT_ID ); + +if (is_mbm_local_enabled ()) +rdtgroup_unassign_cntr_event (r, rdtgrp,NULL ,QOS_L3_MBM_LOCAL_EVENT_ID ); +} +static int rdt_get_tree (struct fs_context *fc) {struct rdt_fs_context *ctx =rdt_fc2context (fc);
@@ -2991,6 +3031,8 @@ static int rdt_get_tree(struct fs_context *fc)if (ret <0 ) goto out_mongrp; rdtgroup_default.mon.mon_data_kn = kn_mondata; + +rdtgroup_assign_cntrs (&rdtgroup_default); } ret =rdt_pseudo_lock_init ();
@@ -3021,8 +3063,10 @@ static int rdt_get_tree(struct fs_context *fc) out_psl:rdt_pseudo_lock_release (); out_mondata: -if (resctrl_arch_mon_capable ()) +if (resctrl_arch_mon_capable ()) { +rdtgroup_unassign_cntrs (&rdtgroup_default);kernfs_remove (kn_mondata); + } out_mongrp:if (resctrl_arch_mon_capable ())kernfs_remove (kn_mongrp);
@@ -3201,6 +3245,7 @@ static void free_all_child_rdtgrp(struct rdtgroup *rdtgrp) head = &rdtgrp->mon.crdtgrp_list;list_for_each_entry_safe (sentry, stmp, head, mon.crdtgrp_list) { +rdtgroup_unassign_cntrs (sentry);free_rmid (sentry->closid, sentry->mon.rmid);list_del (&sentry->mon.crdtgrp_list);
@@ -3241,6 +3286,8 @@ static void rmdir_all_sub(void)cpumask_or (&rdtgroup_default.cpu_mask, &rdtgroup_default.cpu_mask, &rdtgrp->cpu_mask); +rdtgroup_unassign_cntrs (rdtgrp); +free_rmid (rdtgrp->closid, rdtgrp->mon.rmid);kernfs_remove (rdtgrp->kn);
@@ -3272,6 +3319,7 @@ static void rdt_kill_sb(struct super_block *sb)for_each_alloc_capable_rdt_resource (r)reset_all_ctrls (r);rmdir_all_sub (); +rdtgroup_unassign_cntrs (&rdtgroup_default);rdt_pseudo_lock_release (); rdtgroup_default.mode =RDT_MODE_SHAREABLE ;schemata_list_destroy ();
@@ -3280,6 +3328,7 @@ static void rdt_kill_sb(struct super_block *sb)resctrl_arch_disable_alloc ();if (resctrl_arch_mon_capable ())resctrl_arch_disable_mon (); + resctrl_mounted = false;kernfs_kill_sb (sb);mutex_unlock (&rdtgroup_mutex);
@@ -3871,6 +3920,8 @@ static int rdtgroup_mkdir_mon(struct kernfs_node *parent_kn, goto out_unlock; } +rdtgroup_assign_cntrs (rdtgrp); +kernfs_activate (rdtgrp->kn);/*
@@ -3915,6 +3966,8 @@ static int rdtgroup_mkdir_ctrl_mon(struct kernfs_node *parent_kn,if (ret) goto out_closid_free; +rdtgroup_assign_cntrs (rdtgrp); +kernfs_activate (rdtgrp->kn); ret =rdtgroup_init_alloc (rdtgrp);
@@ -3940,6 +3993,7 @@ static int rdtgroup_mkdir_ctrl_mon(struct kernfs_node *parent_kn, out_del_list:list_del (&rdtgrp->rdtgroup_list); out_rmid_free: +rdtgroup_unassign_cntrs (rdtgrp);mkdir_rdt_prepare_rmid_free (rdtgrp); out_closid_free:closid_free (closid);
@@ -4010,6 +4064,9 @@ static int rdtgroup_rmdir_mon(struct rdtgroup *rdtgrp, cpumask_var_t tmpmask)update_closid_rmid (tmpmask,NULL ); rdtgrp->flags =RDT_DELETED ; + +rdtgroup_unassign_cntrs (rdtgrp); +free_rmid (rdtgrp->closid, rdtgrp->mon.rmid);/*
@@ -4056,6 +4113,8 @@ static int rdtgroup_rmdir_ctrl(struct rdtgroup *rdtgrp, cpumask_var_t tmpmask)cpumask_or (tmpmask, tmpmask, &rdtgrp->cpu_mask);update_closid_rmid (tmpmask,NULL ); +rdtgroup_unassign_cntrs (rdtgrp); +free_rmid (rdtgrp->closid, rdtgrp->mon.rmid);closid_free (rdtgrp->closid);
Signature · 1 line
2.34.1
Reinette Chatre
maintainerRe: [PATCH v9 20/26] x86/resctrl: Auto assign/unassign counters when mbm_cntr_assign is enabled
Hi Babu,
Quoted 95 lines · Babu Moger
Assign/unassign counters on resctrl group creation/deletion. Two counters are required per group, one for MBM total event and one for MBM local event.
There are a limited number of counters available for assignment. If these counters are exhausted, the kernel will display the error message: "Out of MBM assignable counters". However, it is not necessary to fail the creation of a group due to assignment failures. Users have the flexibility to modify the assignments at a later time.
Signed-off-by Babu Moger <[email protected]>---
v9: Changedrdtgroup_assign_cntrs()andrdtgroup_unassign_cntrs()to return void.
Updated couple ofrdtgroup_unassign_cntrs()calls properly. Updated function comments.v8: Renamed
rdtgroup_assign_grptordtgroup_assign_cntrs.
Renamedrdtgroup_unassign_grptordtgroup_unassign_cntrs. Fixed the problem with unassigning the child MON groups ofCTRL_MONgroup.v7: Reworded the commit message.
Removed the reference of ABMC withmbm_cntr_assign. Renamed the functionrdtgroup_assign_cntrstordtgroup_assign_grp.v6: Removed the redundant comments on all the calls of
rdtgroup_assign_cntrs. Updated the commit message.
Dropped printing error message on every call ofrdtgroup_assign_cntrs.v5: Removed the code to enable/disable ABMC during the mount.
That will be another patch.
Added arch callers to get the arch specific data. Renamed fuctions to match the other abmc function. Added code comments for assignment failures.v4: Few name changes based on the upstream discussion.
Commit message update.v3: This is a new patch. Patch addresses the upstream comment to enable
ABMC feature by default if the feature is available.--- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 61 +++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-)arch/x86/kernel/cpu/resctrl/rdtgroup.c +40
-0@@ -2932,6 +2932,46 @@ static void schemata_list_destroy(void) } } +/* +* Called when a new group is created. If "mbm_cntr_assign" mode is enabled, +* counters are automatically assigned. Each group can accommodate two counters: +* one for the total event and one for the local event. Assignments may fail +* due to the limited number of counters. However, it is not necessary to fail +* the group creation and thus no failure is returned. Users have the option +* to modify the counter assignments after the group has been created. +*/ +static void rdtgroup_assign_cntrs (struct rdtgroup *rdtgrp) +{ +struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3 ].r_resctrl; + +if (!resctrl_arch_mbm_cntr_assign_enabled (r)) +return ; + +if (is_mbm_total_enabled ()) +rdtgroup_assign_cntr_event (r, rdtgrp,NULL ,QOS_L3_MBM_TOTAL_EVENT_ID ); + +if (is_mbm_local_enabled ()) +rdtgroup_assign_cntr_event (r, rdtgrp,NULL ,QOS_L3_MBM_LOCAL_EVENT_ID ); +} + +/* +* Called when a group is deleted. Counters are unassigned if it was in +* assigned state. +*/ +static void rdtgroup_unassign_cntrs (struct rdtgroup *rdtgrp) +{ +struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3 ].r_resctrl; + +if (!resctrl_arch_mbm_cntr_assign_enabled (r)) +return ; + +if (is_mbm_total_enabled ()) +rdtgroup_unassign_cntr_event (r, rdtgrp,NULL ,QOS_L3_MBM_TOTAL_EVENT_ID ); + +if (is_mbm_local_enabled ()) +rdtgroup_unassign_cntr_event (r, rdtgrp,NULL ,QOS_L3_MBM_LOCAL_EVENT_ID ); +} +static int rdt_get_tree (struct fs_context *fc) {struct rdt_fs_context *ctx =rdt_fc2context (fc);
arch/x86/kernel/cpu/resctrl/rdtgroup.c static int rdt_get_tree(struct fs_context *fc) · line 3035
Quoted 5 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +2
-0@@ -2991,6 +3031,8 @@ static int rdt_get_tree(struct fs_context *fc)if (ret <0 ) goto out_mongrp; rdtgroup_default.mon.mon_data_kn = kn_mondata; + +rdtgroup_assign_cntrs (&rdtgroup_default);
I think counters should be assigned *before* the files exposing them are added to resctrl.
arch/x86/kernel/cpu/resctrl/rdtgroup.c static int rdt_get_tree(struct fs_context *fc) · line 3068
Quoted 11 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +2
-1} ret =rdt_pseudo_lock_init ();@@ -3021,8 +3063,10 @@ static int rdt_get_tree(struct fs_context *fc) out_psl:rdt_pseudo_lock_release (); out_mondata: -if (resctrl_arch_mon_capable ()) +if (resctrl_arch_mon_capable ()) { +rdtgroup_unassign_cntrs (&rdtgroup_default);kernfs_remove (kn_mondata);
... and here remove the files before taking away the data exposed by them.
Quoted 30 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +5
-0+ } out_mongrp:if (resctrl_arch_mon_capable ())kernfs_remove (kn_mongrp);@@ -3201,6 +3245,7 @@ static void free_all_child_rdtgrp(struct rdtgroup *rdtgrp) head = &rdtgrp->mon.crdtgrp_list;list_for_each_entry_safe (sentry, stmp, head, mon.crdtgrp_list) { +rdtgroup_unassign_cntrs (sentry);free_rmid (sentry->closid, sentry->mon.rmid);list_del (&sentry->mon.crdtgrp_list);@@ -3241,6 +3286,8 @@ static void rmdir_all_sub(void)cpumask_or (&rdtgroup_default.cpu_mask, &rdtgroup_default.cpu_mask, &rdtgrp->cpu_mask); +rdtgroup_unassign_cntrs (rdtgrp); +free_rmid (rdtgrp->closid, rdtgrp->mon.rmid);kernfs_remove (rdtgrp->kn);@@ -3272,6 +3319,7 @@ static void rdt_kill_sb(struct super_block *sb)for_each_alloc_capable_rdt_resource (r)reset_all_ctrls (r);rmdir_all_sub (); +rdtgroup_unassign_cntrs (&rdtgroup_default);rdt_pseudo_lock_release (); rdtgroup_default.mode =RDT_MODE_SHAREABLE ;schemata_list_destroy ();
arch/x86/kernel/cpu/resctrl/rdtgroup.c static void rdt_kill_sb(struct super_block *sb) · line 3334
Quoted 7 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +1
-0@@ -3280,6 +3328,7 @@ static void rdt_kill_sb(struct super_block *sb)resctrl_arch_disable_alloc ();if (resctrl_arch_mon_capable ())resctrl_arch_disable_mon (); + resctrl_mounted = false;kernfs_kill_sb (sb);mutex_unlock (&rdtgroup_mutex);
Unnecessary hunk.
Quoted 10 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +2
-0@@ -3871,6 +3920,8 @@ static int rdtgroup_mkdir_mon(struct kernfs_node *parent_kn, goto out_unlock; } +rdtgroup_assign_cntrs (rdtgrp); +kernfs_activate (rdtgrp->kn);/*
arch/x86/kernel/cpu/resctrl/rdtgroup.c static int rdtgroup_mkdir_ctrl_mon(struct kernfs_node *parent_kn, · line 3973
Quoted 8 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +2
-0@@ -3915,6 +3966,8 @@ static int rdtgroup_mkdir_ctrl_mon(struct kernfs_node *parent_kn,if (ret) goto out_closid_free; +rdtgroup_assign_cntrs (rdtgrp); +kernfs_activate (rdtgrp->kn); ret =rdtgroup_init_alloc (rdtgrp);
Please compare the above two hunks with earlier "x86/resctrl: Introduce cntr_id in mongroup for assignments". Earlier patch initializes the counters within mkdir_rdt_prepare_rmid_alloc() while the above hunk assigns the counters after mkdir_rdt_prepare_rmid_alloc() is called. Could this fragmentation be avoided with init done once within mkdir_rdt_prepare_rmid_alloc()?
Quoted 19 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +4
-0@@ -3940,6 +3993,7 @@ static int rdtgroup_mkdir_ctrl_mon(struct kernfs_node *parent_kn, out_del_list:list_del (&rdtgrp->rdtgroup_list); out_rmid_free: +rdtgroup_unassign_cntrs (rdtgrp);mkdir_rdt_prepare_rmid_free (rdtgrp); out_closid_free:closid_free (closid);@@ -4010,6 +4064,9 @@ static int rdtgroup_rmdir_mon(struct rdtgroup *rdtgrp, cpumask_var_t tmpmask)update_closid_rmid (tmpmask,NULL ); rdtgrp->flags =RDT_DELETED ; + +rdtgroup_unassign_cntrs (rdtgrp); +free_rmid (rdtgrp->closid, rdtgrp->mon.rmid);/*
arch/x86/kernel/cpu/resctrl/rdtgroup.c static int rdtgroup_rmdir_ctrl(struct rdtgroup *rdtgrp, cpumask_var_t tmpmask) · line 4120
Quoted 8 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +2
-0@@ -4056,6 +4113,8 @@ static int rdtgroup_rmdir_ctrl(struct rdtgroup *rdtgrp, cpumask_var_t tmpmask)cpumask_or (tmpmask, tmpmask, &rdtgrp->cpu_mask);update_closid_rmid (tmpmask,NULL ); +rdtgroup_unassign_cntrs (rdtgrp); +free_rmid (rdtgrp->closid, rdtgrp->mon.rmid);closid_free (rdtgrp->closid);
There is a potential problem here. rdtgroup_unassign_cntrs() attempts to remove counter from all domains associated with the resource group. This may fail in any of the domains that results in the counter not being marked as free in the global map and not reset the counter in the resource group ... but the resource group is removed right after calling rdtgroup_unassign_cntrs(). In this scenario there is thus a counter that is considered to be in use but not assigned to any resource group.
From what I can tell there is a difference here between default resource group and the others:
on remount of resctrl the default resource group will maintain knowledge of the counter that could not be unassigned. This means that unmount/remount of resctrl does not provide a real "clean slate" when it comes to counter assignment. Is this intended?
Reinette
Re: [PATCH v9 20/26] x86/resctrl: Auto assign/unassign counters when mbm_cntr_assign is enabled
Hi Reinette,
Quoted 98 lines · Reinette Chatre
Hi Babu,
Quoted 95 lines · Babu Moger
Assign/unassign counters on resctrl group creation/deletion. Two counters are required per group, one for MBM total event and one for MBM local event.
There are a limited number of counters available for assignment. If these counters are exhausted, the kernel will display the error message: "Out of MBM assignable counters". However, it is not necessary to fail the creation of a group due to assignment failures. Users have the flexibility to modify the assignments at a later time.
Signed-off-by Babu Moger <[email protected]>---
v9: Changedrdtgroup_assign_cntrs()andrdtgroup_unassign_cntrs()to return void.
Updated couple ofrdtgroup_unassign_cntrs()calls properly. Updated function comments.v8: Renamed
rdtgroup_assign_grptordtgroup_assign_cntrs.
Renamedrdtgroup_unassign_grptordtgroup_unassign_cntrs. Fixed the problem with unassigning the child MON groups ofCTRL_MONgroup.v7: Reworded the commit message.
Removed the reference of ABMC withmbm_cntr_assign. Renamed the functionrdtgroup_assign_cntrstordtgroup_assign_grp.v6: Removed the redundant comments on all the calls of
rdtgroup_assign_cntrs. Updated the commit message.
Dropped printing error message on every call ofrdtgroup_assign_cntrs.v5: Removed the code to enable/disable ABMC during the mount.
That will be another patch.
Added arch callers to get the arch specific data. Renamed fuctions to match the other abmc function. Added code comments for assignment failures.v4: Few name changes based on the upstream discussion.
Commit message update.v3: This is a new patch. Patch addresses the upstream comment to enable
ABMC feature by default if the feature is available.--- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 61 +++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-)arch/x86/kernel/cpu/resctrl/rdtgroup.c +40
-0@@ -2932,6 +2932,46 @@ static void schemata_list_destroy(void) } } +/* +* Called when a new group is created. If "mbm_cntr_assign" mode is enabled, +* counters are automatically assigned. Each group can accommodate two counters: +* one for the total event and one for the local event. Assignments may fail +* due to the limited number of counters. However, it is not necessary to fail +* the group creation and thus no failure is returned. Users have the option +* to modify the counter assignments after the group has been created. +*/ +static void rdtgroup_assign_cntrs (struct rdtgroup *rdtgrp) +{ +struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3 ].r_resctrl; + +if (!resctrl_arch_mbm_cntr_assign_enabled (r)) +return ; + +if (is_mbm_total_enabled ()) +rdtgroup_assign_cntr_event (r, rdtgrp,NULL ,QOS_L3_MBM_TOTAL_EVENT_ID ); + +if (is_mbm_local_enabled ()) +rdtgroup_assign_cntr_event (r, rdtgrp,NULL ,QOS_L3_MBM_LOCAL_EVENT_ID ); +} + +/* +* Called when a group is deleted. Counters are unassigned if it was in +* assigned state. +*/ +static void rdtgroup_unassign_cntrs (struct rdtgroup *rdtgrp) +{ +struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3 ].r_resctrl; + +if (!resctrl_arch_mbm_cntr_assign_enabled (r)) +return ; + +if (is_mbm_total_enabled ()) +rdtgroup_unassign_cntr_event (r, rdtgrp,NULL ,QOS_L3_MBM_TOTAL_EVENT_ID ); + +if (is_mbm_local_enabled ()) +rdtgroup_unassign_cntr_event (r, rdtgrp,NULL ,QOS_L3_MBM_LOCAL_EVENT_ID ); +} +static int rdt_get_tree (struct fs_context *fc) {struct rdt_fs_context *ctx =rdt_fc2context (fc);@@ -2991,6 +3031,8 @@ static int rdt_get_tree(struct fs_context *fc)
Quoted 8 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c static int rdt_get_tree(struct fs_context *fc) · line 3035
Quoted 5 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +2
-0if (ret <0 ) goto out_mongrp; rdtgroup_default.mon.mon_data_kn = kn_mondata; + +rdtgroup_assign_cntrs (&rdtgroup_default);I think counters should be assigned *before* the files exposing them are added to resctrl.
Sure.
Quoted 14 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c static int rdt_get_tree(struct fs_context *fc) · line 3068
Quoted 12 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +2
-1} ret =rdt_pseudo_lock_init ();@@ -3021,8 +3063,10 @@ static int rdt_get_tree(struct fs_context *fc) out_psl:rdt_pseudo_lock_release (); out_mondata: -if (resctrl_arch_mon_capable ()) +if (resctrl_arch_mon_capable ()) { +rdtgroup_unassign_cntrs (&rdtgroup_default);kernfs_remove (kn_mondata);... and here remove the files before taking away the data exposed by them.
Sure.
Quoted 32 lines
Quoted 32 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +5
-0+ } out_mongrp:if (resctrl_arch_mon_capable ())kernfs_remove (kn_mongrp);@@ -3201,6 +3245,7 @@ static void free_all_child_rdtgrp(struct rdtgroup *rdtgrp) head = &rdtgrp->mon.crdtgrp_list;list_for_each_entry_safe (sentry, stmp, head, mon.crdtgrp_list) { +rdtgroup_unassign_cntrs (sentry);free_rmid (sentry->closid, sentry->mon.rmid);list_del (&sentry->mon.crdtgrp_list);@@ -3241,6 +3286,8 @@ static void rmdir_all_sub(void)cpumask_or (&rdtgroup_default.cpu_mask, &rdtgroup_default.cpu_mask, &rdtgrp->cpu_mask); +rdtgroup_unassign_cntrs (rdtgrp); +free_rmid (rdtgrp->closid, rdtgrp->mon.rmid);kernfs_remove (rdtgrp->kn);@@ -3272,6 +3319,7 @@ static void rdt_kill_sb(struct super_block *sb)for_each_alloc_capable_rdt_resource (r)reset_all_ctrls (r);rmdir_all_sub (); +rdtgroup_unassign_cntrs (&rdtgroup_default);rdt_pseudo_lock_release (); rdtgroup_default.mode =RDT_MODE_SHAREABLE ;schemata_list_destroy ();@@ -3280,6 +3328,7 @@ static void rdt_kill_sb(struct super_block *sb)resctrl_arch_disable_alloc ();
Quoted 8 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c static void rdt_kill_sb(struct super_block *sb) · line 3334
Quoted 6 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +1
-0if (resctrl_arch_mon_capable ())resctrl_arch_disable_mon (); + resctrl_mounted = false;kernfs_kill_sb (sb);mutex_unlock (&rdtgroup_mutex);Unnecessary hunk.
ok
Quoted 18 lines
Quoted 18 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +4
-0@@ -3871,6 +3920,8 @@ static int rdtgroup_mkdir_mon(struct kernfs_node *parent_kn, goto out_unlock; } +rdtgroup_assign_cntrs (rdtgrp); +kernfs_activate (rdtgrp->kn);/* @@ -3915,6 +3966,8 @@ static int rdtgroup_mkdir_ctrl_mon(struct kernfs_node *parent_kn,if (ret) goto out_closid_free; +rdtgroup_assign_cntrs (rdtgrp); +kernfs_activate (rdtgrp->kn);
Quoted 6 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c static int rdtgroup_mkdir_ctrl_mon(struct kernfs_node *parent_kn, · line 3973
Quoted 1 line
arch/x86/kernel/cpu/resctrl/rdtgroup.c +0
-0ret =rdtgroup_init_alloc (rdtgrp);Please compare the above two hunks with earlier "x86/resctrl: Introduce
cntr_idin mongroup for assignments". Earlier patch initializes the counters withinmkdir_rdt_prepare_rmid_alloc()while the above hunk assigns the counters aftermkdir_rdt_prepare_rmid_alloc()is called. Could this fragmentation be avoided with init done once withinmkdir_rdt_prepare_rmid_alloc()?
It seems more appropriate to call rdtgroup_cntr_id_init() inside mkdir_rdt_prepare(). This will initialize the cntr_id to MON_CNTR_UNSET.
And then call rdtgroup_assign_cntrs() inside mkdir_rdt_prepare_rmid_alloc().
what do you think?
Quoted 36 lines
Quoted 20 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +4
-0@@ -3940,6 +3993,7 @@ static int rdtgroup_mkdir_ctrl_mon(struct kernfs_node *parent_kn, out_del_list:list_del (&rdtgrp->rdtgroup_list); out_rmid_free: +rdtgroup_unassign_cntrs (rdtgrp);mkdir_rdt_prepare_rmid_free (rdtgrp); out_closid_free:closid_free (closid);@@ -4010,6 +4064,9 @@ static int rdtgroup_rmdir_mon(struct rdtgroup *rdtgrp, cpumask_var_t tmpmask)update_closid_rmid (tmpmask,NULL ); rdtgrp->flags =RDT_DELETED ; + +rdtgroup_unassign_cntrs (rdtgrp); +free_rmid (rdtgrp->closid, rdtgrp->mon.rmid);/* arch/x86/kernel/cpu/resctrl/rdtgroup.c static int rdtgroup_rmdir_ctrl(struct rdtgroup *rdtgrp, cpumask_var_t tmpmask) · line 4120
Quoted 8 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +2
-0@@ -4056,6 +4113,8 @@ static int rdtgroup_rmdir_ctrl(struct rdtgroup *rdtgrp, cpumask_var_t tmpmask)cpumask_or (tmpmask, tmpmask, &rdtgrp->cpu_mask);update_closid_rmid (tmpmask,NULL ); +rdtgroup_unassign_cntrs (rdtgrp); +free_rmid (rdtgrp->closid, rdtgrp->mon.rmid);closid_free (rdtgrp->closid);There is a potential problem here.
rdtgroup_unassign_cntrs()attempts to remove counter from all domains associated with the resource group. This may fail in any of the domains that results in the counter not being marked as free in the global map and not reset the counter in the resource group ... but the resource group is removed right after callingrdtgroup_unassign_cntrs(). In this scenario there is thus a counter that is considered to be in use but not assigned to any resource group.
Quoted 5 lines
Quoted 1 line
From what I can tell there is a difference here between default resource group and the others:
on remount of resctrl the default resource group will maintain knowledge of the counter that could not be unassigned. This means that unmount/remount of resctrl does not provide a real "clean slate" when it comes to counter assignment. Is this intended?
Yes. Agree. It is not intended.
How about adding bitmap_zero() inside rdt_get_tree() to address this problem? Also need to reset the cntr_id in rdt_kill_sb().
Signature · 1 line
- Babu Moger
Re: [PATCH v9 20/26] x86/resctrl: Auto assign/unassign counters when mbm_cntr_assign is enabled
Quoted 244 lines · Babu
Hi Reinette,
Quoted 108 lines · Reinette Chatre
Hi Babu,
Quoted 105 lines · Babu Moger
Assign/unassign counters on resctrl group creation/deletion. Two counters are required per group, one for MBM total event and one for MBM local event.
There are a limited number of counters available for assignment. If these counters are exhausted, the kernel will display the error message: "Out of MBM assignable counters". However, it is not necessary to fail the creation of a group due to assignment failures. Users have the flexibility to modify the assignments at a later time.
Signed-off-by Babu Moger <[email protected]>---
v9: Changedrdtgroup_assign_cntrs()andrdtgroup_unassign_cntrs()to return void. Updated couple ofrdtgroup_unassign_cntrs()calls properly. Updated function comments.v8: Renamed
rdtgroup_assign_grptordtgroup_assign_cntrs.
Renamedrdtgroup_unassign_grptordtgroup_unassign_cntrs. Fixed the problem with unassigning the child MON groups ofCTRL_MONgroup.v7: Reworded the commit message.
Removed the reference of ABMC withmbm_cntr_assign. Renamed the functionrdtgroup_assign_cntrstordtgroup_assign_grp.v6: Removed the redundant comments on all the calls of
rdtgroup_assign_cntrs. Updated the commit message.
Dropped printing error message on every call ofrdtgroup_assign_cntrs.v5: Removed the code to enable/disable ABMC during the mount. That will be another patch.
Added arch callers to get the arch specific data. Renamed fuctions to match the other abmc function. Added code comments for assignment failures.v4: Few name changes based on the upstream discussion. Commit message update.
v3: This is a new patch. Patch addresses the upstream comment to enable ABMC feature by default if the feature is available.
---
arch/x86/kernel/cpu/resctrl/rdtgroup.c| 61 +++++++++++++++++++++++++-1 file changed, 60 insertions(+), 1 deletion(-)arch/x86/kernel/cpu/resctrl/rdtgroup.c +3
-0@@ -2932,6 +2932,46 @@ static void schemata_list_destroy(void) } } +/* +* Called when a new group is created. If "mbm_cntr_assign" mode is enabled, +* counters are automatically assigned. Each group can accommodate two counters:
+ * one for the total event and one for the local event. Assignments may fail
+ * due to the limited number of counters. However, it is not necessary to fail
+ * the group creation and thus no failure is returned. Users have the option
+ * to modify the counter assignments after the group has been created.
+ */arch/x86/kernel/cpu/resctrl/rdtgroup.c +3
-0+static void rdtgroup_assign_cntrs (struct rdtgroup *rdtgrp) +{ + struct rdt_resource *r =&rdt_resources_all[RDT_RESOURCE_L3].r_resctrl;
arch/x86/kernel/cpu/resctrl/rdtgroup.c +6
-0+ + if (!resctrl_arch_mbm_cntr_assign_enabled(r)) + return; + + if (is_mbm_total_enabled()) + rdtgroup_assign_cntr_event(r, rdtgrp, NULL,
QOS_L3_MBM_TOTAL_EVENT_ID);
+
+ if (is_mbm_local_enabled())
+rdtgroup_assign_cntr_event(r, rdtgrp, NULL, QOS_L3_MBM_LOCAL_EVENT_ID);arch/x86/kernel/cpu/resctrl/rdtgroup.c +9
-0+} + +/* +* Called when a group is deleted. Counters are unassigned if it was in +* assigned state. +*/ +static void rdtgroup_unassign_cntrs (struct rdtgroup *rdtgrp) +{ + struct rdt_resource *r =&rdt_resources_all[RDT_RESOURCE_L3].r_resctrl;
arch/x86/kernel/cpu/resctrl/rdtgroup.c +6
-0+ + if (!resctrl_arch_mbm_cntr_assign_enabled(r)) + return; + + if (is_mbm_total_enabled()) + rdtgroup_unassign_cntr_event(r, rdtgrp, NULL,
QOS_L3_MBM_TOTAL_EVENT_ID);
+
+ if (is_mbm_local_enabled())
+rdtgroup_unassign_cntr_event(r, rdtgrp, NULL, QOS_L3_MBM_LOCAL_EVENT_ID);arch/x86/kernel/cpu/resctrl/rdtgroup.c +2
-0+} +static int
rdt_get_tree(struct fs_context *fc){
structrdt_fs_context*ctx =rdt_fc2context(fc);arch/x86/kernel/cpu/resctrl/rdtgroup.c +0
-0@@ -2991,6 +3031,8 @@ static int rdt_get_tree(struct fs_context *fc)Quoted 8 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c static int rdt_get_tree(struct fs_context *fc) · line 3035
Quoted 5 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +2
-0if (ret < 0) goto out_mongrp; rdtgroup_default.mon.mon_data_kn = kn_mondata; + + rdtgroup_assign_cntrs(&rdtgroup_default);I think counters should be assigned *before* the files exposing them are added to resctrl.
Sure.
Quoted 13 lines
Quoted 11 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +0
-0} ret = rdt_pseudo_lock_init();@@ -3021,8 +3063,10 @@ static int rdt_get_tree(struct fs_context *fc)
out_psl:
rdt_pseudo_lock_release();out_mondata:
- if (resctrl_arch_mon_capable())
+ if (resctrl_arch_mon_capable()) {
+rdtgroup_unassign_cntrs(&rdtgroup_default);kernfs_remove(kn_mondata);... and here remove the files before taking away the data exposed by them.
Sure.
Quoted 29 lines
Quoted 29 lines
+ }
out_mongrp:
if (resctrl_arch_mon_capable())
kernfs_remove(kn_mongrp);arch/x86/kernel/cpu/resctrl/rdtgroup.c +4
-0@@ -3201,6 +3245,7 @@ static void free_all_child_rdtgrp(struct rdtgroup *rdtgrp) head = &rdtgrp->mon.crdtgrp_list; list_for_each_entry_safe(sentry, stmp, head, mon.crdtgrp_list) { + rdtgroup_unassign_cntrs(sentry); free_rmid(sentry->closid, sentry->mon.rmid); list_del(&sentry->mon.crdtgrp_list);@@ -3241,6 +3286,8 @@ static void rmdir_all_sub(void) cpumask_or(&rdtgroup_default.cpu_mask, &rdtgroup_default.cpu_mask, &rdtgrp->cpu_mask); + rdtgroup_unassign_cntrs(rdtgrp); + free_rmid(rdtgrp->closid, rdtgrp->mon.rmid); kernfs_remove(rdtgrp->kn);@@ -3272,6 +3319,7 @@ static void rdt_kill_sb(struct super_block *sb) for_each_alloc_capable_rdt_resource(r) reset_all_ctrls(r); rmdir_all_sub(); + rdtgroup_unassign_cntrs(&rdtgroup_default); rdt_pseudo_lock_release(); rdtgroup_default.mode = RDT_MODE_SHAREABLE; schemata_list_destroy();@@ -3280,6 +3328,7 @@ static void rdt_kill_sb(struct super_block *sb) resctrl_arch_disable_alloc();Quoted 8 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c static void rdt_kill_sb(struct super_block *sb) · line 3334
Quoted 6 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +1
-0if (resctrl_arch_mon_capable()) resctrl_arch_disable_mon(); + resctrl_mounted = false; kernfs_kill_sb(sb); mutex_unlock(&rdtgroup_mutex);Unnecessary hunk.
ok
Quoted 14 lines
Quoted 14 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +3
-0@@ -3871,6 +3920,8 @@ static int rdtgroup_mkdir_mon(structkernfs_node *parent_kn, goto out_unlock; } + rdtgroup_assign_cntrs(rdtgrp); + kernfs_activate(rdtgrp->kn); /*@@ -3915,6 +3966,8 @@ static int rdtgroup_mkdir_ctrl_mon(structkernfs_node *parent_kn, if (ret) goto out_closid_free; + rdtgroup_assign_cntrs(rdtgrp);Quoted 8 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c static int rdtgroup_mkdir_ctrl_mon(struct kernfs_node *parent_kn, · line 3973
Quoted 3 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +1
-0+ kernfs_activate(rdtgrp->kn); ret = rdtgroup_init_alloc(rdtgrp);Please compare the above two hunks with earlier "x86/resctrl: Introduce
cntr_idin mongroup for assignments". Earlier patch initializes the counters withinmkdir_rdt_prepare_rmid_alloc()while the above hunk assigns the counters aftermkdir_rdt_prepare_rmid_alloc()is called. Could this fragmentation be avoided with init done once withinmkdir_rdt_prepare_rmid_alloc()?It seems more appropriate to call
rdtgroup_cntr_id_init()insidemkdir_rdt_prepare(). This will initialize thecntr_idtoMON_CNTR_UNSET.And then call
rdtgroup_assign_cntrs()insidemkdir_rdt_prepare_rmid_alloc().what do you think?
Quoted 36 lines
Quoted 20 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +0
-0@@ -3940,6 +3993,7 @@ static int rdtgroup_mkdir_ctrl_mon(struct kernfs_node *parent_kn,
out_del_list:
list_del(&rdtgrp->rdtgroup_list);
out_rmid_free:
+rdtgroup_unassign_cntrs(rdtgrp);
mkdir_rdt_prepare_rmid_free(rdtgrp);
out_closid_free:
closid_free(closid);arch/x86/kernel/cpu/resctrl/rdtgroup.c +3
-0@@ -4010,6 +4064,9 @@ static int rdtgroup_rmdir_mon(struct rdtgroup *rdtgrp, cpumask_var_t tmpmask) update_closid_rmid(tmpmask, NULL); rdtgrp->flags = RDT_DELETED; + + rdtgroup_unassign_cntrs(rdtgrp); + free_rmid(rdtgrp->closid, rdtgrp->mon.rmid); /*arch/x86/kernel/cpu/resctrl/rdtgroup.c static int rdtgroup_rmdir_ctrl(struct rdtgroup · line 4119
Quoted 7 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +2
-0@@ -4056,6 +4113,8 @@ static int rdtgroup_rmdir_ctrl(struct rdtgroup *rdtgrp, cpumask_var_t tmpmask) cpumask_or(tmpmask, tmpmask, &rdtgrp->cpu_mask); update_closid_rmid(tmpmask, NULL); + rdtgroup_unassign_cntrs(rdtgrp); + free_rmid(rdtgrp->closid, rdtgrp->mon.rmid); closid_free(rdtgrp->closid);There is a potential problem here.
rdtgroup_unassign_cntrs()attempts to remove counter from all domains associated with the resource group. This may fail in any of the domains that results in the counter not being marked as free in the global map and not reset the counter in the resource group ... but the resource group is removed right after callingrdtgroup_unassign_cntrs(). In this scenario there is thus a counter that is considered to be in use but not assigned to any resource group.Quoted 1 line
Quoted 1 line
From what I can tell there is a difference here between default resource group and the others:
Quoted 8 lines
Quoted 4 lines
on remount of resctrl the default resource group will maintain knowledge of the counter that could not be unassigned. This means that unmount/remount of resctrl does not provide a real "clean slate" when it comes to counter assignment. Is this intended?
Yes. Agree. It is not intended.
How about adding
bitmap_zero()insiderdt_get_tree()to address this problem? Also need to reset thecntr_idinrdt_kill_sb().
I meant reset the cntr_id for the default group in rdt_kill_sb().
Signature · 1 line
- Babu Moger
Reinette Chatre
maintainerRe: [PATCH v9 20/26] x86/resctrl: Auto assign/unassign counters when mbm_cntr_assign is enabled
Hi Babu,
Quoted 24 lines · Babu
Quoted 23 lines · Babu
Quoted 21 lines · Reinette Chatre
Quoted 8 lines · Babu Moger
arch/x86/kernel/cpu/resctrl/rdtgroup.c +2
-0@@ -3871,6 +3920,8 @@ static int rdtgroup_mkdir_mon(struct kernfs_node *parent_kn, goto out_unlock; } + rdtgroup_assign_cntrs(rdtgrp); + kernfs_activate(rdtgrp->kn); /*arch/x86/kernel/cpu/resctrl/rdtgroup.c static int rdtgroup_mkdir_ctrl_mon(struct kernfs_node *parent_kn, · line 3971
Quoted 6 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +2
-0@@ -3915,6 +3966,8 @@ static int rdtgroup_mkdir_ctrl_mon(struct kernfs_node *parent_kn, if (ret) goto out_closid_free; + rdtgroup_assign_cntrs(rdtgrp); + kernfs_activate(rdtgrp->kn); ret = rdtgroup_init_alloc(rdtgrp);Please compare the above two hunks with earlier "x86/resctrl: Introduce
cntr_idin mongroup for assignments". Earlier patch initializes the counters withinmkdir_rdt_prepare_rmid_alloc()while the above hunk assigns the counters aftermkdir_rdt_prepare_rmid_alloc()is called. Could this fragmentation be avoided with init done once withinmkdir_rdt_prepare_rmid_alloc()?
Quoted 5 lines
Quoted 5 lines
It seems more appropriate to call
rdtgroup_cntr_id_init()insidemkdir_rdt_prepare(). This will initialize thecntr_idtoMON_CNTR_UNSET.And then call
rdtgroup_assign_cntrs()insidemkdir_rdt_prepare_rmid_alloc().what do you think?
Taking a closer look this seems most appropriate. mkdir_rdt_prepare() is where the resource groupreset is created and all fields initialized, control and monitoring (irrespective of monitoring enabled). Doing the MON_CNTR_UNSET initalization in that central place seems good.
Yes, and then assigning the counters in mkdir_rdt_prepare_rmid_alloc() sounds good.
Quoted 37 lines
Quoted 37 lines
Quoted 36 lines
Quoted 17 lines
(quoted diff) +0
-0@@ -3940,6 +3993,7 @@ static int rdtgroup_mkdir_ctrl_mon(struct kernfs_node *parent_kn,
out_del_list:
list_del(&rdtgrp->rdtgroup_list);
out_rmid_free:
+rdtgroup_unassign_cntrs(rdtgrp);
mkdir_rdt_prepare_rmid_free(rdtgrp);
out_closid_free:
closid_free(closid);arch/x86/kernel/cpu/resctrl/rdtgroup.c +3
-0@@ -4010,6 +4064,9 @@ static int rdtgroup_rmdir_mon(struct rdtgroup *rdtgrp, cpumask_var_t tmpmask) update_closid_rmid(tmpmask, NULL); rdtgrp->flags = RDT_DELETED; + + rdtgroup_unassign_cntrs(rdtgrp); + free_rmid(rdtgrp->closid, rdtgrp->mon.rmid); /*arch/x86/kernel/cpu/resctrl/rdtgroup.c static int rdtgroup_rmdir_ctrl(struct rdtgroup *rdtgrp, cpumask_var_t tmpmask) · line 4118
Quoted 6 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +2
-0@@ -4056,6 +4113,8 @@ static int rdtgroup_rmdir_ctrl(struct rdtgroup *rdtgrp, cpumask_var_t tmpmask) cpumask_or(tmpmask, tmpmask, &rdtgrp->cpu_mask); update_closid_rmid(tmpmask, NULL); + rdtgroup_unassign_cntrs(rdtgrp); + free_rmid(rdtgrp->closid, rdtgrp->mon.rmid); closid_free(rdtgrp->closid);There is a potential problem here.
rdtgroup_unassign_cntrs()attempts to remove counter from all domains associated with the resource group. This may fail in any of the domains that results in the counter not being marked as free in the global map and not reset the counter in the resource group ... but the resource group is removed right after callingrdtgroup_unassign_cntrs(). In this scenario there is thus a counter that is considered to be in use but not assigned to any resource group.Quoted 1 line
Quoted 1 line
From what I can tell there is a difference here between default resource group and the others:
on remount of resctrl the default resource group will maintain knowledge of the counter that could not be unassigned. This means that unmount/remount of resctrl does not provide a real "clean slate" when it comes to counter assignment. Is this intended?
Quoted 5 lines
Quoted 3 lines
Yes. Agree. It is not intended.
How about adding
bitmap_zero()insiderdt_get_tree()to address this problem? Also need to reset thecntr_idinrdt_kill_sb().I meant reset the
cntr_idfor the default group inrdt_kill_sb().
Doing the cntr_id reset like this matches the custom is to reset to defaults in rdt_kill_sb(). I am not sure what you envision with the bitmap_zero() in rdt_get_tree() ... I wonder if it may not just be simpler to call mbm_cntr_reset() from rdt_kill_sb()? This does raise the question if mbm_cntr_reset() should reset architectural state. I do not think it does harm, the state will just be reset again when the mon dirs are created?
Reinette
Re: [PATCH v9 20/26] x86/resctrl: Auto assign/unassign counters when mbm_cntr_assign is enabled
Hi Reinette,
Quoted 29 lines · Reinette Chatre
Hi Babu,
Quoted 26 lines · Babu
Quoted 25 lines · Babu
Quoted 13 lines · Reinette Chatre
Quoted 11 lines · Babu Moger
arch/x86/kernel/cpu/resctrl/rdtgroup.c +3
-0@@ -3871,6 +3920,8 @@ static int rdtgroup_mkdir_mon(struct kernfs_node *parent_kn, goto out_unlock; } + rdtgroup_assign_cntrs(rdtgrp); + kernfs_activate(rdtgrp->kn); /*@@ -3915,6 +3966,8 @@ static int rdtgroup_mkdir_ctrl_mon(struct kernfs_node *parent_kn, if (ret) goto out_closid_free; + rdtgroup_assign_cntrs(rdtgrp);Quoted 8 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c static int rdtgroup_mkdir_ctrl_mon(struct kernfs_node *parent_kn, · line 3973
Quoted 3 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +1
-0+ kernfs_activate(rdtgrp->kn); ret = rdtgroup_init_alloc(rdtgrp);Please compare the above two hunks with earlier "x86/resctrl: Introduce
cntr_idin mongroup for assignments". Earlier patch initializes the counters withinmkdir_rdt_prepare_rmid_alloc()while the above hunk assigns the counters aftermkdir_rdt_prepare_rmid_alloc()is called. Could this fragmentation be avoided with init done once withinmkdir_rdt_prepare_rmid_alloc()?It seems more appropriate to call
rdtgroup_cntr_id_init()insidemkdir_rdt_prepare(). This will initialize thecntr_idtoMON_CNTR_UNSET.
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
And then call
rdtgroup_assign_cntrs()insidemkdir_rdt_prepare_rmid_alloc().what do you think?
Taking a closer look this seems most appropriate.
mkdir_rdt_prepare()is where the resource groupreset is created and all fields initialized, control and monitoring (irrespective of monitoring enabled). Doing theMON_CNTR_UNSETinitalization in that central place seems good.
Yes, and then assigning the counters inmkdir_rdt_prepare_rmid_alloc()sounds good.
ok.
Quoted 42 lines
Quoted 42 lines
Quoted 41 lines
Quoted 32 lines
Quoted 18 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +4
-0@@ -3940,6 +3993,7 @@ static int rdtgroup_mkdir_ctrl_mon(struct kernfs_node *parent_kn, out_del_list: list_del(&rdtgrp->rdtgroup_list); out_rmid_free: + rdtgroup_unassign_cntrs(rdtgrp); mkdir_rdt_prepare_rmid_free(rdtgrp); out_closid_free: closid_free(closid);@@ -4010,6 +4064,9 @@ static int rdtgroup_rmdir_mon(struct rdtgroup *rdtgrp, cpumask_var_t tmpmask) update_closid_rmid(tmpmask, NULL); rdtgrp->flags = RDT_DELETED; + + rdtgroup_unassign_cntrs(rdtgrp); + free_rmid(rdtgrp->closid, rdtgrp->mon.rmid); /*arch/x86/kernel/cpu/resctrl/rdtgroup.c static int rdtgroup_rmdir_ctrl(struct rdtgroup *rdtgrp, cpumask_var_t tmpmask) · line 4118
Quoted 6 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +2
-0@@ -4056,6 +4113,8 @@ static int rdtgroup_rmdir_ctrl(struct rdtgroup *rdtgrp, cpumask_var_t tmpmask) cpumask_or(tmpmask, tmpmask, &rdtgrp->cpu_mask); update_closid_rmid(tmpmask, NULL); + rdtgroup_unassign_cntrs(rdtgrp); + free_rmid(rdtgrp->closid, rdtgrp->mon.rmid); closid_free(rdtgrp->closid);There is a potential problem here.
rdtgroup_unassign_cntrs()attempts to remove counter from all domains associated with the resource group. This may fail in any of the domains that results in the counter not being marked as free in the global map and not reset the counter in the resource group ... but the resource group is removed right after callingrdtgroup_unassign_cntrs(). In this scenario there is thus a counter that is considered to be in use but not assigned to any resource group.Quoted 5 lines
Quoted 1 line
Quoted 1 line
From what I can tell there is a difference here between default resource group and the others:
on remount of resctrl the default resource group will maintain knowledge of the counter that could not be unassigned. This means that unmount/remount of resctrl does not provide a real "clean slate" when it comes to counter assignment. Is this intended?
Yes. Agree. It is not intended.
How about adding
bitmap_zero()insiderdt_get_tree()to address this problem? Also need to reset thecntr_idinrdt_kill_sb().
Quoted 7 lines
Quoted 1 line
I meant reset the
cntr_idfor the default group inrdt_kill_sb().Doing the
cntr_idreset like this matches the custom is to reset to defaults inrdt_kill_sb(). I am not sure what you envision with thebitmap_zero()inrdt_get_tree()... I wonder if it may not just be simpler to callmbm_cntr_reset()fromrdt_kill_sb()? This does raise the question ifmbm_cntr_reset()should reset architectural state. I do not think it does harm, the state will just be reset again when the mon dirs are created?
Yes. Calling mbm_cntr_reset() from rdt_kill_sb() seems more clean approach.
Architectural state will reset again when counter is assigned(when mon directories are created).
thanks
- Babu Moger
Re: [PATCH v9 20/26] x86/resctrl: Auto assign/unassign counters when mbm_cntr_assign is enabled
In reply to Babu MogerHi, Babu,
Quoted 58 lines · Babu Moger
Assign/unassign counters on resctrl group creation/deletion. Two counters are required per group, one for MBM total event and one for MBM local event.
There are a limited number of counters available for assignment. If these counters are exhausted, the kernel will display the error message: "Out of MBM assignable counters". However, it is not necessary to fail the creation of a group due to assignment failures. Users have the flexibility to modify the assignments at a later time.
Signed-off-by Babu Moger <[email protected]>---
v9: Changedrdtgroup_assign_cntrs()andrdtgroup_unassign_cntrs()to return void.
Updated couple ofrdtgroup_unassign_cntrs()calls properly. Updated function comments.v8: Renamed
rdtgroup_assign_grptordtgroup_assign_cntrs.
Renamedrdtgroup_unassign_grptordtgroup_unassign_cntrs. Fixed the problem with unassigning the child MON groups ofCTRL_MONgroup.v7: Reworded the commit message.
Removed the reference of ABMC withmbm_cntr_assign. Renamed the functionrdtgroup_assign_cntrstordtgroup_assign_grp.v6: Removed the redundant comments on all the calls of
rdtgroup_assign_cntrs. Updated the commit message.
Dropped printing error message on every call ofrdtgroup_assign_cntrs.v5: Removed the code to enable/disable ABMC during the mount.
That will be another patch.
Added arch callers to get the arch specific data. Renamed fuctions to match the other abmc function. Added code comments for assignment failures.v4: Few name changes based on the upstream discussion.
Commit message update.v3: This is a new patch. Patch addresses the upstream comment to enable
ABMC feature by default if the feature is available.--- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 61 +++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-)arch/x86/kernel/cpu/resctrl/rdtgroup.c +7
-0@@ -2932,6 +2932,46 @@ static void schemata_list_destroy(void) } } +/* +* Called when a new group is created. If "mbm_cntr_assign" mode is enabled, +* counters are automatically assigned. Each group can accommodate two counters: +* one for the total event and one for the local event. Assignments may fail +* due to the limited number of counters. However, it is not necessary to fail +* the group creation and thus no failure is returned. Users have the option +* to modify the counter assignments after the group has been created.
arch/x86/kernel/cpu/resctrl/rdtgroup.c static void schemata_list_destroy(void) · line 2951
Quoted 10 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +10
-0+*/ +static void rdtgroup_assign_cntrs (struct rdtgroup *rdtgrp) +{ +struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3 ].r_resctrl; + +if (!resctrl_arch_mbm_cntr_assign_enabled (r)) +return ; + +if (is_mbm_total_enabled ()) +rdtgroup_assign_cntr_event (r, rdtgrp,NULL ,QOS_L3_MBM_TOTAL_EVENT_ID );
In this code path, resctrl_mkdir()->resctrl_mkdir_ctrl_mon()->rdtgroup_assign_cntrs()->rdtgroup_assign_cntr_event()
CPUs are not protected by read lock while rdtgroup_assign_cntr_event() walks r->mon_domains and run assing counters code on CPUs in the domains. Without CPU protection, r->mon_domains may race with CPU hotplug.
In another patch (i.e. rdt_get_tree()), rdtgroup_assign_cntrs() is protected by cpus_read_lock()/unlock().
So maybe define two helpers:
// Called when caller takes cpus_read_lock()rdtgroup_assign_cntrs_locked()
{
lockdep_assert_cpus_held();
then the current rdtgroup_assign_cntrs() code
}// Called when caller doesn't take cpus_read_lock() rdtgroup_assign_cntrs()
{
cpus_read_lock();
rdtgroup_assign_cntrs_locked();
cpus_read_unlock();
}Quoted 13 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +13
-0+ +if (is_mbm_local_enabled ()) +rdtgroup_assign_cntr_event (r, rdtgrp,NULL ,QOS_L3_MBM_LOCAL_EVENT_ID ); +} + +/* +* Called when a group is deleted. Counters are unassigned if it was in +* assigned state. +*/ +static void rdtgroup_unassign_cntrs (struct rdtgroup *rdtgrp) +{ +struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3 ].r_resctrl; +
arch/x86/kernel/cpu/resctrl/rdtgroup.c static void schemata_list_destroy(void) · line 2974
Quoted 10 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +10
-0+if (!resctrl_arch_mbm_cntr_assign_enabled (r)) +return ; + +if (is_mbm_total_enabled ()) +rdtgroup_unassign_cntr_event (r, rdtgrp,NULL ,QOS_L3_MBM_TOTAL_EVENT_ID ); + +if (is_mbm_local_enabled ()) +rdtgroup_unassign_cntr_event (r, rdtgrp,NULL ,QOS_L3_MBM_LOCAL_EVENT_ID ); +} +
Seems rdtgroup_unassign_cntrs() is always protected by cpus_read_lock()/unlock(). So it's good.
arch/x86/kernel/cpu/resctrl/rdtgroup.c static int rdt_get_tree(struct fs_context *fc) · line 3035
Quoted 9 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +2
-0static int rdt_get_tree (struct fs_context *fc) {struct rdt_fs_context *ctx =rdt_fc2context (fc);@@ -2991,6 +3031,8 @@ static int rdt_get_tree(struct fs_context *fc)if (ret <0 ) goto out_mongrp; rdtgroup_default.mon.mon_data_kn = kn_mondata; + +rdtgroup_assign_cntrs (&rdtgroup_default);
In this case, cpus_read_lock() was called earlier. Change to rdtgroup_assign_cntrs_locked().
Quoted 41 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +7
-1} ret =rdt_pseudo_lock_init ();@@ -3021,8 +3063,10 @@ static int rdt_get_tree(struct fs_context *fc) out_psl:rdt_pseudo_lock_release (); out_mondata: -if (resctrl_arch_mon_capable ()) +if (resctrl_arch_mon_capable ()) { +rdtgroup_unassign_cntrs (&rdtgroup_default);kernfs_remove (kn_mondata); + } out_mongrp:if (resctrl_arch_mon_capable ())kernfs_remove (kn_mongrp);@@ -3201,6 +3245,7 @@ static void free_all_child_rdtgrp(struct rdtgroup *rdtgrp) head = &rdtgrp->mon.crdtgrp_list;list_for_each_entry_safe (sentry, stmp, head, mon.crdtgrp_list) { +rdtgroup_unassign_cntrs (sentry);free_rmid (sentry->closid, sentry->mon.rmid);list_del (&sentry->mon.crdtgrp_list);@@ -3241,6 +3286,8 @@ static void rmdir_all_sub(void)cpumask_or (&rdtgroup_default.cpu_mask, &rdtgroup_default.cpu_mask, &rdtgrp->cpu_mask); +rdtgroup_unassign_cntrs (rdtgrp); +free_rmid (rdtgrp->closid, rdtgrp->mon.rmid);kernfs_remove (rdtgrp->kn);@@ -3272,6 +3319,7 @@ static void rdt_kill_sb(struct super_block *sb)for_each_alloc_capable_rdt_resource (r)reset_all_ctrls (r);rmdir_all_sub (); +rdtgroup_unassign_cntrs (&rdtgroup_default);rdt_pseudo_lock_release (); rdtgroup_default.mode =RDT_MODE_SHAREABLE ;schemata_list_destroy ();
arch/x86/kernel/cpu/resctrl/rdtgroup.c static void rdt_kill_sb(struct super_block *sb) · line 3331
Quoted 4 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +1
-0@@ -3280,6 +3328,7 @@ static void rdt_kill_sb(struct super_block *sb)resctrl_arch_disable_alloc ();if (resctrl_arch_mon_capable ())resctrl_arch_disable_mon (); +
Unnecessary change.
Quoted 39 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +8
-0resctrl_mounted = false;kernfs_kill_sb (sb);mutex_unlock (&rdtgroup_mutex);@@ -3871,6 +3920,8 @@ static int rdtgroup_mkdir_mon(struct kernfs_node *parent_kn, goto out_unlock; } +rdtgroup_assign_cntrs (rdtgrp); + > kernfs_activate(rdtgrp->kn);/* @@ -3915,6 +3966,8 @@ static int rdtgroup_mkdir_ctrl_mon(struct kernfs_node *parent_kn,if (ret) goto out_closid_free; +rdtgroup_assign_cntrs (rdtgrp); +kernfs_activate (rdtgrp->kn); ret =rdtgroup_init_alloc (rdtgrp);@@ -3940,6 +3993,7 @@ static int rdtgroup_mkdir_ctrl_mon(struct kernfs_node *parent_kn, out_del_list:list_del (&rdtgrp->rdtgroup_list); out_rmid_free: +rdtgroup_unassign_cntrs (rdtgrp);mkdir_rdt_prepare_rmid_free (rdtgrp); out_closid_free:closid_free (closid);@@ -4010,6 +4064,9 @@ static int rdtgroup_rmdir_mon(struct rdtgroup *rdtgrp, cpumask_var_t tmpmask)update_closid_rmid (tmpmask,NULL ); rdtgrp->flags =RDT_DELETED ; + +rdtgroup_unassign_cntrs (rdtgrp); +free_rmid (rdtgrp->closid, rdtgrp->mon.rmid);/*
arch/x86/kernel/cpu/resctrl/rdtgroup.c static int rdtgroup_rmdir_ctrl(struct rdtgroup *rdtgrp, cpumask_var_t tmpmask) · line 4120
Quoted 8 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +2
-0@@ -4056,6 +4113,8 @@ static int rdtgroup_rmdir_ctrl(struct rdtgroup *rdtgrp, cpumask_var_t tmpmask)cpumask_or (tmpmask, tmpmask, &rdtgrp->cpu_mask);update_closid_rmid (tmpmask,NULL ); +rdtgroup_unassign_cntrs (rdtgrp); +free_rmid (rdtgrp->closid, rdtgrp->mon.rmid);closid_free (rdtgrp->closid);
Thanks.
-Fenghua
Reinette Chatre
maintainerRe: [PATCH v9 20/26] x86/resctrl: Auto assign/unassign counters when mbm_cntr_assign is enabled
Hi Fenghua,
Quoted 74 lines · Fenghua Yu
Hi, Babu,
Quoted 58 lines · Babu Moger
Assign/unassign counters on resctrl group creation/deletion. Two counters are required per group, one for MBM total event and one for MBM local event.
There are a limited number of counters available for assignment. If these counters are exhausted, the kernel will display the error message: "Out of MBM assignable counters". However, it is not necessary to fail the creation of a group due to assignment failures. Users have the flexibility to modify the assignments at a later time.
Signed-off-by Babu Moger <[email protected]>---
v9: Changedrdtgroup_assign_cntrs()andrdtgroup_unassign_cntrs()to return void. Updated couple ofrdtgroup_unassign_cntrs()calls properly. Updated function comments.v8: Renamed
rdtgroup_assign_grptordtgroup_assign_cntrs.
Renamedrdtgroup_unassign_grptordtgroup_unassign_cntrs. Fixed the problem with unassigning the child MON groups ofCTRL_MONgroup.v7: Reworded the commit message.
Removed the reference of ABMC withmbm_cntr_assign. Renamed the functionrdtgroup_assign_cntrstordtgroup_assign_grp.v6: Removed the redundant comments on all the calls of
rdtgroup_assign_cntrs. Updated the commit message.
Dropped printing error message on every call ofrdtgroup_assign_cntrs.v5: Removed the code to enable/disable ABMC during the mount. That will be another patch.
Added arch callers to get the arch specific data. Renamed fuctions to match the other abmc function. Added code comments for assignment failures.v4: Few name changes based on the upstream discussion. Commit message update.
v3: This is a new patch. Patch addresses the upstream comment to enable ABMC feature by default if the feature is available.
---
arch/x86/kernel/cpu/resctrl/rdtgroup.c| 61 +++++++++++++++++++++++++-1 file changed, 60 insertions(+), 1 deletion(-)arch/x86/kernel/cpu/resctrl/rdtgroup.c +0
-0@@ -2932,6 +2932,46 @@ static void schemata_list_destroy(void) } }+/*
+ * Called when a new group is created. If "mbm_cntr_assign" mode is enabled,
+ * counters are automatically assigned. Each group can accommodate two counters:
+ * one for the total event and one for the local event. Assignments may fail
+ * due to the limited number of counters. However, it is not necessary to fail
+ * the group creation and thus no failure is returned. Users have the option
+ * to modify the counter assignments after the group has been created.
+ */arch/x86/kernel/cpu/resctrl/rdtgroup.c static void schemata_list_destroy(void) · line 2951
Quoted 9 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +9
-0+static void rdtgroup_assign_cntrs (struct rdtgroup *rdtgrp) +{ + struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; + + if (!resctrl_arch_mbm_cntr_assign_enabled(r)) + return; + + if (is_mbm_total_enabled()) + rdtgroup_assign_cntr_event(r, rdtgrp, NULL, QOS_L3_MBM_TOTAL_EVENT_ID);In this code path, resctrl_mkdir()->resctrl_mkdir_ctrl_mon()->rdtgroup_assign_cntrs()->rdtgroup_assign_cntr_event()
Quoted 1 line
CPUs are not protected by read lock while
rdtgroup_assign_cntr_event()walksr->mon_domainsand run assing counters code on CPUs in the domains. Without CPU protection,r->mon_domainsmay race with CPU hotplug.
From what I can tell rdtgroup_assign_cntrs() is called with CPU hotplug lock held:
rdtgroup_mkdir_ctrl_mon()
{
ret = mkdir_rdt_prepare(...); /* mkdir_rdt_prepare()->rdtgroup_kn_lock_live()->cpus_read_lock() */ ... rdtgroup_assign_cntrs(rdtgrp); ... rdtgroup_kn_unlock(parent_kn); /* rdtgroup_kn_unlock()->cpus_read_unlock() */ return ret; }
Reinette
Moger, Babu
reviewerRe: [PATCH v9 20/26] x86/resctrl: Auto assign/unassign counters when mbm_cntr_assign is enabled
In reply to Fenghua YuHi Fenghua,
Thanks for the review.
Quoted 101 lines · Fenghua Yu
Hi, Babu,
Quoted 76 lines · Babu Moger
Assign/unassign counters on resctrl group creation/deletion. Two counters are required per group, one for MBM total event and one for MBM local event.
There are a limited number of counters available for assignment. If these counters are exhausted, the kernel will display the error message: "Out of MBM assignable counters". However, it is not necessary to fail the creation of a group due to assignment failures. Users have the flexibility to modify the assignments at a later time.
Signed-off-by Babu Moger <[email protected]>---
v9: Changedrdtgroup_assign_cntrs()andrdtgroup_unassign_cntrs()to return void.
Updated couple ofrdtgroup_unassign_cntrs()calls properly. Updated function comments.v8: Renamed
rdtgroup_assign_grptordtgroup_assign_cntrs. Renamedrdtgroup_unassign_grptordtgroup_unassign_cntrs. Fixed the problem with unassigning the child MON groups ofCTRL_MONgroup.v7: Reworded the commit message.
Removed the reference of ABMC withmbm_cntr_assign. Renamed the functionrdtgroup_assign_cntrstordtgroup_assign_grp.v6: Removed the redundant comments on all the calls of
rdtgroup_assign_cntrs. Updated the commit message.
Dropped printing error message on every call ofrdtgroup_assign_cntrs.v5: Removed the code to enable/disable ABMC during the mount. That will be another patch.
Added arch callers to get the arch specific data. Renamed fuctions to match the other abmc function. Added code comments for assignment failures.v4: Few name changes based on the upstream discussion. Commit message update.
v3: This is a new patch. Patch addresses the upstream comment to enable ABMC feature by default if the feature is available.
---
arch/x86/kernel/cpu/resctrl/rdtgroup.c| 61 +++++++++++++++++++++++++-1 file changed, 60 insertions(+), 1 deletion(-)arch/x86/kernel/cpu/resctrl/rdtgroup.c +0
-0@@ -2932,6 +2932,46 @@ static void schemata_list_destroy(void) } }+/*
+ * Called when a new group is created. If "mbm_cntr_assign" mode is enabled,
+ * counters are automatically assigned. Each group can accommodate two counters:
+ * one for the total event and one for the local event. Assignments may fail
+ * due to the limited number of counters. However, it is not necessary to fail
+ * the group creation and thus no failure is returned. Users have the option
+ * to modify the counter assignments after the group has been created.
+ */arch/x86/kernel/cpu/resctrl/rdtgroup.c +3
-0+static void rdtgroup_assign_cntrs (struct rdtgroup *rdtgrp) +{ + struct rdt_resource *r =&rdt_resources_all[RDT_RESOURCE_L3].r_resctrl;
arch/x86/kernel/cpu/resctrl/rdtgroup.c +6
-0+ + if (!resctrl_arch_mbm_cntr_assign_enabled(r)) + return; + + if (is_mbm_total_enabled()) + rdtgroup_assign_cntr_event(r, rdtgrp, NULL,Quoted 1 line
QOS_L3_MBM_TOTAL_EVENT_ID);In this code path, resctrl_mkdir()->resctrl_mkdir_ctrl_mon()->rdtgroup_assign_cntrs()->rdtgroup_assign_cntr_event()
CPUs are not protected by read lock while
rdtgroup_assign_cntr_event()walksr->mon_domainsand run assing counters code on CPUs in the domains. Without CPU protection,r->mon_domainsmay race with CPU hotplug.In another patch (i.e.
rdt_get_tree()),rdtgroup_assign_cntrs()is protected by cpus_read_lock()/unlock().So maybe define two helpers:
// Called when caller takes
cpus_read_lock()rdtgroup_assign_cntrs_locked()
{
lockdep_assert_cpus_held();then the current
rdtgroup_assign_cntrs()code
}
Quoted 8 lines
// Called when caller doesn't take
cpus_read_lock()rdtgroup_assign_cntrs()
{
cpus_read_lock();rdtgroup_assign_cntrs_locked();cpus_read_unlock();
}
Good observation. Agree. There is a problem. Some of this code will change with earlier comments.
We know couple of paths are affected here. Why not just add the lock before calling in affected paths instead of adding new helpers?
/*
* Walking r->domains in rdtgroup_assign_cntrs, ensure it can't race
* with cpuhp
*/cpus_read_lock();rdtgroup_assign_cntrs()cpus_read_unlock();
Quoted 22 lines
Quoted 22 lines
+
+ if (is_mbm_local_enabled())
+rdtgroup_assign_cntr_event(r, rdtgrp, NULL, QOS_L3_MBM_LOCAL_EVENT_ID);arch/x86/kernel/cpu/resctrl/rdtgroup.c +9
-0+} + +/* +* Called when a group is deleted. Counters are unassigned if it was in +* assigned state. +*/ +static void rdtgroup_unassign_cntrs (struct rdtgroup *rdtgrp) +{ + struct rdt_resource *r =&rdt_resources_all[RDT_RESOURCE_L3].r_resctrl;
arch/x86/kernel/cpu/resctrl/rdtgroup.c +6
-0+ + if (!resctrl_arch_mbm_cntr_assign_enabled(r)) + return; + + if (is_mbm_total_enabled()) + rdtgroup_unassign_cntr_event(r, rdtgrp, NULL,
QOS_L3_MBM_TOTAL_EVENT_ID);
+
Quoted 8 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c
Quoted 5 lines
+ if (
is_mbm_local_enabled())
+rdtgroup_unassign_cntr_event(r, rdtgrp, NULL, QOS_L3_MBM_LOCAL_EVENT_ID);arch/x86/kernel/cpu/resctrl/rdtgroup.c +2
-0+} +Seems
rdtgroup_unassign_cntrs()is always protected by cpus_read_lock()/unlock(). So it's good.
ok
Quoted 49 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c static int rdt_get_tree(struct fs_context *fc) · line 3035
Quoted 10 lines
static int
rdt_get_tree(struct fs_context *fc){
structrdt_fs_context*ctx =rdt_fc2context(fc);arch/x86/kernel/cpu/resctrl/rdtgroup.c +2
-0@@ -2991,6 +3031,8 @@ static int rdt_get_tree(struct fs_context *fc) if (ret < 0) goto out_mongrp; rdtgroup_default.mon.mon_data_kn = kn_mondata; + + rdtgroup_assign_cntrs(&rdtgroup_default);In this case,
cpus_read_lock()was called earlier. Change tordtgroup_assign_cntrs_locked().Quoted 35 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +0
-0} ret = rdt_pseudo_lock_init();@@ -3021,8 +3063,10 @@ static int rdt_get_tree(struct fs_context *fc)
out_psl:
rdt_pseudo_lock_release();out_mondata:
- if (resctrl_arch_mon_capable())
+ if (resctrl_arch_mon_capable()) {
+rdtgroup_unassign_cntrs(&rdtgroup_default);kernfs_remove(kn_mondata);
+ }
out_mongrp:
if (resctrl_arch_mon_capable())kernfs_remove(kn_mongrp);arch/x86/kernel/cpu/resctrl/rdtgroup.c +1
-0@@ -3201,6 +3245,7 @@ static void free_all_child_rdtgrp(struct rdtgroup *rdtgrp) head = &rdtgrp->mon.crdtgrp_list; list_for_each_entry_safe(sentry, stmp, head, mon.crdtgrp_list) { + rdtgroup_unassign_cntrs(sentry); free_rmid(sentry->closid, sentry->mon.rmid); list_del(&sentry->mon.crdtgrp_list); @@ -3241,6 +3286,8 @@ static void rmdir_all_sub(void)
cpumask_or(&rdtgroup_default.cpu_mask, &rdtgroup_default.cpu_mask, &rdtgrp->cpu_mask); +rdtgroup_unassign_cntrs(rdtgrp);
+
free_rmid(rdtgrp->closid, rdtgrp->mon.rmid);kernfs_remove(rdtgrp->kn);arch/x86/kernel/cpu/resctrl/rdtgroup.c +1
-0@@ -3272,6 +3319,7 @@ static void rdt_kill_sb(struct super_block *sb) for_each_alloc_capable_rdt_resource(r) reset_all_ctrls(r); rmdir_all_sub(); + rdtgroup_unassign_cntrs(&rdtgroup_default); rdt_pseudo_lock_release(); rdtgroup_default.mode = RDT_MODE_SHAREABLE;
Quoted 8 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c static void rdt_kill_sb(struct super_block *sb) · line 3331
Quoted 6 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +1
-0schemata_list_destroy();@@ -3280,6 +3328,7 @@ static void rdt_kill_sb(struct super_block *sb) resctrl_arch_disable_alloc(); if (resctrl_arch_mon_capable()) resctrl_arch_disable_mon(); +Unnecessary change.
ok.
Quoted 51 lines
Quoted 45 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +2
-0resctrl_mounted = false; kernfs_kill_sb(sb); mutex_unlock(&rdtgroup_mutex);@@ -3871,6 +3920,8 @@ static int rdtgroup_mkdir_mon(struct kernfs_node *parent_kn, goto out_unlock; } + rdtgroup_assign_cntrs(rdtgrp); + > kernfs_activate(rdtgrp->kn); /*@@ -3915,6 +3966,8 @@ static int rdtgroup_mkdir_ctrl_mon(structkernfs_node *parent_kn, if (ret) goto out_closid_free; + rdtgroup_assign_cntrs(rdtgrp); + kernfs_activate(rdtgrp->kn); ret = rdtgroup_init_alloc(rdtgrp);@@ -3940,6 +3993,7 @@ static int rdtgroup_mkdir_ctrl_mon(struct kernfs_node *parent_kn,
out_del_list:
list_del(&rdtgrp->rdtgroup_list);
out_rmid_free:
+rdtgroup_unassign_cntrs(rdtgrp);
mkdir_rdt_prepare_rmid_free(rdtgrp);
out_closid_free:
closid_free(closid);arch/x86/kernel/cpu/resctrl/rdtgroup.c +4
-0@@ -4010,6 +4064,9 @@ static int rdtgroup_rmdir_mon(struct rdtgroup *rdtgrp, cpumask_var_t tmpmask) update_closid_rmid(tmpmask, NULL); rdtgrp->flags = RDT_DELETED; + + rdtgroup_unassign_cntrs(rdtgrp); + free_rmid(rdtgrp->closid, rdtgrp->mon.rmid); /*@@ -4056,6 +4113,8 @@ static int rdtgroup_rmdir_ctrl(struct rdtgroup *rdtgrp, cpumask_var_t tmpmask) cpumask_or(tmpmask, tmpmask, &rdtgrp->cpu_mask); update_closid_rmid(tmpmask, NULL); + rdtgroup_unassign_cntrs(rdtgrp); + free_rmid(rdtgrp->closid, rdtgrp->mon.rmid); closid_free(rdtgrp->closid);Quoted 1 line
Thanks.
-Fenghua
Signature · 2 lines
Thanks Babu Moger
Moger, Babu
reviewerRe: [PATCH v9 20/26] x86/resctrl: Auto assign/unassign counters when mbm_cntr_assign is enabled
Hi Fenghua,
Quoted 121 lines · Babu
Hi Fenghua,
Thanks for the review.
Quoted 101 lines · Fenghua Yu
Hi, Babu,
Quoted 76 lines · Babu Moger
Assign/unassign counters on resctrl group creation/deletion. Two counters are required per group, one for MBM total event and one for MBM local event.
There are a limited number of counters available for assignment. If these counters are exhausted, the kernel will display the error message: "Out of MBM assignable counters". However, it is not necessary to fail the creation of a group due to assignment failures. Users have the flexibility to modify the assignments at a later time.
Signed-off-by Babu Moger <[email protected]>---
v9: Changedrdtgroup_assign_cntrs()andrdtgroup_unassign_cntrs()to return void.
Updated couple ofrdtgroup_unassign_cntrs()calls properly. Updated function comments.v8: Renamed
rdtgroup_assign_grptordtgroup_assign_cntrs. Renamedrdtgroup_unassign_grptordtgroup_unassign_cntrs. Fixed the problem with unassigning the child MON groups ofCTRL_MONgroup.v7: Reworded the commit message.
Removed the reference of ABMC withmbm_cntr_assign. Renamed the functionrdtgroup_assign_cntrstordtgroup_assign_grp.v6: Removed the redundant comments on all the calls of
rdtgroup_assign_cntrs. Updated the commit message.
Dropped printing error message on every call ofrdtgroup_assign_cntrs.v5: Removed the code to enable/disable ABMC during the mount. That will be another patch.
Added arch callers to get the arch specific data. Renamed fuctions to match the other abmc function. Added code comments for assignment failures.v4: Few name changes based on the upstream discussion. Commit message update.
v3: This is a new patch. Patch addresses the upstream comment to enable ABMC feature by default if the feature is available.
---
arch/x86/kernel/cpu/resctrl/rdtgroup.c| 61 +++++++++++++++++++++++++-1 file changed, 60 insertions(+), 1 deletion(-)arch/x86/kernel/cpu/resctrl/rdtgroup.c +0
-0@@ -2932,6 +2932,46 @@ static void schemata_list_destroy(void) } }+/*
+ * Called when a new group is created. If "mbm_cntr_assign" mode is enabled,
+ * counters are automatically assigned. Each group can accommodate two counters:
+ * one for the total event and one for the local event. Assignments may fail
+ * due to the limited number of counters. However, it is not necessary to fail
+ * the group creation and thus no failure is returned. Users have the option
+ * to modify the counter assignments after the group has been created.
+ */arch/x86/kernel/cpu/resctrl/rdtgroup.c +3
-0+static void rdtgroup_assign_cntrs (struct rdtgroup *rdtgrp) +{ + struct rdt_resource *r =&rdt_resources_all[RDT_RESOURCE_L3].r_resctrl;
arch/x86/kernel/cpu/resctrl/rdtgroup.c +6
-0+ + if (!resctrl_arch_mbm_cntr_assign_enabled(r)) + return; + + if (is_mbm_total_enabled()) + rdtgroup_assign_cntr_event(r, rdtgrp, NULL,Quoted 1 line
QOS_L3_MBM_TOTAL_EVENT_ID);In this code path, resctrl_mkdir()->resctrl_mkdir_ctrl_mon()->rdtgroup_assign_cntrs()->rdtgroup_assign_cntr_event()
CPUs are not protected by read lock while
rdtgroup_assign_cntr_event()walksr->mon_domainsand run assing counters code on CPUs in the domains. Without CPU protection,r->mon_domainsmay race with CPU hotplug.In another patch (i.e.
rdt_get_tree()),rdtgroup_assign_cntrs()is protected by cpus_read_lock()/unlock().So maybe define two helpers:
// Called when caller takes
cpus_read_lock()rdtgroup_assign_cntrs_locked()
{
lockdep_assert_cpus_held();then the current
rdtgroup_assign_cntrs()code
}Quoted 8 lines
// Called when caller doesn't take
cpus_read_lock()rdtgroup_assign_cntrs()
{
cpus_read_lock();rdtgroup_assign_cntrs_locked();cpus_read_unlock();
}Good observation. Agree. There is a problem. Some of this code will change with earlier comments.
We know couple of paths are affected here. Why not just add the lock before calling in affected paths instead of adding new helpers?
Quoted 8 lines
/*
* Walkingr->domainsinrdtgroup_assign_cntrs, ensure it can't race
* with cpuhp
*/cpus_read_lock();rdtgroup_assign_cntrs()cpus_read_unlock();
Oh no. Looks like we are good here.
Looks at Reinette's response. Thanks Reinette.
https://lore.kernel.org/lkml/[email protected]/
Quoted 147 lines
Quoted 24 lines
Quoted 24 lines
+
+ if (is_mbm_local_enabled())
+rdtgroup_assign_cntr_event(r, rdtgrp, NULL, QOS_L3_MBM_LOCAL_EVENT_ID);arch/x86/kernel/cpu/resctrl/rdtgroup.c +9
-0+} + +/* +* Called when a group is deleted. Counters are unassigned if it was in +* assigned state. +*/ +static void rdtgroup_unassign_cntrs (struct rdtgroup *rdtgrp) +{ + struct rdt_resource *r =&rdt_resources_all[RDT_RESOURCE_L3].r_resctrl;
arch/x86/kernel/cpu/resctrl/rdtgroup.c +6
-0+ + if (!resctrl_arch_mbm_cntr_assign_enabled(r)) + return; + + if (is_mbm_total_enabled()) + rdtgroup_unassign_cntr_event(r, rdtgrp, NULL,
QOS_L3_MBM_TOTAL_EVENT_ID);
+Quoted 8 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c
Quoted 5 lines
+ if (
is_mbm_local_enabled())
+rdtgroup_unassign_cntr_event(r, rdtgrp, NULL, QOS_L3_MBM_LOCAL_EVENT_ID);arch/x86/kernel/cpu/resctrl/rdtgroup.c +2
-0+} +Seems
rdtgroup_unassign_cntrs()is always protected by cpus_read_lock()/unlock(). So it's good.ok
Quoted 49 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c static int rdt_get_tree(struct fs_context *fc) · line 3035
Quoted 10 lines
static int
rdt_get_tree(struct fs_context *fc){
structrdt_fs_context*ctx =rdt_fc2context(fc);arch/x86/kernel/cpu/resctrl/rdtgroup.c +2
-0@@ -2991,6 +3031,8 @@ static int rdt_get_tree(struct fs_context *fc) if (ret < 0) goto out_mongrp; rdtgroup_default.mon.mon_data_kn = kn_mondata; + + rdtgroup_assign_cntrs(&rdtgroup_default);In this case,
cpus_read_lock()was called earlier. Change tordtgroup_assign_cntrs_locked().Quoted 35 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +0
-0} ret = rdt_pseudo_lock_init();@@ -3021,8 +3063,10 @@ static int rdt_get_tree(struct fs_context *fc)
out_psl:
rdt_pseudo_lock_release();out_mondata:
- if (resctrl_arch_mon_capable())
+ if (resctrl_arch_mon_capable()) {
+rdtgroup_unassign_cntrs(&rdtgroup_default);kernfs_remove(kn_mondata);
+ }
out_mongrp:
if (resctrl_arch_mon_capable())kernfs_remove(kn_mongrp);arch/x86/kernel/cpu/resctrl/rdtgroup.c +1
-0@@ -3201,6 +3245,7 @@ static void free_all_child_rdtgrp(struct rdtgroup *rdtgrp) head = &rdtgrp->mon.crdtgrp_list; list_for_each_entry_safe(sentry, stmp, head, mon.crdtgrp_list) { + rdtgroup_unassign_cntrs(sentry); free_rmid(sentry->closid, sentry->mon.rmid); list_del(&sentry->mon.crdtgrp_list); @@ -3241,6 +3286,8 @@ static void rmdir_all_sub(void)
cpumask_or(&rdtgroup_default.cpu_mask, &rdtgroup_default.cpu_mask, &rdtgrp->cpu_mask); +rdtgroup_unassign_cntrs(rdtgrp);
+
free_rmid(rdtgrp->closid, rdtgrp->mon.rmid);kernfs_remove(rdtgrp->kn);arch/x86/kernel/cpu/resctrl/rdtgroup.c +1
-0@@ -3272,6 +3319,7 @@ static void rdt_kill_sb(struct super_block *sb) for_each_alloc_capable_rdt_resource(r) reset_all_ctrls(r); rmdir_all_sub(); + rdtgroup_unassign_cntrs(&rdtgroup_default); rdt_pseudo_lock_release(); rdtgroup_default.mode = RDT_MODE_SHAREABLE;Quoted 8 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c static void rdt_kill_sb(struct super_block *sb) · line 3331
Quoted 6 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +1
-0schemata_list_destroy();@@ -3280,6 +3328,7 @@ static void rdt_kill_sb(struct super_block *sb) resctrl_arch_disable_alloc(); if (resctrl_arch_mon_capable()) resctrl_arch_disable_mon(); +Unnecessary change.
ok.
Quoted 51 lines
Quoted 45 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +2
-0resctrl_mounted = false; kernfs_kill_sb(sb); mutex_unlock(&rdtgroup_mutex);@@ -3871,6 +3920,8 @@ static int rdtgroup_mkdir_mon(struct kernfs_node *parent_kn, goto out_unlock; } + rdtgroup_assign_cntrs(rdtgrp); + > kernfs_activate(rdtgrp->kn); /*@@ -3915,6 +3966,8 @@ static int rdtgroup_mkdir_ctrl_mon(structkernfs_node *parent_kn, if (ret) goto out_closid_free; + rdtgroup_assign_cntrs(rdtgrp); + kernfs_activate(rdtgrp->kn); ret = rdtgroup_init_alloc(rdtgrp);@@ -3940,6 +3993,7 @@ static int rdtgroup_mkdir_ctrl_mon(struct kernfs_node *parent_kn,
out_del_list:
list_del(&rdtgrp->rdtgroup_list);
out_rmid_free:
+rdtgroup_unassign_cntrs(rdtgrp);
mkdir_rdt_prepare_rmid_free(rdtgrp);
out_closid_free:
closid_free(closid);arch/x86/kernel/cpu/resctrl/rdtgroup.c +4
-0@@ -4010,6 +4064,9 @@ static int rdtgroup_rmdir_mon(struct rdtgroup *rdtgrp, cpumask_var_t tmpmask) update_closid_rmid(tmpmask, NULL); rdtgrp->flags = RDT_DELETED; + + rdtgroup_unassign_cntrs(rdtgrp); + free_rmid(rdtgrp->closid, rdtgrp->mon.rmid); /*@@ -4056,6 +4113,8 @@ static int rdtgroup_rmdir_ctrl(struct rdtgroup *rdtgrp, cpumask_var_t tmpmask) cpumask_or(tmpmask, tmpmask, &rdtgrp->cpu_mask); update_closid_rmid(tmpmask, NULL); + rdtgroup_unassign_cntrs(rdtgrp); + free_rmid(rdtgrp->closid, rdtgrp->mon.rmid); closid_free(rdtgrp->closid);Quoted 1 line
Thanks.
-Fenghua
Signature · 2 lines
Thanks Babu Moger
Babu Moger
reviewerPATCH v9 21/26 x86/resctrl: Report "Unassigned" for MBM events in mbm_cntr_assign mode
In reply to Babu MogerIn mbm_cntr_assign mode, the hardware counter should be assigned to read the MBM events.
Report "Unassigned" in case the user attempts to read the events without assigning the counter.
---
v9: Used is_mbm_event() to check the event type.
Minor user documentation update.
v8: Used MBM_EVENT_ARRAY_INDEX to get the index for the MBM event.
Documentation update to make the text generic.
v7: Moved the documentation under "mon_data".
Updated the text little bit.
v6: Added more explaination in the resctrl.rst
Added checks to detect "Unassigned" before reading RMID.
v5: New patch.
--- Documentation/arch/x86/resctrl.rst | 10 ++++++++++ arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 12 +++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-)
Documentation/arch/x86/resctrl.rst +10 -0
@@ -430,6 +430,16 @@ When monitoring is enabled all MON groups will also contain: for the L3 cache they occupy). These are named "mon_sub_L3_YY" where "YY" is the node number. + When supported the 'mbm_cntr_assign' mode allows users to assign a + counter to mon_hw_id, event pair enabling bandwidth monitoring for + as long as the counter remains assigned. The hardware will continue + tracking the assigned mon_hw_id until the user manually unassigns + it, ensuring that counters are not reset during this period. With + a limited number of counters, the system may run out of assignable + counters. In that case, MBM event counters will return "Unassigned" + when the event is read. Users must manually assign a counter to read + the events. + "mon_hw_id": Available only with debug option. The identifier used by hardware for the monitor group. On x86 this is the RMID.
arch/x86/kernel/cpu/resctrl/ctrlmondata.c +11 -1
@@ -567,7 +567,7 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg)struct rdtgroup *rdtgrp;struct rdt_resource *r;union mon_data_bits md; -int ret =0 ; +int ret =0 , index; rdtgrp =rdtgroup_kn_lock_live (of->kn);if (!rdtgrp) {
@@ -581,6 +581,14 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg) evtid = md.u.evtid; r = &rdt_resources_all[resid].r_resctrl; +if (resctrl_arch_mbm_cntr_assign_enabled (r) &&is_mbm_event (evtid)) { + index =MBM_EVENT_ARRAY_INDEX (evtid); +if (rdtgrp->mon.cntr_id[index] ==MON_CNTR_UNSET ) { + rr.err = -ENOENT ; + goto checkresult; + } + } +if (md.u.sum) {/* * This file requires summing across all domains that share
@@ -618,6 +626,8 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg)seq_puts (m,"Error\n" ); else if (rr.err == -EINVAL) seq_puts(m, "Unavailable\n"); + else if (rr.err == -ENOENT) + seq_puts(m, "Unassigned\n"); else seq_printf(m, "%llu\n", rr.val);
Signature · 1 line
2.34.1
Reinette Chatre
maintainerRe: [PATCH v9 21/26] x86/resctrl: Report "Unassigned" for MBM events in mbm_cntr_assign mode
Hi Babu,
Quoted 31 lines · Babu Moger
In
mbm_cntr_assignmode, the hardware counter should be assigned to read the MBM events.Report "Unassigned" in case the user attempts to read the events without assigning the counter.
Signed-off-by Babu Moger <[email protected]>---
v9: Usedis_mbm_event()to check the event type.
Minor user documentation update.v8: Used
MBM_EVENT_ARRAY_INDEXto get the index for the MBM event.
Documentation update to make the text generic.v7: Moved the documentation under "
mon_data".
Updated the text little bit.v6: Added more explaination in the
resctrl.rst
Added checks to detect "Unassigned" before reading RMID.v5: New patch.
--- Documentation/arch/x86/resctrl.rst | 10 ++++++++++ arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 12 +++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-)Documentation/arch/x86/resctrl.rst +0
-0
Documentation/arch/x86/resctrl.rst When monitoring is enabled all MON groups will also contain: · line 433
Quoted 4 lines
Documentation/arch/x86/resctrl.rst +1
-0@@ -430,6 +430,16 @@ When monitoring is enabled all MON groups will also contain: for the L3 cache they occupy). These are named "mon_sub_L3_YY" where "YY" is the node number. + When supported the 'mbm_cntr_assign' mode allows users to assign a
Could you please do through the documentation changes and make all the quote usage consistent with existing styles? For example, in this series "mbm_cntr_assign" is used in doc in various ways ... within double quotes, within single quotes, as well as without any quotes.
Documentation/arch/x86/resctrl.rst When monitoring is enabled all MON groups will also contain: · line 439
Quoted 6 lines
Documentation/arch/x86/resctrl.rst +6
-0+ counter to mon_hw_id, event pair enabling bandwidth monitoring for + as long as the counter remains assigned. The hardware will continue + tracking the assigned mon_hw_id until the user manually unassigns + it, ensuring that counters are not reset during this period. With + a limited number of counters, the system may run out of assignable + counters. In that case, MBM event counters will return "Unassigned"
Please review style for all quote usage, for example, "Unassigned" above is also not consistent.
Documentation/arch/x86/resctrl.rst When monitoring is enabled all MON groups will also contain: · line 442
Quoted 3 lines
Documentation/arch/x86/resctrl.rst +3
-0+ when the event is read. Users must manually assign a counter to read + the events. +
Reinette
Moger, Babu
reviewerRe: [PATCH v9 21/26] x86/resctrl: Report "Unassigned" for MBM events in mbm_cntr_assign mode
Hi Reinette,
Quoted 37 lines · Reinette Chatre
Hi Babu,
Quoted 34 lines · Babu Moger
In
mbm_cntr_assignmode, the hardware counter should be assigned to read the MBM events.Report "Unassigned" in case the user attempts to read the events without assigning the counter.
Signed-off-by Babu Moger <[email protected]>---
v9: Usedis_mbm_event()to check the event type.
Minor user documentation update.v8: Used
MBM_EVENT_ARRAY_INDEXto get the index for the MBM event.
Documentation update to make the text generic.v7: Moved the documentation under "
mon_data".
Updated the text little bit.v6: Added more explaination in the
resctrl.rst
Added checks to detect "Unassigned" before reading RMID.v5: New patch.
--- Documentation/arch/x86/resctrl.rst | 10 ++++++++++ arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 12 +++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-)Documentation/arch/x86/resctrl.rst +0
-0@@ -430,6 +430,16 @@ When monitoring is enabled all MON groups will also contain: for the L3 cache they occupy). These are named "mon_sub_L3_YY" where "YY" is the node number.
Quoted 6 lines
Documentation/arch/x86/resctrl.rst When monitoring is enabled all MON groups will also contain: · line 433
Quoted 1 line
Documentation/arch/x86/resctrl.rst +1
-0+ When supported the 'mbm_cntr_assign' mode allows users to assign aCould you please do through the documentation changes and make all the quote usage consistent with existing styles? For example, in this series "
mbm_cntr_assign" is used in doc in various ways ... within double quotes, within single quotes, as well as without any quotes.
Yea. Will do. It should "mbm_cntr_assign" in all the references.
Quoted 10 lines
Documentation/arch/x86/resctrl.rst When monitoring is enabled all MON groups will also contain: · line 439
Quoted 7 lines
Documentation/arch/x86/resctrl.rst +6
-0+ counter to mon_hw_id, event pair enabling bandwidth monitoring for + as long as the counter remains assigned. The hardware will continue + tracking the assigned mon_hw_id until the user manually unassigns + it, ensuring that counters are not reset during this period. With + a limited number of counters, the system may run out of assignable + counters. In that case, MBM event counters will return "Unassigned"Please review style for all quote usage, for example, "Unassigned" above is also not consistent.
Yes. Will change it to 'Unassigned'.
Quoted 6 lines
Documentation/arch/x86/resctrl.rst When monitoring is enabled all MON groups will also contain: · line 442
Quoted 4 lines
Documentation/arch/x86/resctrl.rst +3
-0+ when the event is read. Users must manually assign a counter to read + the events. +Reinette
Signature · 2 lines
Thanks Babu Moger
Babu Moger
reviewerPATCH v9 22/26 x86/resctrl: Introduce the interface to switch between monitor modes
In reply to Babu MogerIntroduce interface to switch between mbm_cntr_assign and default modes.
$ cat /sys/fs/resctrl/info/L3_MON/mbm_assign_mode [mbm_cntr_assign] default
To enable the "mbm_cntr_assign" mode:
$ echo "mbm_cntr_assign" > /sys/fs/resctrl/info/L3_MON/mbm_assign_mode
To enable the default monitoring mode:
$ echo "default" > /sys/fs/resctrl/info/L3_MON/mbm_assign_mode
MBM event counters will reset when mbm_assign_mode is changed.
---
v9: Fixed extra spaces in user documentation.
Fixed problem changing the mode to mbm_cntr_assign mode when it is not supported. Added extra checks to detect if systems supports it. Used the rdtgroup_cntr_id_init to initialize cntr_id.
v8: Reset the internal counters after mbm_cntr_assign mode is changed.
Renamed rdtgroup_mbm_cntr_reset() to mbm_cntr_reset() Updated the documentation to make text generic.
v7: Changed the interface name to mbm_assign_mode.
Removed the references of ABMC.
Added the changes to reset global and domain bitmaps. Added the changes to reset rmid.
v6: Changed the mode name to mbm_cntr_assign.
Moved all the FS related code here.
Added changes to reset mbm_cntr_map and resctrl group counters.
v5: Change log and mode description text correction.
v4: Minor commit text changes. Keep the default to ABMC when supported.
Fixed comments to reflect changed interface "mbm_mode".
v3: New patch to address the review comments from upstream.
--- Documentation/arch/x86/resctrl.rst | 15 +++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 81 +++++++++++++++++++++++++- 2 files changed, 95 insertions(+), 1 deletion(-)
Documentation/arch/x86/resctrl.rst +15 -0
@@ -290,6 +290,21 @@ with the following files: mbm_local_bytes may report 'Unavailable' if there is no counter associated with that event. + * To enable "mbm_cntr_assign" mode: + :: + + # echo "mbm_cntr_assign" > /sys/fs/resctrl/info/L3_MON/mbm_assign_mode + + * To enable default monitoring mode: + :: + + # echo "default" > /sys/fs/resctrl/info/L3_MON/mbm_assign_mode + + The MBM events (mbm_total_bytes and/or mbm_local_bytes) associated with + counters may reset when mbm_assign_mode is changed. Moving to + mbm_cntr_assign mode require users to assign the counters to the events. + Otherwise, the MBM event counters will return "Unassigned" when read. + "num_mbm_cntrs": The number of monitoring counters available for assignment when the architecture supports mbm_cntr_assign mode.
arch/x86/kernel/cpu/resctrl/rdtgroup.c +80 -1
95 lines not on this page · raw message
Signature · 1 line
2.34.1
Babu Moger
reviewerPATCH v9 23/26 x86/resctrl: Configure mbm_cntr_assign mode if supported
In reply to Babu MogerConfigure mbm_cntr_assign on AMD. 'mbm_cntr_assign' mode in AMD is ABMC (Assignable Bandwidth Monitoring Counters). It is enabled by default when supported on the system.
When the ABMC is updated, it must be updated on all the logical processors in the resctrl domain.
---
v9: Minor code change due to merge. Actual code did not change.
v8: Renamed resctrl_arch_mbm_cntr_assign_configure to
resctrl_arch_mbm_cntr_assign_set_one.
Adde r->mon_capable check.
Commit message update.v7: Introduced resctrl_arch_mbm_cntr_assign_configure() to configure.
Moved the default settings to rdt_get_mon_l3_config(). It should be done before the hotplug handler is called. It cannot be done at rdtgroup_init().
v6: Keeping the default enablement in arch init code for now.
This may need some discussion.
Renamed resctrl_arch_configure_abmc to resctrl_arch_mbm_cntr_assign_configure.
v5: New patch to enable ABMC by default.
--- arch/x86/kernel/cpu/resctrl/internal.h | 1 + arch/x86/kernel/cpu/resctrl/monitor.c | 1 + arch/x86/kernel/cpu/resctrl/rdtgroup.c | 11 +++++++++++ 3 files changed, 13 insertions(+)
arch/x86/kernel/cpu/resctrl/internal.h +1 -0
@@ -721,6 +721,7 @@ int rdtgroup_assign_cntr_event(struct rdt_resource *r, struct rdtgroup *rdtgrp, struct rdt_mon_domain *d, enum resctrl_event_id evtid);int rdtgroup_unassign_cntr_event (struct rdt_resource *r,struct rdtgroup *rdtgrp,struct rdt_mon_domain *d,enum resctrl_event_id evtid); +void resctrl_arch_mbm_cntr_assign_set_one (struct rdt_resource *r);void rdt_staged_configs_clear (void );bool closid_allocated (unsigned int closid);int resctrl_find_cleanest_closid (void );
arch/x86/kernel/cpu/resctrl/monitor.c +1 -0
@@ -1267,6 +1267,7 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r) r->mon.mbm_cntr_assignable = true;cpuid_count (0x80000020 ,5 , &eax, &ebx, &ecx, &edx); r->mon.num_mbm_cntrs = (ebx &GENMASK (15 ,0 )) +1 ; + hw_res->mbm_cntr_assign_enabled = true;resctrl_file_fflags_init ("num_mbm_cntrs" ,RFTYPE_MON_INFO );resctrl_file_fflags_init ("available_mbm_cntrs" ,RFTYPE_MON_INFO ); }
arch/x86/kernel/cpu/resctrl/rdtgroup.c +11 -0
@@ -2799,6 +2799,13 @@ int resctrl_arch_mbm_cntr_assign_set(struct rdt_resource *r, bool enable)return 0 ; } +void resctrl_arch_mbm_cntr_assign_set_one (struct rdt_resource *r) +{ +struct rdt_hw_resource *hw_res =resctrl_to_arch_res (r); + +resctrl_abmc_set_one_amd (&hw_res->mbm_cntr_assign_enabled); +} +/* * We don't allow rdtgroup directories to be created anywhere * except the root directory. Thus when looking for the rdtgroup
@@ -4582,9 +4589,13 @@ int resctrl_online_mon_domain(struct rdt_resource *r, struct rdt_mon_domain *d)void resctrl_online_cpu (unsigned int cpu) { +struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3 ].r_resctrl; +mutex_lock (&rdtgroup_mutex);/* The CPU is set in default rdtgroup after online. */ cpumask_set_cpu (cpu, &rdtgroup_default.cpu_mask); +if (r->mon_capable && r->mon.mbm_cntr_assignable) +resctrl_arch_mbm_cntr_assign_set_one (r);mutex_unlock (&rdtgroup_mutex); }
Signature · 1 line
2.34.1
Reinette Chatre
maintainerRe: [PATCH v9 23/26] x86/resctrl: Configure mbm_cntr_assign mode if supported
Hi Babu,
Quoted 6 lines · Babu Moger
Configure
mbm_cntr_assignon AMD. 'mbm_cntr_assign' mode in AMD is ABMC (Assignable Bandwidth Monitoring Counters). It is enabled by default when supported on the system.When the ABMC is updated, it must be updated on all the logical processors in the resctrl domain.
This needs imperative tone.
Reinette
Moger, Babu
reviewerRe: [PATCH v9 23/26] x86/resctrl: Configure mbm_cntr_assign mode if supported
Hi Reinette,
Quoted 12 lines · Reinette Chatre
Hi Babu,
Quoted 6 lines · Babu Moger
Configure
mbm_cntr_assignon AMD. 'mbm_cntr_assign' mode in AMD is ABMC (Assignable Bandwidth Monitoring Counters). It is enabled by default when supported on the system.When the ABMC is updated, it must be updated on all the logical processors in the resctrl domain.
This needs imperative tone.
Ensure that the ABMC is updated on all logical processors in the resctrl domain.
Signature · 2 lines
Thanks Babu Moger
Babu Moger
reviewerPATCH v9 24/26 x86/resctrl: Update assignments on event configuration changes
In reply to Babu MogerUsers can modify the configuration of assignable events. Whenever the event configuration is updated, MBM assignments must be revised across all monitor groups within the impacted domains.
---
v9: Again patch changed completely based on the comment.
https://lore.kernel.org/lkml/[email protected]/
Introduced resctrl_mon_event_config_set to handle IPI.
But sending another IPI inside IPI causes problem. Kernel reports SMP warning. So, introduced resctrl_arch_update_cntr() to send the command directly.
v8: Patch changed completely.
Updated the assignment on same IPI as the event is updated. Could not do the way we discussed in the thread.
https://lore.kernel.org/lkml/[email protected]/
Needed to figure out event type to update the configuration.
v7: New patch to update the assignments. Missed it earlier.
--- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 86 +++++++++++++++++++++++--- include/linux/resctrl.h | 3 +- 2 files changed, 79 insertions(+), 10 deletions(-)
arch/x86/kernel/cpu/resctrl/rdtgroup.c +77 -9
@@ -1710,6 +1710,7 @@ static int rdtgroup_size_show(struct kernfs_open_file *of, }struct mon_config_info { +struct rdt_resource *r;struct rdt_mon_domain *d;u32 evtid;u32 mon_config;
@@ -1735,26 +1736,28 @@ u32 resctrl_arch_mon_event_config_get(struct rdt_mon_domain *d,return INVALID_CONFIG_VALUE ; } -void resctrl_arch_mon_event_config_set (void *info) +void resctrl_arch_mon_event_config_set (struct rdt_mon_domain *d, +enum resctrl_event_id eventid,u32 val) { -struct mon_config_info *mon_info = info;struct rdt_hw_mon_domain *hw_dom;unsigned int index; - index =mon_event_config_index_get (mon_info->evtid); + index =mon_event_config_index_get (eventid);if (index ==INVALID_CONFIG_INDEX )return ; -wrmsr (MSR_IA32_EVT_CFG_BASE + index, mon_info->mon_config,0 ); +wrmsr (MSR_IA32_EVT_CFG_BASE + index, val,0 ); - hw_dom =resctrl_to_arch_mon_dom (mon_info->d); + hw_dom =resctrl_to_arch_mon_dom (d); -switch (mon_info->evtid) { +switch (eventid) {case QOS_L3_MBM_TOTAL_EVENT_ID : - hw_dom->mbm_total_cfg = mon_info->mon_config; + hw_dom->mbm_total_cfg = val;break ;case QOS_L3_MBM_LOCAL_EVENT_ID : - hw_dom->mbm_local_cfg = mon_info->mon_config; + hw_dom->mbm_local_cfg = val; +break ; +default :break ; } }
@@ -1826,6 +1829,70 @@ static int mbm_local_bytes_config_show(struct kernfs_open_file *of,return 0 ; } +static struct rdtgroup *rdtgroup_find_grp_by_cntr_id_index (int cntr_id,unsigned int index) +{ +struct rdtgroup *prgrp, *crgrp; + +/* Check if the cntr_id is associated to the event type updated */ +list_for_each_entry (prgrp, &rdt_all_groups, rdtgroup_list) { +if (prgrp->mon.cntr_id[index] == cntr_id) +return prgrp; + +list_for_each_entry (crgrp, &prgrp->mon.crdtgrp_list, mon.crdtgrp_list) { +if (crgrp->mon.cntr_id[index] == cntr_id) +return crgrp; + } + } + +return NULL ; +} + +static void resctrl_arch_update_cntr (struct rdt_resource *r,struct rdt_mon_domain *d, +enum resctrl_event_id evtid,u32 rmid, +u32 closid,u32 cntr_id,u32 val) +{ +union l3_qos_abmc_cfg abmc_cfg = {0 }; + + abmc_cfg.split.cfg_en =1 ; + abmc_cfg.split.cntr_en =1 ; + abmc_cfg.split.cntr_id = cntr_id; + abmc_cfg.split.bw_src = rmid; + abmc_cfg.split.bw_type = val; + +wrmsrl (MSR_IA32_L3_QOS_ABMC_CFG , abmc_cfg.full); +} + +static void resctrl_mon_event_config_set (void *info) +{ +struct mon_config_info *mon_info = info; +struct rdt_mon_domain *d = mon_info->d; +struct rdt_resource *r = mon_info->r; +struct rdtgroup *rdtgrp; +unsigned int index; +u32 cntr_id; + +resctrl_arch_mon_event_config_set (d, mon_info->evtid, mon_info->mon_config); + +if (!resctrl_arch_mbm_cntr_assign_enabled (r)) +return ; + + index =mon_event_config_index_get (mon_info->evtid); +if (index ==INVALID_CONFIG_INDEX ) +return ; + +for (cntr_id =0 ; cntr_id < r->mon.num_mbm_cntrs; cntr_id++) { +if (test_bit (cntr_id, d->mbm_cntr_map)) { + rdtgrp =rdtgroup_find_grp_by_cntr_id_index (cntr_id, index); +if (rdtgrp) +resctrl_arch_update_cntr (mon_info->r, d, + mon_info->evtid, + rdtgrp->mon.rmid, + rdtgrp->closid, + cntr_id, + mon_info->mon_config); + } + } +}static void mbm_config_write_domain (struct rdt_resource *r,struct rdt_mon_domain *d,u32 evtid,u32 val)
@@ -1841,6 +1908,7 @@ static void mbm_config_write_domain(struct rdt_resource *r,if (config_val ==INVALID_CONFIG_VALUE || config_val == val)return ; + mon_info.r = r; mon_info.d = d; mon_info.evtid = evtid; mon_info.mon_config = val;
@@ -1852,7 +1920,7 @@ static void mbm_config_write_domain(struct rdt_resource *r,* on one CPU is observed by all the CPUs in the domain. */ smp_call_function_any (&d->hdr.cpu_mask, - resctrl_arch_mon_event_config_set, + resctrl_mon_event_config_set, &mon_info,1 );/*
include/linux/resctrl.h +2 -1
@@ -356,7 +356,8 @@ void resctrl_arch_reset_rmid(struct rdt_resource *r, struct rdt_mon_domain *d,*/ void resctrl_arch_reset_rmid_all (struct rdt_resource *r,struct rdt_mon_domain *d); -void resctrl_arch_mon_event_config_set (void *info); +void resctrl_arch_mon_event_config_set (struct rdt_mon_domain *d, +enum resctrl_event_id eventid,u32 val);u32 resctrl_arch_mon_event_config_get (struct rdt_mon_domain *d,enum resctrl_event_id eventid);
Signature · 1 line
2.34.1
Reinette Chatre
maintainerRe: [PATCH v9 24/26] x86/resctrl: Update assignments on event configuration changes
Hi Babu,
Quoted 3 lines · Babu Moger
Users can modify the configuration of assignable events. Whenever the event configuration is updated, MBM assignments must be revised across all monitor groups within the impacted domains.
Please revisit the "Changelog" section inDocumentation/process/maintainer-tip.rst
Quoted 8 lines
Signed-off-by Babu Moger <[email protected]>---
v9: Again patch changed completely based on the comment.
https://lore.kernel.org/lkml/[email protected]/
Introducedresctrl_mon_event_config_setto handle IPI.
But sending another IPI inside IPI causes problem. Kernel reports SMP warning. So, introducedresctrl_arch_update_cntr()to send the command directly.
I see ... the WARN is because there is a check whether IRQs are disabled before the check whether the function can be run locally.
Quoted 87 lines
v8: Patch changed completely.
Updated the assignment on same IPI as the event is updated. Could not do the way we discussed in the thread.
https://lore.kernel.org/lkml/[email protected]/
Needed to figure out event type to update the configuration.v7: New patch to update the assignments. Missed it earlier.
--- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 86 +++++++++++++++++++++++--- include/linux/resctrl.h | 3 +- 2 files changed, 79 insertions(+), 10 deletions(-)arch/x86/kernel/cpu/resctrl/rdtgroup.c +32
-8@@ -1710,6 +1710,7 @@ static int rdtgroup_size_show(struct kernfs_open_file *of, }struct mon_config_info { +struct rdt_resource *r;struct rdt_mon_domain *d;u32 evtid;u32 mon_config;@@ -1735,26 +1736,28 @@ u32 resctrl_arch_mon_event_config_get(struct rdt_mon_domain *d,return INVALID_CONFIG_VALUE ; } -void resctrl_arch_mon_event_config_set (void *info) +void resctrl_arch_mon_event_config_set (struct rdt_mon_domain *d, +enum resctrl_event_id eventid,u32 val) { -struct mon_config_info *mon_info = info;struct rdt_hw_mon_domain *hw_dom;unsigned int index; - index =mon_event_config_index_get (mon_info->evtid); + index =mon_event_config_index_get (eventid);if (index ==INVALID_CONFIG_INDEX )return ; -wrmsr (MSR_IA32_EVT_CFG_BASE + index, mon_info->mon_config,0 ); +wrmsr (MSR_IA32_EVT_CFG_BASE + index, val,0 ); - hw_dom =resctrl_to_arch_mon_dom (mon_info->d); + hw_dom =resctrl_to_arch_mon_dom (d); -switch (mon_info->evtid) { +switch (eventid) {case QOS_L3_MBM_TOTAL_EVENT_ID : - hw_dom->mbm_total_cfg = mon_info->mon_config; + hw_dom->mbm_total_cfg = val;break ;case QOS_L3_MBM_LOCAL_EVENT_ID : - hw_dom->mbm_local_cfg = mon_info->mon_config; + hw_dom->mbm_local_cfg = val; +break ; +default :break ; } }@@ -1826,6 +1829,70 @@ static int mbm_local_bytes_config_show(struct kernfs_open_file *of,return 0 ; } +static struct rdtgroup *rdtgroup_find_grp_by_cntr_id_index (int cntr_id,unsigned int index) +{ +struct rdtgroup *prgrp, *crgrp; + +/* Check if the cntr_id is associated to the event type updated */ +list_for_each_entry (prgrp, &rdt_all_groups, rdtgroup_list) { +if (prgrp->mon.cntr_id[index] == cntr_id) +return prgrp; + +list_for_each_entry (crgrp, &prgrp->mon.crdtgrp_list, mon.crdtgrp_list) { +if (crgrp->mon.cntr_id[index] == cntr_id) +return crgrp; + } + } + +return NULL ; +} + +static void resctrl_arch_update_cntr (struct rdt_resource *r,struct rdt_mon_domain *d, +enum resctrl_event_id evtid,u32 rmid, +u32 closid,u32 cntr_id,u32 val)
arch/x86/kernel/cpu/resctrl/rdtgroup.c static int mbm_local_bytes_config_show(struct kernfs_open_file *of, · line 1862
Quoted 10 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +10
-0+{ +union l3_qos_abmc_cfg abmc_cfg = {0 }; + + abmc_cfg.split.cfg_en =1 ; + abmc_cfg.split.cntr_en =1 ; + abmc_cfg.split.cntr_id = cntr_id; + abmc_cfg.split.bw_src = rmid; + abmc_cfg.split.bw_type = val; + +wrmsrl (MSR_IA32_L3_QOS_ABMC_CFG , abmc_cfg.full);
Is it needed to create an almost duplicate function? What if instead only resctrl_arch_config_cntr() exists and it uses parameter to decide whether to call resctrl_abmc_config_one_amd() directly or via smp_call_function_any()? I think that should help to make clear how the code flows.
Also note that this is an almost identical arch callback with no error return. I expect that building on existing resctrl_arch_config_cntr() will make things easier to understand.
arch/x86/kernel/cpu/resctrl/rdtgroup.c static int mbm_local_bytes_config_show(struct kernfs_open_file *of, · line 1869
Quoted 7 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +7
-0+} + +static void resctrl_mon_event_config_set (void *info) +{ +struct mon_config_info *mon_info = info; +struct rdt_mon_domain *d = mon_info->d; +struct rdt_resource *r = mon_info->r;
Note that local variable r is created here while the function is inconsistent by switching between using r and mon_info->r.
arch/x86/kernel/cpu/resctrl/rdtgroup.c static int mbm_local_bytes_config_show(struct kernfs_open_file *of, · line 1879
Quoted 10 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +10
-0+struct rdtgroup *rdtgrp; +unsigned int index; +u32 cntr_id; + +resctrl_arch_mon_event_config_set (d, mon_info->evtid, mon_info->mon_config); + +if (!resctrl_arch_mbm_cntr_assign_enabled (r)) +return ; + + index =mon_event_config_index_get (mon_info->evtid);
This is an AMD arch specific helper to know which offset of an MSR to use. It should not be used directly in resctrl fs code, this is what MBM_EVENT_ARRAY_INDEX was created for.
Since MBM_EVENT_ARRAY_INDEX is a macro it can be called closer to where it is used, within rdtgroup_find_grp_by_cntr_id_index(), which prompts a reconsider of that function name.
Quoted 6 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +6
-0+if (index ==INVALID_CONFIG_INDEX ) +return ; + +for (cntr_id =0 ; cntr_id < r->mon.num_mbm_cntrs; cntr_id++) { +if (test_bit (cntr_id, d->mbm_cntr_map)) { + rdtgrp =rdtgroup_find_grp_by_cntr_id_index (cntr_id, index);
arch/x86/kernel/cpu/resctrl/rdtgroup.c static int mbm_local_bytes_config_show(struct kernfs_open_file *of, · line 1895
Quoted 10 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +10
-0+if (rdtgrp) +resctrl_arch_update_cntr (mon_info->r, d, + mon_info->evtid, + rdtgrp->mon.rmid, + rdtgrp->closid, + cntr_id, + mon_info->mon_config); + } + } +}
Could you please add some function comments to explain the flow here? For example, what should reader consider if there is to rdtgroup found?
Reinette
Re: [PATCH v9 24/26] x86/resctrl: Update assignments on event configuration changes
Hi Reinette,
Quoted 10 lines · Reinette Chatre
Hi Babu,
Quoted 3 lines · Babu Moger
Users can modify the configuration of assignable events. Whenever the event configuration is updated, MBM assignments must be revised across all monitor groups within the impacted domains.
Please revisit the "Changelog" section in
Documentation/process/maintainer-tip.rst
ok.
Imperative mood, context, problem and solution.
Quoted 11 lines
Quoted 8 lines
Signed-off-by Babu Moger <[email protected]>---
v9: Again patch changed completely based on the comment.
https://lore.kernel.org/lkml/[email protected]/
Introducedresctrl_mon_event_config_setto handle IPI.
But sending another IPI inside IPI causes problem. Kernel reports SMP warning. So, introducedresctrl_arch_update_cntr()to send the command directly.I see ... the WARN is because there is a check whether IRQs are disabled before the check whether the function can be run locally.
ok
Quoted 99 lines
Quoted 88 lines
v8: Patch changed completely.
Updated the assignment on same IPI as the event is updated. Could not do the way we discussed in the thread.
https://lore.kernel.org/lkml/[email protected]/
Needed to figure out event type to update the configuration.v7: New patch to update the assignments. Missed it earlier.
--- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 86 +++++++++++++++++++++++--- include/linux/resctrl.h | 3 +- 2 files changed, 79 insertions(+), 10 deletions(-)arch/x86/kernel/cpu/resctrl/rdtgroup.c +32
-8@@ -1710,6 +1710,7 @@ static int rdtgroup_size_show(struct kernfs_open_file *of, }struct mon_config_info { +struct rdt_resource *r;struct rdt_mon_domain *d;u32 evtid;u32 mon_config;@@ -1735,26 +1736,28 @@ u32 resctrl_arch_mon_event_config_get(struct rdt_mon_domain *d,return INVALID_CONFIG_VALUE ; } -void resctrl_arch_mon_event_config_set (void *info) +void resctrl_arch_mon_event_config_set (struct rdt_mon_domain *d, +enum resctrl_event_id eventid,u32 val) { -struct mon_config_info *mon_info = info;struct rdt_hw_mon_domain *hw_dom;unsigned int index; - index =mon_event_config_index_get (mon_info->evtid); + index =mon_event_config_index_get (eventid);if (index ==INVALID_CONFIG_INDEX )return ; -wrmsr (MSR_IA32_EVT_CFG_BASE + index, mon_info->mon_config,0 ); +wrmsr (MSR_IA32_EVT_CFG_BASE + index, val,0 ); - hw_dom =resctrl_to_arch_mon_dom (mon_info->d); + hw_dom =resctrl_to_arch_mon_dom (d); -switch (mon_info->evtid) { +switch (eventid) {case QOS_L3_MBM_TOTAL_EVENT_ID : - hw_dom->mbm_total_cfg = mon_info->mon_config; + hw_dom->mbm_total_cfg = val;break ;case QOS_L3_MBM_LOCAL_EVENT_ID : - hw_dom->mbm_local_cfg = mon_info->mon_config; + hw_dom->mbm_local_cfg = val; +break ; +default :break ; } }@@ -1826,6 +1829,70 @@ static int mbm_local_bytes_config_show(struct kernfs_open_file *of,return 0 ; } +static struct rdtgroup *rdtgroup_find_grp_by_cntr_id_index (int cntr_id,unsigned int index) +{ +struct rdtgroup *prgrp, *crgrp; + +/* Check if the cntr_id is associated to the event type updated */ +list_for_each_entry (prgrp, &rdt_all_groups, rdtgroup_list) { +if (prgrp->mon.cntr_id[index] == cntr_id) +return prgrp; + +list_for_each_entry (crgrp, &prgrp->mon.crdtgrp_list, mon.crdtgrp_list) { +if (crgrp->mon.cntr_id[index] == cntr_id) +return crgrp; + } + } + +return NULL ; +} + +static void resctrl_arch_update_cntr (struct rdt_resource *r,struct rdt_mon_domain *d, +enum resctrl_event_id evtid,u32 rmid, +u32 closid,u32 cntr_id,u32 val)arch/x86/kernel/cpu/resctrl/rdtgroup.c static int mbm_local_bytes_config_show(struct kernfs_open_file *of, · line 1862
Quoted 10 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +10
-0+{ +union l3_qos_abmc_cfg abmc_cfg = {0 }; + + abmc_cfg.split.cfg_en =1 ; + abmc_cfg.split.cntr_en =1 ; + abmc_cfg.split.cntr_id = cntr_id; + abmc_cfg.split.bw_src = rmid; + abmc_cfg.split.bw_type = val; + +wrmsrl (MSR_IA32_L3_QOS_ABMC_CFG , abmc_cfg.full);
Quoted 8 lines
Is it needed to create an almost duplicate function? What if instead only
resctrl_arch_config_cntr()exists and it uses parameter to decide whether to callresctrl_abmc_config_one_amd()directly or viasmp_call_function_any()? I think that should help to make clear how the code flows.
Also note that this is an almost identical arch callback with no error return. I expect that building on existingresctrl_arch_config_cntr()will make things easier to understand.
It can be done. But it takes another parameter to the function. It has 7 parameters already. This will be 8th.
Will change it if that is ok.
Quoted 11 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c static int mbm_local_bytes_config_show(struct kernfs_open_file *of, · line 1869
Quoted 8 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +7
-0+} + +static void resctrl_mon_event_config_set (void *info) +{ +struct mon_config_info *mon_info = info; +struct rdt_mon_domain *d = mon_info->d; +struct rdt_resource *r = mon_info->r;Note that local variable r is created here while the function is inconsistent by switching between using r and
mon_info->r.
Sure. Got it.
Quoted 14 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c static int mbm_local_bytes_config_show(struct kernfs_open_file *of, · line 1879
Quoted 11 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +10
-0+struct rdtgroup *rdtgrp; +unsigned int index; +u32 cntr_id; + +resctrl_arch_mon_event_config_set (d, mon_info->evtid, mon_info->mon_config); + +if (!resctrl_arch_mbm_cntr_assign_enabled (r)) +return ; + + index =mon_event_config_index_get (mon_info->evtid);This is an AMD arch specific helper to know which offset of an MSR to use. It should not be used directly in resctrl fs code, this is what
MBM_EVENT_ARRAY_INDEXwas created for.
Sure.
Quoted 3 lines
Since
MBM_EVENT_ARRAY_INDEXis a macro it can be called closer to where it is used, withinrdtgroup_find_grp_by_cntr_id_index(), which prompts a reconsider of that function name.
How about ?
static struct rdtgroup *rdtgroup_find_grp_by_cntr_id_event(int cntr_id, enum resctrl_event_id evtid)
Will move the macro MBM_EVENT_ARRAY_INDEX inside the function.
Quoted 12 lines
Quoted 12 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +11
-0+if (index ==INVALID_CONFIG_INDEX ) +return ; + +for (cntr_id =0 ; cntr_id < r->mon.num_mbm_cntrs; cntr_id++) { +if (test_bit (cntr_id, d->mbm_cntr_map)) { + rdtgrp =rdtgroup_find_grp_by_cntr_id_index (cntr_id, index); +if (rdtgrp) + resctrl_arch_update_cntr(mon_info->r, d, + mon_info->evtid, + rdtgrp->mon.rmid, + rdtgrp->closid,
Quoted 8 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c static int mbm_local_bytes_config_show(struct kernfs_open_file *of, · line 1895
Quoted 5 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +5
-0+ cntr_id, + mon_info->mon_config); + } + } +}Could you please add some function comments to explain the flow here? For example, what should reader consider if there is to rdtgroup found?
Sure.
Signature · 1 line
- Babu Moger
Reinette Chatre
maintainerRe: [PATCH v9 24/26] x86/resctrl: Update assignments on event configuration changes
Hi Babu,
Quoted 26 lines · Babu
Quoted 16 lines · Reinette Chatre
arch/x86/kernel/cpu/resctrl/rdtgroup.c static int mbm_local_bytes_config_show(struct kernfs_open_file *of, · line 1862
Quoted 13 lines · Babu Moger
arch/x86/kernel/cpu/resctrl/rdtgroup.c +13
-0+static void resctrl_arch_update_cntr (struct rdt_resource *r,struct rdt_mon_domain *d, + enum resctrl_event_id evtid, u32 rmid, + u32 closid, u32 cntr_id, u32 val) +{ + union l3_qos_abmc_cfg abmc_cfg = { 0 }; + + abmc_cfg.split.cfg_en = 1; + abmc_cfg.split.cntr_en = 1; + abmc_cfg.split.cntr_id = cntr_id; + abmc_cfg.split.bw_src = rmid; + abmc_cfg.split.bw_type = val; + + wrmsrl(MSR_IA32_L3_QOS_ABMC_CFG, abmc_cfg.full);Quoted 8 lines
Is it needed to create an almost duplicate function? What if instead only
resctrl_arch_config_cntr()exists and it uses parameter to decide whether to callresctrl_abmc_config_one_amd()directly or viasmp_call_function_any()? I think that should help to make clear how the code flows.
Also note that this is an almost identical arch callback with no error return. I expect that building on existingresctrl_arch_config_cntr()will make things easier to understand.
Quoted 3 lines
It can be done. But it takes another parameter to the function. It has 7 parameters already. This will be 8th.
Will change it if that is ok.
Please correct me if I am wrong but I am not familiar with a restriction on number of parameters. It seems unnecessary to me to create two almost duplicate 7 parameter functions to avoid one 8 parameter function.
Quoted 7 lines
Quoted 2 lines
Since
MBM_EVENT_ARRAY_INDEXis a macro it can be called closer to where it is used, withinrdtgroup_find_grp_by_cntr_id_index(), which prompts a reconsider of that function name.How about ?
static struct rdtgroup *rdtgroup_find_grp_by_cntr_id_event(int
cntr_id, enumresctrl_event_idevtid)
... or for something shorter just get_rdtgroup_from_cntr_event(), but no hard requirement.
Reinette
Re: [PATCH v9 24/26] x86/resctrl: Update assignments on event configuration changes
Hi Reinette,
Quoted 29 lines · Reinette Chatre
Hi Babu,
Quoted 26 lines · Babu
Quoted 24 lines · Reinette Chatre
arch/x86/kernel/cpu/resctrl/rdtgroup.c static int mbm_local_bytes_config_show(struct kernfs_open_file *of, · line 1862
Quoted 13 lines · Babu Moger
arch/x86/kernel/cpu/resctrl/rdtgroup.c +13
-0+static void resctrl_arch_update_cntr (struct rdt_resource *r,struct rdt_mon_domain *d, + enum resctrl_event_id evtid, u32 rmid, + u32 closid, u32 cntr_id, u32 val) +{ + union l3_qos_abmc_cfg abmc_cfg = { 0 }; + + abmc_cfg.split.cfg_en = 1; + abmc_cfg.split.cntr_en = 1; + abmc_cfg.split.cntr_id = cntr_id; + abmc_cfg.split.bw_src = rmid; + abmc_cfg.split.bw_type = val; + + wrmsrl(MSR_IA32_L3_QOS_ABMC_CFG, abmc_cfg.full);Is it needed to create an almost duplicate function? What if instead only
resctrl_arch_config_cntr()exists and it uses parameter to decide whether to callresctrl_abmc_config_one_amd()directly or viasmp_call_function_any()? I think that should help to make clear how the code flows.
Also note that this is an almost identical arch callback with no error return. I expect that building on existingresctrl_arch_config_cntr()will make things easier to understand.
Quoted 7 lines
Quoted 3 lines
It can be done. But it takes another parameter to the function. It has 7 parameters already. This will be 8th.
Will change it if that is ok.Please correct me if I am wrong but I am not familiar with a restriction on number of parameters. It seems unnecessary to me to create two almost duplicate 7 parameter functions to avoid one 8 parameter function.
I dont see any hard requirement. Will add one parameter for smp call or direct call.
Quoted 11 lines
Quoted 8 lines
Quoted 3 lines
Since
MBM_EVENT_ARRAY_INDEXis a macro it can be called closer to where it is used, withinrdtgroup_find_grp_by_cntr_id_index(), which prompts a reconsider of that function name.How about ?
static struct rdtgroup *rdtgroup_find_grp_by_cntr_id_event(int
cntr_id, enumresctrl_event_idevtid)... or for something shorter just
get_rdtgroup_from_cntr_event(), but no hard requirement.
Sure
Thanks
Signature · 1 line
- Babu Moger
Babu Moger
reviewerPATCH v9 25/26 x86/resctrl: Introduce interface to list assignment states of all the groups
In reply to Babu MogerProvide the interface to list the assignment states of all the resctrl groups in mbm_cntr_assign mode.
Example:
$ mount -t resctrl resctrl /sys/fs/resctrl/ $ cat /sys/fs/resctrl/info/L3_MON/mbm_assign_control //0=tl;1=tl;
List follows the following format:
"<CTRL_MON group>/<MON group>/<domain_id>=<flags>"
Format for specific type of groups:
- Default CTRL_MON group:
"//<domain_id>=<flags>"
- Non-default CTRL_MON group:
"<CTRL_MON group>//<domain_id>=<flags>"
- Child MON group of default CTRL_MON group:
"/<MON group>/<domain_id>=<flags>"
- Child MON group of non-default CTRL_MON group:
"<CTRL_MON group>/<MON group>/<domain_id>=<flags>"
Flags can be one of the following:
t MBM total event is assigned
l MBM local event is assigned
tl Both total and local MBM events are assigned
_ None of the MBM events are assigned
---
v9: Minor parameter update in resctrl_mbm_event_assigned().
v8: Moved resctrl_mbm_event_assigned() in here as it is first used here.
Moved rdt_last_cmd_clear() before making any call. Updated the commit log.
Corrected the doc format.
v7: Renamed the interface name from 'mbm_control' to 'mbm_assign_control'
to match 'mbm_assign_mode'.
Removed Arch references from FS code.
Added rdt_last_cmd_clear() before the command processing. Added rdtgroup_mutex before all the calls.
Removed references of ABMC from FS code.
v6: The domain specific assignment can be determined looking at mbm_cntr_map.
Removed rdtgroup_abmc_dom_cfg() and rdtgroup_abmc_dom_state(). Removed the switch statement for the domain_state detection. Determined the flags incremently.
Removed special handling of default group while printing..
v5: Replaced "assignment flags" with "flags".
Changes related to mon structure.
Changes related renaming the interface from mbm_assign_control to mbm_control.
v4: Added functionality to query domain specific assigment in.
rdtgroup_abmc_dom_state().
v3: New patch.
Addresses the feedback to provide the global assignment interface.
https://lore.kernel.org/lkml/[email protected]/
--- Documentation/arch/x86/resctrl.rst | 44 +++++++++++++++ arch/x86/kernel/cpu/resctrl/monitor.c | 1 + arch/x86/kernel/cpu/resctrl/rdtgroup.c | 77 ++++++++++++++++++++++++++ 3 files changed, 122 insertions(+)
Documentation/arch/x86/resctrl.rst +44 -0
@@ -321,6 +321,50 @@ with the following files: The number of free monitoring counters available assignment in each domain when the architecture supports mbm_cntr_assign mode. +"mbm_assign_control": + Reports the resctrl group and monitor status of each group. + + List follows the following format: + "<CTRL_MON group>/<MON group>/<domain_id>=<flags>" + + Format for specific type of groups: + + * Default CTRL_MON group: + "//<domain_id>=<flags>" + + * Non-default CTRL_MON group: + "<CTRL_MON group>//<domain_id>=<flags>" + + * Child MON group of default CTRL_MON group: + "/<MON group>/<domain_id>=<flags>" + + * Child MON group of non-default CTRL_MON group: + "<CTRL_MON group>/<MON group>/<domain_id>=<flags>" + + Flags can be one of the following: + :: + + t MBM total event is assigned. + l MBM local event is assigned. + tl Both MBM total and local events are assigned. + _ None of the MBM events are assigned. + + Examples: + :: + + # mkdir /sys/fs/resctrl/mon_groups/child_default_mon_grp + # mkdir /sys/fs/resctrl/non_default_ctrl_mon_grp + # mkdir /sys/fs/resctrl/non_default_ctrl_mon_grp/mon_groups/child_non_default_mon_grp + + # cat /sys/fs/resctrl/info/L3_MON/mbm_assign_control + non_default_ctrl_mon_grp//0=tl;1=tl; + non_default_ctrl_mon_grp/child_non_default_mon_grp/0=tl;1=tl; + //0=tl;1=tl; + /child_default_mon_grp/0=tl;1=tl; + + There are four resctrl groups. All the groups have total and local MBM events + assigned on domain 0 and 1. + "max_threshold_occupancy": Read/write file provides the largest value (in bytes) at which a previously used LLC_occupancy
arch/x86/kernel/cpu/resctrl/monitor.c +1 -0
@@ -1270,6 +1270,7 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r) hw_res->mbm_cntr_assign_enabled = true;resctrl_file_fflags_init ("num_mbm_cntrs" ,RFTYPE_MON_INFO );resctrl_file_fflags_init ("available_mbm_cntrs" ,RFTYPE_MON_INFO ); +resctrl_file_fflags_init ("mbm_assign_control" ,RFTYPE_MON_INFO ); } }
arch/x86/kernel/cpu/resctrl/rdtgroup.c +77 -0
89 lines not on this page · raw message
Signature · 1 line
2.34.1
Babu Moger
reviewerPATCH v9 26/26 x86/resctrl: Introduce interface to modify assignment states of the groups
In reply to Babu MogerIntroduce the interface to assign MBM events in mbm_cntr_assign mode.
Events can be enabled or disabled by writing to file /sys/fs/resctrl/info/L3_MON/mbm_assign_control
Format is similar to the list format with addition of opcode for the assignment operation.
"<CTRL_MON group>/<MON group>/<domain_id><opcode><flags>"
Format for specific type of groups:
* Default CTRL_MON group:
"//<domain_id><opcode><flags>"
* Non-default CTRL_MON group:
"<CTRL_MON group>//<domain_id><opcode><flags>"
* Child MON group of default CTRL_MON group:
"/<MON group>/<domain_id><opcode><flags>"
* Child MON group of non-default CTRL_MON group:
"<CTRL_MON group>/<MON group>/<domain_id><opcode><flags>"
Domain_id '*' will apply the flags on all the domains.
Opcode can be one of the following:
= Update the assignment to match the flags
+ Assign a new MBM event without impacting existing assignments.
- Unassign a MBM event from currently assigned events.
Assignment flags can be one of the following:
t MBM total event
l MBM local event
tl Both total and local MBM events
_ None of the MBM events. Valid only with '=' opcode. This flag cannot
be combined with other flags.
---
v9: Fixed handling special case '//0=' and '//".
Removed extra strstr() call.
Added generic failure text when assignment operation fails. Corrected user documentation format texts.
v8: Moved unassign as the first action during the assign modification.
Assign none "_" takes priority. Cannot be mixed with other flags. Updated the documentation and .rst file format. htmldoc looks ok.
v7: Simplified the parsing (strsep(&token, "//") in rdtgroup_mbm_assign_control_write().
Added mutex lock in rdtgroup_mbm_assign_control_write() while processing. Renamed rdtgroup_find_grp to rdtgroup_find_grp_by_name.
Fixed rdtgroup_str_to_mon_state to return error for invalid flags. Simplified the calls rdtgroup_assign_cntr by merging few functions earlier. Removed ABMC reference in FS code.
Reinette commented about handling the combination of flags like 'lt_' and '_lt'. Not sure if we need to change the behaviour here. Processed them sequencially right now. Users have the liberty to pass the flags. Restricting it might be a problem later.
v6: Added support assign all if domain id is '*'
Fixed the allocation of counter id if it not assigned already.
v5: Interface name changed from mbm_assign_control to mbm_control.
Fixed opcode and flags combination.
'=_" is valid.
"-_" amd "+_" is not valid.
Minor message update.
Renamed the function with prefix - rdtgroup_. Corrected few documentation mistakes.
Rebase related changes after SNC support.
v4: Added domain specific assignments. Fixed the opcode parsing.
v3: New patch.
Addresses the feedback to provide the global assignment interface.
https://lore.kernel.org/lkml/[email protected]/
--- Documentation/arch/x86/resctrl.rst | 116 +++++++++++- arch/x86/kernel/cpu/resctrl/internal.h | 10 ++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 236 ++++++++++++++++++++++++- 3 files changed, 360 insertions(+), 2 deletions(-)
Documentation/arch/x86/resctrl.rst +115 -1
@@ -347,7 +347,8 @@ with the following files: t MBM total event is assigned. l MBM local event is assigned. tl Both MBM total and local events are assigned. - _ None of the MBM events are assigned. + _ None of the MBM events are assigned. Only works with opcode '=' for write + and cannot be combined with other flags. Examples: ::
@@ -365,6 +366,119 @@ with the following files: There are four resctrl groups. All the groups have total and local MBM events assigned on domain 0 and 1. + Assignment state can be updated by writing to the interface. + + Format is similar to the list format with addition of opcode for the + assignment operation. + + "<CTRL_MON group>/<MON group>/<domain_id><opcode><flags>" + + Format for each type of groups: + + * Default CTRL_MON group: + "//<domain_id><opcode><flags>" + + * Non-default CTRL_MON group: + "<CTRL_MON group>//<domain_id><opcode><flags>" + + * Child MON group of default CTRL_MON group: + "/<MON group>/<domain_id><opcode><flags>" + + * Child MON group of non-default CTRL_MON group: + "<CTRL_MON group>/<MON group>/<domain_id><opcode><flags>" + + Domain_id '*' will apply the flags on all the domains. + + Opcode can be one of the following: + :: + + = Update the assignment to match the MBM event. + + Assign a new MBM event without impacting existing assignments. + - Unassign a MBM event from currently assigned events. + + Examples: + Initial group status: + :: + + # cat /sys/fs/resctrl/info/L3_MON/mbm_assign_control + non_default_ctrl_mon_grp//0=tl;1=tl; + non_default_ctrl_mon_grp/child_non_default_mon_grp/0=tl;1=tl; + //0=tl;1=tl; + /child_default_mon_grp/0=tl;1=tl; + + To update the default group to assign only total MBM event on domain 0: + :: + + # echo "//0=t" > /sys/fs/resctrl/info/L3_MON/mbm_assign_control + + Assignment status after the update: + :: + + # cat /sys/fs/resctrl/info/L3_MON/mbm_assign_control + non_default_ctrl_mon_grp//0=tl;1=tl; + non_default_ctrl_mon_grp/child_non_default_mon_grp/0=tl;1=tl; + //0=t;1=tl; + /child_default_mon_grp/0=tl;1=tl; + + To update the MON group child_default_mon_grp to remove total MBM event on domain 1: + :: + + # echo "/child_default_mon_grp/1-t" > /sys/fs/resctrl/info/L3_MON/mbm_assign_control + + Assignment status after the update: + :: + + # cat /sys/fs/resctrl/info/L3_MON/mbm_assign_control + non_default_ctrl_mon_grp//0=tl;1=tl; + non_default_ctrl_mon_grp/child_non_default_mon_grp/0=tl;1=tl; + //0=t;1=tl; + /child_default_mon_grp/0=tl;1=l; + + To update the MON group non_default_ctrl_mon_grp/child_non_default_mon_grp to unassign + both local and total MBM events on domain 1: + :: + + # echo "non_default_ctrl_mon_grp/child_non_default_mon_grp/1=_" > + /sys/fs/resctrl/info/L3_MON/mbm_assign_control + + Assignment status after the update: + :: + + # cat /sys/fs/resctrl/info/L3_MON/mbm_assign_control + non_default_ctrl_mon_grp//0=tl;1=tl; + non_default_ctrl_mon_grp/child_non_default_mon_grp/0=tl;1=_; + //0=t;1=tl; + /child_default_mon_grp/0=tl;1=l; + + To update the default group to add a local MBM event domain 0. + :: + + # echo "//0+l" > /sys/fs/resctrl/info/L3_MON/mbm_assign_control + + Assignment status after the update: + :: + + # cat /sys/fs/resctrl/info/L3_MON/mbm_assign_control + non_default_ctrl_mon_grp//0=tl;1=tl; + non_default_ctrl_mon_grp/child_non_default_mon_grp/0=tl;1=_; + //0=tl;1=tl; + /child_default_mon_grp/0=tl;1=l; + + To update the non default CTRL_MON group non_default_ctrl_mon_grp to unassign all the + MBM events on all the domains. + :: + + # echo "non_default_ctrl_mon_grp//*=_" > /sys/fs/resctrl/info/L3_MON/mbm_assign_control + + Assignment status after the update: + :: + + # cat /sys/fs/resctrl/info/L3_MON/mbm_assign_control + non_default_ctrl_mon_grp//0=_;1=_; + non_default_ctrl_mon_grp/child_non_default_mon_grp/0=tl;1=_; + //0=tl;1=tl; + /child_default_mon_grp/0=tl;1=l; + "max_threshold_occupancy": Read/write file provides the largest value (in bytes) at which a previously used LLC_occupancy
arch/x86/kernel/cpu/resctrl/internal.h +10 -0
@@ -74,6 +74,16 @@*/ #define MBM_EVENT_ARRAY_INDEX (_event) ((_event) - 2) +/* +* Assignment flags for mbm_cntr_assign feature +*/ +enum { +ASSIGN_NONE =0 , +ASSIGN_TOTAL =BIT (QOS_L3_MBM_TOTAL_EVENT_ID ), +ASSIGN_LOCAL =BIT (QOS_L3_MBM_LOCAL_EVENT_ID ), +ASSIGN_INVALID , +}; +/** * cpumask_any_housekeeping() - Choose any CPU in @mask, preferring those that * aren't marked nohz_full
arch/x86/kernel/cpu/resctrl/rdtgroup.c +235 -1
250 lines not on this page · raw message
Signature · 1 line
2.34.1