x86,fs/resctrl: Support L3 Smart Data Cache Injection Allocation Enforcement (SDCIAE)
Subsystems (3)
Babu Moger
reviewerv7 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.
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.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 (6.16.0-rc5) commit b4ec95e3bc3f ("Merge x86/microcode into tip/master")
# 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 will be 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 for the 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
d. 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/
---
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:
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: Update bit_usage to reflect io_alloc 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 rdt_parse_data to pass mode and CLOSID fs/resctrl: Introduce interface to modify io_alloc Capacity Bit Masks
.../admin-guide/kernel-parameters.txt | 2 +- Documentation/filesystems/resctrl.rst | 79 +++- arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/include/asm/msr-index.h | 1 + arch/x86/kernel/cpu/cpuid-deps.c | 1 + arch/x86/kernel/cpu/resctrl/core.c | 9 + arch/x86/kernel/cpu/resctrl/internal.h | 5 + arch/x86/kernel/cpu/resctrl/rdtgroup.c | 40 ++ arch/x86/kernel/cpu/scattered.c | 1 + fs/resctrl/ctrlmondata.c | 41 +- fs/resctrl/internal.h | 10 + fs/resctrl/rdtgroup.c | 374 +++++++++++++++++- include/linux/resctrl.h | 24 ++ 13 files changed, 558 insertions(+), 30 deletions(-)
Signature · 1 line
2.34.1
Babu Moger
reviewerPATCH v7 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 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.4.7 L3 Smart Data Cache Injection Allocation Enforcement (SDCIAE)
---
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
@@ -494,6 +494,7 @@#define X86_FEATURE_TSA_SQ_NO (21*32+11)/* AMD CPU not vulnerable to TSA-SQ */ #define X86_FEATURE_TSA_L1_NO (21*32+12)/* AMD CPU not vulnerable to TSA-L1 */ #define X86_FEATURE_CLEAR_CPU_BUF_VM (21*32+13)/* Clear CPU buffers using VERW before VMRUN */ +#define X86_FEATURE_SDCIAE (21*32+14)/* 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
@@ -50,6 +50,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_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
Re: [PATCH v7 01/10] x86/cpufeatures: Add support for L3 Smart Data Cache Injection Allocation Enforcement
Quoted 35 lines · Babu Moger
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_nregister, where n is the maximum supported CLOSID.Add CPUID feature bit that can be used to configure SDCIAE.
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.4.7 L3 Smart Data Cache Injection Allocation Enforcement (SDCIAE)---
v7: No changes. Fixed few conflicts in
arch/x86/include/asm/cpufeatures.h
arch/x86/kernel/cpu/scattered.cv6: Resolved conflicts in
cpufeatures.h.v5: No changes.
v4: Resolved a minor conflict in
cpufeatures.h.v3: No changes.
Quoted 8 lines
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(+)
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteRe: [PATCH v7 01/10] x86/cpufeatures: Add support for L3 Smart Data Cache Injection Allocation Enforcement
In reply to Babu MogerHi Babu,
Quoted 15 lines · Babu Moger
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_nregister, where n is the maximum supported CLOSID.Add CPUID feature bit that can be used to configure SDCIAE.
Quoted 8 lines
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.4.7 L3 Smart Data Cache Injection Allocation Enforcement (SDCIAE)---
Reinette
Babu Moger
reviewerPATCH v7 2/10 x86/resctrl: Add SDCIAE feature in the command line options
In reply to Babu MogerAdd the command line options to enable or disable the new resctrl feature L3 Smart Data Cache Injection Allocation Enforcement (SDCIAE).
---
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 +- arch/x86/kernel/cpu/resctrl/core.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-)
Documentation/admin-guide/kernel-parameters.txt +1 -1
@@ -6066,7 +6066,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, sdciae. E.g. to turn on cmt and turn off mba use: rdt=cmt,!mba
arch/x86/kernel/cpu/resctrl/core.c +2 -0
@@ -707,6 +707,7 @@ enum {RDT_FLAG_MBA ,RDT_FLAG_SMBA ,RDT_FLAG_BMEC , + RDT_FLAG_SDCIAE, };#define RDT_OPT (idx, n, f) \
@@ -732,6 +733,7 @@ static struct rdt_options rdt_options[] __ro_after_init = {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_SDCIAE, "sdciae", X86_FEATURE_SDCIAE), };#define NUM_RDT_OPTIONS ARRAY_SIZE(rdt_options)
Signature · 1 line
2.34.1
Reinette Chatre
maintainerRe: [PATCH v7 02/10] x86/resctrl: Add SDCIAE feature in the command line options
Hi Babu,
Quoted 5 lines · Babu Moger
Add the command line options to enable or disable the new resctrl feature L3 Smart Data Cache Injection Allocation Enforcement (SDCIAE).
Signed-off-by Babu Moger <[email protected]>---
...
Quoted 4 lines
--- Documentation/admin-guide/kernel-parameters.txt | 2 +- arch/x86/kernel/cpu/resctrl/core.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-)
Could you please also add associated update to Documentation/filesystems/resctrl.rst ? For reference, the similar ABMC change:
https://lore.kernel.org/lkml/00cd603997e3ee6a389f83aef066fe7313b1abaf.1752013061.git.babu.moger@amd.com/
Reinette
Moger, Babu
reviewerRe: [PATCH v7 02/10] x86/resctrl: Add SDCIAE feature in the command line options
Hi Reinette,
Quoted 14 lines · Reinette Chatre
Hi Babu,
Quoted 5 lines · Babu Moger
Add the command line options to enable or disable the new resctrl feature L3 Smart Data Cache Injection Allocation Enforcement (SDCIAE).
Signed-off-by Babu Moger <[email protected]>---
...
Quoted 4 lines
--- Documentation/admin-guide/kernel-parameters.txt | 2 +- arch/x86/kernel/cpu/resctrl/core.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-)
Quoted 5 lines
Could you please also add associated update to
Documentation/filesystems/resctrl.rst? For reference, the similar ABMC change:
https://lore.kernel.org/lkml/00cd603997e3ee6a389f83aef066fe7313b1abaf.1752013061.git.babu.moger@amd.com/
Sure. Will take care of it.
Signature · 2 lines
Thanks Babu Moger
Babu Moger
reviewerPATCH v7 3/10 x86,fs/resctrl: Detect io_alloc feature
In reply to Babu MogerSmart Data Cache Injection (SDCI) is a mechanism that enables direct insertion of data from I/O devices into the L3 cache. It can reduce the demands on DRAM bandwidth and reduces latency to the processor consuming the I/O data.
Introduce cache resource property "io_alloc_capable" that an architecture can set if a portion of the cache can be allocated for I/O traffic.
Set this property on x86 systems that support SDCIAE (L3 Smart Data Cache Injection Allocation Enforcement). This property is set only for the L3 cache resource on systems that support SDCIAE.
---
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 );
@@ -842,6 +847,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
@@ -191,6 +191,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;
@@ -198,6 +200,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
Re: [PATCH v7 03/10] x86,fs/resctrl: Detect io_alloc feature
Hi Babu,
Quoted 8 lines · Babu Moger
Smart Data Cache Injection (SDCI) is a mechanism that enables direct insertion of data from I/O devices into the L3 cache. It can reduce the demands on DRAM bandwidth and reduces latency to the processor consuming the I/O data.
Introduce cache resource property "
io_alloc_capable" that an architecture can set if a portion of the cache can be allocated for I/O traffic.
Quoted 6 lines
Set this property on x86 systems that support SDCIAE (L3 Smart Data Cache Injection Allocation Enforcement). This property is set only for the L3 cache resource on systems that support SDCIAE.
Signed-off-by Babu Moger <[email protected]>---
Reinette
Babu Moger
reviewerPATCH v7 4/10 x86,fs/resctrl: Implement "io_alloc" enable/disable handlers
In reply to Babu Moger"io_alloc" enables direct insertion of data from I/O devices into the cache.
On AMD systems, "io_alloc" feature is backed by L3 Smart Data Cache Injection Allocation Enforcement (SDCIAE). Change SDCIAE state by setting (to enable) or clearing (to disable) bit 1 of MSR L3_QOS_EXT_CFG on all logical processors within the cache domain.
Introduce architecture-specific call to enable and disable the feature.
The SDCIAE feature details are available in APM listed below [1].
[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)
---
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/include/asm/msr-index.h | 1 + arch/x86/kernel/cpu/resctrl/internal.h | 5 ++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 40 ++++++++++++++++++++++++++ include/linux/resctrl.h | 21 ++++++++++++++ 4 files changed, 67 insertions(+)
arch/x86/include/asm/msr-index.h +1 -0
@@ -1222,6 +1222,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/internal.h +5 -0
@@ -37,6 +37,9 @@ struct arch_mbm_state {u64 prev_msr; }; +/* Setting bit 1 in 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
@@ -102,6 +105,7 @@ struct msr_param {* @mon_scale: cqm counter * mon_scale = occupancy in bytes * @mbm_width: Monitor width, to detect and correct for overflow. * @cdp_enabled: CDP state of this resource +* @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.
@@ -115,6 +119,7 @@ struct rdt_hw_resource {unsigned int mon_scale;unsigned int mbm_width;bool cdp_enabled; +bool sdciae_enabled; };static inline struct rdt_hw_resource *resctrl_to_arch_res (struct rdt_resource *r)
arch/x86/kernel/cpu/resctrl/rdtgroup.c +40 -0
@@ -229,6 +229,46 @@ bool resctrl_arch_get_cdp_enabled(enum resctrl_res_level l)return rdt_resources_all[l].cdp_enabled; } +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 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 ; +} +void resctrl_arch_reset_all_ctrls (struct rdt_resource *r) {struct rdt_hw_resource *hw_res =resctrl_to_arch_res (r);
include/linux/resctrl.h +21 -0
@@ -531,6 +531,27 @@ void resctrl_arch_reset_rmid_all(struct rdt_resource *r, struct rdt_mon_domain **/ void resctrl_arch_reset_all_ctrls (struct rdt_resource *r); +/** +* 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
Reinette Chatre
maintainerRe: [PATCH v7 04/10] x86,fs/resctrl: Implement "io_alloc" enable/disable handlers
Hi Babu,
Quoted 18 lines · Babu Moger
"
io_alloc" enables direct insertion of data from I/O devices into the cache.On AMD systems, "
io_alloc" feature is backed by L3 Smart Data Cache Injection Allocation Enforcement (SDCIAE). Change SDCIAE state by setting (to enable) or clearing (to disable) bit 1 of MSRL3_QOS_EXT_CFGon all logical processors within the cache domain.Introduce architecture-specific call to enable and disable the feature.
The SDCIAE feature details are available in APM listed below [1].
[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)---
...
arch/x86/kernel/cpu/resctrl/rdtgroup.c
Quoted 5 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +0
-0
The code looks good to me but rdtgroup.c is becoming bloated by being the default place for any resctrl changes. While I do know there are counter examples (and I admit I do not have a clear understanding of original intent) ctrlmondata.c is documented and supported by its content as the place for cache allocation code. Could you please move these changes to arch/x86/kernel/cpu/resctrl/ctrlmondata.c? I will try to highlight the other places where I believe the either fs/resctrl/ctrlmondata.c or arch/x86/kernel/cpu/resctrl/ctrlmondata.c is more appropriate but please as a high level consider where appropriate to move the IO alloc code to be with the rest of the cache allocation code. Looking at the series it will help keep a couple of existing static functions static and keep data structures local to cache allocation code.
Reinette
Moger, Babu
reviewerRe: [PATCH v7 04/10] x86,fs/resctrl: Implement "io_alloc" enable/disable handlers
Quoted 25 lines · Reinette Chatre
Hi Babu,
Quoted 18 lines · Babu Moger
"
io_alloc" enables direct insertion of data from I/O devices into the cache.On AMD systems, "
io_alloc" feature is backed by L3 Smart Data Cache Injection Allocation Enforcement (SDCIAE). Change SDCIAE state by setting (to enable) or clearing (to disable) bit 1 of MSRL3_QOS_EXT_CFGon all logical processors within the cache domain.Introduce architecture-specific call to enable and disable the feature.
The SDCIAE feature details are available in APM listed below [1].
[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)---
...
Quoted 1 line
Quoted 16 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c
Quoted 4 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +0
-0The code looks good to me but
rdtgroup.cis becoming bloated by being the default place for any resctrl changes. While I do know there are counter examples (and I admit I do not have a clear understanding of original intent)ctrlmondata.cis documented and supported by its content as the place for cache allocation code. Could you please move these changes toarch/x86/kernel/cpu/resctrl/ctrlmondata.c? I will try to highlight the other places where I believe the eitherfs/resctrl/ctrlmondata.corarch/x86/kernel/cpu/resctrl/ctrlmondata.cis more appropriate but please as a high level consider where appropriate to move the IO alloc code to be with the rest of the cache allocation code. Looking at the series it will help keep a couple of existing static functions static and keep data structures local to cache allocation code.
Sure. Moved it to arch/x86/kernel/cpu/resctrl/ctrlmondata.c.
Signature · 2 lines
Thanks Babu Moger
Babu Moger
reviewerPATCH v7 5/10 fs/resctrl: Update bit_usage to reflect io_alloc
In reply to Babu MogerWhen the io_alloc feature is enabled, a portion of the cache can be configured for shared use between hardware and software.
Update the bit_usage representation to reflect the io_alloc configuration.
---
v7: New patch split from earlier patch #5.
Added resctrl_io_alloc_closid() to return max COSID.
--- Documentation/filesystems/resctrl.rst | 20 ++++++++++----- fs/resctrl/rdtgroup.c | 37 +++++++++++++++++++++++++-- 2 files changed, 49 insertions(+), 8 deletions(-)
Documentation/filesystems/resctrl.rst +14 -6
@@ -89,12 +89,20 @@ 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" feature is enabled, a portion of the cache + 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. + "bit_usage": Annotated capacity bitmasks showing how all instances of the resource are used. The legend is:
fs/resctrl/rdtgroup.c +35 -2
@@ -1030,6 +1030,20 @@ static int rdt_shareable_bits_show(struct kernfs_open_file *of,return 0 ; } +/* +* resctrl_io_alloc_closid() - io_alloc feature routes I/O traffic using +* the highest available CLOSID. Retrieve the maximum CLOSID supported by the +* 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) +{ +if (resctrl_arch_get_cdp_enabled (r->rid)) +return resctrl_arch_get_num_closid (r) /2 -1 ; +else +return resctrl_arch_get_num_closid (r) -1 ; +} +/* * rdt_bit_usage_show - Display current usage of resources *
@@ -1063,15 +1077,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);
@@ -1099,6 +1115,23 @@ 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. +*/ +if (resctrl_arch_get_io_alloc_enabled (r)) { +if (resctrl_arch_get_cdp_enabled (r->rid)) + ctrl_val =resctrl_arch_get_config (r, dom, +resctrl_io_alloc_closid (r), +CDP_CODE ); +else + ctrl_val =resctrl_arch_get_config (r, dom, +resctrl_io_alloc_closid (r), +CDP_NONE ); + 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 v7 05/10] fs/resctrl: Update bit_usage to reflect io_alloc
Hi Babu,
Quoted 4 lines · Babu Moger
When the
io_allocfeature is enabled, a portion of the cache can be configured for shared use between hardware and software.Update the
bit_usagerepresentation to reflect theio_allocconfiguration.
This patch is early in the series but also relies on capabilities added later in the series. This cryptic changelog leaves a lot for the user to decipher. For example:
- How is the "io_alloc CLOSID" chosen? This is mentioned in cover letter but not here. Doing so here may help explain the hardcoding of CDP_CODE done in this patch (which seem unnecessary, more later, but a lot depends on changes that follow this patch).
- No mention that when io_alloc is enabled then an associated CLOSID will be allocated. This is done later in series but assumed to be known here where rdt_bit_usage_show() implicitly assumes that when io_alloc is enabled then the "io_alloc CLOSID" is supported AND allocated (otherwise array overrun?)
Quoted 22 lines
Signed-off-by Babu Moger <[email protected]>---
v7: New patch split from earlier patch #5.
Addedresctrl_io_alloc_closid()to return max COSID.--- Documentation/filesystems/resctrl.rst | 20 ++++++++++----- fs/resctrl/rdtgroup.c | 37 +++++++++++++++++++++++++-- 2 files changed, 49 insertions(+), 8 deletions(-)Documentation/filesystems/resctrl.rst +0
-4@@ -89,12 +89,20 @@ 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
Documentation/filesystems/resctrl.rst related to allocation: · line 99
Quoted 10 lines
Documentation/filesystems/resctrl.rst +8
-2- 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" feature is enabled, a portion of the cache + can be configured for shared use between hardware and software.
To help distinguish how "io_alloc" is different from "shareable_bits" this can be:
When "io_alloc" is enabled, a portion of each cache instance can be configured for shared use between hardware and software.
Please merge these two paragraphs.
Documentation/filesystems/resctrl.rst related to allocation: · line 104
Quoted 4 lines
Documentation/filesystems/resctrl.rst +4
-0+ "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.
append " via "io_alloc_cbm"."?
(but io_alloc_cbm does not exist at this point ... another motivation for this patch to move later)
Documentation/filesystems/resctrl.rst related to allocation: · line 108
Quoted 4 lines
Documentation/filesystems/resctrl.rst +1
-0+ "bit_usage": Annotated capacity bitmasks showing how all instances of the resource are used. The legend is:
Please note that this "bit_usage" section contain several references to "shareable_bits" that should be updated to refer to "io_alloc_cbm" also.
With all these new terms introduced as common knowledge it is starting to look like this patch would be easier to consume later in the series.
Quoted 5 lines
fs/resctrl/rdtgroup.c +0
-0
fs/resctrl/rdtgroup.c static int rdt_shareable_bits_show(struct kernfs_open_file *of, · line 1039
Quoted 10 lines
fs/resctrl/rdtgroup.c +7
-0@@ -1030,6 +1030,20 @@ static int rdt_shareable_bits_show(struct kernfs_open_file *of,return 0 ; } +/* +* resctrl_io_alloc_closid() - io_alloc feature routes I/O traffic using +* the highest available CLOSID. Retrieve the maximum CLOSID supported by the +* 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)
Please move to ctrlmondata.c.
Quoted 31 lines
fs/resctrl/rdtgroup.c +11
-2+{ +if (resctrl_arch_get_cdp_enabled (r->rid)) +return resctrl_arch_get_num_closid (r) /2 -1 ; +else +return resctrl_arch_get_num_closid (r) -1 ; +} +/* * rdt_bit_usage_show - Display current usage of resources * @@ -1063,15 +1077,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);
fs/resctrl/rdtgroup.c static int rdt_bit_usage_show(struct kernfs_open_file *of, · line 1123
Quoted 9 lines
fs/resctrl/rdtgroup.c +6
-0@@ -1099,6 +1115,23 @@ 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. +*/ +if (resctrl_arch_get_io_alloc_enabled (r)) {
Here is undocumented implicit assumption that when io_alloc is enabled then the "io_alloc CLOSID" is allocated. This is also outside the closids_supported() loop which adds the other implicit assumption that if io_alloc is enabled then its CLOSID is supported by resctrl fs. None of these concepts have been introduced so far and is not mentioned in changelog.
It is not obvious here that an io_alloc CLOSID must be supported (this is just something enforced by later patches) and also not obvious that an io_alloc CLOSID must be allocated from same "pool" as other CLOSIDs. Without a good changelog and context of later patches this is hard to understand.
These are motivations for this patch to move later in the series and then the changelog can just refer to these assumptions as fact, making it all easier to follow.
fs/resctrl/rdtgroup.c static int rdt_bit_usage_show(struct kernfs_open_file *of, · line 1131
Quoted 8 lines
fs/resctrl/rdtgroup.c +8
-0+if (resctrl_arch_get_cdp_enabled (r->rid)) + ctrl_val =resctrl_arch_get_config (r, dom, +resctrl_io_alloc_closid (r), +CDP_CODE ); +else + ctrl_val =resctrl_arch_get_config (r, dom, +resctrl_io_alloc_closid (r), +CDP_NONE );
This does not look necessary to me. Why not just:
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;
}Since the later patches keep the CDP_CODE and CDP_DATA CBMs in sync it does not matter if the io_alloc CBM is obtained from CDP_CODE or CDP_DATA and just providing the schema's type to resctrl_arch_get_config() will have it retrieve the right CBM, no?
This may also be easier to understand/claim if this patch is later in the series.
fs/resctrl/rdtgroup.c static int rdt_bit_usage_show(struct kernfs_open_file *of, · line 1137
Quoted 6 lines
fs/resctrl/rdtgroup.c +3
-0+ 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);
Reinette
Moger, Babu
reviewerRe: [PATCH v7 05/10] fs/resctrl: Update bit_usage to reflect io_alloc
Hi Reinette,
Quoted 8 lines · Reinette Chatre
Hi Babu,
Quoted 4 lines · Babu Moger
When the
io_allocfeature is enabled, a portion of the cache can be configured for shared use between hardware and software.Update the
bit_usagerepresentation to reflect theio_allocconfiguration.
Quoted 11 lines
This patch is early in the series but also relies on capabilities added later in the series. This cryptic changelog leaves a lot for the user to decipher. For example:
- How is the "io_allocCLOSID" chosen? This is mentioned in cover letter but not here. Doing so here may help explain the hardcoding ofCDP_CODEdone in this patch (which seem unnecessary, more later, but a lot depends on changes that follow this patch).
- No mention that whenio_allocis enabled then an associated CLOSID will be allocated. This is done later in series but assumed to be known here whererdt_bit_usage_show()implicitly assumes that whenio_allocis enabled then the "io_allocCLOSID" is supported AND allocated (otherwise array overrun?)
Make sense. Moved this patch to the last.
Quoted 29 lines
Quoted 29 lines
Signed-off-by Babu Moger <[email protected]>---
v7: New patch split from earlier patch #5.
Addedresctrl_io_alloc_closid()to return max COSID.--- Documentation/filesystems/resctrl.rst | 20 ++++++++++----- fs/resctrl/rdtgroup.c | 37 +++++++++++++++++++++++++-- 2 files changed, 49 insertions(+), 8 deletions(-)Documentation/filesystems/resctrl.rst +4
-6@@ -89,12 +89,20 @@ 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
Quoted 8 lines
Documentation/filesystems/resctrl.rst related to allocation: · line 99
Quoted 4 lines
Documentation/filesystems/resctrl.rst +4
-0+ own settings for cache use which can over-ride these bits. + + When "io_alloc" feature is enabled, a portion of the cache + can be configured for shared use between hardware and software.To help distinguish how "
io_alloc" is different from "shareable_bits" this can be:
When "io_alloc" is enabled, a portion of each cache instance can be configured for shared use between hardware and software.
Sure.
Quoted 2 lines
Please merge these two paragraphs.
Sure.
Quoted 7 lines
Documentation/filesystems/resctrl.rst related to allocation: · line 104
Quoted 5 lines
Documentation/filesystems/resctrl.rst +4
-0+ "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.append " via "
io_alloc_cbm"."?
sure.
Quoted 3 lines
(but
io_alloc_cbmdoes not exist at this point ... another motivation for this patch to move later)
Sure.
Quoted 10 lines
Documentation/filesystems/resctrl.rst related to allocation: · line 108
Quoted 4 lines
Documentation/filesystems/resctrl.rst +1
-0+ "bit_usage": Annotated capacity bitmasks showing how all instances of the resource are used. The legend is:Please note that this "
bit_usage" section contain several references to "shareable_bits" that should be updated to refer to "io_alloc_cbm" also.With all these new terms introduced as common knowledge it is starting to look like this patch would be easier to consume later in the series.
Sure.
Quoted 9 lines
Quoted 9 lines
fs/resctrl/rdtgroup.c +0
-0@@ -1030,6 +1030,20 @@ static int rdt_shareable_bits_show(struct kernfs_open_file *of,return 0 ; }
Quoted 9 lines
fs/resctrl/rdtgroup.c static int rdt_shareable_bits_show(struct kernfs_open_file *of, · line 1039
Quoted 7 lines
fs/resctrl/rdtgroup.c +7
-0+/* +* resctrl_io_alloc_closid() - io_alloc feature routes I/O traffic using +* the highest available CLOSID. Retrieve the maximum CLOSID supported by the +* 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)Please move to
ctrlmondata.c.
Yes.
Quoted 45 lines
Quoted 32 lines
fs/resctrl/rdtgroup.c +11
-2+{ +if (resctrl_arch_get_cdp_enabled (r->rid)) +return resctrl_arch_get_num_closid (r) /2 -1 ; +else +return resctrl_arch_get_num_closid (r) -1 ; +} +/* * rdt_bit_usage_show - Display current usage of resources * @@ -1063,15 +1077,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);fs/resctrl/rdtgroup.c static int rdt_bit_usage_show(struct kernfs_open_file *of, · line 1123
Quoted 9 lines
fs/resctrl/rdtgroup.c +6
-0@@ -1099,6 +1115,23 @@ 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. +*/ +if (resctrl_arch_get_io_alloc_enabled (r)) {Here is undocumented implicit assumption that when
io_allocis enabled then the "io_allocCLOSID" is allocated. This is also outside theclosids_supported()loop which adds the other implicit assumption that ifio_allocis enabled then
Quoted 8 lines
its CLOSID is supported by resctrl fs. None of these concepts have been introduced so far and is not mentioned in changelog.
It is not obvious here that anio_allocCLOSID must be supported (this is just something enforced by later patches) and also not obvious that anio_allocCLOSID must be allocated from same "pool" as other CLOSIDs. Without a good changelog and context of later patches this is hard to understand.
These are motivations for this patch to move later in the series and then the changelog can just refer to these assumptions as fact, making it all easier to follow.
Sure.
Quoted 18 lines
fs/resctrl/rdtgroup.c static int rdt_bit_usage_show(struct kernfs_open_file *of, · line 1131
Quoted 9 lines
fs/resctrl/rdtgroup.c +8
-0+if (resctrl_arch_get_cdp_enabled (r->rid)) + ctrl_val =resctrl_arch_get_config (r, dom, +resctrl_io_alloc_closid (r), +CDP_CODE ); +else + ctrl_val =resctrl_arch_get_config (r, dom, +resctrl_io_alloc_closid (r), +CDP_NONE );This does not look necessary to me. Why not just:
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; }
Quoted 3 lines
Since the later patches keep the
CDP_CODEandCDP_DATACBMs in sync it does not matter if theio_allocCBM is obtained fromCDP_CODEorCDP_DATAand just providing the schema's type toresctrl_arch_get_config()will have it retrieve the right CBM, no?
Yes. That is correct.
Quoted 2 lines
This may also be easier to understand/claim if this patch is later in the series.
Sure.
Quoted 11 lines
fs/resctrl/rdtgroup.c static int rdt_bit_usage_show(struct kernfs_open_file *of, · line 1137
Quoted 8 lines
fs/resctrl/rdtgroup.c +3
-0+ 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);Reinette
Signature · 2 lines
Thanks Babu Moger
Babu Moger
reviewerPATCH v7 6/10 fs/resctrl: Introduce interface to display "io_alloc" support
In reply to Babu Moger"io_alloc" feature in resctrl allows direct insertion of data from I/O devices into the cache.
Introduce the 'io_alloc' resctrl file to indicate the support for the feature.
---
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 | 25 +++++++++++++++++ fs/resctrl/rdtgroup.c | 39 +++++++++++++++++++++++++++ 2 files changed, 64 insertions(+)
Documentation/filesystems/resctrl.rst +25 -0
@@ -143,6 +143,31 @@ 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": + 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 on the system. + + 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, the io_alloc feature is supported by the L3 Smart + Data Cache Injection Allocation Enforcement (SDCIAE). The CLOSID for + io_alloc is determined by the highest CLOSID supported by the resource. + When CDP is enabled, io_alloc routes I/O traffic using the highest + CLOSID allocated for the instruction cache (L3CODE). + Memory bandwidth(MB) subdirectory contains the following files with respect to allocation:
fs/resctrl/rdtgroup.c +39 -0
@@ -1836,6 +1836,28 @@ static ssize_t mbm_local_bytes_config_write(struct kernfs_open_file *of,return ret ?: nbytes; } +static 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 ; +} +/* rdtgroup information files for one cache resource. */ static struct rftype res_common_files[] = { {
@@ -1926,6 +1948,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,
@@ -2095,6 +2123,15 @@ static void thread_throttle_mode_init(void) RFTYPE_CTRL_INFO | RFTYPE_RES_MB); } +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;
@@ -4282,6 +4319,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
Reinette Chatre
maintainerRe: [PATCH v7 06/10] fs/resctrl: Introduce interface to display "io_alloc" support
Hi Babu,
Quoted 8 lines · Babu Moger
"
io_alloc" feature in resctrl allows direct insertion of data from I/O devices into the cache.Introduce the '
io_alloc' resctrl file to indicate the support for the feature.Signed-off-by Babu Moger <[email protected]>---
...
Quoted 16 lines
--- Documentation/filesystems/resctrl.rst | 25 +++++++++++++++++ fs/resctrl/rdtgroup.c | 39 +++++++++++++++++++++++++++ 2 files changed, 64 insertions(+)Documentation/filesystems/resctrl.rst +3
-0@@ -143,6 +143,31 @@ 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
Documentation/filesystems/resctrl.rst related to allocation: · line 158
Quoted 10 lines
Documentation/filesystems/resctrl.rst +10
-0+ system supports this feature on some of its cache resources. + + "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 on the system.
"Support not available on the system." -> "Support not available for this resource."?
Documentation/filesystems/resctrl.rst related to allocation: · line 163
Quoted 5 lines
Documentation/filesystems/resctrl.rst +5
-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:
"disabled:" -> "disabled."?
Documentation/filesystems/resctrl.rst related to allocation: · line 167
Quoted 4 lines
Documentation/filesystems/resctrl.rst +4
-0+ + On AMD systems, the io_alloc feature is supported by the L3 Smart + Data Cache Injection Allocation Enforcement (SDCIAE). The CLOSID for + io_alloc is determined by the highest CLOSID supported by the resource.
"is determined by the" -> "is the"?
To make clear connection with previous paragraph you can append something like:
When io_alloc is enabled on an AMD system the highest CLOSID is dedicated to io_alloc and no longer available for general (CPU) cache allocation.
Documentation/filesystems/resctrl.rst related to allocation: · line 169
Quoted 2 lines
Documentation/filesystems/resctrl.rst +2
-0+ When CDP is enabled, io_alloc routes I/O traffic using the highest + CLOSID allocated for the instruction cache (L3CODE).
To clear up what happens with L3DATA, what do you think of appending something like:
, making this CLOSID no longer available for general (CPU) cache allocation for both the L3CODE and L3DATA resources.
fs/resctrl/rdtgroup.c static ssize_t mbm_local_bytes_config_write(struct kernfs_open_file *of, · line 1839
Quoted 13 lines
Documentation/filesystems/resctrl.rst +1
-0+ Memory bandwidth(MB) subdirectory contains the following files with respect to allocation:fs/resctrl/rdtgroup.c +1
-0@@ -1836,6 +1836,28 @@ static ssize_t mbm_local_bytes_config_write(struct kernfs_open_file *of,return ret ?: nbytes; } +static int resctrl_io_alloc_show(struct kernfs_open_file *of,
Please move to ctrlmondata.c
Quoted 38 lines
fs/resctrl/rdtgroup.c +27
-0+ 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 ; +} +/* rdtgroup information files for one cache resource. */ static struct rftype res_common_files[] = { {@@ -1926,6 +1948,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,
fs/resctrl/rdtgroup.c static void thread_throttle_mode_init(void) · line 2126
Quoted 4 lines
fs/resctrl/rdtgroup.c +1
-0@@ -2095,6 +2123,15 @@ static void thread_throttle_mode_init(void) RFTYPE_CTRL_INFO | RFTYPE_RES_MB); } +static void io_alloc_init (void )
This function's comment can benefit from a snippet that highlights that even though this operates on hardcoded L3 resource it results in this file being visible for *all* cache resources (eg. L2 cache also), whether they support io_alloc or not.
Quoted 12 lines
fs/resctrl/rdtgroup.c +8
-0+{ +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;
fs/resctrl/rdtgroup.c int resctrl_init(void) · line 4326
Quoted 8 lines
fs/resctrl/rdtgroup.c +2
-0@@ -4282,6 +4319,8 @@ int resctrl_init(void)thread_throttle_mode_init (); +io_alloc_init (); + ret =resctrl_mon_resource_init ();if (ret)return ret;
Reinette
Moger, Babu
reviewerRe: [PATCH v7 06/10] fs/resctrl: Introduce interface to display "io_alloc" support
Hi Reinette,
Quoted 27 lines · Reinette Chatre
Hi Babu,
Quoted 8 lines · Babu Moger
"
io_alloc" feature in resctrl allows direct insertion of data from I/O devices into the cache.Introduce the '
io_alloc' resctrl file to indicate the support for the feature.Signed-off-by Babu Moger <[email protected]>---
...
Quoted 13 lines
--- Documentation/filesystems/resctrl.rst | 25 +++++++++++++++++ fs/resctrl/rdtgroup.c | 39 +++++++++++++++++++++++++++ 2 files changed, 64 insertions(+)Documentation/filesystems/resctrl.rst +0
-0@@ -143,6 +143,31 @@ related to allocation: "1": Non-contiguous 1s value in CBM is supported.
Quoted 15 lines
Documentation/filesystems/resctrl.rst related to allocation: · line 158
Quoted 13 lines
Documentation/filesystems/resctrl.rst +13
-0+"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": + 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 on the system."Support not available on the system." -> "Support not available for this resource."?
Sure.
Quoted 8 lines
Documentation/filesystems/resctrl.rst related to allocation: · line 163
Quoted 6 lines
Documentation/filesystems/resctrl.rst +5
-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:"disabled:" -> "disabled."?
Sure.
Quoted 8 lines
Documentation/filesystems/resctrl.rst related to allocation: · line 167
Quoted 5 lines
Documentation/filesystems/resctrl.rst +4
-0+ + On AMD systems, the io_alloc feature is supported by the L3 Smart + Data Cache Injection Allocation Enforcement (SDCIAE). The CLOSID for + io_alloc is determined by the highest CLOSID supported by the resource."is determined by the" -> "is the"?
Sure.
Quoted 3 lines
To make clear connection with previous paragraph you can append something like:
Whenio_allocis enabled on an AMD system the highest CLOSID is dedicated toio_allocand no longer available for general (CPU) cache allocation.
Sure.
Quoted 8 lines
Documentation/filesystems/resctrl.rst related to allocation: · line 169
Quoted 3 lines
Documentation/filesystems/resctrl.rst +2
-0+ When CDP is enabled, io_alloc routes I/O traffic using the highest + CLOSID allocated for the instruction cache (L3CODE).To clear up what happens with L3DATA, what do you think of appending something like:
, making this CLOSID no longer available for general (CPU) cache allocation for both the L3CODE and L3DATA resources.
Sure.
Quoted 12 lines
Quoted 12 lines
Documentation/filesystems/resctrl.rst +1
-0+ Memory bandwidth(MB) subdirectory contains the following files with respect to allocation:fs/resctrl/rdtgroup.c +0
-0@@ -1836,6 +1836,28 @@ static ssize_t mbm_local_bytes_config_write(struct kernfs_open_file *of,return ret ?: nbytes; }
Quoted 3 lines
fs/resctrl/rdtgroup.c static ssize_t mbm_local_bytes_config_write(struct kernfs_open_file *of, · line 1839
Quoted 1 line
fs/resctrl/rdtgroup.c +1
-0+static int resctrl_io_alloc_show(struct kernfs_open_file *of,Please move to
ctrlmondata.c
Yes.
Quoted 43 lines
Quoted 43 lines
fs/resctrl/rdtgroup.c +27
-0+ 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 ; +} +/* rdtgroup information files for one cache resource. */ static struct rftype res_common_files[] = { {@@ -1926,6 +1948,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,@@ -2095,6 +2123,15 @@ static void thread_throttle_mode_init(void) RFTYPE_CTRL_INFO | RFTYPE_RES_MB); }
Quoted 6 lines
fs/resctrl/rdtgroup.c static void thread_throttle_mode_init(void) · line 2126
Quoted 1 line
fs/resctrl/rdtgroup.c +1
-0+static void io_alloc_init (void )This function's comment can benefit from a snippet that highlights that even though this operates on hardcoded L3 resource it results in this file being visible for *all* cache resources (eg. L2 cache also), whether they support
io_allocor not.
Added the comment.
Quoted 24 lines
Quoted 13 lines
fs/resctrl/rdtgroup.c +8
-0+{ +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;fs/resctrl/rdtgroup.c int resctrl_init(void) · line 4326
Quoted 8 lines
fs/resctrl/rdtgroup.c +2
-0@@ -4282,6 +4319,8 @@ int resctrl_init(void)thread_throttle_mode_init (); +io_alloc_init (); + ret =resctrl_mon_resource_init ();if (ret)return ret;Reinette
Signature · 2 lines
Thanks Babu Moger
Babu Moger
reviewerPATCH v7 7/10 fs/resctrl: Add user interface to enable/disable io_alloc feature
In reply to Babu Moger"io_alloc" feature in resctrl enables direct insertion of data from I/O devices into the cache.
Introduce user interface to enable/disable io_alloc feature.
On AMD systems, io_alloc feature is backed by SDCIAE (L3 Smart Data Cache Injection Allocation Enforcement). When enabled, SDCIAE directs all SDCI lines to be placed into the L3 cache partitions specified by the register corresponding to the highest CLOSID supported by the resource. With CDP enabled, io_alloc routes I/O traffic using the highest CLOSID assigned to the instruction cache (L3CODE).
---
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 | 8 ++ fs/resctrl/rdtgroup.c | 149 +++++++++++++++++++++++++- 2 files changed, 156 insertions(+), 1 deletion(-)
Documentation/filesystems/resctrl.rst +8 -0
@@ -157,6 +157,14 @@ related to allocation: "not supported": Support not available on the system. + 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
fs/resctrl/rdtgroup.c +148 -1
181 lines not on this page · raw message
Signature · 1 line
2.34.1
Reinette Chatre
maintainerRe: [PATCH v7 07/10] fs/resctrl: Add user interface to enable/disable io_alloc feature
Hi Babu,
Quoted 4 lines · Babu Moger
"
io_alloc" feature in resctrl enables direct insertion of data from I/O devices into the cache.Introduce user interface to enable/disable
io_allocfeature.
I think it is worth a mention *why* a user may want to disable this feature and why is not just always enabled. Here it can be highlighted that this feature may take resources (CLOSID) away from general (CPU) cache allocation and since this may be scarce enabling user to disable this feature supports different use cases.
Quoted 7 lines
On AMD systems,
io_allocfeature is backed by SDCIAE (L3 Smart Data Cache Injection Allocation Enforcement). When enabled, SDCIAE directs all SDCI lines to be placed into the L3 cache partitions specified by the register corresponding to the highest CLOSID supported by the resource. With CDP enabled,io_allocroutes I/O traffic using the highest CLOSID assigned to the instruction cache (L3CODE).
This is a lot of architecture specific text for a resctrl fs patch ... I think you are trying to motivate the resctrl fs implementation. Similar motivation as proposed for cover letter can be used here to help explain the implementation choices.
Quoted 3 lines
Signed-off-by Babu Moger <[email protected]>---
...
Quoted 39 lines
--- Documentation/filesystems/resctrl.rst | 8 ++ fs/resctrl/rdtgroup.c | 149 +++++++++++++++++++++++++- 2 files changed, 156 insertions(+), 1 deletion(-)Documentation/filesystems/resctrl.rst +8
-0@@ -157,6 +157,14 @@ related to allocation: "not supported": Support not available on the system. + 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 enabledfs/resctrl/rdtgroup.c +1
-0@@ -70,6 +70,7 @@ static struct seq_buf last_cmd_status;static char last_cmd_status_buf[512 ];static int rdtgroup_setup_root (struct rdt_fs_context *ctx); +static int rdtgroup_init_cat (struct resctrl_schema *s,u32 closid);static void rdtgroup_destroy_root (void );@@ -232,6 +233,16 @@ bool closid_allocated(unsigned int closid)return !test_bit (closid, closid_free_map); }
fs/resctrl/rdtgroup.c bool closid_allocated(unsigned int closid) · line 244
Quoted 10 lines
fs/resctrl/rdtgroup.c +9
-0+static bool resctrl_io_alloc_closid_alloc (u32 io_alloc_closid) +{ +return __test_and_clear_bit (io_alloc_closid, closid_free_map); +} + +static void resctrl_io_alloc_closid_free (u32 io_alloc_closid) +{ +closid_free (io_alloc_closid); +}
I do not think these should be helpers/wrappers with a separate namespace. It will make the code easier to understand if it is clear that the "io_alloc" CLOSID is allocated from the same "pool" as the CLOSID for control groups.
I would thus propose a specific, for example closid_alloc_fixed(u32 closid) helper, and just call closid_free() directly.
Quoted 5 lines
fs/resctrl/rdtgroup.c +1
-0+/** * rdtgroup_mode_by_closid - Return mode of resource group with closid * @closid: closid if the resource group
fs/resctrl/rdtgroup.c static int rdt_shareable_bits_show(struct kernfs_open_file *of, · line 1049
Quoted 9 lines
fs/resctrl/rdtgroup.c +6
-0@@ -1030,6 +1041,16 @@ static int rdt_shareable_bits_show(struct kernfs_open_file *of,return 0 ; } +/* +* resctrl_io_alloc_closid_supported() - io_alloc feature utilizes the +* highest CLOSID value to direct I/O traffic. Ensure that io_alloc_closid +* is in the supported range. +*/ +static bool resctrl_io_alloc_closid_supported (u32 io_alloc_closid)
Please move to ctrlmondata.c
Quoted 8 lines
fs/resctrl/rdtgroup.c +4
-0+{ +return io_alloc_closid <closids_supported (); +} +/* * resctrl_io_alloc_closid() - io_alloc feature routes I/O traffic using * the highest available CLOSID. Retrieve the maximum CLOSID supported by the
fs/resctrl/rdtgroup.c static int resctrl_io_alloc_show(struct kernfs_open_file *of, · line 1886
Quoted 8 lines
fs/resctrl/rdtgroup.c +5
-0@@ -1858,6 +1879,131 @@ static int resctrl_io_alloc_show(struct kernfs_open_file *of,return 0 ; } +/* +* Initialize io_alloc CLOSID cache resource CBM with all usable (shared +* and unused) cache portions. +*/ +static int resctrl_io_alloc_init_cat(struct rdt_resource *r,
Mixing two features (io_alloc and CAT) in the function name is confusing. How about resctrl_io_alloc_init_cbm() and move to ctrlmondata.c?
fs/resctrl/rdtgroup.c static int resctrl_io_alloc_show(struct kernfs_open_file *of, · line 1887
Quoted 1 line
fs/resctrl/rdtgroup.c +1
-0+ struct resctrl_schema *s, u32 closid)
No need to provide resource as parameter, it can be determined from schema.
fs/resctrl/rdtgroup.c static int resctrl_io_alloc_show(struct kernfs_open_file *of, · line 1895
Quoted 8 lines
fs/resctrl/rdtgroup.c +8
-0+{ +int ret; + +rdt_staged_configs_clear (); + + ret =rdtgroup_init_cat (s, closid); +if (ret <0 ) + goto out;
More below, but I think this flow can be simplified by moving the logic handling CDP here. If CDP is enabled for the resource then a successful rdtgroup_init_cat() can just be followed by a snippet that copies the staged config of the CDP type to the staged config of its peer type. Their CBMs are supposed to be identical so there is no reason for all the rdtgroup_init_cat() processing to be repeated. resctrl_arch_update_domains() can handle updating both in a single call.
fs/resctrl/rdtgroup.c static int resctrl_io_alloc_show(struct kernfs_open_file *of, · line 1904
Quoted 9 lines
fs/resctrl/rdtgroup.c +9
-0+ + ret =resctrl_arch_update_domains (r, closid); + +out: +rdt_staged_configs_clear (); +return ret; +} + +static const char *rdtgroup_name_by_closid (int closid)
This seems generic enough and appropriate for rdtgroup.c
fs/resctrl/rdtgroup.c static int resctrl_io_alloc_show(struct kernfs_open_file *of, · line 1916
Quoted 12 lines
fs/resctrl/rdtgroup.c +12
-0+{ +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 ; +} + +static struct resctrl_schema *resctrl_get_schema (enum resctrl_conf_type type)
This also seems generic enough and appropriate for rdtgroup.c
Quoted 52 lines
fs/resctrl/rdtgroup.c +52
-0+{ +struct resctrl_schema *schema; + +list_for_each_entry (schema, &resctrl_schema_all, list) { +if (schema->conf_type == type) +return schema; + } + +return NULL ; +} + +static ssize_t resctrl_io_alloc_write (struct kernfs_open_file *of,char *buf, +size_t nbytes,loff_t off) +{ +struct resctrl_schema *s =rdt_kn_parent_priv (of->kn); +enum resctrl_conf_type peer_type; +struct rdt_resource *r = s->res; +struct resctrl_schema *peer_s; +char const *grp_name; +u32 io_alloc_closid; +bool enable; +int ret; + + ret =kstrtobool (buf, &enable); +if (ret) +return ret; + +cpus_read_lock (); +mutex_lock (&rdtgroup_mutex); + +rdt_last_cmd_clear (); + +if (!r->cache.io_alloc_capable) { +rdt_last_cmd_printf ("io_alloc is not supported on %s\n" , s->name); + ret = -ENODEV ; + goto out_unlock; + } + + io_alloc_closid =resctrl_io_alloc_closid (r); +if (!resctrl_io_alloc_closid_supported (io_alloc_closid)) { +rdt_last_cmd_printf ("io_alloc CLOSID (ctrl_hw_id) %d is not available\n" , + io_alloc_closid); + ret = -EINVAL ; + goto out_unlock; + } + +/* If the feature is already up to date, no action is needed. */ +if (resctrl_arch_get_io_alloc_enabled (r) == enable) + goto out_unlock; + +if (enable) { +if (!resctrl_io_alloc_closid_alloc (io_alloc_closid)) {
fs/resctrl/rdtgroup.c static int resctrl_io_alloc_show(struct kernfs_open_file *of, · line 1978
Quoted 10 lines
fs/resctrl/rdtgroup.c +10
-0+ grp_name =rdtgroup_name_by_closid (io_alloc_closid); +WARN_ON_ONCE (!grp_name); +rdt_last_cmd_printf ("CLOSID (ctrl_hw_id) %d for io_alloc is used by %s group\n" , + io_alloc_closid, grp_name ? grp_name :"another" ); + ret = -ENOSPC ; + goto out_unlock; + } + +/* Initialize schema for both CDP_DATA and CDP_CODE when CDP is enabled */ +if (resctrl_arch_get_cdp_enabled (r->rid)) {
I think this block can be removed to simplify the flow by moving the CDP handling to resctrl_io_alloc_init_cat().
Quoted 33 lines
fs/resctrl/rdtgroup.c +28
-0+ peer_type =resctrl_peer_type (s->conf_type); + peer_s =resctrl_get_schema (peer_type); +if (peer_s) + ret =resctrl_io_alloc_init_cat (r, peer_s, io_alloc_closid); + } + +if (!ret) + ret =resctrl_io_alloc_init_cat (r, s, io_alloc_closid); + +if (ret) { +rdt_last_cmd_puts ("Failed to initialize io_alloc allocations\n" ); +resctrl_io_alloc_closid_free (io_alloc_closid); + goto out_unlock; + } + + }else { +resctrl_io_alloc_closid_free (io_alloc_closid); + } + + ret =resctrl_arch_io_alloc_enable (r, enable); + +out_unlock: +mutex_unlock (&rdtgroup_mutex); +cpus_read_unlock (); + +return ret ?: nbytes; +} +/* rdtgroup information files for one cache resource. */ static struct rftype res_common_files[] = { {@@ -1950,9 +2096,10 @@ static struct rftype res_common_files[] = { },
fs/resctrl/rdtgroup.c static struct rftype res_common_files[] = { · line 2105
Quoted 10 lines
fs/resctrl/rdtgroup.c +2
-1{ .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",
Reinette
Re: [PATCH v7 07/10] fs/resctrl: Add user interface to enable/disable io_alloc feature
Hi Reinette,
Quoted 6 lines · Reinette Chatre
Hi Babu,
Quoted 3 lines · Babu Moger
"
io_alloc" feature in resctrl enables direct insertion of data from I/O devices into the cache.
Quoted 7 lines
Quoted 1 line
Introduce user interface to enable/disable
io_allocfeature.I think it is worth a mention *why* a user may want to disable this feature and why is not just always enabled. Here it can be highlighted that this feature may take resources (CLOSID) away from general (CPU) cache allocation and since this may be scarce enabling user to disable this feature supports different use cases.
Sure.
Quoted 8 lines
Quoted 7 lines
On AMD systems,
io_allocfeature is backed by SDCIAE (L3 Smart Data Cache Injection Allocation Enforcement). When enabled, SDCIAE directs all SDCI lines to be placed into the L3 cache partitions specified by the register corresponding to the highest CLOSID supported by the resource. With CDP enabled,io_allocroutes I/O traffic using the highest CLOSID assigned to the instruction cache (L3CODE).
Quoted 4 lines
This is a lot of architecture specific text for a resctrl fs patch ... I think you are trying to motivate the resctrl fs implementation. Similar motivation as proposed for cover letter can be used here to help explain the implementation choices.
Updated the whole changelog.
fs/resctrl: Add user interface to enable/disable io_alloc feature
"io_alloc" feature in resctrl enables direct insertion of data from I/O devices into the cache.
Introduce user interface to enable/disable io_alloc feature.
On AMD systems, when io_alloc is enabled, the highest CLOSID is reserved exclusively for I/O allocation traffic and is no longer available for general CPU cache allocation. This feature is disabled by default. Users are encouraged to enable it only when running workloads that can benefit from this functionality.
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.
Quoted 62 lines
Quoted 4 lines
Signed-off-by Babu Moger <[email protected]>---
...
Quoted 39 lines
--- Documentation/filesystems/resctrl.rst | 8 ++ fs/resctrl/rdtgroup.c | 149 +++++++++++++++++++++++++- 2 files changed, 156 insertions(+), 1 deletion(-)Documentation/filesystems/resctrl.rst +8
-0@@ -157,6 +157,14 @@ related to allocation: "not supported": Support not available on the system. + 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 enabledfs/resctrl/rdtgroup.c +1
-0@@ -70,6 +70,7 @@ static struct seq_buf last_cmd_status;static char last_cmd_status_buf[512 ];static int rdtgroup_setup_root (struct rdt_fs_context *ctx); +static int rdtgroup_init_cat (struct resctrl_schema *s,u32 closid);static void rdtgroup_destroy_root (void );@@ -232,6 +233,16 @@ bool closid_allocated(unsigned int closid)return !test_bit (closid, closid_free_map); }fs/resctrl/rdtgroup.c bool closid_allocated(unsigned int closid) · line 244
Quoted 10 lines
fs/resctrl/rdtgroup.c +9
-0+static bool resctrl_io_alloc_closid_alloc (u32 io_alloc_closid) +{ +return __test_and_clear_bit (io_alloc_closid, closid_free_map); +} + +static void resctrl_io_alloc_closid_free (u32 io_alloc_closid) +{ +closid_free (io_alloc_closid); +}I do not think these should be helpers/wrappers with a separate namespace. It will make the code easier to understand if it is clear that the "
io_alloc" CLOSID is allocated from the same "pool" as the CLOSID for control groups.
Quoted 3 lines
I would thus propose a specific, for example
closid_alloc_fixed(u32 closid)helper, and just callclosid_free()directly.
Sure.
Quoted 8 lines
Quoted 8 lines
fs/resctrl/rdtgroup.c +1
-0+/** * rdtgroup_mode_by_closid - Return mode of resource group with closid * @closid: closid if the resource group @@ -1030,6 +1041,16 @@ static int rdt_shareable_bits_show(struct kernfs_open_file *of,return 0 ; }
Quoted 9 lines
fs/resctrl/rdtgroup.c static int rdt_shareable_bits_show(struct kernfs_open_file *of, · line 1049
Quoted 6 lines
fs/resctrl/rdtgroup.c +6
-0+/* +* resctrl_io_alloc_closid_supported() - io_alloc feature utilizes the +* highest CLOSID value to direct I/O traffic. Ensure that io_alloc_closid +* is in the supported range. +*/ +static bool resctrl_io_alloc_closid_supported (u32 io_alloc_closid)Please move to
ctrlmondata.c
Sure.
Quoted 11 lines
Quoted 11 lines
fs/resctrl/rdtgroup.c +4
-0+{ +return io_alloc_closid <closids_supported (); +} +/* * resctrl_io_alloc_closid() - io_alloc feature routes I/O traffic using * the highest available CLOSID. Retrieve the maximum CLOSID supported by the @@ -1858,6 +1879,131 @@ static int resctrl_io_alloc_show(struct kernfs_open_file *of,return 0 ; }
Quoted 8 lines
fs/resctrl/rdtgroup.c static int resctrl_io_alloc_show(struct kernfs_open_file *of, · line 1886
Quoted 5 lines
fs/resctrl/rdtgroup.c +5
-0+/* +* Initialize io_alloc CLOSID cache resource CBM with all usable (shared +* and unused) cache portions. +*/ +static int resctrl_io_alloc_init_cat(struct rdt_resource *r,Mixing two features (
io_allocand CAT) in the function name is confusing. How aboutresctrl_io_alloc_init_cbm()and move toctrlmondata.c?
Yes.
Quoted 4 lines
fs/resctrl/rdtgroup.c static int resctrl_io_alloc_show(struct kernfs_open_file *of, · line 1887
Quoted 2 lines
fs/resctrl/rdtgroup.c +1
-0+ struct resctrl_schema *s, u32 closid)No need to provide resource as parameter, it can be determined from schema.
Sure.
Quoted 17 lines
fs/resctrl/rdtgroup.c static int resctrl_io_alloc_show(struct kernfs_open_file *of, · line 1895
Quoted 9 lines
fs/resctrl/rdtgroup.c +8
-0+{ +int ret; + +rdt_staged_configs_clear (); + + ret =rdtgroup_init_cat (s, closid); +if (ret <0 ) + goto out;More below, but I think this flow can be simplified by moving the logic handling CDP here. If CDP is enabled for the resource then a successful
rdtgroup_init_cat()can just be followed by a snippet that copies the staged config of the CDP type to the staged config of its peer type. Their CBMs are supposed to be identical so there is no reason for all therdtgroup_init_cat()processing to be repeated.resctrl_arch_update_domains()can handle updating both in a single call.
Yes.
Quoted 85 lines
fs/resctrl/rdtgroup.c static int resctrl_io_alloc_show(struct kernfs_open_file *of, · line 1904
Quoted 10 lines
fs/resctrl/rdtgroup.c +9
-0+ + ret =resctrl_arch_update_domains (r, closid); + +out: +rdt_staged_configs_clear (); +return ret; +} + +static const char *rdtgroup_name_by_closid (int closid)This seems generic enough and appropriate for
rdtgroup.cfs/resctrl/rdtgroup.c static int resctrl_io_alloc_show(struct kernfs_open_file *of, · line 1916
Quoted 12 lines
fs/resctrl/rdtgroup.c +12
-0+{ +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 ; +} + +static struct resctrl_schema *resctrl_get_schema (enum resctrl_conf_type type)This also seems generic enough and appropriate for
rdtgroup.cQuoted 57 lines
fs/resctrl/rdtgroup.c +57
-0+{ +struct resctrl_schema *schema; + +list_for_each_entry (schema, &resctrl_schema_all, list) { +if (schema->conf_type == type) +return schema; + } + +return NULL ; +} + +static ssize_t resctrl_io_alloc_write (struct kernfs_open_file *of,char *buf, +size_t nbytes,loff_t off) +{ +struct resctrl_schema *s =rdt_kn_parent_priv (of->kn); +enum resctrl_conf_type peer_type; +struct rdt_resource *r = s->res; +struct resctrl_schema *peer_s; +char const *grp_name; +u32 io_alloc_closid; +bool enable; +int ret; + + ret =kstrtobool (buf, &enable); +if (ret) +return ret; + +cpus_read_lock (); +mutex_lock (&rdtgroup_mutex); + +rdt_last_cmd_clear (); + +if (!r->cache.io_alloc_capable) { +rdt_last_cmd_printf ("io_alloc is not supported on %s\n" , s->name); + ret = -ENODEV ; + goto out_unlock; + } + + io_alloc_closid =resctrl_io_alloc_closid (r); +if (!resctrl_io_alloc_closid_supported (io_alloc_closid)) { +rdt_last_cmd_printf ("io_alloc CLOSID (ctrl_hw_id) %d is not available\n" , + io_alloc_closid); + ret = -EINVAL ; + goto out_unlock; + } + +/* If the feature is already up to date, no action is needed. */ +if (resctrl_arch_get_io_alloc_enabled (r) == enable) + goto out_unlock; + +if (enable) { +if (!resctrl_io_alloc_closid_alloc (io_alloc_closid)) { + grp_name =rdtgroup_name_by_closid (io_alloc_closid); +WARN_ON_ONCE (!grp_name); +rdt_last_cmd_printf ("CLOSID (ctrl_hw_id) %d for io_alloc is used by %s group\n" , + io_alloc_closid, grp_name ? grp_name :"another" ); + ret = -ENOSPC ;
Quoted 8 lines
fs/resctrl/rdtgroup.c static int resctrl_io_alloc_show(struct kernfs_open_file *of, · line 1978
Quoted 5 lines
fs/resctrl/rdtgroup.c +5
-0+ goto out_unlock; + } + +/* Initialize schema for both CDP_DATA and CDP_CODE when CDP is enabled */ +if (resctrl_arch_get_cdp_enabled (r->rid)) {I think this block can be removed to simplify the flow by moving the CDP handling to
resctrl_io_alloc_init_cat().
Sure. Also moved the whole function to fs/resctrl/ctrlmondata.c.
Quoted 38 lines
Quoted 38 lines
fs/resctrl/rdtgroup.c +29
-1+ peer_type =resctrl_peer_type (s->conf_type); + peer_s =resctrl_get_schema (peer_type); +if (peer_s) + ret =resctrl_io_alloc_init_cat (r, peer_s, io_alloc_closid); + } + +if (!ret) + ret =resctrl_io_alloc_init_cat (r, s, io_alloc_closid); + +if (ret) { +rdt_last_cmd_puts ("Failed to initialize io_alloc allocations\n" ); +resctrl_io_alloc_closid_free (io_alloc_closid); + goto out_unlock; + } + + }else { +resctrl_io_alloc_closid_free (io_alloc_closid); + } + + ret =resctrl_arch_io_alloc_enable (r, enable); + +out_unlock: +mutex_unlock (&rdtgroup_mutex); +cpus_read_unlock (); + +return ret ?: nbytes; +} +/* rdtgroup information files for one cache resource. */ static struct rftype res_common_files[] = { {@@ -1950,9 +2096,10 @@ static struct rftype res_common_files[] = { }, { .name = "io_alloc", - .mode = 0444, + .mode = 0644,
Quoted 9 lines
fs/resctrl/rdtgroup.c static struct rftype res_common_files[] = { · line 2105
Quoted 6 lines
fs/resctrl/rdtgroup.c +1
-0.kf_ops = &rdtgroup_kf_single_ops, .seq_show = resctrl_io_alloc_show, + .write = resctrl_io_alloc_write, }, { .name = "max_threshold_occupancy",Reinette
Thanks
Babu
Reinette Chatre
maintainerRe: [PATCH v7 07/10] fs/resctrl: Add user interface to enable/disable io_alloc feature
Hi Babu,
Quoted 32 lines · Babu
Hi Reinette,
Quoted 6 lines · Reinette Chatre
Hi Babu,
Quoted 3 lines · Babu Moger
"
io_alloc" feature in resctrl enables direct insertion of data from I/O devices into the cache.Quoted 7 lines
Quoted 1 line
Introduce user interface to enable/disable
io_allocfeature.I think it is worth a mention *why* a user may want to disable this feature and why is not just always enabled. Here it can be highlighted that this feature may take resources (CLOSID) away from general (CPU) cache allocation and since this may be scarce enabling user to disable this feature supports different use cases.
Sure.
Quoted 8 lines
Quoted 7 lines
On AMD systems,
io_allocfeature is backed by SDCIAE (L3 Smart Data Cache Injection Allocation Enforcement). When enabled, SDCIAE directs all SDCI lines to be placed into the L3 cache partitions specified by the register corresponding to the highest CLOSID supported by the resource. With CDP enabled,io_allocroutes I/O traffic using the highest CLOSID assigned to the instruction cache (L3CODE).Quoted 4 lines
This is a lot of architecture specific text for a resctrl fs patch ... I think you are trying to motivate the resctrl fs implementation. Similar motivation as proposed for cover letter can be used here to help explain the implementation choices.
Quoted 8 lines
Updated the whole changelog.
fs/resctrl: Add user interface to enable/disable
io_allocfeature"
io_alloc" feature in resctrl enables direct insertion of data from I/O devices into the cache.Introduce user interface to enable/disable
io_allocfeature.
The solution should be at end of changelog after description of problem it solves.
Quoted 3 lines
On AMD systems, when
io_allocis enabled, the highest CLOSID is reserved exclusively for I/O allocation traffic and is no longer available for general CPU cache allocation. This feature is disabled by default. Users
Changelog should always be in imperative tone and problem and solution should be in separate paragraphs (above paragraph mixes problem and solution).
For example, "Disable "io_alloc" feature by default to ensure all resources are available for general CPU cache allocation. ..." Although I do not think this is accurate since this patch does not do this?
Quoted 9 lines
are encouraged to enable it only when running workloads that can benefit from this functionality.
Since CLOSIDs are managed by resctrl fs, it is least invasive to make the "
io_allocis supported by maximum supported CLOSID" part of the initial resctrl fs support forio_alloc. Take care not to expose this use of CLOSID forio_allocto user space so that this is not required from other architectures that may supportio_allocdifferently in the future.
The changelog requirements I refer to are documented in "Changelog" section of Documentation/process/maintainer-tip.rst. I feel like this should be familiar to you by now.
Reinette
Moger, Babu
reviewerRe: [PATCH v7 07/10] fs/resctrl: Add user interface to enable/disable io_alloc feature
Hi Reinette,
Quoted 39 lines · Reinette Chatre
Hi Babu,
Quoted 36 lines · Babu
Hi Reinette,
Quoted 6 lines · Reinette Chatre
Hi Babu,
Quoted 3 lines · Babu Moger
"
io_alloc" feature in resctrl enables direct insertion of data from I/O devices into the cache.Quoted 7 lines
Quoted 1 line
Introduce user interface to enable/disable
io_allocfeature.I think it is worth a mention *why* a user may want to disable this feature and why is not just always enabled. Here it can be highlighted that this feature may take resources (CLOSID) away from general (CPU) cache allocation and since this may be scarce enabling user to disable this feature supports different use cases.
Sure.
Quoted 8 lines
Quoted 7 lines
On AMD systems,
io_allocfeature is backed by SDCIAE (L3 Smart Data Cache Injection Allocation Enforcement). When enabled, SDCIAE directs all SDCI lines to be placed into the L3 cache partitions specified by the register corresponding to the highest CLOSID supported by the resource. With CDP enabled,io_allocroutes I/O traffic using the highest CLOSID assigned to the instruction cache (L3CODE).Quoted 4 lines
This is a lot of architecture specific text for a resctrl fs patch ... I think you are trying to motivate the resctrl fs implementation. Similar motivation as proposed for cover letter can be used here to help explain the implementation choices.
Updated the whole changelog.
fs/resctrl: Add user interface to enable/disable
io_allocfeature
Quoted 7 lines
Quoted 4 lines
"
io_alloc" feature in resctrl enables direct insertion of data from I/O devices into the cache.Introduce user interface to enable/disable
io_allocfeature.The solution should be at end of changelog after description of problem it solves.
Sure. Moved this text below.
Quoted 11 lines
Quoted 4 lines
On AMD systems, when
io_allocis enabled, the highest CLOSID is reserved exclusively for I/O allocation traffic and is no longer available for general CPU cache allocation. This feature is disabled by default. UsersChangelog should always be in imperative tone and problem and solution should be in separate paragraphs (above paragraph mixes problem and solution).
For example, "Disable "
io_alloc" feature by default to ensure all resources are available for general CPU cache allocation. ..." Although I do not think this is accurate since this patch does not do this?
Yes. Removed the text "This feature is disabled by default."
Quoted 11 lines
Quoted 10 lines
are encouraged to enable it only when running workloads that can benefit from this functionality.
Since CLOSIDs are managed by resctrl fs, it is least invasive to make the "
io_allocis supported by maximum supported CLOSID" part of the initial resctrl fs support forio_alloc. Take care not to expose this use of CLOSID forio_allocto user space so that this is not required from other architectures that may supportio_allocdifferently in the future.
Quoted 3 lines
The changelog requirements I refer to are documented in "Changelog" section of
Documentation/process/maintainer-tip.rst. I feel like this should be familiar to you by now.
Sure, Thank you.
Signature · 2 lines
Thanks Babu Moger
Babu Moger
reviewerPATCH v7 8/10 fs/resctrl: Introduce interface to display io_alloc CBMs
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.
Add "io_alloc_cbm" resctrl file to display CBMs (Capacity Bit Mask) o fio_alloc feature.
The CBM interface file io_alloc_cbm will reside in the info directory (e.g., /sys/fs/resctrl/info/L3/). Displaying the resource name is not necessary. Pass the resource name to show_doms() and print it only if the name is valid. For io_alloc, pass NULL to suppress printing the resource name.
When CDP is enabled, io_alloc routes traffic using the highest CLOSID associated with an L3CODE resource. However, CBMs can be accessed via either L3CODE or L3DATA resources.
---
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 | 18 +++++++++++ fs/resctrl/ctrlmondata.c | 8 +++-- fs/resctrl/internal.h | 2 ++ fs/resctrl/rdtgroup.c | 43 ++++++++++++++++++++++++++- 4 files changed, 67 insertions(+), 4 deletions(-)
Documentation/filesystems/resctrl.rst +18 -0
@@ -176,6 +176,24 @@ related to allocation: When CDP is enabled, io_alloc routes I/O traffic using the highest CLOSID allocated for the instruction cache (L3CODE). +"io_alloc_cbm": + CBMs(Capacity Bit Masks) that describe the portions of cache instances + to which I/O traffic from supported I/O devices are routed. + + 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 DATA and 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 +5 -3
@@ -381,7 +381,8 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,return ret ?: nbytes; } -static void show_doms (struct seq_file *s,struct resctrl_schema *schema,int closid) +void show_doms (struct seq_file *s,struct resctrl_schema *schema,char *resource_name, +int closid) {struct rdt_resource *r = schema->res;struct rdt_ctrl_domain *dom;
@@ -391,7 +392,8 @@ static void show_doms(struct seq_file *s, struct resctrl_schema *schema, int clo/* Walking r->domains, ensure it can't race with cpuhp */ lockdep_assert_cpus_held (); -seq_printf (s,"%*s:" , max_name_width, schema->name); +if (resource_name) +seq_printf (s,"%*s:" , max_name_width, resource_name);list_for_each_entry (dom, &r->ctrl_domains, hdr.list) {if (sep)seq_puts (s,";" );
@@ -437,7 +439,7 @@ int rdtgroup_schemata_show(struct kernfs_open_file *of, closid = rdtgrp->closid;list_for_each_entry (schema, &resctrl_schema_all, list) {if (closid < schema->num_closid) -show_doms (s, schema, closid); +show_doms (s, schema, schema->name, closid); } } }else {
fs/resctrl/internal.h +2 -0
@@ -374,6 +374,8 @@ void rdt_staged_configs_clear(void);bool closid_allocated (unsigned int closid);int resctrl_find_cleanest_closid (void ); +void show_doms (struct seq_file *s,struct resctrl_schema *schema, +char *name,int closid);#ifdef CONFIG_RESCTRL_FS_PSEUDO_LOCK int rdtgroup_locksetup_enter (struct rdtgroup *rdtgrp);
fs/resctrl/rdtgroup.c +42 -1
63 lines not on this page · raw message
Signature · 1 line
2.34.1
Reinette Chatre
maintainerRe: [PATCH v7 08/10] fs/resctrl: Introduce interface to display io_alloc CBMs
Hi Babu,
Quoted 5 lines · Babu Moger
The
io_allocfeature in resctrl enables system software to configure the portion of the cache allocated for I/O traffic.Add "
io_alloc_cbm" resctrl file to display CBMs (Capacity Bit Mask) ofio_allocfeature.
"o fio_alloc" -> "of the io_alloc"
Quoted 2 lines
The CBM interface file
io_alloc_cbmwill reside in the info directory
"will reside" -> "resides"
Quoted 8 lines
(e.g.,
/sys/fs/resctrl/info/L3/). Displaying the resource name is not necessary. Pass the resource name toshow_doms()and print it only if the name is valid. Forio_alloc, pass NULL to suppress printing the resource name.When CDP is enabled,
io_allocroutes traffic using the highest CLOSID associated with an L3CODE resource. However, CBMs can be accessed via either L3CODE or L3DATA resources.
Seems like something is missing here since this is motivation for a behavior but no mention of the behavior being motivated. Also please use imperative tone.
Quoted 3 lines
Signed-off-by Babu Moger <[email protected]>---
...
Quoted 12 lines
--- Documentation/filesystems/resctrl.rst | 18 +++++++++++ fs/resctrl/ctrlmondata.c | 8 +++-- fs/resctrl/internal.h | 2 ++ fs/resctrl/rdtgroup.c | 43 ++++++++++++++++++++++++++- 4 files changed, 67 insertions(+), 4 deletions(-)Documentation/filesystems/resctrl.rst +0
-0
Documentation/filesystems/resctrl.rst related to allocation: · line 181
Quoted 6 lines
Documentation/filesystems/resctrl.rst +3
-0@@ -176,6 +176,24 @@ related to allocation: When CDP is enabled, io_alloc routes I/O traffic using the highest CLOSID allocated for the instruction cache (L3CODE). +"io_alloc_cbm": + CBMs(Capacity Bit Masks) that describe the portions of cache instances + to which I/O traffic from supported I/O devices are routed.
"are routed" -> "are routed when "io_alloc" is enabled"?
Quoted 23 lines
Documentation/filesystems/resctrl.rst +15
-0+ + 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 DATA and 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 +0
-0
fs/resctrl/ctrlmondata.c ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of, · line 384
Quoted 5 lines
fs/resctrl/ctrlmondata.c +1
-1@@ -381,7 +381,8 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,return ret ?: nbytes; } -static void show_doms (struct seq_file *s,struct resctrl_schema *schema,int closid) +void show_doms(struct seq_file *s, struct resctrl_schema *schema, char *resource_name,
show_doms() can remain static within ctrlmondata.c by moving resctrl_io_alloc_cbm_show() to ctrlmondata.c
Reinette
Moger, Babu
reviewerRe: [PATCH v7 08/10] fs/resctrl: Introduce interface to display io_alloc CBMs
Hi Reinette,
Quoted 11 lines · Reinette Chatre
Hi Babu,
Quoted 5 lines · Babu Moger
The
io_allocfeature in resctrl enables system software to configure the portion of the cache allocated for I/O traffic.Add "
io_alloc_cbm" resctrl file to display CBMs (Capacity Bit Mask) ofio_allocfeature."o
fio_alloc" -> "of theio_alloc"
Sure.
Quoted 5 lines
Quoted 2 lines
The CBM interface file
io_alloc_cbmwill reside in the info directory"will reside" -> "resides"
Sure.
Quoted 11 lines
Quoted 8 lines
(e.g.,
/sys/fs/resctrl/info/L3/). Displaying the resource name is not necessary. Pass the resource name toshow_doms()and print it only if the name is valid. Forio_alloc, pass NULL to suppress printing the resource name.When CDP is enabled,
io_allocroutes traffic using the highest CLOSID associated with an L3CODE resource. However, CBMs can be accessed via either L3CODE or L3DATA resources.Seems like something is missing here since this is motivation for a behavior but no mention of the behavior being motivated. Also please use imperative tone.
Sure. Added motivation for this.
Quoted 22 lines
Quoted 4 lines
Signed-off-by Babu Moger <[email protected]>---
...
Quoted 15 lines
--- Documentation/filesystems/resctrl.rst | 18 +++++++++++ fs/resctrl/ctrlmondata.c | 8 +++-- fs/resctrl/internal.h | 2 ++ fs/resctrl/rdtgroup.c | 43 ++++++++++++++++++++++++++- 4 files changed, 67 insertions(+), 4 deletions(-)Documentation/filesystems/resctrl.rst +0
-0@@ -176,6 +176,24 @@ related to allocation: When CDP is enabled, io_alloc routes I/O traffic using the highest CLOSID allocated for the instruction cache (L3CODE).
Quoted 6 lines
Documentation/filesystems/resctrl.rst related to allocation: · line 181
Quoted 3 lines
Documentation/filesystems/resctrl.rst +3
-0+"io_alloc_cbm": + CBMs(Capacity Bit Masks) that describe the portions of cache instances + to which I/O traffic from supported I/O devices are routed."are routed" -> "are routed when "
io_alloc" is enabled"?
Sure.
Quoted 26 lines
Quoted 26 lines
Documentation/filesystems/resctrl.rst +15
-0+ + 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 DATA and 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 +0
-0@@ -381,7 +381,8 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,return ret ?: nbytes; }
Quoted 6 lines
fs/resctrl/ctrlmondata.c ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of, · line 384
Quoted 2 lines
fs/resctrl/ctrlmondata.c +1
-1-static void show_doms (struct seq_file *s,struct resctrl_schema *schema,int closid) +void show_doms(struct seq_file *s, struct resctrl_schema *schema, char *resource_name,
show_doms()can remain static withinctrlmondata.cby movingresctrl_io_alloc_cbm_show()toctrlmondata.c
Yes. Moved it to ctrlmondata.c.
Thanks
Babu Moger
Babu Moger
reviewerPATCH v7 9/10 fs/resctrl: Modify rdt_parse_data to pass mode and CLOSID
In reply to Babu MogerThe functions parse_cbm() and parse_bw() require mode and CLOSID to validate the Capacity Bit Mask (CBM). It is passed through struct rdtgroup in rdt_parse_data.
This can be simplified by passing the mode and closid directly, instead of through the rdtgroup struct. Doing so also facilitates calling parse_cbm() to verify the CBM within the io_alloc feature, since io_alloc does not have rdtgroup context.
---
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 | 29 +++++++++++++---------------- fs/resctrl/internal.h | 6 ++++++ 2 files changed, 19 insertions(+), 16 deletions(-)
fs/resctrl/ctrlmondata.c +13 -16
@@ -23,11 +23,6 @@#include "internal.h" -struct rdt_parse_data { -struct rdtgroup *rdtgrp; -char *buf; -}; -typedef int (ctrlval_parser_t )(struct rdt_parse_data *data,struct resctrl_schema *s,struct rdt_ctrl_domain *d);
@@ -77,8 +72,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 +151,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 +167,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,9 +176,9 @@ 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 ) && -rdtgroup_cbm_overlaps_pseudo_locked (d, cbm_val)) { +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 +187,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 +258,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 ) {
fs/resctrl/internal.h +6 -0
@@ -201,6 +201,12 @@ struct rdtgroup {struct pseudo_lock_region *plr; }; +struct rdt_parse_data { +u32 closid; +enum rdtgrp_mode mode; +char *buf; +}; +/* rdtgroup.flags */ #define RDT_DELETED 1
Signature · 1 line
2.34.1
Reinette Chatre
maintainerRe: [PATCH v7 09/10] fs/resctrl: Modify rdt_parse_data to pass mode and CLOSID
Hi Babu,
Quoted 1 line · Babu Moger
The functions
parse_cbm()andparse_bw()require mode and CLOSID to
No need to say "function" when using (). Also, drop parse_bw(), since it does not validate CBMs.
Quoted 1 line
validate the Capacity Bit Mask (CBM). It is passed through struct
"passed through" -> "passed via"?
Quoted 1 line
rdtgroup in
rdt_parse_data.
"rdt_parse_data" -> "struct rdt_parse_data"
Quoted 2 lines
This can be simplified by passing the mode and closid directly, instead of
closid -> CLOSID
Quoted 3 lines
through the rdtgroup struct. Doing so also facilitates calling
parse_cbm()to verify the CBM within theio_allocfeature, sinceio_allocdoes not have rdtgroup context.
Above notes that "simplification" is the primary motivation but I do not think this change qualifies as a "simplification". How about second paragraph changed to something like:
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 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.
(please feel free to improve)
Quoted 16 lines
Signed-off-by Babu Moger <[email protected]>---
--- fs/resctrl/ctrlmondata.c | 29 +++++++++++++---------------- fs/resctrl/internal.h | 6 ++++++ 2 files changed, 19 insertions(+), 16 deletions(-)fs/resctrl/ctrlmondata.c +0
-0
fs/resctrl/ctrlmondata.c line 30
Quoted 8 lines
fs/resctrl/ctrlmondata.c +0
-5@@ -23,11 +23,6 @@#include "internal.h" -struct rdt_parse_data { -struct rdtgroup *rdtgrp; -char *buf; -}; -
This patch is only about replacing rdtgroup with mode and CLOSID, there is no motivation for relocating the structure declaration. This looks to be a change needed by following patch but is another change that becomes unnecessary if the io_alloc code, specifically resctrl_io_alloc_cbm_write() and resctrl_io_alloc_parse_line() from next patch, are moved to ctrlmondata.c.
...
Quoted 10 lines
fs/resctrl/ctrlmondata.c +1
-1@@ -171,7 +167,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 ;
fs/resctrl/ctrlmondata.c static int parse_cbm(struct rdt_parse_data *data, struct resctrl_schema *s, · line 181
Quoted 9 lines
fs/resctrl/ctrlmondata.c +3
-3@@ -180,9 +176,9 @@ 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 ) && -rdtgroup_cbm_overlaps_pseudo_locked (d, cbm_val)) { +if ((mode ==RDT_MODE_EXCLUSIVE || + mode ==RDT_MODE_SHAREABLE ) && +rdtgroup_cbm_overlaps_pseudo_locked (d, cbm_val)) {
Please fix alignment.
fs/resctrl/ctrlmondata.c static int parse_cbm(struct rdt_parse_data *data, struct resctrl_schema *s, · line 184
Quoted 3 lines
fs/resctrl/ctrlmondata.c +0
-0rdt_last_cmd_puts ("CBM overlaps with pseudo-locked region\n" );return -EINVAL ; }
Reinette
Moger, Babu
reviewerRe: [PATCH v7 09/10] fs/resctrl: Modify rdt_parse_data to pass mode and CLOSID
Hi Reinette,
Quoted 7 lines · Reinette Chatre
Hi Babu,
Quoted 1 line · Babu Moger
The functions
parse_cbm()andparse_bw()require mode and CLOSID toNo need to say "function" when using (). Also, drop
parse_bw(), since it does not validate CBMs.
Sure.
Quoted 5 lines
Quoted 2 lines
validate the Capacity Bit Mask (CBM). It is passed through struct
"passed through" -> "passed via"?
Sure.
Quoted 4 lines
Quoted 1 line
rdtgroup in
rdt_parse_data."
rdt_parse_data" -> "structrdt_parse_data"
Sure.
Quoted 5 lines
Quoted 2 lines
This can be simplified by passing the mode and closid directly, instead of
closid -> CLOSID
Sure,
Quoted 14 lines
Quoted 3 lines
through the rdtgroup struct. Doing so also facilitates calling
parse_cbm()to verify the CBM within theio_allocfeature, sinceio_allocdoes not have rdtgroup context.Above notes that "simplification" is the primary motivation but I do not think this change qualifies as a "simplification". How about second paragraph changed to something like:
The
io_allocfeature 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 sinceio_allocdoes not have rdtgroup context.
Quoted 6 lines
Pass the mode and CLOSID directly to
parse_cbm()via structrdt_parse_datainstead of through the rdtgroup struct to facilitate callingparse_cbm()to verify the CBM of theio_allocfeature.(please feel free to improve)
Looks good.
Quoted 19 lines
Quoted 19 lines
Signed-off-by Babu Moger <[email protected]>---
--- fs/resctrl/ctrlmondata.c | 29 +++++++++++++---------------- fs/resctrl/internal.h | 6 ++++++ 2 files changed, 19 insertions(+), 16 deletions(-)fs/resctrl/ctrlmondata.c +0
-0@@ -23,11 +23,6 @@#include "internal.h"
Quoted 12 lines
fs/resctrl/ctrlmondata.c line 30
Quoted 5 lines
fs/resctrl/ctrlmondata.c +0
-5-struct rdt_parse_data { -struct rdtgroup *rdtgrp; -char *buf; -}; -This patch is only about replacing rdtgroup with mode and CLOSID, there is no motivation for relocating the structure declaration. This looks to be a change needed by following patch but is another change that becomes unnecessary if the
io_alloccode, specificallyresctrl_io_alloc_cbm_write()andresctrl_io_alloc_parse_line()from next patch, are moved toctrlmondata.c.
Yes. Not required to move now.
Quoted 15 lines
...
Quoted 13 lines
fs/resctrl/ctrlmondata.c +1
-1@@ -171,7 +167,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,9 +176,9 @@ static int parse_cbm(struct rdt_parse_data *data, struct resctrl_schema *s,if (!cbm_validate (data->buf, &cbm_val, r))return -EINVAL ;
Quoted 8 lines
fs/resctrl/ctrlmondata.c static int parse_cbm(struct rdt_parse_data *data, struct resctrl_schema *s, · line 181
Quoted 6 lines
fs/resctrl/ctrlmondata.c +3
-3-if ((rdtgrp->mode ==RDT_MODE_EXCLUSIVE || - rdtgrp->mode ==RDT_MODE_SHAREABLE ) && -rdtgroup_cbm_overlaps_pseudo_locked (d, cbm_val)) { +if ((mode ==RDT_MODE_EXCLUSIVE || + mode ==RDT_MODE_SHAREABLE ) && +rdtgroup_cbm_overlaps_pseudo_locked (d, cbm_val)) {Please fix alignment.
Sure.
Quoted 7 lines
fs/resctrl/ctrlmondata.c static int parse_cbm(struct rdt_parse_data *data, struct resctrl_schema *s, · line 184
Quoted 4 lines
fs/resctrl/ctrlmondata.c +0
-0rdt_last_cmd_puts ("CBM overlaps with pseudo-locked region\n" );return -EINVAL ; }Reinette
Signature · 2 lines
Thanks Babu Moger
Babu Moger
reviewerPATCH v7 10/10 fs/resctrl: Introduce interface to modify io_alloc Capacity Bit Masks
In reply to Babu Moger"io_alloc" feature enables direct insertion of data from I/O devices into the cache. By directly caching data from I/O devices rather than first storing the I/O data in DRAM, it reduces the demands on DRAM bandwidth and reduces latency to the processor consuming the I/O data.
Provide the interface to modify io_alloc CBMs (Capacity Bit Mask) when feature is enabled. Update the CBMs for both CDP_DATA and CDP_CODE when CDP is enabled.
---
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 | 8 ++ fs/resctrl/ctrlmondata.c | 4 +- fs/resctrl/internal.h | 2 + fs/resctrl/rdtgroup.c | 112 +++++++++++++++++++++++++- 4 files changed, 123 insertions(+), 3 deletions(-)
Documentation/filesystems/resctrl.rst +8 -0
@@ -189,6 +189,14 @@ 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 + When CDP is enabled "io_alloc_cbm" associated with the DATA and 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 +2 -2
@@ -148,8 +148,8 @@ static bool cbm_validate(char *buf, u32 *data, struct rdt_resource *r)* Read one cache bit mask (hex). Check that it is valid for the current * resource type. */ -static int parse_cbm (struct rdt_parse_data *data,struct resctrl_schema *s, -struct rdt_ctrl_domain *d) +int parse_cbm (struct rdt_parse_data *data,struct resctrl_schema *s, +struct rdt_ctrl_domain *d) {enum rdtgrp_mode mode = data->mode;struct resctrl_staged_config *cfg;
fs/resctrl/internal.h +2 -0
@@ -382,6 +382,8 @@ bool closid_allocated(unsigned int closid);int resctrl_find_cleanest_closid (void );void show_doms (struct seq_file *s,struct resctrl_schema *schema,char *name,int closid); +int parse_cbm (struct rdt_parse_data *data,struct resctrl_schema *s, +struct rdt_ctrl_domain *d);#ifdef CONFIG_RESCTRL_FS_PSEUDO_LOCK int rdtgroup_locksetup_enter (struct rdtgroup *rdtgrp);
fs/resctrl/rdtgroup.c +111 -1
126 lines not on this page · raw message
Signature · 1 line
2.34.1
Reinette Chatre
maintainerRe: [PATCH v7 10/10] fs/resctrl: Introduce interface to modify io_alloc Capacity Bit Masks
Hi Babu,
Quoted 6 lines · Babu Moger
"
io_alloc" feature enables direct insertion of data from I/O devices into the cache. By directly caching data from I/O devices rather than first storing the I/O data in DRAM, it reduces the demands on DRAM bandwidth and reduces latency to the processor consuming the I/O data.Provide the interface to modify
io_allocCBMs (Capacity Bit Mask) when
"Provide the interface to modify io_alloc CBMs (Capacity Bit Mask) when feature is enabled." ->
"Enable users to modify io_alloc CBMs (Capacity Bit Masks) via the io_alloc_cbm resctrl file when io_alloc is enabled."?
Quoted 5 lines
feature is enabled. Update the CBMs for both
CDP_DATAandCDP_CODEwhen CDP is enabled.Signed-off-by Babu Moger <[email protected]>---
...
Quoted 31 lines
--- Documentation/filesystems/resctrl.rst | 8 ++ fs/resctrl/ctrlmondata.c | 4 +- fs/resctrl/internal.h | 2 + fs/resctrl/rdtgroup.c | 112 +++++++++++++++++++++++++- 4 files changed, 123 insertions(+), 3 deletions(-)Documentation/filesystems/resctrl.rst +8
-0@@ -189,6 +189,14 @@ 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 + When CDP is enabled "io_alloc_cbm" associated with the DATA and 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 byfs/resctrl/ctrlmondata.c +0
-0
fs/resctrl/ctrlmondata.c static bool cbm_validate(char *buf, u32 *data, struct rdt_resource *r) · line 152
Quoted 7 lines
fs/resctrl/ctrlmondata.c +2
-2@@ -148,8 +148,8 @@ static bool cbm_validate(char *buf, u32 *data, struct rdt_resource *r)* Read one cache bit mask (hex). Check that it is valid for the current * resource type. */ -static int parse_cbm (struct rdt_parse_data *data,struct resctrl_schema *s, -struct rdt_ctrl_domain *d) +int parse_cbm (struct rdt_parse_data *data,struct resctrl_schema *s, +struct rdt_ctrl_domain *d)
This can remain static by moving caller to ctrlmondata.c
Quoted 21 lines
fs/resctrl/ctrlmondata.c +0
-0{enum rdtgrp_mode mode = data->mode;struct resctrl_staged_config *cfg;fs/resctrl/internal.h +2
-0@@ -382,6 +382,8 @@ bool closid_allocated(unsigned int closid);int resctrl_find_cleanest_closid (void );void show_doms (struct seq_file *s,struct resctrl_schema *schema,char *name,int closid); +int parse_cbm (struct rdt_parse_data *data,struct resctrl_schema *s, +struct rdt_ctrl_domain *d);#ifdef CONFIG_RESCTRL_FS_PSEUDO_LOCK int rdtgroup_locksetup_enter (struct rdtgroup *rdtgrp);fs/resctrl/rdtgroup.c +0
-0
fs/resctrl/rdtgroup.c static int resctrl_io_alloc_cbm_show(struct kernfs_open_file *of, · line 2040
Quoted 5 lines
fs/resctrl/rdtgroup.c +2
-0@@ -2036,6 +2036,115 @@ static int resctrl_io_alloc_cbm_show(struct kernfs_open_file *of,return ret; } +static int resctrl_io_alloc_parse_line (char *line,struct rdt_resource *r, +struct resctrl_schema *s,u32 closid)
Please move to ctrlmondata.c
Quoted 23 lines
fs/resctrl/rdtgroup.c +23
-0+{ +struct rdt_parse_data data; +struct rdt_ctrl_domain *d; +char *dom =NULL , *id; +unsigned long dom_id; + +next: +if (!line || line[0 ] =='\0' ) +return 0 ; + + dom =strsep (&line,";" ); + id =strsep (&dom,"=" ); +if (!dom ||kstrtoul (id,10 , &dom_id)) { +rdt_last_cmd_puts ("Missing '=' or non-numeric domain\n" ); +return -EINVAL ; + } + + dom =strim (dom); +list_for_each_entry (d, &r->ctrl_domains, hdr.list) { +if (d->hdr.id == dom_id) { + data.buf = dom; + data.mode =RDT_MODE_SHAREABLE ; + data.closid = closid;
fs/resctrl/rdtgroup.c static int resctrl_io_alloc_cbm_show(struct kernfs_open_file *of, · line 2073
Quoted 10 lines
fs/resctrl/rdtgroup.c +10
-0+if (parse_cbm (&data, s, d)) +return -EINVAL ; + goto next; + } + } +return -EINVAL ; +} + +static ssize_t resctrl_io_alloc_cbm_write (struct kernfs_open_file *of, +char *buf,size_t nbytes,loff_t off)
Please move to ctrlmondata.c
Quoted 10 lines
fs/resctrl/rdtgroup.c +10
-0+{ +struct resctrl_schema *s =rdt_kn_parent_priv (of->kn); +enum resctrl_conf_type peer_type; +struct rdt_resource *r = s->res; +struct resctrl_schema *peer_s; +u32 io_alloc_closid; +char *peer_buf; +int ret =0 ; + +/* Valid input requires a trailing newline */
fs/resctrl/rdtgroup.c static int resctrl_io_alloc_cbm_show(struct kernfs_open_file *of, · line 2093
Quoted 10 lines
fs/resctrl/rdtgroup.c +10
-0+if (nbytes ==0 || buf[nbytes -1 ] !='\n' ) +return -EINVAL ; + + buf[nbytes -1 ] ='\0' ; + +cpus_read_lock (); +mutex_lock (&rdtgroup_mutex); + +if (!r->cache.io_alloc_capable) { +rdt_last_cmd_printf ("io_alloc is not supported on %s\n" , s->name);
rdt_last_cmd_clear() is required before any write to the buffer.
fs/resctrl/rdtgroup.c static int resctrl_io_alloc_cbm_show(struct kernfs_open_file *of, · line 2103
Quoted 10 lines
fs/resctrl/rdtgroup.c +10
-0+ ret = -EINVAL ; + goto out_unlock; + } + +rdt_last_cmd_clear (); +rdt_staged_configs_clear (); + +if (!resctrl_arch_get_io_alloc_enabled (r)) { +rdt_last_cmd_printf ("io_alloc is not enabled on %s\n" , s->name); + ret = -EINVAL ;
Inconsistent error codes when io_alloc is not enabled. resctrl_io_alloc_write() and resctrl_io_alloc_cbm_show() returns -ENODEV.
Quoted 14 lines
fs/resctrl/rdtgroup.c +14
-0+ goto out_unlock; + } + + io_alloc_closid =resctrl_io_alloc_closid (r); + +/* +* When CDP is enabled, update the schema for both CDP_DATA and CDP_CODE. +* Since the buffer is altered during parsing, create a copy to handle +* peer schemata separately. +*/ +if (resctrl_arch_get_cdp_enabled (r->rid)) { + peer_type =resctrl_peer_type (s->conf_type); + peer_s =resctrl_get_schema (peer_type); + peer_buf =kmalloc (nbytes,GFP_KERNEL );
fs/resctrl/rdtgroup.c static int resctrl_io_alloc_cbm_show(struct kernfs_open_file *of, · line 2127
Quoted 10 lines
fs/resctrl/rdtgroup.c +10
-0+if (!peer_buf) { +rdt_last_cmd_puts ("Out of Memory - io_alloc update failed\n" ); + ret = -ENOMEM ; + goto out_unlock; + } + +memcpy (peer_buf, buf, nbytes); + +if (peer_s) + ret =resctrl_io_alloc_parse_line (peer_buf, r, peer_s, io_alloc_closid);
Similar to resctrl_io_alloc_write() this looks unnecessary. I think this can be simplified by moving the CDP check to resctrl_io_alloc_parse_line() where the provided CBM can be parsed *once* and the staged config of a CDP type just copied to the staged config of its peer type.
Quoted 25 lines
fs/resctrl/rdtgroup.c +20
-0+ +kfree (peer_buf); + } + +if (!ret) + ret =resctrl_io_alloc_parse_line (buf, r, s, io_alloc_closid); + +if (ret) + goto out_unlock; + + ret =resctrl_arch_update_domains (r, io_alloc_closid); + +out_unlock: +rdt_staged_configs_clear (); +mutex_unlock (&rdtgroup_mutex); +cpus_read_unlock (); + +return ret ?: nbytes; +} +/* rdtgroup information files for one cache resource. */ static struct rftype res_common_files[] = { {@@ -2135,9 +2244,10 @@ static struct rftype res_common_files[] = { },
fs/resctrl/rdtgroup.c static struct rftype res_common_files[] = { · line 2253
Quoted 10 lines
fs/resctrl/rdtgroup.c +2
-1{ .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",
Reinette
Moger, Babu
reviewerRe: [PATCH v7 10/10] fs/resctrl: Introduce interface to modify io_alloc Capacity Bit Masks
Hi Reinette,
Quoted 8 lines · Reinette Chatre
Hi Babu,
Quoted 5 lines · Babu Moger
"
io_alloc" feature enables direct insertion of data from I/O devices into the cache. By directly caching data from I/O devices rather than first storing the I/O data in DRAM, it reduces the demands on DRAM bandwidth and reduces latency to the processor consuming the I/O data.
Quoted 6 lines
Quoted 1 line
Provide the interface to modify
io_allocCBMs (Capacity Bit Mask) when"Provide the interface to modify
io_allocCBMs (Capacity Bit Mask) when feature is enabled." ->
"Enable users to modifyio_allocCBMs (Capacity Bit Masks) via theio_alloc_cbmresctrl file whenio_allocis enabled."?
Sure.
Quoted 41 lines
Quoted 6 lines
feature is enabled. Update the CBMs for both
CDP_DATAandCDP_CODEwhen CDP is enabled.Signed-off-by Babu Moger <[email protected]>---
...
Quoted 32 lines
--- Documentation/filesystems/resctrl.rst | 8 ++ fs/resctrl/ctrlmondata.c | 4 +- fs/resctrl/internal.h | 2 + fs/resctrl/rdtgroup.c | 112 +++++++++++++++++++++++++- 4 files changed, 123 insertions(+), 3 deletions(-)Documentation/filesystems/resctrl.rst +8
-0@@ -189,6 +189,14 @@ 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 + When CDP is enabled "io_alloc_cbm" associated with the DATA and 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 byfs/resctrl/ctrlmondata.c +0
-0@@ -148,8 +148,8 @@ static bool cbm_validate(char *buf, u32 *data, struct rdt_resource *r)* Read one cache bit mask (hex). Check that it is valid for the current
Quoted 8 lines
fs/resctrl/ctrlmondata.c static bool cbm_validate(char *buf, u32 *data, struct rdt_resource *r) · line 152
Quoted 6 lines
fs/resctrl/ctrlmondata.c +2
-2* resource type. */ -static int parse_cbm (struct rdt_parse_data *data,struct resctrl_schema *s, -struct rdt_ctrl_domain *d) +int parse_cbm (struct rdt_parse_data *data,struct resctrl_schema *s, +struct rdt_ctrl_domain *d)This can remain static by moving caller to
ctrlmondata.c
Yes.
Quoted 25 lines
Quoted 25 lines
fs/resctrl/ctrlmondata.c +0
-0{enum rdtgrp_mode mode = data->mode;struct resctrl_staged_config *cfg;fs/resctrl/internal.h +2
-0@@ -382,6 +382,8 @@ bool closid_allocated(unsigned int closid);int resctrl_find_cleanest_closid (void );void show_doms (struct seq_file *s,struct resctrl_schema *schema,char *name,int closid); +int parse_cbm (struct rdt_parse_data *data,struct resctrl_schema *s, +struct rdt_ctrl_domain *d);#ifdef CONFIG_RESCTRL_FS_PSEUDO_LOCK int rdtgroup_locksetup_enter (struct rdtgroup *rdtgrp);fs/resctrl/rdtgroup.c +0
-0@@ -2036,6 +2036,115 @@ static int resctrl_io_alloc_cbm_show(struct kernfs_open_file *of,return ret; }
Quoted 4 lines
fs/resctrl/rdtgroup.c static int resctrl_io_alloc_cbm_show(struct kernfs_open_file *of, · line 2040
Quoted 2 lines
fs/resctrl/rdtgroup.c +2
-0+static int resctrl_io_alloc_parse_line (char *line,struct rdt_resource *r, +struct resctrl_schema *s,u32 closid)Please move to
ctrlmondata.c
Yes.
Quoted 28 lines
Quoted 28 lines
fs/resctrl/rdtgroup.c +27
-0+{ +struct rdt_parse_data data; +struct rdt_ctrl_domain *d; +char *dom =NULL , *id; +unsigned long dom_id; + +next: +if (!line || line[0 ] =='\0' ) +return 0 ; + + dom =strsep (&line,";" ); + id =strsep (&dom,"=" ); +if (!dom ||kstrtoul (id,10 , &dom_id)) { +rdt_last_cmd_puts ("Missing '=' or non-numeric domain\n" ); +return -EINVAL ; + } + + dom =strim (dom); +list_for_each_entry (d, &r->ctrl_domains, hdr.list) { +if (d->hdr.id == dom_id) { + data.buf = dom; + data.mode =RDT_MODE_SHAREABLE ; + data.closid = closid; +if (parse_cbm (&data, s, d)) +return -EINVAL ; + goto next; + }
Quoted 8 lines
fs/resctrl/rdtgroup.c static int resctrl_io_alloc_cbm_show(struct kernfs_open_file *of, · line 2073
Quoted 6 lines
fs/resctrl/rdtgroup.c +6
-0+ } +return -EINVAL ; +} + +static ssize_t resctrl_io_alloc_cbm_write (struct kernfs_open_file *of, +char *buf,size_t nbytes,loff_t off)Please move to
ctrlmondata.c
Yes.
Quoted 15 lines
Quoted 15 lines
fs/resctrl/rdtgroup.c +14
-0+{ +struct resctrl_schema *s =rdt_kn_parent_priv (of->kn); +enum resctrl_conf_type peer_type; +struct rdt_resource *r = s->res; +struct resctrl_schema *peer_s; +u32 io_alloc_closid; +char *peer_buf; +int ret =0 ; + +/* Valid input requires a trailing newline */ +if (nbytes ==0 || buf[nbytes -1 ] !='\n' ) +return -EINVAL ; + + buf[nbytes -1 ] ='\0' ;
Quoted 8 lines
fs/resctrl/rdtgroup.c static int resctrl_io_alloc_cbm_show(struct kernfs_open_file *of, · line 2093
Quoted 6 lines
fs/resctrl/rdtgroup.c +6
-0+ +cpus_read_lock (); +mutex_lock (&rdtgroup_mutex); + +if (!r->cache.io_alloc_capable) { +rdt_last_cmd_printf ("io_alloc is not supported on %s\n" , s->name);
rdt_last_cmd_clear()is required before any write to the buffer.
Added now.
Quoted 14 lines
fs/resctrl/rdtgroup.c static int resctrl_io_alloc_cbm_show(struct kernfs_open_file *of, · line 2103
Quoted 11 lines
fs/resctrl/rdtgroup.c +10
-0+ ret = -EINVAL ; + goto out_unlock; + } + +rdt_last_cmd_clear (); +rdt_staged_configs_clear (); + +if (!resctrl_arch_get_io_alloc_enabled (r)) { +rdt_last_cmd_printf ("io_alloc is not enabled on %s\n" , s->name); + ret = -EINVAL ;Inconsistent error codes when
io_allocis not enabled.resctrl_io_alloc_write()andresctrl_io_alloc_cbm_show()returns-ENODEV.
Changed it to -ENODEV.
Quoted 21 lines
Quoted 21 lines
fs/resctrl/rdtgroup.c +20
-0+ goto out_unlock; + } + + io_alloc_closid =resctrl_io_alloc_closid (r); + +/* +* When CDP is enabled, update the schema for both CDP_DATA and CDP_CODE. +* Since the buffer is altered during parsing, create a copy to handle +* peer schemata separately. +*/ +if (resctrl_arch_get_cdp_enabled (r->rid)) { + peer_type =resctrl_peer_type (s->conf_type); + peer_s =resctrl_get_schema (peer_type); + peer_buf =kmalloc (nbytes,GFP_KERNEL ); +if (!peer_buf) { +rdt_last_cmd_puts ("Out of Memory - io_alloc update failed\n" ); + ret = -ENOMEM ; + goto out_unlock; + } +
Quoted 8 lines
fs/resctrl/rdtgroup.c static int resctrl_io_alloc_cbm_show(struct kernfs_open_file *of, · line 2127
Quoted 4 lines
fs/resctrl/rdtgroup.c +4
-0+memcpy (peer_buf, buf, nbytes); + +if (peer_s) + ret =resctrl_io_alloc_parse_line (peer_buf, r, peer_s, io_alloc_closid);Similar to
resctrl_io_alloc_write()this looks unnecessary. I think this can be simplified by moving the CDP check toresctrl_io_alloc_parse_line()where the provided CBM can be parsed *once* and the staged config of a CDP type just copied to the staged config of its peer type.
Yes. Changed it now.
Quoted 39 lines
Quoted 26 lines
fs/resctrl/rdtgroup.c +20
-0+ +kfree (peer_buf); + } + +if (!ret) + ret =resctrl_io_alloc_parse_line (buf, r, s, io_alloc_closid); + +if (ret) + goto out_unlock; + + ret =resctrl_arch_update_domains (r, io_alloc_closid); + +out_unlock: +rdt_staged_configs_clear (); +mutex_unlock (&rdtgroup_mutex); +cpus_read_unlock (); + +return ret ?: nbytes; +} +/* rdtgroup information files for one cache resource. */ static struct rftype res_common_files[] = { {@@ -2135,9 +2244,10 @@ static struct rftype res_common_files[] = { },fs/resctrl/rdtgroup.c static struct rftype res_common_files[] = { · line 2253
Quoted 10 lines
fs/resctrl/rdtgroup.c +2
-1{ .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",Reinette
Signature · 2 lines
Thanks Babu Moger
Reinette Chatre
maintainerHi Babu,
Quoted 12 lines · Babu Moger
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.
Quoted 6 lines
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_nregister, where n is the maximum supported CLOSID.
Even though this CLOSID use is unique to AMD this implementation makes it part of resctrl fs's support of io_alloc. It is confusing to have architectural specific features be handled by resctrl fs so I think it will be useful to add a snippet here to help folks trying to decipher this work. Consider for example a snippet like:
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.
Quoted 19 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.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 (6.16.0-rc5) commit
b4ec95e3bc3f("Merge x86/microcode into tip/master")# Linux Implementation
Feature adds following interface files when the resctrl "
io_alloc" feature is supported on the resource:
Quoted 8 lines
/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 whenio_allocfeature is enabled. Configure the CBM by writing to the interface.When CDP is enabled, these files will be created both in L3CODE and L3DATA.
"will be" -> "are"
Quoted 15 lines
# Examples:
a. Check if
io_allocfeature is available# mount -t resctrl resctrl /sys/fs/resctrl/# cat /sys/fs/resctrl/info/L3/io_alloc disabledb. Enable the
io_allocfeature.# echo 1 > /sys/fs/resctrl/info/L3/io_alloc # cat /sys/fs/resctrl/info/L3/io_alloc enabled
Quoted 6 lines
c. Check the CBM values for the
io_allocfeature.# cat /sys/fs/resctrl/info/L3/io_alloc_cbm 0=ffff;1=ffffd. Change the CBM value for the domain 1:
"for the domain 1" -> "of domain 1"?
(nit: inconsistent use of "." vs. ":" in items)
Quoted 7 lines
# echo 1=FF > /sys/fs/resctrl/info/L3/io_alloc_cbm# cat /sys/fs/resctrl/info/L3/io_alloc_cbm 0=ffff;1=00ffd. Disable
io_allocfeature and exit.
Quoted 7 lines
# echo 0 > /sys/fs/resctrl/info/L3/io_alloc # cat /sys/fs/resctrl/info/L3/io_alloc disabled# umount /sys/fs/resctrl/---
Reinette
Moger, Babu
reviewerHi Reinette,
Quoted 28 lines · Reinette Chatre
Hi Babu,
Quoted 12 lines · Babu Moger
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.
Quoted 6 lines
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_nregister, where n is the maximum supported CLOSID.Even though this CLOSID use is unique to AMD this implementation makes it part of resctrl fs's support of
io_alloc. It is confusing to have architectural specific features be handled by resctrl fs so I think it will be useful to add a snippet here to help folks trying to decipher this work. Consider for example a snippet like:
Quoted 6 lines
Since CLOSIDs are managed by resctrl fs it is least invasive to make the "
io_allocis supported by maximum supported CLOSID" part of the initial resctrl fs support forio_alloc. Take care not to expose this use of CLOSID forio_allocto user space so that this is not required from other architectures that may supportio_allocdifferently in the future.
Sure.
Quoted 22 lines
Quoted 22 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.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 (6.16.0-rc5) commit
b4ec95e3bc3f("Merge x86/microcode into tip/master")# 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.
Quoted 8 lines
Quoted 5 lines
/sys/fs/resctrl/info/L3/io_alloc_cbm: List the Capacity Bit Masks (CBMs) available
for I/O devices whenio_allocfeature is enabled. Configure the CBM by writing to the interface.When CDP is enabled, these files will be created both in L3CODE and L3DATA.
"will be" -> "are"
Sure.
Quoted 15 lines
Quoted 15 lines
# Examples:
a. Check if
io_allocfeature is available# mount -t resctrl resctrl /sys/fs/resctrl/# cat /sys/fs/resctrl/info/L3/io_alloc disabledb. Enable the
io_allocfeature.# echo 1 > /sys/fs/resctrl/info/L3/io_alloc # cat /sys/fs/resctrl/info/L3/io_alloc enabled
Quoted 8 lines
Quoted 6 lines
c. Check the CBM values for the
io_allocfeature.# cat /sys/fs/resctrl/info/L3/io_alloc_cbm 0=ffff;1=ffffd. Change the CBM value for the domain 1:
"for the domain 1" -> "of domain 1"?
Sure.
Quoted 2 lines
(nit: inconsistent use of "." vs. ":" in items)
Fixed it.
Quoted 19 lines
Quoted 8 lines
# echo 1=FF > /sys/fs/resctrl/info/L3/io_alloc_cbm# cat /sys/fs/resctrl/info/L3/io_alloc_cbm 0=ffff;1=00ffd. Disable
io_allocfeature and exit.Quoted 7 lines
# echo 0 > /sys/fs/resctrl/info/L3/io_alloc # cat /sys/fs/resctrl/info/L3/io_alloc disabled# umount /sys/fs/resctrl/---
Reinette
Signature · 2 lines
Thanks Babu Moger