x86,fs/resctrl: Support L3 Smart Data Cache Injection Allocation Enforcement (SDCIAE)
Subsystems (3)
Babu Moger
reviewerv11 cover x86,fs/resctrl: Support L3 Smart Data Cache Injection Allocation Enforcement (SDCIAE)
This series adds the support for L3 Smart Data Cache Injection Allocation Enforcement (SDCIAE) to resctrl infrastructure. It is referred to as "io_alloc" in resctrl subsystem.
Upcoming AMD hardware implements Smart Data Cache Injection (SDCI). Smart Data Cache Injection (SDCI) is a mechanism that enables direct insertion of data from I/O devices into the L3 cache. By directly caching data from I/O devices rather than first storing the I/O data in DRAM, SDCI reduces demands on DRAM bandwidth and reduces latency to the processor consuming the I/O data.
The SDCIAE (SDCI Allocation Enforcement) PQE feature allows system software to control the portion of the L3 cache used for SDCI devices.
When enabled, SDCIAE forces all SDCI lines to be placed into the L3 cache partitions identified by the highest-supported L3_MASK_n register, where n is the maximum supported CLOSID.
Since CLOSIDs are managed by resctrl fs it is least invasive to make the "io_alloc is supported by maximum supported CLOSID" part of the initial resctrl fs support for io_alloc. Take care not to expose this use of CLOSID for io_alloc to user space so that this is not required from other architectures that may support io_alloc differently in the future.
The SDCIAE feature details are documented in APM [1] available from [2].
[1] AMD64 Architecture Programmer's Manual Volume 2: System Programming Publication # 24593 Revision 3.41 section 19.4.7 L3 Smart Data Cache Injection Allocation Enforcement (SDCIAE)
The feature requires linux support of TPH (TLP Processing Hints). The support is available in linux kernel after the commit 48d0fd2b903e3 ("PCI/TPH: Add TPH documentation")
The patches are based on top of commit (v6.18.0-rc3)
Commit 1f7c44e84b9b (tip/master) ("Merge branch into tip/master: 'x86/sgx'")
Comments and suggestions are always welcome as usual.
# Linux Implementation
Feature adds following interface files when the resctrl "io_alloc" feature is supported on the resource:
/sys/fs/resctrl/info/L3/io_alloc: Report the feature status. Enable/disable the
feature by writing to the interface.
/sys/fs/resctrl/info/L3/io_alloc_cbm: List the Capacity Bit Masks (CBMs) available
for I/O devices when io_alloc feature is enabled. Configure the CBM by writing to the interface.
When CDP is enabled, these files are created both in L3CODE and L3DATA.
# Examples:
a. Check if io_alloc feature is available.
# mount -t resctrl resctrl /sys/fs/resctrl/
# cat /sys/fs/resctrl/info/L3/io_alloc disabled
b. Enable the io_alloc feature.
# echo 1 > /sys/fs/resctrl/info/L3/io_alloc # cat /sys/fs/resctrl/info/L3/io_alloc enabled
c. Check the CBM values for the io_alloc feature.
# cat /sys/fs/resctrl/info/L3/io_alloc_cbm 0=ffff;1=ffff
d. Change the CBM value of domain 1.
# echo 1=ff > /sys/fs/resctrl/info/L3/io_alloc_cbm
# cat /sys/fs/resctrl/info/L3/io_alloc_cbm 0=ffff;1=00ff
e. Change the CBM value of domain 0 and 1.
# echo "0=ff;1=f" > /sys/fs/resctrl/info/L3/io_alloc_cbm
# cat /sys/fs/resctrl/info/L3/io_alloc_cbm 0=00ff;1=000f
f. Disable io_alloc feature and exit.
# echo 0 > /sys/fs/resctrl/info/L3/io_alloc # cat /sys/fs/resctrl/info/L3/io_alloc disabled
# umount /sys/fs/resctrl/ --- v11: Took care of review commnet on patch 6. Fixed typo CDP_3DATA -> CDP_DATA. Added code to free the CLOSID on resctrl_arch_io_alloc_enable() failure. Fixed the prototype of rdtgroup_name_by_closid().
Other patches did not change.
Added Reviewed-by: tag for few patches.
Took care of few minor conflicts in fs/resctrl/internal.h due to code displacement.
v10:
Updated the changelogs in most patches when there is some repetitions in texts. Thanks to Reinette.
Fixed the minor conflicts in scattered.c and cpufeatures.h.
Fixed the few conflicts due to recent ABMC feature merge.
Code comment update to match MSR names correctly.
Re-arranged the details in resctrl.rst file.
Changed the text L3CODE to CDP_CODE and L3DATA to CDP_DATA.
Updated the return code to EINVAL when feature is not enabled in resctrl_io_alloc_cbm_write().
Few other text changes. Added details in each patch about the specifics.
v9:
Major change is related to CDP.
The processing and updating CBMs for CDP_CODE and CDP_DATA are done only once. The updated CBMs are copied to the peers using staged_config.
Removed resctrl_get_schema(). Not required anymore.
Updated the "bit_usage" section of resctrl.rst for io_alloc.
Fixed the tabs in SMBA and BMEC lines in resctrl.rst.
Improved the changelog for all the patches.
Added the code comments about CDP_CODE and CDP_DATA where applicable.
Added Reviewed-by: tag for couple of patches.
Added comments in each patch about the changes.
v8:
Added Acked-by, Reviewed-by tags to couple of patches.
Updated Documentation/filesystems/resctrl.rst for each interface.
Updated the changelog in most patches.
Moved the patch to update the rdt_bit_usage_show() for io_alloc changes to the end.
Moved resctrl_arch_io_alloc_enable() and its dependancies to arch/x86/kernel/cpu/resctrl/ctrlmondata.c file.
Moved resctrl_io_alloc_show() to fs/resctrl/ctrlmondata.c. Added prototype for rdt_kn_parent_priv() in fs/resctrl/internal.h so, it can be uses in other fs/resctrl/ files.
Renamed resctrl_io_alloc_init_cat() to resctrl_io_alloc_init_cbm(). Moved resctrl_io_alloc_write() and all its dependancies to fs/resctrl/ctrlmondata.c. Added prototypes for all the functions in fs/resctrl/internal.h.
Moved resctrl_io_alloc_cbm_show() to fs/resctrl/ctrlmondata.c. show_doms remains static with this change.
Moved resctrl_io_alloc_parse_line() and resctrl_io_alloc_cbm_write() to fs/resctrl/ctrlmondata.c.
Added resctrl_arch_get_cdp_enabled() check inside resctrl_io_alloc_parse_line(). parse_cbm() remains static as everything moved to ctrlmondata.c.
Simplified the CDT check in rdt_bit_usage_show() as CDP_DATA and CDP_CODE are in sync with io_alloc enabled.
v7:
Fixed few conflicts in
arch/x86/include/asm/cpufeatures.h
arch/x86/kernel/cpu/scattered.c
Updated the changelog in most patches. Removed the references of L3 in filesystem related changes.
Removed the inline for resctrl_arch_get_io_alloc_enabled(). Updated the code comment in resctrl.h.
Changed the subject to x86,fs/resctrl where applicable.
Split the patches based on the comment.
https://lore.kernel.org/lkml/[email protected]/
Separated resctrl_io_alloc_show and bit_usage changes in two separate patches.
Added new function resctrl_io_alloc_closid_supported() to verify io_alloc CLOSID.
Added the code to initialize/update the schemata for both CDP_DATA and CDP_CODE when CDP is enabled.
Rephrased the changelog and code comments in all the patches.
v6:
Sorry if you see this series duplicate. Messed up the emails [email protected] and [email protected].
Sent v5 by mistake before completing all testing.
Most of the changes are in resctrl.rst user doc.
The resource name is no longer printed in io_alloc_cbms. Updated the related documentation accordingly.
Resolved conflicts in cpufeatures.h
Added lockdep_assert_cpus_held() in _resctrl_sdciae_enable() to protect r->ctrl_domains.
Added more comments in include/linux/resctrl.h.
Updated "io_alloc_cbm" details in user doc resctrl.rst. Resource name is not printed in CBM now.
Updated subjects to fs/resctrl: where applicable.
v5:
Patches are created on top of recent resctrl FS/ARCH code restructure. The files monitor.c/rdtgroup.c have been split between FS and ARCH directories. Resolved the conflict due to the merge.
Updated bit_usage to reflect the io_alloc CBM as discussed in the thread:
https://lore.kernel.org/lkml/[email protected]/
Modified rdt_bit_usage_show() to read io_alloc_cbm in hw_shareable, ensuring that bit_usage accurately represents the CBMs.
Moved prototypes of resctrl_arch_io_alloc_enable() and resctrl_arch_get_io_alloc_enabled() to include/linux/resctrl.h.
Used rdt_kn_name to get the rdtgroup name instead of accesssing it directly while printing group name used by the io_alloc_closid.
Updated show_doms() to print the resource if only it is valid. Pass NULL while printing io_alloc CBM.
Changed the code to access io_alloc CBMs via either L3CODE or L3DATA resources.
v4: The "io_alloc" interface will report "enabled/disabled/not supported"
instead of 0 or 1..
Updated resctrl_io_alloc_closid_get() to verify the max closid availability using closids_supported().
Updated the documentation for "shareable_bits" and "bit_usage".
NOTE: io_alloc is about specific CLOS. rdt_bit_usage_show() is not designed handle bit_usage for specific CLOS. Its about overall system. So, we cannot really tell the user which CLOS is shared across both hardware and software. This is something we need to discuss.
Introduced io_alloc_init() to initialize fflags.
Printed the group name when io_alloc enablement fails to help user.
Added rdtgroup_mutex before rdt_last_cmd_puts() in resctrl_io_alloc_cbm_show(). Returned -ENODEV when resource type is CDP_DATA.
Kept the resource name while printing the CBM (L3:0=ffff) that way we dont have to change show_doms() just for this feature and it is consistant across all the schemata display.
Added new patch to call parse_cbm() directly to avoid code duplication.
Checked all the series(v1-v3) again to verify if I missed any comment.
v3: Rewrote commit log for the last 3 patches. Changed the text to bit
more generic than the AMD specific feature. Added AMD feature specifics in the end.
Renamed the rdt_get_sdciae_alloc_cfg() to rdt_set_io_alloc_capable(). Renamed the _resctrl_io_alloc_enable() to _resctrl_sdciae_enable() as it is arch specific.
Changed the return to void in _resctrl_sdciae_enable() instead of int.
The number of CLOSIDs is determined based on the minimum supported across all resources (in closid_init). It needs to match the max supported on the resource. Added the check to verify if MAX CLOSID availability on the system.
Added CDP check to make sure io_alloc is configured in CDP_CODE. Highest CLOSID corresponds to CDP_CODE.
Added resctrl_io_alloc_closid_free() to free the io_alloc CLOSID.
Added errors in few cases when CLOSID allocation fails.
Fixes splat reported when info/L3/bit_usage is accesed when io_alloc is enabled.
https://lore.kernel.org/lkml/SJ1PR11MB60837B532254E7B23BC27E84FC052@SJ1PR11MB6083.namprd11.prod.outlook.com/
v2: Added dependancy on X86_FEATURE_CAT_L3
Removed the "" in CPU feature definition.
Changed sdciae_capable to io_alloc_capable to make it as generic feature. Moved io_alloc_capable field in struct resctrl_cache.
Changed the name of few arch functions similar to ABMC series. resctrl_arch_get_io_alloc_enabled() resctrl_arch_io_alloc_enable()
Renamed the feature to "io_alloc".
Added generic texts for the feature in commit log and resctrl.rst doc. Added resctrl_io_alloc_init_cat() to initialize io_alloc to default values when enabled.
Fixed io_alloc interface to show only on L3 resource.
Added the locks while processing io_alloc CBMs.
Previous versions:
v10: https://lore.kernel.org/lkml/[email protected]/
v9: https://lore.kernel.org/lkml/[email protected]/
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 (10):
x86/cpufeatures: Add support for L3 Smart Data Cache Injection
Allocation Enforcement
x86/resctrl: Add SDCIAE feature in the command line options x86,fs/resctrl: Detect io_alloc feature
x86,fs/resctrl: Implement "io_alloc" enable/disable handlers fs/resctrl: Introduce interface to display "io_alloc" support fs/resctrl: Add user interface to enable/disable io_alloc feature fs/resctrl: Introduce interface to display io_alloc CBMs fs/resctrl: Modify struct rdt_parse_data to pass mode and CLOSID fs/resctrl: Introduce interface to modify io_alloc capacity bitmasks fs/resctrl: Update bit_usage to reflect io_alloc
.../admin-guide/kernel-parameters.txt | 2 +- Documentation/filesystems/resctrl.rst | 127 +++++-- arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/kernel/cpu/cpuid-deps.c | 1 + arch/x86/kernel/cpu/resctrl/core.c | 9 + arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 40 +++ arch/x86/kernel/cpu/resctrl/internal.h | 5 + arch/x86/kernel/cpu/scattered.c | 1 + fs/resctrl/ctrlmondata.c | 309 +++++++++++++++++- fs/resctrl/internal.h | 17 + fs/resctrl/rdtgroup.c | 75 ++++- include/linux/resctrl.h | 24 ++ 12 files changed, 567 insertions(+), 44 deletions(-)
Signature · 1 line
2.34.1
Babu Moger
reviewerPATCH v11 1/10 x86/cpufeatures: Add support for L3 Smart Data Cache Injection Allocation Enforcement
Smart Data Cache Injection (SDCI) is a mechanism that enables direct insertion of data from I/O devices into the L3 cache. By directly caching data from I/O devices rather than first storing the I/O data in DRAM, SDCI reduces demands on DRAM bandwidth and reduces latency to the processor consuming the I/O data.
The SDCIAE (SDCI Allocation Enforcement) PQE feature allows system software to control the portion of the L3 cache used for SDCI.
When enabled, SDCIAE forces all SDCI lines to be placed into the L3 cache partitions identified by the highest-supported L3_MASK_n register, where n is the maximum supported CLOSID.
Add CPUID feature bit that can be used to configure SDCIAE.
The SDCIAE feature details are documented in APM [1] available from [2].
[1] AMD64 Architecture Programmer's Manual Volume 2: System Programming Publication # 24593 Revision 3.41 section 19.4.7 L3 Smart Data Cache Injection Allocation Enforcement (SDCIAE).
---
v11: No changes.
v10: Fixed the minor conflicts in scattered.c and cpufeatures.h.
Updated the changelog to fix minor formating.
v9: No changes.
v8: Added Acked-by, Reviewed-by tags.
v7: No changes. Fixed few conflicts in
arch/x86/include/asm/cpufeatures.h
arch/x86/kernel/cpu/scattered.c
v6: Resolved conflicts in cpufeatures.h.
v5: No changes.
v4: Resolved a minor conflict in cpufeatures.h.
v3: No changes.
v2: Added dependancy on X86_FEATURE_CAT_L3
Removed the "" in CPU feature definition.
Minor text changes.
--- arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/kernel/cpu/cpuid-deps.c | 1 + arch/x86/kernel/cpu/scattered.c | 1 + 3 files changed, 3 insertions(+)
arch/x86/include/asm/cpufeatures.h +1 -0
@@ -503,6 +503,7 @@#define X86_FEATURE_ABMC (21*32+15)/* Assignable Bandwidth Monitoring Counters */ #define X86_FEATURE_MSR_IMM (21*32+16)/* MSR immediate form instructions */ #define X86_FEATURE_SGX_EUPDATESVN (21*32+17)/* Support for ENCLS[EUPDATESVN] instruction */ +#define X86_FEATURE_SDCIAE (21*32+18)/* L3 Smart Data Cache Injection Allocation Enforcement */ /* * BUG word(s)
arch/x86/kernel/cpu/cpuid-deps.c +1 -0
@@ -72,6 +72,7 @@ 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_SDCIAE, X86_FEATURE_CAT_L3 }, { 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
@@ -57,6 +57,7 @@ static const struct cpuid_bit cpuid_bits[] = { { 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_SDCIAE, CPUID_EBX, 6, 0x80000020, 0 }, { X86_FEATURE_TSA_SQ_NO, CPUID_ECX, 1, 0x80000021, 0 }, { X86_FEATURE_TSA_L1_NO, CPUID_ECX, 2, 0x80000021, 0 }, { X86_FEATURE_AMD_WORKLOAD_CLASS, CPUID_EAX, 22, 0x80000021, 0 },
Signature · 1 line
2.34.1
Babu Moger
reviewerPATCH v11 2/10 x86/resctrl: Add SDCIAE feature in the command line options
In reply to Babu MogerAdd a kernel command-line parameter to enable or disable the exposure of the L3 Smart Data Cache Injection Allocation Enforcement (SDCIAE) hardware feature to resctrl.
---
v11: No changes.
v10: Changelog update.
Fixed the few conflicts due to recent ABMC feature merge.
v9: Minor changelog update.
Fixed the tabs in SMBA and BMEC lines.
v8: Updated Documentation/filesystems/resctrl.rst.
v7: No changes.
v6: No changes.
v5: No changes.
v4: No changes.
v3: No changes.
v2: No changes.
--- .../admin-guide/kernel-parameters.txt | 2 +- Documentation/filesystems/resctrl.rst | 23 ++++++++++--------- arch/x86/kernel/cpu/resctrl/core.c | 2 ++ 3 files changed, 15 insertions(+), 12 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +1 -1
@@ -6207,7 +6207,7 @@ rdt= [HW,X86,RDT] Turn on/off individual RDT features. List is: cmt, mbmtotal, mbmlocal, l3cat, l3cdp, l2cat, l2cdp, - mba, smba, bmec, abmc. + mba, smba, bmec, abmc, sdciae. E.g. to turn on cmt and turn off mba use: rdt=cmt,!mba
Documentation/filesystems/resctrl.rst +12 -11
@@ -17,17 +17,18 @@ AMD refers to this feature as AMD Platform Quality of Service(AMD QoS). This feature is enabled by the CONFIG_X86_CPU_RESCTRL and the x86 /proc/cpuinfo flag bits: -=============================================== ================================ -RDT (Resource Director Technology) Allocation "rdt_a" -CAT (Cache Allocation Technology) "cat_l3", "cat_l2" -CDP (Code and Data Prioritization) "cdp_l3", "cdp_l2" -CQM (Cache QoS Monitoring) "cqm_llc", "cqm_occup_llc" -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) "" -=============================================== ================================ +=============================================================== ================================ +RDT (Resource Director Technology) Allocation "rdt_a" +CAT (Cache Allocation Technology) "cat_l3", "cat_l2" +CDP (Code and Data Prioritization) "cdp_l3", "cdp_l2" +CQM (Cache QoS Monitoring) "cqm_llc", "cqm_occup_llc" +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) "" +SDCIAE (Smart Data Cache Injection Allocation Enforcement) "" +=============================================================== ================================ Historically, new features were made visible by default in /proc/cpuinfo. This resulted in the feature flags becoming hard to parse by humans. Adding a new
arch/x86/kernel/cpu/resctrl/core.c +2 -0
@@ -719,6 +719,7 @@ enum {RDT_FLAG_SMBA ,RDT_FLAG_BMEC ,RDT_FLAG_ABMC , + RDT_FLAG_SDCIAE, };#define RDT_OPT (idx, n, f) \
@@ -745,6 +746,7 @@ static struct rdt_options rdt_options[] __ro_after_init = {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 ), + RDT_OPT(RDT_FLAG_SDCIAE, "sdciae", X86_FEATURE_SDCIAE), };#define NUM_RDT_OPTIONS ARRAY_SIZE(rdt_options)
Signature · 1 line
2.34.1
Babu Moger
reviewerPATCH v11 3/10 x86,fs/resctrl: Detect io_alloc feature
In reply to Babu MogerAMD's SDCIAE (SDCI Allocation Enforcement) PQE feature enables system software to control the portions of L3 cache used for direct insertion of data from I/O devices into the L3 cache.
Introduce a generic resctrl cache resource property "io_alloc_capable" as the first part of the new "io_alloc" resctrl feature that will support AMD's SDCIAE. Any architecture can set a cache resource as "io_alloc_capable" if a portion of the cache can be allocated for I/O traffic.
Set the "io_alloc_capable" property for the L3 cache resource on x86 (AMD) systems that support SDCIAE.
---
v11: No changes.
v10: Updated the changelog.
v9: No changes.
v8: Added Reviewed-by tag.
v7: Few text updates in changelog and resctrl.h.
v6: No changes.
v5: No changes.
v4: Updated the commit message and code comment based on feedback.
v3: Rewrote commit log. Changed the text to bit generic than the AMD specific.
Renamed the rdt_get_sdciae_alloc_cfg() to rdt_set_io_alloc_capable(). Removed leftover comment from v2.
v2: Changed sdciae_capable to io_alloc_capable to make it generic feature.
Also moved the io_alloc_capable in struct resctrl_cache.
--- arch/x86/kernel/cpu/resctrl/core.c | 7 +++++++ include/linux/resctrl.h | 3 +++ 2 files changed, 10 insertions(+)
arch/x86/kernel/cpu/resctrl/core.c +7 -0
@@ -274,6 +274,11 @@ static void rdt_get_cdp_config(int level) rdt_resources_all[level].r_resctrl.cdp_capable = true; } +static void rdt_set_io_alloc_capable (struct rdt_resource *r) +{ + r->cache.io_alloc_capable = true; +} +static void rdt_get_cdp_l3_config (void ) {rdt_get_cdp_config (RDT_RESOURCE_L3 );
@@ -855,6 +860,8 @@ static __init bool get_rdt_alloc_resources(void)rdt_get_cache_alloc_cfg (1 , r);if (rdt_cpu_has (X86_FEATURE_CDP_L3 ))rdt_get_cdp_l3_config (); +if (rdt_cpu_has (X86_FEATURE_SDCIAE )) +rdt_set_io_alloc_capable (r); ret = true; }if (rdt_cpu_has (X86_FEATURE_CAT_L2 )) {
include/linux/resctrl.h +3 -0
@@ -206,6 +206,8 @@ struct rdt_mon_domain {* @arch_has_sparse_bitmasks: True if a bitmask like f00f is valid. * @arch_has_per_cpu_cfg: True if QOS_CFG register for this cache * level has CPU scope. +* @io_alloc_capable: True if portion of the cache can be configured +* for I/O traffic. */ struct resctrl_cache {unsigned int cbm_len;
@@ -213,6 +215,7 @@ struct resctrl_cache {unsigned int shareable_bits;bool arch_has_sparse_bitmasks;bool arch_has_per_cpu_cfg; +bool io_alloc_capable; };/**
Signature · 1 line
2.34.1
Babu Moger
reviewerPATCH v11 4/10 x86,fs/resctrl: Implement "io_alloc" enable/disable handlers
In reply to Babu Moger"io_alloc" is the generic name of the new resctrl feature that enables system software to configure the portion of cache allocated for I/O traffic. On AMD systems, "io_alloc" resctrl feature is backed by AMD's L3 Smart Data Cache Injection Allocation Enforcement (SDCIAE).
Introduce the architecture-specific functions that resctrl fs should call to enable, disable, or check status of the "io_alloc" feature. Change SDCIAE state by setting (to enable) or clearing (to disable) bit 1 of MSR_IA32_L3_QOS_EXT_CFG on all logical processors within the cache domain.
The SDCIAE feature details are documented in APM [1] available from [2].
[1] AMD64 Architecture Programmer's Manual Volume 2: System Programming Publication # 24593 Revision 3.41 section 19.4.7 L3 Smart Data Cache Injection Allocation Enforcement (SDCIAE).
---
v11: Added Reviewed-by: tag.
v10: Changelog update.
Code comment update to match MSR names.
Removed the Reviewed-by tag as there are more than one change.
v9: Minor changelog update.
Added Reviewed-by: tag.
v8: Moved resctrl_arch_io_alloc_enable() and its dependancies to
arch/x86/kernel/cpu/resctrl/ctrlmondata.c file.
v7: Removed the inline for resctrl_arch_get_io_alloc_enabled().
Update code comment in resctrl.h.
Changed the subject to x86,fs/resctrl.
v6: Added lockdep_assert_cpus_held() in _resctrl_sdciae_enable() to protect
r->ctrl_domains.
Added more comments in include/linux/resctrl.h.
v5: Resolved conflicts due to recent resctrl FS/ARCH code restructure.
The files monitor.c/rdtgroup.c have been split between FS and ARCH directories. Moved prototypes of resctrl_arch_io_alloc_enable() and resctrl_arch_get_io_alloc_enabled() to include/linux/resctrl.h.
v4: Updated the commit log to address the feedback.
v3: Passed the struct rdt_resource to resctrl_arch_get_io_alloc_enabled() instead of resource id.
Renamed the _resctrl_io_alloc_enable() to _resctrl_sdciae_enable() as it is arch specific. Changed the return to void in _resctrl_sdciae_enable() instead of int.
Added more context in commit log and fixed few typos.
v2: Renamed the functions to simplify the code.
Renamed sdciae_capable to io_alloc_capable.
Changed the name of few arch functions similar to ABMC series. resctrl_arch_get_io_alloc_enabled() resctrl_arch_io_alloc_enable()
--- arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 40 +++++++++++++++++++++++ arch/x86/kernel/cpu/resctrl/internal.h | 5 +++ include/linux/resctrl.h | 21 ++++++++++++ 3 files changed, 66 insertions(+)
arch/x86/kernel/cpu/resctrl/ctrlmondata.c +40 -0
@@ -91,3 +91,43 @@ u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_ctrl_domain *d,return hw_dom->ctrl_val[idx]; } + +bool resctrl_arch_get_io_alloc_enabled (struct rdt_resource *r) +{ +return resctrl_to_arch_res (r)->sdciae_enabled; +} + +static void resctrl_sdciae_set_one_amd (void *arg) +{ +bool *enable = arg; + +if (*enable) +msr_set_bit (MSR_IA32_L3_QOS_EXT_CFG ,SDCIAE_ENABLE_BIT ); +else +msr_clear_bit (MSR_IA32_L3_QOS_EXT_CFG ,SDCIAE_ENABLE_BIT ); +} + +static void _resctrl_sdciae_enable (struct rdt_resource *r,bool enable) +{ +struct rdt_ctrl_domain *d; + +/* Walking r->ctrl_domains, ensure it can't race with cpuhp */ +lockdep_assert_cpus_held (); + +/* Update MSR_IA32_L3_QOS_EXT_CFG MSR on all the CPUs in all domains */ +list_for_each_entry (d, &r->ctrl_domains, hdr.list) +on_each_cpu_mask (&d->hdr.cpu_mask, resctrl_sdciae_set_one_amd, &enable,1 ); +} + +int resctrl_arch_io_alloc_enable (struct rdt_resource *r,bool enable) +{ +struct rdt_hw_resource *hw_res =resctrl_to_arch_res (r); + +if (hw_res->r_resctrl.cache.io_alloc_capable && + hw_res->sdciae_enabled != enable) { +_resctrl_sdciae_enable (r, enable); + hw_res->sdciae_enabled = enable; + } + +return 0 ; +}
arch/x86/kernel/cpu/resctrl/internal.h +5 -0
@@ -46,6 +46,9 @@ struct arch_mbm_state {#define ABMC_EXTENDED_EVT_ID BIT(31)#define ABMC_EVT_ID BIT(0) +/* Setting bit 1 in MSR_IA32_L3_QOS_EXT_CFG enables the SDCIAE feature. */ +#define SDCIAE_ENABLE_BIT 1 +/** * struct rdt_hw_ctrl_domain - Arch private attributes of a set of CPUs that share * a resource for a control function
@@ -112,6 +115,7 @@ struct msr_param {* @mbm_width: Monitor width, to detect and correct for overflow. * @cdp_enabled: CDP state of this resource * @mbm_cntr_assign_enabled: ABMC feature is enabled +* @sdciae_enabled: SDCIAE feature (backing "io_alloc") 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.
@@ -126,6 +130,7 @@ struct rdt_hw_resource {unsigned int mbm_width;bool cdp_enabled;bool mbm_cntr_assign_enabled; +bool sdciae_enabled; };static inline struct rdt_hw_resource *resctrl_to_arch_res (struct rdt_resource *r)
include/linux/resctrl.h +21 -0
@@ -657,6 +657,27 @@ void resctrl_arch_reset_cntr(struct rdt_resource *r, struct rdt_mon_domain *d, u32 closid, u32 rmid, int cntr_id, enum resctrl_event_id eventid); +/** +* resctrl_arch_io_alloc_enable() - Enable/disable io_alloc feature. +* @r: The resctrl resource. +* @enable: Enable (true) or disable (false) io_alloc on resource @r. +* +* This can be called from any CPU. +* +* Return: +* 0 on success, <0 on error. +*/ +int resctrl_arch_io_alloc_enable (struct rdt_resource *r,bool enable); + +/** +* resctrl_arch_get_io_alloc_enabled() - Get io_alloc feature state. +* @r: The resctrl resource. +* +* Return: +* true if io_alloc is enabled or false if disabled. +*/ +bool resctrl_arch_get_io_alloc_enabled (struct rdt_resource *r); +extern unsigned int resctrl_rmid_realloc_threshold;extern unsigned int resctrl_rmid_realloc_limit;
Signature · 1 line
2.34.1
Babu Moger
reviewerPATCH v11 5/10 fs/resctrl: Introduce interface to display "io_alloc" support
In reply to Babu MogerIntroduce the "io_alloc" resctrl file to the "info" area of a cache resource, for example /sys/fs/resctrl/info/L3/io_alloc. "io_alloc" indicates support for the "io_alloc" feature that allows direct insertion of data from I/O devices into the cache.
Restrict exposing support for "io_alloc" to the L3 resource that is the only resource where this feature can be backed by AMD's L3 Smart Data Cache Injection Allocation Enforcement (SDCIAE). With that, the "io_alloc" file is only visible to user space if the L3 resource supports "io_alloc". Doing so makes the file visible for all cache resources though, for example also L2 cache (if it supports cache allocation). As a consequence, add capability for file to report expected "enabled" and "disabled", as well as "not supported".
---
v11:Added Reviewed-by: tag.
v10:Changelog update.
Removed the h/w specific details from this patch and will add to the next patch.
v9: Minor user doc(resctrl.rst) update.
v8: Updated Documentation/filesystems/resctrl.rst.
Moved resctrl_io_alloc_show() to fs/resctrl/ctrlmondata.c. Added prototype for rdt_kn_parent_priv() in fs/resctrl/internal.h so, it can be uses in other fs/resctrl/ files.
Added comment for io_alloc_init().
v7: Updated the changelog.
Updated user doc for io_alloc in resctrl.rst. Added mutex rdtgroup_mutex in resctrl_io_alloc_show();
v6: Added "io_alloc_cbm" details in user doc resctrl.rst.
Resource name is not printed in CBM now. Corrected the texts about it in resctrl.rst.
v5: Resolved conflicts due to recent resctrl FS/ARCH code restructure.
Updated show_doms() to print the resource if only it is valid. Pass NULL while printing io_alloc CBM.
Changed the code to access the CBMs via either L3CODE or L3DATA resources.
v4: Updated the change log.
Added rdtgroup_mutex before rdt_last_cmd_puts(). Returned -ENODEV when resource type is CDP_DATA.
Kept the resource name while printing the CBM (L3:0=fff) that way I dont have to change show_doms() just for this feature and it is consistant across all the schemata display.
v3: Minor changes due to changes in resctrl_arch_get_io_alloc_enabled()
and resctrl_io_alloc_closid_get().
Added the check to verify CDP resource type.
Updated the commit log.
v2: Fixed to display only on L3 resources.
Added the locks while processing.
Rename the displat to io_alloc_cbm (from sdciae_cmd).
--- Documentation/filesystems/resctrl.rst | 15 +++++++++++++++ fs/resctrl/ctrlmondata.c | 21 +++++++++++++++++++++ fs/resctrl/internal.h | 1 + fs/resctrl/rdtgroup.c | 22 ++++++++++++++++++++++ 4 files changed, 59 insertions(+)
Documentation/filesystems/resctrl.rst +15 -0
@@ -137,6 +137,21 @@ related to allocation: "1": Non-contiguous 1s value in CBM is supported. +"io_alloc": + "io_alloc" enables system software to configure the portion of + the cache allocated for I/O traffic. File may only exist if the + system supports this feature on some of its cache resources. + + "disabled": + Resource supports "io_alloc" but the feature is disabled. + Portions of cache used for allocation of I/O traffic cannot + be configured. + "enabled": + Portions of cache used for allocation of I/O traffic + can be configured using "io_alloc_cbm". + "not supported": + Support not available for this resource. + Memory bandwidth(MB) subdirectory contains the following files with respect to allocation:
fs/resctrl/ctrlmondata.c +21 -0
@@ -676,3 +676,24 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg)rdtgroup_kn_unlock (of->kn);return ret; } + +int resctrl_io_alloc_show (struct kernfs_open_file *of,struct seq_file *seq,void *v) +{ +struct resctrl_schema *s =rdt_kn_parent_priv (of->kn); +struct rdt_resource *r = s->res; + +mutex_lock (&rdtgroup_mutex); + +if (r->cache.io_alloc_capable) { +if (resctrl_arch_get_io_alloc_enabled (r)) +seq_puts (seq,"enabled\n" ); +else +seq_puts (seq,"disabled\n" ); + }else { +seq_puts (seq,"not supported\n" ); + } + +mutex_unlock (&rdtgroup_mutex); + +return 0 ; +}
fs/resctrl/internal.h +1 -0
@@ -426,6 +426,7 @@ int mbm_L3_assignments_show(struct kernfs_open_file *of, struct seq_file *s, voissize_t mbm_L3_assignments_write (struct kernfs_open_file *of,char *buf,size_t nbytes,loff_t off); +int resctrl_io_alloc_show (struct kernfs_open_file *of,struct seq_file *seq,void *v);#ifdef CONFIG_RESCTRL_FS_PSEUDO_LOCK int rdtgroup_locksetup_enter (struct rdtgroup *rdtgrp);
fs/resctrl/rdtgroup.c +22 -0
@@ -1947,6 +1947,12 @@ static struct rftype res_common_files[] = { .kf_ops = &rdtgroup_kf_single_ops, .seq_show = rdt_thread_throttle_mode_show, }, + { + .name = "io_alloc", + .mode = 0444, + .kf_ops = &rdtgroup_kf_single_ops, + .seq_show = resctrl_io_alloc_show, + }, { .name = "max_threshold_occupancy", .mode = 0644,
@@ -2138,6 +2144,20 @@ static void thread_throttle_mode_init(void) RFTYPE_CTRL_INFO | RFTYPE_RES_MB); } +/* +* The resctrl file "io_alloc" is added using L3 resource. However, it results +* in this file being visible for *all* cache resources (eg. L2 cache), +* whether it supports "io_alloc" or not. +*/ +static void io_alloc_init (void ) +{ +struct rdt_resource *r =resctrl_arch_get_resource (RDT_RESOURCE_L3 ); + +if (r->cache.io_alloc_capable) +resctrl_file_fflags_init ("io_alloc" ,RFTYPE_CTRL_INFO | +RFTYPE_RES_CACHE ); +} +void resctrl_file_fflags_init (const char *config,unsigned long fflags) {struct rftype *rft;
@@ -4408,6 +4428,8 @@ int resctrl_init(void)thread_throttle_mode_init (); +io_alloc_init (); + ret =resctrl_mon_resource_init ();if (ret)return ret;
Signature · 1 line
2.34.1
Babu Moger
reviewerPATCH v11 6/10 fs/resctrl: Add user interface to enable/disable io_alloc feature
In reply to Babu MogerAMD's SDCIAE forces all SDCI lines to be placed into the L3 cache portions identified by the highest-supported L3_MASK_n register, where n is the maximum supported CLOSID.
To support AMD's SDCIAE, when io_alloc resctrl feature is enabled, reserve the highest CLOSID exclusively for I/O allocation traffic making it no longer available for general CPU cache allocation.
Introduce user interface to enable/disable io_alloc feature and encourage users to enable io_alloc only when running workloads that can benefit from this functionality. On enable, initialize the io_alloc CLOSID with all usable CBMs across all the domains.
Since CLOSIDs are managed by resctrl fs, it is least invasive to make "io_alloc is supported by maximum supported CLOSID" part of the initial resctrl fs support for io_alloc. Take care to minimally (only in error messages) expose this use of CLOSID for io_alloc to user space so that this is not required from other architectures that may support io_alloc differently in the future.
When resctrl is mounted with "-o cdp" to enable code/data prioritization, there are two L3 resources that can support I/O allocation: L3CODE and L3DATA. From resctrl fs perspective the two resources share a CLOSID and the architecture's available CLOSID are halved to support this. The architecture's underlying CLOSID used by SDCIAE when CDP is enabled is the CLOSID associated with the CDP_CODE resource, but from resctrl's perspective there is only one CLOSID for both CDP_CODE and CDP_DATA. CDP_DATA is thus not usable for general (CPU) cache allocation nor I/O allocation. Keep the CDP_CODE and CDP_DATA I/O alloc status in sync to avoid any confusion to user space. That is, enabling io_alloc on CDP_CODE does so on CDP_DATA and vice-versa, and keep the I/O allocation CBMs of CDP_CODE and CDP_DATA in sync.
---
v11: Fixed typo CDP_3DATA -> CDP_DATA.
Added code to free the CLOSID on resctrl_arch_io_alloc_enable() failure. Fixed the prototype of rdtgroup_name_by_closid().
v10: Rephrase of the whole changelog to avoid repetion. Thanks to Reinette.
Minor print format changes.
Moved the hardware specific detail to resctrl.rst.
Changed the text L3CODE to CDP_CODE and L3DATA to CDP_DATA
v9: Updated the changelog.
Moved resctrl_arch_get_io_alloc_enabled() check earlier in the Removed resctrl_get_schema().
Copied staged_config from peer when CDP is enabled.
v8: Updated the changelog.
Renamed resctrl_io_alloc_init_cat() to resctrl_io_alloc_init_cbm(). Moved resctrl_io_alloc_write() and all its dependancies to fs/resctrl/ctrlmondata.c. Added prototypes for all the functions in fs/resctrl/internal.h.
v7: Separated resctrl_io_alloc_show and bit_usage changes in two separate
patches.
Added resctrl_io_alloc_closid_supported() to verify io_alloc CLOSID. Initialized the schema for both CDP_DATA and CDP_CODE when CDP is enabled.
v6: Changed the subject to fs/resctrl:
v5: Resolved conflicts due to recent resctrl FS/ARCH code restructure.
Used rdt_kn_name to get the rdtgroup name instead of accesssing it directly while printing group name used by the io_alloc_closid.
Updated bit_usage to reflect the io_alloc CBM as discussed in the thread:
https://lore.kernel.org/lkml/[email protected]/
Modified rdt_bit_usage_show() to read io_alloc_cbm in hw_shareable, ensuring that bit_usage accurately represents the CBMs.
Updated the code to modify io_alloc either with L3CODE or L3DATA.
https://lore.kernel.org/lkml/[email protected]/
v4: Updated the change log.
Updated the user doc.
The "io_alloc" interface will report "enabled/disabled/not supported". Updated resctrl_io_alloc_closid_get() to verify the max closid availability. Updated the documentation for "shareable_bits" and "bit_usage". Introduced io_alloc_init() to initialize fflags.
Printed the group name when io_alloc enablement fails.
NOTE: io_alloc is about specific CLOS. rdt_bit_usage_show() is not designed handle bit_usage for specific CLOS. Its about overall system. So, we cannot really tell the user which CLOS is shared across both hardware and software. We need to discuss this.
v3: Rewrote the change to make it generic.
Rewrote the documentation in resctrl.rst to be generic and added AMD feature details in the end.
Added the check to verify if MAX CLOSID availability on the system. Added CDP check to make sure io_alloc is configured in CDP_CODE. Added resctrl_io_alloc_closid_free() to free the io_alloc CLOSID. Added errors in few cases when CLOSID allocation fails. Fixes splat reported when info/L3/bit_usage is accesed when io_alloc is enabled.
https://lore.kernel.org/lkml/SJ1PR11MB60837B532254E7B23BC27E84FC052@SJ1PR11MB6083.namprd11.prod.outlook.com/
v2: Renamed the feature to "io_alloc".
Added generic texts for the feature in commit log and resctrl.rst doc. Added resctrl_io_alloc_init_cat() to initialize io_alloc to default values when enabled.
Fixed io_alloc show functinality to display only on L3 resource.
--- Documentation/filesystems/resctrl.rst | 23 +++++ fs/resctrl/ctrlmondata.c | 126 ++++++++++++++++++++++++++ fs/resctrl/internal.h | 11 +++ fs/resctrl/rdtgroup.c | 24 ++++- 4 files changed, 181 insertions(+), 3 deletions(-)
Documentation/filesystems/resctrl.rst +23 -0
@@ -152,6 +152,29 @@ related to allocation: "not supported": Support not available for this resource. + The feature can be modified by writing to the interface, for example: + + To enable: + # echo 1 > /sys/fs/resctrl/info/L3/io_alloc + + To disable: + # echo 0 > /sys/fs/resctrl/info/L3/io_alloc + + The underlying implementation may reduce resources available to + general (CPU) cache allocation. See architecture specific notes + below. Depending on usage requirements the feature can be enabled + or disabled. + + On AMD systems, io_alloc feature is supported by the L3 Smart + Data Cache Injection Allocation Enforcement (SDCIAE). The CLOSID for + io_alloc is the highest CLOSID supported by the resource. When + io_alloc is enabled, the highest CLOSID is dedicated to io_alloc and + no longer available for general (CPU) cache allocation. When CDP is + enabled, io_alloc routes I/O traffic using the highest CLOSID allocated + for the instruction cache (CDP_CODE), making this CLOSID no longer + available for general (CPU) cache allocation for both the CDP_CODE + and CDP_DATA resources. + Memory bandwidth(MB) subdirectory contains the following files with respect to allocation:
fs/resctrl/ctrlmondata.c +126 -0
129 lines not on this page · raw message
fs/resctrl/internal.h +11 -0
@@ -390,6 +390,8 @@ void rdt_staged_configs_clear(void);bool closid_allocated (unsigned int closid); +bool closid_alloc_fixed (u32 closid); +int resctrl_find_cleanest_closid (void );void *rdt_kn_parent_priv (struct kernfs_node *kn);
@@ -428,6 +430,15 @@ ssize_t mbm_L3_assignments_write(struct kernfs_open_file *of, char *buf, size_t loff_t off);int resctrl_io_alloc_show (struct kernfs_open_file *of,struct seq_file *seq,void *v); +int rdtgroup_init_cat (struct resctrl_schema *s,u32 closid); + +enum resctrl_conf_type resctrl_peer_type (enum resctrl_conf_type my_type); + +ssize_t resctrl_io_alloc_write (struct kernfs_open_file *of,char *buf, +size_t nbytes,loff_t off); + +const char *rdtgroup_name_by_closid (u32 closid); +#ifdef CONFIG_RESCTRL_FS_PSEUDO_LOCK int rdtgroup_locksetup_enter (struct rdtgroup *rdtgrp);
fs/resctrl/rdtgroup.c +21 -3
@@ -226,6 +226,11 @@ bool closid_allocated(unsigned int closid)return !test_bit (closid, closid_free_map); } +bool closid_alloc_fixed (u32 closid) +{ +return __test_and_clear_bit (closid, closid_free_map); +} +/** * rdtgroup_mode_by_closid - Return mode of resource group with closid * @closid: closid if the resource group
@@ -1247,7 +1252,7 @@ static int rdtgroup_mode_show(struct kernfs_open_file *of,return 0 ; } -static enum resctrl_conf_type resctrl_peer_type (enum resctrl_conf_type my_type) +enum resctrl_conf_type resctrl_peer_type (enum resctrl_conf_type my_type) {switch (my_type) {case CDP_CODE :
@@ -1838,6 +1843,18 @@ void resctrl_bmec_files_show(struct rdt_resource *r, struct kernfs_node *l3_mon_kernfs_put (mon_kn); } +const char *rdtgroup_name_by_closid (u32 closid) +{ +struct rdtgroup *rdtgrp; + +list_for_each_entry (rdtgrp, &rdt_all_groups, rdtgroup_list) { +if (rdtgrp->closid == closid) +return rdt_kn_name (rdtgrp->kn); + } + +return NULL ; +} +/* rdtgroup information files for one cache resource. */ static struct rftype res_common_files[] = { {
@@ -1949,9 +1966,10 @@ static struct rftype res_common_files[] = { }, { .name = "io_alloc", - .mode = 0444, + .mode = 0644, .kf_ops = &rdtgroup_kf_single_ops, .seq_show = resctrl_io_alloc_show, + .write = resctrl_io_alloc_write, }, { .name = "max_threshold_occupancy",
@@ -3500,7 +3518,7 @@ static int __init_one_rdt_domain(struct rdt_ctrl_domain *d, struct resctrl_schem* If there are no more shareable bits available on any domain then * the entire allocation will fail. */ -static int rdtgroup_init_cat (struct resctrl_schema *s,u32 closid) +int rdtgroup_init_cat (struct resctrl_schema *s,u32 closid) {struct rdt_ctrl_domain *d;int ret;
Signature · 1 line
2.34.1
Babu Moger
reviewerPATCH v11 7/10 fs/resctrl: Introduce interface to display io_alloc CBMs
In reply to Babu MogerIntroduce the "io_alloc_cbm" resctrl file to display the capacity bitmasks (CBMs) that represent the portions of each cache instance allocated for I/O traffic on a cache resource that supports the "io_alloc" feature.
io_alloc_cbm resides in the info directory of a cache resource, for example, /sys/fs/resctrl/info/L3/. Since the resource name is part of the path, it is not necessary to display the resource name as done in the schemata file.
When CDP is enabled, io_alloc routes traffic using the highest CLOSID associated with the CDP_CODE resource and that CLOSID becomes unusable for the CDP_DATA resource. The highest CLOSID of CDP_CODE and CDP_DATA resources will be kept in sync to ensure consistent user interface. In preparation for this, access the CBMs for I/O traffic through highest CLOSID of either CDP_CODE or CDP_DATA resource.
---
v11: Fixed the minor conflict due to previous patch.
Added Reviewed-by: tag.
v10: Rephrase of changelog.
Minor code comment change.
v9: Updated the changelog with respect to CDP.
Added code comment in resctrl_io_alloc_cbm_show().
v8: Updated the changelog.
Moved resctrl_io_alloc_cbm_show() to fs/resctrl/ctrlmondata.c. show_doms is remains static with this change.
v7: Updated changelog.
Updated use doc (resctrl.rst).
Removed if (io_alloc_closid < 0) check. Not required anymore.
v6: Added "io_alloc_cbm" details in user doc resctrl.rst.
Resource name is not printed in CBM now. Corrected the texts about it in resctrl.rst.
v5: Resolved conflicts due to recent resctrl FS/ARCH code restructure.
Updated show_doms() to print the resource if only it is valid. Pass NULL while printing io_alloc CBM.
Changed the code to access the CBMs via either L3CODE or L3DATA resources.
v4: Updated the change log.
Added rdtgroup_mutex before rdt_last_cmd_puts(). Returned -ENODEV when resource type is CDP_DATA.
Kept the resource name while printing the CBM (L3:0=fff) that way I dont have to change show_doms() just for this feature and it is consistant across all the schemata display.
v3: Minor changes due to changes in resctrl_arch_get_io_alloc_enabled()
and resctrl_io_alloc_closid_get().
Added the check to verify CDP resource type.
Updated the commit log.
v2: Fixed to display only on L3 resources.
Added the locks while processing.
Rename the displat to io_alloc_cbm (from sdciae_cmd).
--- Documentation/filesystems/resctrl.rst | 19 +++++++++++ fs/resctrl/ctrlmondata.c | 45 +++++++++++++++++++++++++-- fs/resctrl/internal.h | 2 ++ fs/resctrl/rdtgroup.c | 11 ++++++- 4 files changed, 73 insertions(+), 4 deletions(-)
Documentation/filesystems/resctrl.rst +19 -0
@@ -175,6 +175,25 @@ related to allocation: available for general (CPU) cache allocation for both the CDP_CODE and CDP_DATA resources. +"io_alloc_cbm": + Capacity bitmasks that describe the portions of cache instances to + which I/O traffic from supported I/O devices are routed when "io_alloc" + is enabled. + + CBMs are displayed in the following format: + + <cache_id0>=<cbm>;<cache_id1>=<cbm>;... + + Example:: + + # cat /sys/fs/resctrl/info/L3/io_alloc_cbm + 0=ffff;1=ffff + + When CDP is enabled "io_alloc_cbm" associated with the CDP_DATA and CDP_CODE + resources may reflect the same values. For example, values read from and + written to /sys/fs/resctrl/info/L3DATA/io_alloc_cbm may be reflected by + /sys/fs/resctrl/info/L3CODE/io_alloc_cbm and vice versa. + Memory bandwidth(MB) subdirectory contains the following files with respect to allocation:
fs/resctrl/ctrlmondata.c +42 -3
66 lines not on this page · raw message
fs/resctrl/internal.h +2 -0
@@ -438,6 +438,8 @@ ssize_t resctrl_io_alloc_write(struct kernfs_open_file *of, char *buf, size_t nbytes, loff_t off);const char *rdtgroup_name_by_closid (u32 closid); +int resctrl_io_alloc_cbm_show (struct kernfs_open_file *of,struct seq_file *seq, +void *v);#ifdef CONFIG_RESCTRL_FS_PSEUDO_LOCK int rdtgroup_locksetup_enter (struct rdtgroup *rdtgrp);
fs/resctrl/rdtgroup.c +10 -1
@@ -1971,6 +1971,12 @@ static struct rftype res_common_files[] = { .seq_show = resctrl_io_alloc_show, .write = resctrl_io_alloc_write, }, + { + .name = "io_alloc_cbm", + .mode = 0444, + .kf_ops = &rdtgroup_kf_single_ops, + .seq_show = resctrl_io_alloc_cbm_show, + }, { .name = "max_threshold_occupancy", .mode = 0644,
@@ -2171,9 +2177,12 @@ static void io_alloc_init(void) {struct rdt_resource *r =resctrl_arch_get_resource (RDT_RESOURCE_L3 ); -if (r->cache.io_alloc_capable) +if (r->cache.io_alloc_capable) {resctrl_file_fflags_init ("io_alloc" ,RFTYPE_CTRL_INFO |RFTYPE_RES_CACHE ); +resctrl_file_fflags_init ("io_alloc_cbm" , +RFTYPE_CTRL_INFO |RFTYPE_RES_CACHE ); + } }void resctrl_file_fflags_init (const char *config,unsigned long fflags)
Signature · 1 line
2.34.1
Babu Moger
reviewerPATCH v11 8/10 fs/resctrl: Modify struct rdt_parse_data to pass mode and CLOSID
In reply to Babu Mogerparse_cbm() require resource group mode and CLOSID to validate the capacity bitmask (CBM). It is passed via struct rdtgroup in struct rdt_parse_data.
The io_alloc feature also uses CBMs to indicate which portions of cache are allocated for I/O traffic. The CBMs are provided by user space and need to be validated the same as CBMs provided for general (CPU) cache allocation. parse_cbm() cannot be used as-is since io_alloc does not have rdtgroup context.
Pass the resource group mode and CLOSID directly to parse_cbm() via struct rdt_parse_data, instead of through the rdtgroup struct, to facilitate calling parse_cbm() to verify the CBM of the io_alloc feature.
---
v11: No changes.
v10: Subject line change. Added Reviewed-by tag.
v9: Rephrase of changelog.
Minor code syntax update.
v8: Rephrase of changelog.
v7: Rephrase of changelog.
v6: Changed the subject line to fs/resctrl.
v5: Resolved conflicts due to recent resctrl FS/ARCH code restructure.
v4: New patch to call parse_cbm() directly to avoid code duplication.
--- fs/resctrl/ctrlmondata.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-)
fs/resctrl/ctrlmondata.c +13 -11
@@ -24,7 +24,8 @@#include "internal.h" struct rdt_parse_data { -struct rdtgroup *rdtgrp; +u32 closid; +enum rdtgrp_mode mode;char *buf; };
@@ -77,8 +78,8 @@ static int parse_bw(struct rdt_parse_data *data, struct resctrl_schema *s, struct rdt_ctrl_domain *d) {struct resctrl_staged_config *cfg; -u32 closid = data->rdtgrp->closid;struct rdt_resource *r = s->res; +u32 closid = data->closid;u32 bw_val; cfg = &d->staged_config[s->conf_type];
@@ -156,9 +157,10 @@ static bool cbm_validate(char *buf, u32 *data, struct rdt_resource *r)static int parse_cbm (struct rdt_parse_data *data,struct resctrl_schema *s,struct rdt_ctrl_domain *d) { -struct rdtgroup *rdtgrp = data->rdtgrp; +enum rdtgrp_mode mode = data->mode;struct resctrl_staged_config *cfg;struct rdt_resource *r = s->res; +u32 closid = data->closid;u32 cbm_val; cfg = &d->staged_config[s->conf_type];
@@ -171,7 +173,7 @@ static int parse_cbm(struct rdt_parse_data *data, struct resctrl_schema *s,* Cannot set up more than one pseudo-locked region in a cache * hierarchy. */ -if (rdtgrp->mode ==RDT_MODE_PSEUDO_LOCKSETUP && +if (mode ==RDT_MODE_PSEUDO_LOCKSETUP &&rdtgroup_pseudo_locked_in_hierarchy (d)) {rdt_last_cmd_puts ("Pseudo-locked region in hierarchy\n" );return -EINVAL ;
@@ -180,8 +182,7 @@ static int parse_cbm(struct rdt_parse_data *data, struct resctrl_schema *s,if (!cbm_validate (data->buf, &cbm_val, r))return -EINVAL ; -if ((rdtgrp->mode ==RDT_MODE_EXCLUSIVE || - rdtgrp->mode ==RDT_MODE_SHAREABLE ) && +if ((mode ==RDT_MODE_EXCLUSIVE || mode ==RDT_MODE_SHAREABLE ) &&rdtgroup_cbm_overlaps_pseudo_locked (d, cbm_val)) {rdt_last_cmd_puts ("CBM overlaps with pseudo-locked region\n" );return -EINVAL ;
@@ -191,14 +192,14 @@ static int parse_cbm(struct rdt_parse_data *data, struct resctrl_schema *s,* The CBM may not overlap with the CBM of another closid if * either is exclusive. */ -if (rdtgroup_cbm_overlaps (s, d, cbm_val, rdtgrp->closid, true)) { +if (rdtgroup_cbm_overlaps (s, d, cbm_val, closid, true)) {rdt_last_cmd_puts ("Overlaps with exclusive group\n" );return -EINVAL ; } -if (rdtgroup_cbm_overlaps (s, d, cbm_val, rdtgrp->closid, false)) { -if (rdtgrp->mode ==RDT_MODE_EXCLUSIVE || - rdtgrp->mode ==RDT_MODE_PSEUDO_LOCKSETUP ) { +if (rdtgroup_cbm_overlaps (s, d, cbm_val, closid, false)) { +if (mode ==RDT_MODE_EXCLUSIVE || + mode ==RDT_MODE_PSEUDO_LOCKSETUP ) {rdt_last_cmd_puts ("Overlaps with other group\n" );return -EINVAL ; }
@@ -262,7 +263,8 @@ static int parse_line(char *line, struct resctrl_schema *s,list_for_each_entry (d, &r->ctrl_domains, hdr.list) {if (d->hdr.id == dom_id) { data.buf = dom; - data.rdtgrp = rdtgrp; + data.closid = rdtgrp->closid; + data.mode = rdtgrp->mode;if (parse_ctrlval (&data, s, d))return -EINVAL ;if (rdtgrp->mode ==RDT_MODE_PSEUDO_LOCKSETUP ) {
Signature · 1 line
2.34.1
Babu Moger
reviewerPATCH v11 9/10 fs/resctrl: Introduce interface to modify io_alloc capacity bitmasks
In reply to Babu MogerThe io_alloc feature in resctrl enables system software to configure the portion of the cache allocated for I/O traffic. When supported, the io_alloc_cbm file in resctrl provides access to capacity bitmasks (CBMs) allocated for I/O devices.
Enable users to modify io_alloc CBMs by writing to the io_alloc_cbm resctrl file when the io_alloc feature is enabled.
Mirror the CBMs between CDP_CODE and CDP_DATA when CDP is enabled to present consistent I/O allocation information to user space.
---
v11: Fixed the minor conflict in internal.h due to previous patch.
Added Reviwed-by tag.
v10: Updated the changelog.
Updated the return code to EINVAL when feature is not enabled. Minor code comment update.
v9: Rewrote the changelog.
Removed duplicated rdt_last_cmd_clear().
Corrected rdt_staged_configs_clear() placement.
Added one more example to update the schemata with multiple domains. Copied staged_config from peer when CDP is enabled.
v8: Updated changelog.
Moved resctrl_io_alloc_parse_line() and resctrl_io_alloc_cbm_write() to fs/resctrl/ctrlmondata.c.
Added resctrl_arch_get_cdp_enabled() check inside resctrl_io_alloc_parse_line(). Made parse_cbm() static again as everything moved to ctrlmondata.c.
v7: Updated changelog.
Updated CBMs for both CDP_DATA and CDP_CODE when CDP is enabled.
v6: Updated the user doc restctr.doc for minor texts.
Changed the subject to fs/resctrl.
v5: Changes due to FS/ARCH code restructure. The files monitor.c/rdtgroup.c
have been split between FS and ARCH directories.
Changed the code to access the CBMs via either L3CODE or L3DATA resources.
v4: Removed resctrl_io_alloc_parse_cbm and called parse_cbm() directly.
v3: Minor changes due to changes in resctrl_arch_get_io_alloc_enabled()
and resctrl_io_alloc_closid_get().
Taken care of handling the CBM update when CDP is enabled. Updated the commit log to make it generic.
v2: Added more generic text in documentation.
--- Documentation/filesystems/resctrl.rst | 12 ++++ fs/resctrl/ctrlmondata.c | 93 +++++++++++++++++++++++++++ fs/resctrl/internal.h | 2 + fs/resctrl/rdtgroup.c | 3 +- 4 files changed, 109 insertions(+), 1 deletion(-)
Documentation/filesystems/resctrl.rst +12 -0
@@ -189,6 +189,18 @@ related to allocation: # cat /sys/fs/resctrl/info/L3/io_alloc_cbm 0=ffff;1=ffff + CBMs can be configured by writing to the interface. + + Example:: + + # echo 1=ff > /sys/fs/resctrl/info/L3/io_alloc_cbm + # cat /sys/fs/resctrl/info/L3/io_alloc_cbm + 0=ffff;1=00ff + + # echo "0=ff;1=f" > /sys/fs/resctrl/info/L3/io_alloc_cbm + # cat /sys/fs/resctrl/info/L3/io_alloc_cbm + 0=00ff;1=000f + When CDP is enabled "io_alloc_cbm" associated with the CDP_DATA and CDP_CODE resources may reflect the same values. For example, values read from and written to /sys/fs/resctrl/info/L3DATA/io_alloc_cbm may be reflected by
fs/resctrl/ctrlmondata.c +93 -0
96 lines not on this page · raw message
fs/resctrl/internal.h +2 -0
@@ -440,6 +440,8 @@ ssize_t resctrl_io_alloc_write(struct kernfs_open_file *of, char *buf,const char *rdtgroup_name_by_closid (u32 closid);int resctrl_io_alloc_cbm_show (struct kernfs_open_file *of,struct seq_file *seq,void *v); +ssize_t resctrl_io_alloc_cbm_write (struct kernfs_open_file *of,char *buf, +size_t nbytes,loff_t off);#ifdef CONFIG_RESCTRL_FS_PSEUDO_LOCK int rdtgroup_locksetup_enter (struct rdtgroup *rdtgrp);
fs/resctrl/rdtgroup.c +2 -1
@@ -1973,9 +1973,10 @@ static struct rftype res_common_files[] = { }, { .name = "io_alloc_cbm", - .mode = 0444, + .mode = 0644, .kf_ops = &rdtgroup_kf_single_ops, .seq_show = resctrl_io_alloc_cbm_show, + .write = resctrl_io_alloc_cbm_write, }, { .name = "max_threshold_occupancy",
Signature · 1 line
2.34.1
Babu Moger
reviewerPATCH v11 10/10 fs/resctrl: Update bit_usage to reflect io_alloc
In reply to Babu MogerThe "shareable_bits" and "bit_usage" resctrl files associated with cache resources give insight into how instances of a cache is used.
Update the annotated capacity bitmasks displayed by "bit_usage" to include the cache portions allocated for I/O via the "io_alloc" feature. "shareable_bits" is a global bitmask of shareable cache with I/O and can thus not present the per-domain I/O allocations possible with the "io_alloc" feature. Revise the "shareable_bits" documentation to direct users to "bit_usage" for accurate cache usage information.
---
v11: Fixed the minor conflict in internal.h.
Added Reviewed-by tag.
v10: Changelog update.
Updated schematas to schemata.
v9: Changelog update.
Added code comments about CDP.
Updated the "bit_usage" section of resctrl.rst for io_alloc.
v8: Moved the patch to last after all the concepts are initialized.
Updated user doc resctrl.rst.
Simplified the CDT check in rdt_bit_usage_show() as CDP_DATA and CDP_CODE are in sync with io_alloc enabled.
v7: New patch split from earlier patch #5.
Added resctrl_io_alloc_closid() to return max COSID.
--- Documentation/filesystems/resctrl.rst | 35 ++++++++++++++++----------- fs/resctrl/ctrlmondata.c | 2 +- fs/resctrl/internal.h | 1 + fs/resctrl/rdtgroup.c | 21 ++++++++++++++-- 4 files changed, 42 insertions(+), 17 deletions(-)
Documentation/filesystems/resctrl.rst +21 -14
@@ -91,12 +91,19 @@ related to allocation: must be set when writing a mask. "shareable_bits": - Bitmask of shareable resource with other executing - entities (e.g. I/O). User can use this when - setting up exclusive cache partitions. Note that - some platforms support devices that have their - own settings for cache use which can over-ride - these bits. + Bitmask of shareable resource with other executing entities + (e.g. I/O). Applies to all instances of this resource. User + can use this when setting up exclusive cache partitions. + Note that some platforms support devices that have their + own settings for cache use which can over-ride these bits. + + When "io_alloc" is enabled, a portion of each cache instance can + be configured for shared use between hardware and software. + "bit_usage" should be used to see which portions of each cache + instance is configured for hardware use via "io_alloc" feature + because every cache instance can have its "io_alloc" bitmask + configured independently via "io_alloc_cbm". + "bit_usage": Annotated capacity bitmasks showing how all instances of the resource are used. The legend is:
@@ -110,16 +117,16 @@ related to allocation: "H": Corresponding region is used by hardware only but available for software use. If a resource - has bits set in "shareable_bits" but not all - of these bits appear in the resource groups' - schematas then the bits appearing in - "shareable_bits" but no resource group will - be marked as "H". + has bits set in "shareable_bits" or "io_alloc_cbm" + but not all of these bits appear in the resource + groups' schemata then the bits appearing in + "shareable_bits" or "io_alloc_cbm" but no + resource group will be marked as "H". "X": Corresponding region is available for sharing and - used by hardware and software. These are the - bits that appear in "shareable_bits" as - well as a resource group's allocation. + used by hardware and software. These are the bits + that appear in "shareable_bits" or "io_alloc_cbm" + as well as a resource group's allocation. "S": Corresponding region is used by software and available for sharing.
fs/resctrl/ctrlmondata.c +1 -1
@@ -750,7 +750,7 @@ static int resctrl_io_alloc_init_cbm(struct resctrl_schema *s, u32 closid)* resource. Note that if Code Data Prioritization (CDP) is enabled, the number * of available CLOSIDs is reduced by half. */ -static u32 resctrl_io_alloc_closid (struct rdt_resource *r) +u32 resctrl_io_alloc_closid (struct rdt_resource *r) {if (resctrl_arch_get_cdp_enabled (r->rid))return resctrl_arch_get_num_closid (r) /2 -1 ;
fs/resctrl/internal.h +1 -0
@@ -442,6 +442,7 @@ int resctrl_io_alloc_cbm_show(struct kernfs_open_file *of, struct seq_file *seq, void *v);ssize_t resctrl_io_alloc_cbm_write (struct kernfs_open_file *of,char *buf,size_t nbytes,loff_t off); +u32 resctrl_io_alloc_closid (struct rdt_resource *r);#ifdef CONFIG_RESCTRL_FS_PSEUDO_LOCK int rdtgroup_locksetup_enter (struct rdtgroup *rdtgrp);
fs/resctrl/rdtgroup.c +19 -2
@@ -1062,15 +1062,17 @@ static int rdt_bit_usage_show(struct kernfs_open_file *of,cpus_read_lock ();mutex_lock (&rdtgroup_mutex); - hw_shareable = r->cache.shareable_bits;list_for_each_entry (dom, &r->ctrl_domains, hdr.list) {if (sep)seq_putc (seq,';' ); + hw_shareable = r->cache.shareable_bits; sw_shareable =0 ; exclusive =0 ;seq_printf (seq,"%d=" , dom->hdr.id);for (i =0 ; i <closids_supported (); i++) { -if (!closid_allocated (i)) +if (!closid_allocated (i) || + (resctrl_arch_get_io_alloc_enabled (r) && + i ==resctrl_io_alloc_closid (r)))continue ; ctrl_val =resctrl_arch_get_config (r, dom, i, s->conf_type);
@@ -1098,6 +1100,21 @@ static int rdt_bit_usage_show(struct kernfs_open_file *of,break ; } } + +/* +* When the "io_alloc" feature is enabled, a portion of the cache +* is configured for shared use between hardware and software. +* Also, when CDP is enabled the CBMs of CDP_CODE and CDP_DATA +* resources are kept in sync. So, the CBMs for "io_alloc" can +* be accessed through either resource. +*/ +if (resctrl_arch_get_io_alloc_enabled (r)) { + ctrl_val =resctrl_arch_get_config (r, dom, +resctrl_io_alloc_closid (r), + s->conf_type); + hw_shareable |= ctrl_val; + } +for (i = r->cache.cbm_len -1 ; i >=0 ; i--) { pseudo_locked = dom->plr ? dom->plr->cbm :0 ; hwb =test_bit (i, &hw_shareable);
Signature · 1 line
2.34.1
Reinette Chatre
maintainerRe: [PATCH v11 06/10] fs/resctrl: Add user interface to enable/disable io_alloc feature
In reply to Babu MogerHi Babu,
On 10/30/25 10:15 AM, Babu Moger wrote:
...
Quoted 6 lines
Documentation/filesystems/resctrl.rst +0
-0@@ -152,6 +152,29 @@ related to allocation: "not supported":
Documentation/filesystems/resctrl.rst related to allocation: · line 162
Quoted 10 lines
Documentation/filesystems/resctrl.rst +8
-0Support not available for this resource. + The feature can be modified by writing to the interface, for example: + + To enable: + # echo 1 > /sys/fs/resctrl/info/L3/io_alloc + + To disable: + # echo 0 > /sys/fs/resctrl/info/L3/io_alloc +
Above examples are missing the '::' that will format them as fixed width text blocks used for these shell examples.
Quoted 8 lines
Documentation/filesystems/resctrl.rst +8
-0+ The underlying implementation may reduce resources available to + general (CPU) cache allocation. See architecture specific notes + below. Depending on usage requirements the feature can be enabled + or disabled. + + On AMD systems, io_alloc feature is supported by the L3 Smart + Data Cache Injection Allocation Enforcement (SDCIAE). The CLOSID for + io_alloc is the highest CLOSID supported by the resource. When
Documentation/filesystems/resctrl.rst related to allocation: · line 180
Quoted 10 lines
Documentation/filesystems/resctrl.rst +7
-0+ io_alloc is enabled, the highest CLOSID is dedicated to io_alloc and + no longer available for general (CPU) cache allocation. When CDP is + enabled, io_alloc routes I/O traffic using the highest CLOSID allocated + for the instruction cache (CDP_CODE), making this CLOSID no longer + available for general (CPU) cache allocation for both the CDP_CODE + and CDP_DATA resources. + Memory bandwidth(MB) subdirectory contains the following files with respect to allocation:
With the doc formatting fixed:
| Reviewed-by: Reinette Chatre <[email protected]>
Reinette
Re: [PATCH v11 06/10] fs/resctrl: Add user interface to enable/disable io_alloc feature
Hi Reinette,
Quoted 14 lines · Reinette Chatre
Hi Babu,
On 10/30/25 10:15 AM, Babu Moger wrote:
...
Quoted 8 lines
Documentation/filesystems/resctrl.rst +0
-0@@ -152,6 +152,29 @@ related to allocation: "not supported": Support not available for this resource.
Quoted 10 lines
Documentation/filesystems/resctrl.rst related to allocation: · line 162
Quoted 8 lines
Documentation/filesystems/resctrl.rst +8
-0+ The feature can be modified by writing to the interface, for example: + + To enable: + # echo 1 > /sys/fs/resctrl/info/L3/io_alloc + + To disable: + # echo 0 > /sys/fs/resctrl/info/L3/io_alloc +Above examples are missing the '::' that will format them as fixed width text blocks used for these shell examples.
Sure. Will update:
Documentation/filesystems/resctrl.rst +0 -0
@@ -161,10 +161,12 @@ related to allocation:
The feature can be modified by writing to the interface, for example:
- To enable:
+ To enable::
+
# echo 1 > /sys/fs/resctrl/info/L3/io_alloc
- To disable:
+ To disable::
+
# echo 0 > /sys/fs/resctrl/info/L3/io_alloc
The underlying implementation may reduce resources available to
Quoted 13 lines
Quoted 13 lines
Documentation/filesystems/resctrl.rst +12
-0+ The underlying implementation may reduce resources available to + general (CPU) cache allocation. See architecture specific notes + below. Depending on usage requirements the feature can be enabled + or disabled. + + On AMD systems, io_alloc feature is supported by the L3 Smart + Data Cache Injection Allocation Enforcement (SDCIAE). The CLOSID for + io_alloc is the highest CLOSID supported by the resource. When + io_alloc is enabled, the highest CLOSID is dedicated to io_alloc and + no longer available for general (CPU) cache allocation. When CDP is + enabled, io_alloc routes I/O traffic using the highest CLOSID allocated + for the instruction cache (CDP_CODE), making this CLOSID no longer
Quoted 9 lines
Documentation/filesystems/resctrl.rst related to allocation: · line 180
Quoted 6 lines
Documentation/filesystems/resctrl.rst +3
-0+ available for general (CPU) cache allocation for both the CDP_CODE + and CDP_DATA resources. + Memory bandwidth(MB) subdirectory contains the following files with respect to allocation:With the doc formatting fixed:
| Reviewed-by: Reinette Chatre <[email protected]>
Thank you.
Babu
Dave Martin
reviewerRe: [PATCH v11 06/10] fs/resctrl: Add user interface to enable/disable io_alloc feature
In reply to Babu MogerHi Babu,
Quoted 7 lines · Babu Moger
AMD's SDCIAE forces all SDCI lines to be placed into the L3 cache portions identified by the highest-supported
L3_MASK_nregister, where n is the maximum supported CLOSID.To support AMD's SDCIAE, when
io_allocresctrl feature is enabled, reserve the highest CLOSID exclusively for I/O allocation traffic making it no longer available for general CPU cache allocation.
Does resctrl have a free choice for which CLOSID to use? (From the code, it appears "yes"?)
Could this be exposed as a special control group? Or could IO be made a special "task" that can be added to regular control groups?
e.g.,
# mkdir /sys/fs/resctrl/some_group # some_group IO >/sys/fs/resctrl/some_group/tasks
This would assign the group's CLOSID to IO (in addition to any tasks using the CLOSID).
Or, we have some special file:
# echo foo >/sys/fs/resctrl/some_group/io_devices
This would assign the group's CLOSID to the device "foo" (we'd need some manageable naming scheme, preferably that maps in a sane way to sysfs).
I'm not trying to rock the boat here, but for MPAM we're anticipating the need to be able to control the CLOSID used by devices that are behind an IOMMU. (Arm's SMMU allows a PARTID to be configured for each device I/O context behind the SMMU.)
This is desirable for assigning devices to VMs, so that their traffic can be managed alongside the VM.
Do you think SDCIAE could fit in with this kind of scheme?
[...]
Quoted 5 lines
Documentation/filesystems/resctrl.rst +0
-0
Documentation/filesystems/resctrl.rst related to allocation: · line 161
Quoted 10 lines
Documentation/filesystems/resctrl.rst +7
-0@@ -152,6 +152,29 @@ related to allocation: "not supported": Support not available for this resource. + The feature can be modified by writing to the interface, for example: + + To enable: + # echo 1 > /sys/fs/resctrl/info/L3/io_alloc + + To disable: + # echo 0 > /sys/fs/resctrl/info/L3/io_alloc
"info" is mostly read-only, though it does seems a reasonable place for per-resource global controls. Today, there is already "max_threshold_occupancy".
It doesn't feel worth trying to introduce a new hierarchy for this kind of thing, but the name "info" does not suggest that there are writable controls here.
To make it official, does it make sense to add something like:
--8<--
Documentation/filesystems/resctrl.rst +4 -0
@@ -72,6 +72,10 @@ The 'info' directory contains information about the enabled resources. Each resource has its own subdirectory. The subdirectory names reflect the resource names. +Most of the files in the resource's subdirectory are read-only, and describe +properties of the resource. Resources that have global configuration options +provide writable files here that can be used to control them. + Each subdirectory contains the following files with respect to allocation:
[...]
Cheers
---Dave
Re: [PATCH v11 06/10] fs/resctrl: Add user interface to enable/disable io_alloc feature
Hi Dave,
Quoted 7 lines · Dave Martin
Hi Babu,
Quoted 4 lines · Babu Moger
AMD's SDCIAE forces all SDCI lines to be placed into the L3 cache portions identified by the highest-supported
L3_MASK_nregister, where n is the maximum supported CLOSID.
Quoted 6 lines
Quoted 3 lines
To support AMD's SDCIAE, when
io_allocresctrl feature is enabled, reserve the highest CLOSID exclusively for I/O allocation traffic making it no longer available for general CPU cache allocation.Does resctrl have a free choice for which CLOSID to use? (From the code, it appears "yes"?)
Yes.
But in AMD systems its the highest CLOSID (15). Also, this CLOSID usage in not visible to user. There is no update of PQR_ASSOC register during the context switch. Hardware internally routes the traffic using the CLOSID's(15) limits.
Quoted 26 lines
Could this be exposed as a special control group? Or could IO be made a special "task" that can be added to regular control groups?
e.g.,
# mkdir /sys/fs/resctrl/some_group # some_group IO >/sys/fs/resctrl/some_group/tasksThis would assign the group's CLOSID to IO (in addition to any tasks using the CLOSID).
Or, we have some special file:
# echo foo >/sys/fs/resctrl/some_group/io_devicesThis would assign the group's CLOSID to the device "foo" (we'd need some manageable naming scheme, preferably that maps in a sane way to sysfs).
I'm not trying to rock the boat here, but for MPAM we're anticipating the need to be able to control the CLOSID used by devices that are behind an IOMMU. (Arm's SMMU allows a PARTID to be configured for each device I/O context behind the SMMU.)
Quoted 5 lines
This is desirable for assigning devices to VMs, so that their traffic can be managed alongside the VM.
Do you think SDCIAE could fit in with this kind of scheme?
All these things you mentioned can be done today without SDCIAE also. It does not need SDCIAE or similar feature.
You can consolidate all the IO tasks into one group and assign limits or monitor. However, resctrl does not have the knowledge of IO devices (or names of the devices). It only knows about the tasks.
Quoted 12 lines
[...]
Quoted 8 lines
Documentation/filesystems/resctrl.rst +0
-0@@ -152,6 +152,29 @@ related to allocation: "not supported": Support not available for this resource.
Quoted 11 lines
Documentation/filesystems/resctrl.rst related to allocation: · line 161
Quoted 7 lines
Documentation/filesystems/resctrl.rst +7
-0+ The feature can be modified by writing to the interface, for example: + + To enable: + # echo 1 > /sys/fs/resctrl/info/L3/io_alloc + + To disable: + # echo 0 > /sys/fs/resctrl/info/L3/io_alloc"info" is mostly read-only, though it does seems a reasonable place for per-resource global controls. Today, there is already "
max_threshold_occupancy".
Agree.
Quoted 14 lines
It doesn't feel worth trying to introduce a new hierarchy for this kind of thing, but the name "info" does not suggest that there are writable controls here.
To make it official, does it make sense to add something like:
--8<--
Documentation/filesystems/resctrl.rst +0
-0
Documentation/filesystems/resctrl.rst The 'info' directory contains information about the enabled · line 78
Quoted 7 lines
Documentation/filesystems/resctrl.rst +4
-0@@ -72,6 +72,10 @@ The 'info' directory contains information about the enabled resources. Each resource has its own subdirectory. The subdirectory names reflect the resource names. +Most of the files in the resource's subdirectory are read-only, and describe +properties of the resource. Resources that have global configuration options +provide writable files here that can be used to control them. +
Yes. It is reasonable. We can add it. How about this?
"Most of the files in the resource's subdirectory are read-only, and describe properties of the resource. Resources that support global configuration options also include writable files that can be used to modify those settings."
Thanks
Babu
Luck, Tony
maintainerRE: [PATCH v11 06/10] fs/resctrl: Add user interface to enable/disable io_alloc feature
Quoted 4 lines
But in AMD systems its the highest CLOSID (15). Also, this CLOSID usage in not visible to user. There is no update of
PQR_ASSOCregister during the context switch. Hardware internally routes the traffic using the CLOSID's(15) limits.
Things are even more complex for Intel IO as described in the RDT architecture specification. There can be separate IO caches from the CPU caches. When this happens the RMIDs and CLOSIDs for IO are in a separate space from those for CPU. I.e. you can assign RMID=1 CLOSID=1 to some tasks and those will measure and control traffic from a CPU L3 cache instance. IO devices may also use RMID=1, CLOSID=1 ... but those measure and control traffic from an IO cache instance.
This looks like the multi-socket case where RMID=1 on socket 0 (and thus L3 cache 0) is independent from RMID=1 on socket 1. But resctrl partially hides this by making RMID allocation global and just providing separate event files for each L3 cache instance.
I don't think this maps to CPU vs IO. As Babu notes above, there's no update for IO CLOSID/RMID on process context switch. So it makes no sense to allocate IO RMIDs from the same pool as CPU RMIDs.
I haven't come up with any concrete plans for how to implement this version of IO RDT into resctrl. The earlier implementation on Granite Rapids didn't have IO caches independent from CPU caches.
-Tony
Reinette Chatre
maintainerRe: [PATCH v11 06/10] fs/resctrl: Add user interface to enable/disable io_alloc feature
Hi Dave and Tony,
Quoted 19 lines · Tony
Quoted 4 lines
But in AMD systems its the highest CLOSID (15). Also, this CLOSID usage in not visible to user. There is no update of
PQR_ASSOCregister during the context switch. Hardware internally routes the traffic using the CLOSID's(15) limits.Things are even more complex for Intel IO as described in the RDT architecture specification. There can be separate IO caches from the CPU caches. When this happens the RMIDs and CLOSIDs for IO are in a separate space from those for CPU. I.e. you can assign RMID=1 CLOSID=1 to some tasks and those will measure and control traffic from a CPU L3 cache instance. IO devices may also use RMID=1, CLOSID=1 ... but those measure and control traffic from an IO cache instance.
This looks like the multi-socket case where RMID=1 on socket 0 (and thus L3 cache 0) is independent from RMID=1 on socket 1. But resctrl partially hides this by making RMID allocation global and just providing separate event files for each L3 cache instance.
Quoted 8 lines
I don't think this maps to CPU vs IO. As Babu notes above, there's no update for IO CLOSID/RMID on process context switch. So it makes no sense to allocate IO RMIDs from the same pool as CPU RMIDs.
I haven't come up with any concrete plans for how to implement this version of IO RDT into resctrl. The earlier implementation on Granite Rapids didn't have IO caches independent from CPU caches.
It seems to common now that we need to build support for new features and ideally any new interface can be designed with some gateway to enable future enhancements. SDCIAE/io_alloc is a global IO alloc feature while the ones mentioned here for Arm and Intel seem to be a better match to be managed per resource group. I did try to think how to "keep the door open" for future enhancements, hypothetically "/sys/fs/resctrl/info/L3/io_alloc" could in the future return a new value that implies "managed_in_resource_group" that opens door to create new interfaces in the resource groups to manage IO alloc there. The "io_alloc" documentation does seem high level enough to support such an enhancement.
Do you see any additional changes we can add to the interface or documentation to set resctrl up for success to support these features in the future?
Reinette