2023-09-29 13:13:03

by Maciej Wieczor-Retman

[permalink] [raw]
Subject: [PATCH v3 0/4] x86/resctrl: Non-contiguous bitmasks in Intel CAT

Until recently Intel CPUs didn't support using non-contiguous 1s
in Cache Allocation Technology (CAT). Writing a bitmask with
non-contiguous 1s to the resctrl schemata file would fail.

Intel CPUs that support non-contiguous 1s can be identified through a
CPUID leaf mentioned in the "Intel® 64 and IA-32 Architectures
Software Developer’s Manual" document available at:
https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html

Add kernel support for detecting if non-contiguous 1s in Cache
Allocation Technology (CAT) are supported by the hardware. Also add a
new resctrl FS file to output this information to the userspace.
Keep the hardcoded value for Haswell CPUs only since they do not have
CPUID enumeration support for Cache allocation.

Since the selftests/resctrl files are going through many rewrites and
cleanups the appropriate selftest is still a work in progress. For
basic selftesting capabilities use the bash script attached below this
paragraph. It checks whether various bitmasks written into resctrl FS
generate output consistent with reported feature support.

Changelog v3:
- Add Peter's tested-by and reviewed-by tags.
- Change patch order to make 4th one the 1st.
- Add error checking to schema_len variable.
- Update cover letter since now the feature has moved from the SDM.

Changelog v2:
- Change git signature from Wieczor-Retman Maciej to Maciej
Wieczor-Retman.
- Change bitmap naming convention to bit mask.
- Add patch to change arch_has_sparce_bitmaps name to match bitmask
naming convention.

Fenghua Yu (2):
x86/resctrl: Add sparse_masks file in info
Documentation/x86: Document resctrl's new sparse_masks

Maciej Wieczor-Retman (2):
x86/resctrl: Rename arch_has_sparse_bitmaps
x86/resctrl: Enable non-contiguous CBMs in Intel CAT

Documentation/arch/x86/resctrl.rst | 16 ++++++++++++----
arch/x86/kernel/cpu/resctrl/core.c | 11 +++++++----
arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 14 ++++++++------
arch/x86/kernel/cpu/resctrl/internal.h | 9 +++++++++
arch/x86/kernel/cpu/resctrl/rdtgroup.c | 18 ++++++++++++++++++
include/linux/resctrl.h | 4 ++--
6 files changed, 56 insertions(+), 16 deletions(-)


base-commit: 27bbf45eae9ca98877a2d52a92a188147cd61b07
--
2.42.0


2023-09-30 03:36:53

by Maciej Wieczor-Retman

[permalink] [raw]
Subject: [PATCH v3 3/4] x86/resctrl: Add sparse_masks file in info

From: Fenghua Yu <[email protected]>

Add the interface in resctrl FS to show if sparse cache allocation
bit masks are supported on the platform. Reading the file returns
either a "1" if non-contiguous 1s are supported and "0" otherwise.
The file path is /sys/fs/resctrl/info/{resource}/sparse_masks, where
{resource} can be either "L2" or "L3".

Signed-off-by: Fenghua Yu <[email protected]>
Reviewed-by: Peter Newman <[email protected]>
Tested-by: Peter Newman <[email protected]>
Signed-off-by: Maciej Wieczor-Retman <[email protected]>
---
Changelog v3:
- Add Peter's tested-by and reviewed-by tags.
- Reword patch message slightly. (Reinette)

Changelog v2:
- Change bitmap naming convention to bit mask. (Reinette)
- Change file name to "sparse_masks". (Reinette)

arch/x86/kernel/cpu/resctrl/rdtgroup.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)

diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
index 725344048f85..945801898a4d 100644
--- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
+++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
@@ -895,6 +895,17 @@ static int rdt_shareable_bits_show(struct kernfs_open_file *of,
return 0;
}

+static int rdt_has_sparse_bitmasks_show(struct kernfs_open_file *of,
+ struct seq_file *seq, void *v)
+{
+ struct resctrl_schema *s = of->kn->parent->priv;
+ struct rdt_resource *r = s->res;
+
+ seq_printf(seq, "%u\n", r->cache.arch_has_sparse_bitmasks);
+
+ return 0;
+}
+
/**
* rdt_bit_usage_show - Display current usage of resources
*
@@ -1839,6 +1850,13 @@ static struct rftype res_common_files[] = {
.seq_show = rdtgroup_size_show,
.fflags = RF_CTRL_BASE,
},
+ {
+ .name = "sparse_masks",
+ .mode = 0444,
+ .kf_ops = &rdtgroup_kf_single_ops,
+ .seq_show = rdt_has_sparse_bitmasks_show,
+ .fflags = RF_CTRL_INFO | RFTYPE_RES_CACHE,
+ },

};

--
2.42.0

2023-09-30 06:34:05

by Reinette Chatre

[permalink] [raw]
Subject: Re: [PATCH v3 0/4] x86/resctrl: Non-contiguous bitmasks in Intel CAT

Hi Maciej,

On 9/29/2023 2:00 AM, Maciej Wieczor-Retman wrote:
> Add kernel support for detecting if non-contiguous 1s in Cache
> Allocation Technology (CAT) are supported by the hardware. Also add a
> new resctrl FS file to output this information to the userspace.
> Keep the hardcoded value for Haswell CPUs only since they do not have
> CPUID enumeration support for Cache allocation.

This series looks good to me.

I do have one comment that applies to all patches: Could you please
take a look at the "Ordering of commit tags" section within
Documentation/process/maintainer-tip.rst and apply it to all patches
in this series?

With that done you can add:
Reviewed-by: Reinette Chatre <[email protected]>

Thank you.

Reinette



2023-10-02 14:10:51

by Maciej Wieczor-Retman

[permalink] [raw]
Subject: Re: [PATCH v3 0/4] x86/resctrl: Non-contiguous bitmasks in Intel CAT

On 2023-09-29 at 13:30:22 -0700, Reinette Chatre wrote:
>Hi Maciej,
>
>On 9/29/2023 2:00 AM, Maciej Wieczor-Retman wrote:
>> Add kernel support for detecting if non-contiguous 1s in Cache
>> Allocation Technology (CAT) are supported by the hardware. Also add a
>> new resctrl FS file to output this information to the userspace.
>> Keep the hardcoded value for Haswell CPUs only since they do not have
>> CPUID enumeration support for Cache allocation.
>
>This series looks good to me.
>
>I do have one comment that applies to all patches: Could you please
>take a look at the "Ordering of commit tags" section within
>Documentation/process/maintainer-tip.rst and apply it to all patches
>in this series?
>
>With that done you can add:
>Reviewed-by: Reinette Chatre <[email protected]>
>
>Thank you.
>
>Reinette
>

Sure, I'll fix the ordering, thank you for reviewing!

--
Kind regards
Maciej Wiecz?r-Retman