Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1478824 > unrolled thread
| Started by | "Fenghua Yu" <fenghua.yu@intel.com> |
|---|---|
| First post | 2016-09-08 09:00 +0200 |
| Last post | 2016-09-08 12:20 +0200 |
| Articles | 20 on this page of 63 — 6 participants |
Back to article view | Back to linux.kernel
[PATCH v2 00/33] Enable Intel Resource Allocation in Resource Director Technology "Fenghua Yu" <fenghua.yu@intel.com> - 2016-09-08 09:00 +0200
[PATCH v2 32/33] MAINTAINERS: Add maintainer for Intel RDT resource allocation "Fenghua Yu" <fenghua.yu@intel.com> - 2016-09-08 09:00 +0200
[PATCH v2 30/33] x86/intel_rdt_rdtgroup.c: Process schemata input from resctrl interface "Fenghua Yu" <fenghua.yu@intel.com> - 2016-09-08 09:00 +0200
Re: [PATCH v2 30/33] x86/intel_rdt_rdtgroup.c: Process schemata input from resctrl interface Thomas Gleixner <tglx@linutronix.de> - 2016-09-09 00:30 +0200
[PATCH v2 31/33] Documentation/kernel-parameters: Add kernel parameter "resctrl" for CAT "Fenghua Yu" <fenghua.yu@intel.com> - 2016-09-08 09:00 +0200
Re: [PATCH v2 31/33] Documentation/kernel-parameters: Add kernel parameter "resctrl" for CAT Thomas Gleixner <tglx@linutronix.de> - 2016-09-09 00:30 +0200
[PATCH v2 28/33] x86/intel_rdt_rdtgroup.c: Read and write cpus "Fenghua Yu" <fenghua.yu@intel.com> - 2016-09-08 09:10 +0200
Re: [PATCH v2 28/33] x86/intel_rdt_rdtgroup.c: Read and write cpus Thomas Gleixner <tglx@linutronix.de> - 2016-09-08 22:30 +0200
[PATCH v2 24/33] x86/intel_rdt_rdtgroup.c: Create info directory "Fenghua Yu" <fenghua.yu@intel.com> - 2016-09-08 09:10 +0200
Re: [PATCH v2 24/33] x86/intel_rdt_rdtgroup.c: Create info directory Thomas Gleixner <tglx@linutronix.de> - 2016-09-08 18:10 +0200
[PATCH v2 11/33] x86/intel_rdt: Hot cpu support for Cache Allocation "Fenghua Yu" <fenghua.yu@intel.com> - 2016-09-08 09:10 +0200
Re: [PATCH v2 11/33] x86/intel_rdt: Hot cpu support for Cache Allocation Thomas Gleixner <tglx@linutronix.de> - 2016-09-08 12:10 +0200
[PATCH v2 13/33] Define CONFIG_INTEL_RDT "Fenghua Yu" <fenghua.yu@intel.com> - 2016-09-08 09:10 +0200
Re: [PATCH v2 13/33] Define CONFIG_INTEL_RDT Thomas Gleixner <tglx@linutronix.de> - 2016-09-08 12:20 +0200
[PATCH v2 08/33] x86/intel_rdt: Add Class of service management "Fenghua Yu" <fenghua.yu@intel.com> - 2016-09-08 09:10 +0200
Re: [PATCH v2 08/33] x86/intel_rdt: Add Class of service management Thomas Gleixner <tglx@linutronix.de> - 2016-09-08 11:00 +0200
[PATCH v2 22/33] x86/intel_rdt.c: Extend RDT to per cache and per resources "Fenghua Yu" <fenghua.yu@intel.com> - 2016-09-08 09:10 +0200
Re: [PATCH v2 22/33] x86/intel_rdt.c: Extend RDT to per cache and per resources Thomas Gleixner <tglx@linutronix.de> - 2016-09-08 17:10 +0200
[PATCH v2 20/33] x86/intel_rdt.h: Header for inter_rdt.c "Fenghua Yu" <fenghua.yu@intel.com> - 2016-09-08 09:10 +0200
Re: [PATCH v2 20/33] x86/intel_rdt.h: Header for inter_rdt.c Thomas Gleixner <tglx@linutronix.de> - 2016-09-08 14:40 +0200
[PATCH v2 10/33] x86/intel_rdt: Implement scheduling support for Intel RDT "Fenghua Yu" <fenghua.yu@intel.com> - 2016-09-08 09:10 +0200
Re: [PATCH v2 10/33] x86/intel_rdt: Implement scheduling support for Intel RDT Thomas Gleixner <tglx@linutronix.de> - 2016-09-08 12:00 +0200
[PATCH v2 16/33] x86/intel_rdt: Class of service and capacity bitmask management for CDP "Fenghua Yu" <fenghua.yu@intel.com> - 2016-09-08 09:10 +0200
Re: [PATCH v2 16/33] x86/intel_rdt: Class of service and capacity bitmask management for CDP Thomas Gleixner <tglx@linutronix.de> - 2016-09-08 12:40 +0200
[PATCH v2 04/33] drivers/base/cacheinfo.c: Export some cacheinfo functions for others to use "Fenghua Yu" <fenghua.yu@intel.com> - 2016-09-08 09:10 +0200
Re: [PATCH v2 04/33] drivers/base/cacheinfo.c: Export some cacheinfo functions for others to use Thomas Gleixner <tglx@linutronix.de> - 2016-09-08 10:30 +0200
[PATCH v2 25/33] include/linux/resctrl.h: Define fork and exit functions in a new header file "Fenghua Yu" <fenghua.yu@intel.com> - 2016-09-08 09:10 +0200
Re: [PATCH v2 25/33] include/linux/resctrl.h: Define fork and exit functions in a new header file Thomas Gleixner <tglx@linutronix.de> - 2016-09-08 18:20 +0200
[PATCH v2 27/33] x86/intel_rdt_rdtgroup.c: Implement resctrl file system commands "Fenghua Yu" <fenghua.yu@intel.com> - 2016-09-08 09:10 +0200
Re: [PATCH v2 27/33] x86/intel_rdt_rdtgroup.c: Implement resctrl file system commands Thomas Gleixner <tglx@linutronix.de> - 2016-09-08 22:20 +0200
Re: [PATCH v2 27/33] x86/intel_rdt_rdtgroup.c: Implement resctrl file system commands Fenghua Yu <fenghua.yu@intel.com> - 2016-09-09 00:30 +0200
[PATCH v2 29/33] x86/intel_rdt_rdtgroup.c: Tasks iterator and write "Fenghua Yu" <fenghua.yu@intel.com> - 2016-09-08 09:10 +0200
Re: [PATCH v2 29/33] x86/intel_rdt_rdtgroup.c: Tasks iterator and write Thomas Gleixner <tglx@linutronix.de> - 2016-09-08 23:00 +0200
[PATCH v2 17/33] x86/intel_rdt: Hot cpu update for code data prioritization "Fenghua Yu" <fenghua.yu@intel.com> - 2016-09-08 09:10 +0200
Re: [PATCH v2 17/33] x86/intel_rdt: Hot cpu update for code data prioritization Thomas Gleixner <tglx@linutronix.de> - 2016-09-08 12:40 +0200
[PATCH v2 06/33] Documentation, x86: Documentation for Intel resource allocation user interface "Fenghua Yu" <fenghua.yu@intel.com> - 2016-09-08 09:10 +0200
Re: [PATCH v2 06/33] Documentation, x86: Documentation for Intel resource allocation user interface Borislav Petkov <bp@suse.de> - 2016-09-08 13:30 +0200
Re: [PATCH v2 06/33] Documentation, x86: Documentation for Intel resource allocation user interface Fenghua Yu <fenghua.yu@intel.com> - 2016-09-09 00:20 +0200
Re: [PATCH v2 06/33] Documentation, x86: Documentation for Intel resource allocation user interface Fenghua Yu <fenghua.yu@intel.com> - 2016-09-09 06:30 +0200
[PATCH v2 03/33] x86, intel_cacheinfo: Enable cache id in x86 "Fenghua Yu" <fenghua.yu@intel.com> - 2016-09-08 09:10 +0200
[PATCH v2 09/33] x86/intel_rdt: Add L3 cache capacity bitmask management "Fenghua Yu" <fenghua.yu@intel.com> - 2016-09-08 09:10 +0200
Re: [PATCH v2 09/33] x86/intel_rdt: Add L3 cache capacity bitmask management Thomas Gleixner <tglx@linutronix.de> - 2016-09-08 11:50 +0200
[PATCH v2 07/33] x86/intel_rdt: Add support for Cache Allocation detection "Fenghua Yu" <fenghua.yu@intel.com> - 2016-09-08 09:10 +0200
Re: [PATCH v2 07/33] x86/intel_rdt: Add support for Cache Allocation detection Borislav Petkov <bp@suse.de> - 2016-09-08 14:00 +0200
RE: [PATCH v2 07/33] x86/intel_rdt: Add support for Cache Allocation detection "Yu, Fenghua" <fenghua.yu@intel.com> - 2016-09-08 19:00 +0200
Re: [PATCH v2 07/33] x86/intel_rdt: Add support for Cache Allocation detection Borislav Petkov <bp@suse.de> - 2016-09-08 19:20 +0200
Re: [PATCH v2 07/33] x86/intel_rdt: Add support for Cache Allocation detection Thomas Gleixner <tglx@linutronix.de> - 2016-09-08 15:20 +0200
RE: [PATCH v2 07/33] x86/intel_rdt: Add support for Cache Allocation detection "Yu, Fenghua" <fenghua.yu@intel.com> - 2016-09-08 16:00 +0200
[PATCH v2 01/33] cacheinfo: Introduce cache id "Fenghua Yu" <fenghua.yu@intel.com> - 2016-09-08 09:10 +0200
[PATCH v2 05/33] x86/intel_rdt: Cache Allocation documentation "Fenghua Yu" <fenghua.yu@intel.com> - 2016-09-08 09:10 +0200
[PATCH v2 19/33] magic number for resctrl file system "Fenghua Yu" <fenghua.yu@intel.com> - 2016-09-08 09:10 +0200
Re: [PATCH v2 19/33] magic number for resctrl file system Thomas Gleixner <tglx@linutronix.de> - 2016-09-08 12:50 +0200
Re: [PATCH v2 19/33] magic number for resctrl file system Borislav Petkov <bp@alien8.de> - 2016-09-08 12:50 +0200
[PATCH v2 21/33] x86/intel_rdt_rdtgroup.h: Header for user interface "Fenghua Yu" <fenghua.yu@intel.com> - 2016-09-08 09:10 +0200
Re: [PATCH v2 21/33] x86/intel_rdt_rdtgroup.h: Header for user interface Thomas Gleixner <tglx@linutronix.de> - 2016-09-08 14:50 +0200
[PATCH v2 26/33] Task fork and exit for rdtgroup "Fenghua Yu" <fenghua.yu@intel.com> - 2016-09-08 09:10 +0200
Re: [PATCH v2 26/33] Task fork and exit for rdtgroup Thomas Gleixner <tglx@linutronix.de> - 2016-09-08 21:50 +0200
[PATCH v2 18/33] sched.h: Add rg_list and rdtgroup in task_struct "Fenghua Yu" <fenghua.yu@intel.com> - 2016-09-08 09:10 +0200
Re: [PATCH v2 18/33] sched.h: Add rg_list and rdtgroup in task_struct Thomas Gleixner <tglx@linutronix.de> - 2016-09-08 12:40 +0200
[PATCH v2 02/33] Documentation, ABI: Add a document entry for cache id "Fenghua Yu" <fenghua.yu@intel.com> - 2016-09-08 09:10 +0200
Re: [PATCH v2 02/33] Documentation, ABI: Add a document entry for cache id Thomas Gleixner <tglx@linutronix.de> - 2016-09-08 21:40 +0200
[PATCH v2 12/33] x86/intel_rdt: Intel haswell Cache Allocation enumeration "Fenghua Yu" <fenghua.yu@intel.com> - 2016-09-08 09:10 +0200
Re: [PATCH v2 12/33] x86/intel_rdt: Intel haswell Cache Allocation enumeration Thomas Gleixner <tglx@linutronix.de> - 2016-09-08 12:20 +0200
Page 3 of 4 — ← Prev page 1 2 [3] 4 Next page →
| From | "Fenghua Yu" <fenghua.yu@intel.com> |
|---|---|
| Date | 2016-09-08 09:10 +0200 |
| Subject | [PATCH v2 09/33] x86/intel_rdt: Add L3 cache capacity bitmask management |
| Message-ID | <sf1Dc-2F3-41@gated-at.bofh.it> |
| In reply to | #1478824 |
From: Vikas Shivappa <vikas.shivappa@linux.intel.com>
This patch adds different APIs to manage the L3 cache capacity bitmask.
The capacity bit mask(CBM) needs to have only contiguous bits set. The
current implementation has a global CBM for each class of service id.
There are APIs added to update the CBM via MSR write to IA32_L3_MASK_n
on all packages. Other APIs are to read and write entries to the
clos_cbm_table.
Signed-off-by: Vikas Shivappa <vikas.shivappa@linux.intel.com>
Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
Reviewed-by: Tony Luck <tony.luck@intel.com>
---
arch/x86/include/asm/intel_rdt.h | 4 ++++
arch/x86/kernel/cpu/intel_rdt.c | 48 +++++++++++++++++++++++++++++++++++++++-
2 files changed, 51 insertions(+), 1 deletion(-)
diff --git a/arch/x86/include/asm/intel_rdt.h b/arch/x86/include/asm/intel_rdt.h
index 68bab26..68c9a79 100644
--- a/arch/x86/include/asm/intel_rdt.h
+++ b/arch/x86/include/asm/intel_rdt.h
@@ -3,6 +3,10 @@
#ifdef CONFIG_INTEL_RDT
+#define MAX_CBM_LENGTH 32
+#define IA32_L3_CBM_BASE 0xc90
+#define CBM_FROM_INDEX(x) (IA32_L3_CBM_BASE + x)
+
struct clos_cbm_table {
unsigned long cbm;
unsigned int clos_refcnt;
diff --git a/arch/x86/kernel/cpu/intel_rdt.c b/arch/x86/kernel/cpu/intel_rdt.c
index b25940a..9cf3a7d 100644
--- a/arch/x86/kernel/cpu/intel_rdt.c
+++ b/arch/x86/kernel/cpu/intel_rdt.c
@@ -31,8 +31,22 @@ static struct clos_cbm_table *cctable;
* closid availability bit map.
*/
unsigned long *closmap;
+/*
+ * Mask of CPUs for writing CBM values. We only need one CPU per-socket.
+ */
+static cpumask_t rdt_cpumask;
+/*
+ * Temporary cpumask used during hot cpu notificaiton handling. The usage
+ * is serialized by hot cpu locks.
+ */
+static cpumask_t tmp_cpumask;
static DEFINE_MUTEX(rdtgroup_mutex);
+struct rdt_remote_data {
+ int msr;
+ u64 val;
+};
+
static inline void closid_get(u32 closid)
{
struct clos_cbm_table *cct = &cctable[closid];
@@ -79,11 +93,41 @@ static void closid_put(u32 closid)
closid_free(closid);
}
+static void msr_cpu_update(void *arg)
+{
+ struct rdt_remote_data *info = arg;
+
+ wrmsrl(info->msr, info->val);
+}
+
+/*
+ * msr_update_all() - Update the msr for all packages.
+ */
+static inline void msr_update_all(int msr, u64 val)
+{
+ struct rdt_remote_data info;
+
+ info.msr = msr;
+ info.val = val;
+ on_each_cpu_mask(&rdt_cpumask, msr_cpu_update, &info, 1);
+}
+
+static inline bool rdt_cpumask_update(int cpu)
+{
+ cpumask_and(&tmp_cpumask, &rdt_cpumask, topology_core_cpumask(cpu));
+ if (cpumask_empty(&tmp_cpumask)) {
+ cpumask_set_cpu(cpu, &rdt_cpumask);
+ return true;
+ }
+
+ return false;
+}
+
static int __init intel_rdt_late_init(void)
{
struct cpuinfo_x86 *c = &boot_cpu_data;
u32 maxid;
- int err = 0, size;
+ int err = 0, size, i;
if (!cpu_has(c, X86_FEATURE_CAT_L3))
return -ENODEV;
@@ -105,6 +149,8 @@ static int __init intel_rdt_late_init(void)
goto out_err;
}
+ for_each_online_cpu(i)
+ rdt_cpumask_update(i);
pr_info("Intel cache allocation enabled\n");
out_err:
--
2.5.0
[toc] | [prev] | [next] | [standalone]
| From | Thomas Gleixner <tglx@linutronix.de> |
|---|---|
| Date | 2016-09-08 11:50 +0200 |
| Subject | Re: [PATCH v2 09/33] x86/intel_rdt: Add L3 cache capacity bitmask management |
| Message-ID | <sf482-44o-21@gated-at.bofh.it> |
| In reply to | #1478846 |
On Thu, 8 Sep 2016, Fenghua Yu wrote: > > + for_each_online_cpu(i) > + rdt_cpumask_update(i); The only reason why this does not blow up in your face is that at this point the secondary cpus have been brought up already and user space is not yet running, so cpu hotplug cannot happen in parallel. Protection by chance is never a good idea. Thanks, tglx
[toc] | [prev] | [next] | [standalone]
| From | "Fenghua Yu" <fenghua.yu@intel.com> |
|---|---|
| Date | 2016-09-08 09:10 +0200 |
| Subject | [PATCH v2 07/33] x86/intel_rdt: Add support for Cache Allocation detection |
| Message-ID | <sf1Dc-2F3-43@gated-at.bofh.it> |
| In reply to | #1478824 |
From: Vikas Shivappa <vikas.shivappa@linux.intel.com>
This patch includes CPUID enumeration routines for Cache allocation and
new values to track resources to the cpuinfo_x86 structure.
Cache allocation provides a way for the Software (OS/VMM) to restrict
cache allocation to a defined 'subset' of cache which may be overlapping
with other 'subsets'. This feature is used when allocating a line in
cache ie when pulling new data into the cache. The programming of the
hardware is done via programming MSRs (model specific registers).
Signed-off-by: Vikas Shivappa <vikas.shivappa@linux.intel.com>
Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
Reviewed-by: Tony Luck <tony.luck@intel.com>
---
arch/x86/include/asm/cpufeature.h | 8 +++++--
arch/x86/include/asm/cpufeatures.h | 6 +++++-
arch/x86/include/asm/disabled-features.h | 3 ++-
arch/x86/include/asm/processor.h | 3 +++
arch/x86/include/asm/required-features.h | 3 ++-
arch/x86/kernel/cpu/common.c | 19 ++++++++++++++++
arch/x86/kernel/cpu/intel_rdt.c | 37 ++++++++++++++++++++++++++++++++
7 files changed, 74 insertions(+), 5 deletions(-)
create mode 100644 arch/x86/kernel/cpu/intel_rdt.c
diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
index 1d2b69f..9985b4cf 100644
--- a/arch/x86/include/asm/cpufeature.h
+++ b/arch/x86/include/asm/cpufeature.h
@@ -28,6 +28,8 @@ enum cpuid_leafs
CPUID_8000_000A_EDX,
CPUID_7_ECX,
CPUID_8000_0007_EBX,
+ CPUID_10_0_EBX,
+ CPUID_10_1_ECX,
};
#ifdef CONFIG_X86_FEATURE_NAMES
@@ -78,8 +80,9 @@ extern const char * const x86_bug_flags[NBUGINTS*32];
CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 15, feature_bit) || \
CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 16, feature_bit) || \
CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 17, feature_bit) || \
+ CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 18, feature_bit) || \
REQUIRED_MASK_CHECK || \
- BUILD_BUG_ON_ZERO(NCAPINTS != 18))
+ BUILD_BUG_ON_ZERO(NCAPINTS != 19))
#define DISABLED_MASK_BIT_SET(feature_bit) \
( CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 0, feature_bit) || \
@@ -100,8 +103,9 @@ extern const char * const x86_bug_flags[NBUGINTS*32];
CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 15, feature_bit) || \
CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 16, feature_bit) || \
CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 17, feature_bit) || \
+ CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 18, feature_bit) || \
DISABLED_MASK_CHECK || \
- BUILD_BUG_ON_ZERO(NCAPINTS != 18))
+ BUILD_BUG_ON_ZERO(NCAPINTS != 19))
#define cpu_has(c, bit) \
(__builtin_constant_p(bit) && REQUIRED_MASK_BIT_SET(bit) ? 1 : \
diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h
index 92a8308..62d979b9 100644
--- a/arch/x86/include/asm/cpufeatures.h
+++ b/arch/x86/include/asm/cpufeatures.h
@@ -12,7 +12,7 @@
/*
* Defines x86 CPU feature bits
*/
-#define NCAPINTS 18 /* N 32-bit words worth of info */
+#define NCAPINTS 19 /* N 32-bit words worth of info */
#define NBUGINTS 1 /* N 32-bit bug flags */
/*
@@ -220,6 +220,7 @@
#define X86_FEATURE_RTM ( 9*32+11) /* Restricted Transactional Memory */
#define X86_FEATURE_CQM ( 9*32+12) /* Cache QoS Monitoring */
#define X86_FEATURE_MPX ( 9*32+14) /* Memory Protection Extension */
+#define X86_FEATURE_RDT ( 9*32+15) /* Resource Director Technology */
#define X86_FEATURE_AVX512F ( 9*32+16) /* AVX-512 Foundation */
#define X86_FEATURE_AVX512DQ ( 9*32+17) /* AVX-512 DQ (Double/Quad granular) Instructions */
#define X86_FEATURE_RDSEED ( 9*32+18) /* The RDSEED instruction */
@@ -286,6 +287,9 @@
#define X86_FEATURE_SUCCOR (17*32+1) /* Uncorrectable error containment and recovery */
#define X86_FEATURE_SMCA (17*32+3) /* Scalable MCA */
+/* Intel-defined CPU features, CPUID level 0x00000010:0 (ebx), word 18 */
+#define X86_FEATURE_CAT_L3 (18*32+ 1) /* Cache Allocation L3 */
+
/*
* BUG word(s)
*/
diff --git a/arch/x86/include/asm/disabled-features.h b/arch/x86/include/asm/disabled-features.h
index 85599ad..8b45e08 100644
--- a/arch/x86/include/asm/disabled-features.h
+++ b/arch/x86/include/asm/disabled-features.h
@@ -57,6 +57,7 @@
#define DISABLED_MASK15 0
#define DISABLED_MASK16 (DISABLE_PKU|DISABLE_OSPKE)
#define DISABLED_MASK17 0
-#define DISABLED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 18)
+#define DISABLED_MASK18 0
+#define DISABLED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 19)
#endif /* _ASM_X86_DISABLED_FEATURES_H */
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index 63def95..e940b2d 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -119,6 +119,9 @@ struct cpuinfo_x86 {
int x86_cache_occ_scale; /* scale to bytes */
int x86_power;
unsigned long loops_per_jiffy;
+ /* Cache Allocation values: */
+ u16 x86_l3_max_cbm_len;
+ u16 x86_l3_max_closid;
/* cpuid returned max cores value: */
u16 x86_max_cores;
u16 apicid;
diff --git a/arch/x86/include/asm/required-features.h b/arch/x86/include/asm/required-features.h
index fac9a5c..6847d85 100644
--- a/arch/x86/include/asm/required-features.h
+++ b/arch/x86/include/asm/required-features.h
@@ -100,6 +100,7 @@
#define REQUIRED_MASK15 0
#define REQUIRED_MASK16 0
#define REQUIRED_MASK17 0
-#define REQUIRED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 18)
+#define REQUIRED_MASK18 0
+#define REQUIRED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 19)
#endif /* _ASM_X86_REQUIRED_FEATURES_H */
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 809eda0..997d1d5 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -711,6 +711,25 @@ void get_cpu_cap(struct cpuinfo_x86 *c)
}
}
+ /* Additional Intel-defined flags: level 0x00000010 */
+ if (c->cpuid_level >= 0x00000010) {
+ u32 eax, ebx, ecx, edx;
+
+ cpuid_count(0x00000010, 0, &eax, &ebx, &ecx, &edx);
+ c->x86_capability[CPUID_10_0_EBX] = ebx;
+
+ if (cpu_has(c, X86_FEATURE_CAT_L3)) {
+
+ cpuid_count(0x00000010, 1, &eax, &ebx, &ecx, &edx);
+ c->x86_l3_max_closid = edx + 1;
+ c->x86_l3_max_cbm_len = eax + 1;
+ c->x86_capability[CPUID_10_1_ECX] = ecx;
+ } else {
+ c->x86_l3_max_closid = -1;
+ c->x86_l3_max_cbm_len = -1;
+ }
+ }
+
/* AMD-defined flags: level 0x80000001 */
eax = cpuid_eax(0x80000000);
c->extended_cpuid_level = eax;
diff --git a/arch/x86/kernel/cpu/intel_rdt.c b/arch/x86/kernel/cpu/intel_rdt.c
new file mode 100644
index 0000000..fcd0642
--- /dev/null
+++ b/arch/x86/kernel/cpu/intel_rdt.c
@@ -0,0 +1,37 @@
+/*
+ * Resource Director Technology(RDT)
+ * - Cache Allocation code.
+ *
+ * Copyright (C) 2014 Intel Corporation
+ *
+ * 2015-05-25 Written by
+ * Vikas Shivappa <vikas.shivappa@intel.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * More information about RDT be found in the Intel (R) x86 Architecture
+ * Software Developer Manual June 2015, volume 3, section 17.15.
+ */
+#include <linux/slab.h>
+#include <linux/err.h>
+
+static int __init intel_rdt_late_init(void)
+{
+ struct cpuinfo_x86 *c = &boot_cpu_data;
+
+ if (!cpu_has(c, X86_FEATURE_CAT_L3))
+ return -ENODEV;
+
+ pr_info("Intel cache allocation detected\n");
+
+ return 0;
+}
+
+late_initcall(intel_rdt_late_init);
--
2.5.0
[toc] | [prev] | [next] | [standalone]
| From | Borislav Petkov <bp@suse.de> |
|---|---|
| Date | 2016-09-08 14:00 +0200 |
| Subject | Re: [PATCH v2 07/33] x86/intel_rdt: Add support for Cache Allocation detection |
| Message-ID | <sf69Q-5kf-17@gated-at.bofh.it> |
| In reply to | #1478847 |
On Thu, Sep 08, 2016 at 02:57:01AM -0700, Fenghua Yu wrote:
> From: Vikas Shivappa <vikas.shivappa@linux.intel.com>
>
> This patch includes CPUID enumeration routines for Cache allocation and
> new values to track resources to the cpuinfo_x86 structure.
>
> Cache allocation provides a way for the Software (OS/VMM) to restrict
> cache allocation to a defined 'subset' of cache which may be overlapping
> with other 'subsets'. This feature is used when allocating a line in
> cache ie when pulling new data into the cache. The programming of the
> hardware is done via programming MSRs (model specific registers).
>
> Signed-off-by: Vikas Shivappa <vikas.shivappa@linux.intel.com>
> Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
> Reviewed-by: Tony Luck <tony.luck@intel.com>
> ---
...
> diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h
> index 92a8308..62d979b9 100644
> --- a/arch/x86/include/asm/cpufeatures.h
> +++ b/arch/x86/include/asm/cpufeatures.h
> @@ -12,7 +12,7 @@
> /*
> * Defines x86 CPU feature bits
> */
> -#define NCAPINTS 18 /* N 32-bit words worth of info */
> +#define NCAPINTS 19 /* N 32-bit words worth of info */
> #define NBUGINTS 1 /* N 32-bit bug flags */
>
> /*
> @@ -220,6 +220,7 @@
> #define X86_FEATURE_RTM ( 9*32+11) /* Restricted Transactional Memory */
> #define X86_FEATURE_CQM ( 9*32+12) /* Cache QoS Monitoring */
> #define X86_FEATURE_MPX ( 9*32+14) /* Memory Protection Extension */
> +#define X86_FEATURE_RDT ( 9*32+15) /* Resource Director Technology */
> #define X86_FEATURE_AVX512F ( 9*32+16) /* AVX-512 Foundation */
> #define X86_FEATURE_AVX512DQ ( 9*32+17) /* AVX-512 DQ (Double/Quad granular) Instructions */
> #define X86_FEATURE_RDSEED ( 9*32+18) /* The RDSEED instruction */
> @@ -286,6 +287,9 @@
> #define X86_FEATURE_SUCCOR (17*32+1) /* Uncorrectable error containment and recovery */
> #define X86_FEATURE_SMCA (17*32+3) /* Scalable MCA */
>
> +/* Intel-defined CPU features, CPUID level 0x00000010:0 (ebx), word 18 */
Seems like this leaf is dedicated to CAT and has only 2 feature bits
defined in the SDM. Please use init_scattered_cpuid_features() instead
of adding a whole CAP word.
--
Regards/Gruss,
Boris.
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
--
[toc] | [prev] | [next] | [standalone]
| From | "Yu, Fenghua" <fenghua.yu@intel.com> |
|---|---|
| Date | 2016-09-08 19:00 +0200 |
| Subject | RE: [PATCH v2 07/33] x86/intel_rdt: Add support for Cache Allocation detection |
| Message-ID | <sfaQa-8hz-3@gated-at.bofh.it> |
| In reply to | #1479143 |
> From: Borislav Petkov [mailto:bp@suse.de] > On Thu, Sep 08, 2016 at 02:57:01AM -0700, Fenghua Yu wrote: > > From: Vikas Shivappa <vikas.shivappa@linux.intel.com> > > > > This patch includes CPUID enumeration routines for Cache allocation > > and new values to track resources to the cpuinfo_x86 structure. > > > > Cache allocation provides a way for the Software (OS/VMM) to restrict > > cache allocation to a defined 'subset' of cache which may be > > overlapping with other 'subsets'. This feature is used when allocating > > a line in cache ie when pulling new data into the cache. The > > programming of the hardware is done via programming MSRs (model > specific registers). > > > > Signed-off-by: Vikas Shivappa <vikas.shivappa@linux.intel.com> > > Signed-off-by: Fenghua Yu <fenghua.yu@intel.com> > > Reviewed-by: Tony Luck <tony.luck@intel.com> > > --- > > ... > > > diff --git a/arch/x86/include/asm/cpufeatures.h > > b/arch/x86/include/asm/cpufeatures.h > > index 92a8308..62d979b9 100644 > > --- a/arch/x86/include/asm/cpufeatures.h > > +++ b/arch/x86/include/asm/cpufeatures.h > > @@ -12,7 +12,7 @@ > > /* > > * Defines x86 CPU feature bits > > */ > > -#define NCAPINTS 18 /* N 32-bit words worth of info */ > > +#define NCAPINTS 19 /* N 32-bit words worth of info */ > > #define NBUGINTS 1 /* N 32-bit bug flags */ > > > > /* > > @@ -220,6 +220,7 @@ > > #define X86_FEATURE_RTM ( 9*32+11) /* Restricted Transactional > Memory */ > > #define X86_FEATURE_CQM ( 9*32+12) /* Cache QoS Monitoring > */ > > #define X86_FEATURE_MPX ( 9*32+14) /* Memory Protection > Extension */ > > +#define X86_FEATURE_RDT ( 9*32+15) /* Resource Director > Technology */ > > #define X86_FEATURE_AVX512F ( 9*32+16) /* AVX-512 Foundation */ > > #define X86_FEATURE_AVX512DQ ( 9*32+17) /* AVX-512 DQ > (Double/Quad granular) Instructions */ > > #define X86_FEATURE_RDSEED ( 9*32+18) /* The RDSEED instruction > */ > > @@ -286,6 +287,9 @@ > > #define X86_FEATURE_SUCCOR (17*32+1) /* Uncorrectable error > containment and recovery */ > > #define X86_FEATURE_SMCA (17*32+3) /* Scalable MCA */ > > > > +/* Intel-defined CPU features, CPUID level 0x00000010:0 (ebx), word > > +18 */ > > Seems like this leaf is dedicated to CAT and has only 2 feature bits defined in > the SDM. Please use init_scattered_cpuid_features() instead of adding a > whole CAP word. Actually this leaf will be extended to have more bits for more resources allocation. Thanks. -Fenghua
[toc] | [prev] | [next] | [standalone]
| From | Borislav Petkov <bp@suse.de> |
|---|---|
| Date | 2016-09-08 19:20 +0200 |
| Subject | Re: [PATCH v2 07/33] x86/intel_rdt: Add support for Cache Allocation detection |
| Message-ID | <sfb9v-bn-9@gated-at.bofh.it> |
| In reply to | #1479379 |
On Thu, Sep 08, 2016 at 04:53:52PM +0000, Yu, Fenghua wrote:
> Actually this leaf will be extended to have more bits for more
> resources allocation.
You can move it to a separate leaf then.
--
Regards/Gruss,
Boris.
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
--
[toc] | [prev] | [next] | [standalone]
| From | Thomas Gleixner <tglx@linutronix.de> |
|---|---|
| Date | 2016-09-08 15:20 +0200 |
| Subject | Re: [PATCH v2 07/33] x86/intel_rdt: Add support for Cache Allocation detection |
| Message-ID | <sf7pg-6h3-33@gated-at.bofh.it> |
| In reply to | #1478847 |
On Thu, 8 Sep 2016, Fenghua Yu wrote:
> + cpuid_count(0x00000010, 1, &eax, &ebx, &ecx, &edx);
> + c->x86_l3_max_closid = edx + 1;
> + c->x86_l3_max_cbm_len = eax + 1;
According to the SDM:
EAX Bits 4:0: Length of the capacity bit mask for the corresponding ResID.
Bits 31:05: Reserved
EDX Bits 15:0: Highest COS number supported for this ResID.
Bits 31:16: Reserved
So why are we assuming that bits 31-5 of EAX and 16-31 of EDX are going to
be zero forever and if not that they are just extending the existing bits?
If that's the case then we don't need to mask out the upper bits, but the
code wants a proper comment about this.
Thanks,
tglx
[toc] | [prev] | [next] | [standalone]
| From | "Yu, Fenghua" <fenghua.yu@intel.com> |
|---|---|
| Date | 2016-09-08 16:00 +0200 |
| Subject | RE: [PATCH v2 07/33] x86/intel_rdt: Add support for Cache Allocation detection |
| Message-ID | <sf81Y-6tT-23@gated-at.bofh.it> |
| In reply to | #1479218 |
> On Thu, 8 Sep 2016, Fenghua Yu wrote: > > + cpuid_count(0x00000010, 1, &eax, &ebx, &ecx, > &edx); > > + c->x86_l3_max_closid = edx + 1; > > + c->x86_l3_max_cbm_len = eax + 1; > > According to the SDM: > > EAX Bits 4:0: Length of the capacity bit mask for the corresponding ResID. > Bits 31:05: Reserved > > EDX Bits 15:0: Highest COS number supported for this ResID. > Bits 31:16: Reserved > > So why are we assuming that bits 31-5 of EAX and 16-31 of EDX are going to > be zero forever and if not that they are just extending the existing bits? > If that's the case then we don't need to mask out the upper bits, but the > code wants a proper comment about this. You are right. We cannot assume the upper bits are always zero. I fixed the issue by masking out the upper bits. Thanks. -Fenghua
[toc] | [prev] | [next] | [standalone]
| From | "Fenghua Yu" <fenghua.yu@intel.com> |
|---|---|
| Date | 2016-09-08 09:10 +0200 |
| Subject | [PATCH v2 01/33] cacheinfo: Introduce cache id |
| Message-ID | <sf1Dd-2F3-55@gated-at.bofh.it> |
| In reply to | #1478824 |
From: Fenghua Yu <fenghua.yu@intel.com>
Each cache is described by cacheinfo and is unique in the same index
across the platform. But there is no id for a cache. We introduce cache
ID to identify a cache.
Intel Cache Allocation Technology (CAT) allows some control on the
allocation policy within each cache that it controls. We need a unique
cache ID for each cache level to allow the user to specify which
controls are applied to which cache. Cache id is a concise way to specify
a cache.
Cache id is first enabled on x86. It can be enabled on other platforms
as well. The cache id is not necessary contiguous.
Add an "id" entry to /sys/devices/system/cpu/cpu*/cache/index*/
Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
Reviewed-by: Tony Luck <tony.luck@intel.com>
Acked-by: Borislav Petkov <bp@suse.com>
---
drivers/base/cacheinfo.c | 5 +++++
include/linux/cacheinfo.h | 3 +++
2 files changed, 8 insertions(+)
diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c
index e9fd32e..2a21c15 100644
--- a/drivers/base/cacheinfo.c
+++ b/drivers/base/cacheinfo.c
@@ -233,6 +233,7 @@ static ssize_t file_name##_show(struct device *dev, \
return sprintf(buf, "%u\n", this_leaf->object); \
}
+show_one(id, id);
show_one(level, level);
show_one(coherency_line_size, coherency_line_size);
show_one(number_of_sets, number_of_sets);
@@ -314,6 +315,7 @@ static ssize_t write_policy_show(struct device *dev,
return n;
}
+static DEVICE_ATTR_RO(id);
static DEVICE_ATTR_RO(level);
static DEVICE_ATTR_RO(type);
static DEVICE_ATTR_RO(coherency_line_size);
@@ -327,6 +329,7 @@ static DEVICE_ATTR_RO(shared_cpu_list);
static DEVICE_ATTR_RO(physical_line_partition);
static struct attribute *cache_default_attrs[] = {
+ &dev_attr_id.attr,
&dev_attr_type.attr,
&dev_attr_level.attr,
&dev_attr_shared_cpu_map.attr,
@@ -350,6 +353,8 @@ cache_default_attrs_is_visible(struct kobject *kobj,
const struct cpumask *mask = &this_leaf->shared_cpu_map;
umode_t mode = attr->mode;
+ if ((attr == &dev_attr_id.attr) && this_leaf->attributes & CACHE_ID)
+ return mode;
if ((attr == &dev_attr_type.attr) && this_leaf->type)
return mode;
if ((attr == &dev_attr_level.attr) && this_leaf->level)
diff --git a/include/linux/cacheinfo.h b/include/linux/cacheinfo.h
index 2189935..cf6984d 100644
--- a/include/linux/cacheinfo.h
+++ b/include/linux/cacheinfo.h
@@ -18,6 +18,7 @@ enum cache_type {
/**
* struct cacheinfo - represent a cache leaf node
+ * @id: This cache's id. ID is unique in the same index on the platform.
* @type: type of the cache - data, inst or unified
* @level: represents the hierarchy in the multi-level cache
* @coherency_line_size: size of each cache line usually representing
@@ -44,6 +45,7 @@ enum cache_type {
* keeping, the remaining members form the core properties of the cache
*/
struct cacheinfo {
+ unsigned int id;
enum cache_type type;
unsigned int level;
unsigned int coherency_line_size;
@@ -61,6 +63,7 @@ struct cacheinfo {
#define CACHE_WRITE_ALLOCATE BIT(3)
#define CACHE_ALLOCATE_POLICY_MASK \
(CACHE_READ_ALLOCATE | CACHE_WRITE_ALLOCATE)
+#define CACHE_ID BIT(4)
struct device_node *of_node;
bool disable_sysfs;
--
2.5.0
[toc] | [prev] | [next] | [standalone]
| From | "Fenghua Yu" <fenghua.yu@intel.com> |
|---|---|
| Date | 2016-09-08 09:10 +0200 |
| Subject | [PATCH v2 05/33] x86/intel_rdt: Cache Allocation documentation |
| Message-ID | <sf1Dd-2F3-57@gated-at.bofh.it> |
| In reply to | #1478824 |
From: Vikas Shivappa <vikas.shivappa@linux.intel.com> Adds a description of Cache allocation technology, overview of kernel framework implementation. The framework has APIs to manage class of service, capacity bitmask(CBM), scheduling support and other architecture specific implementation. The APIs are used to build the resctrl interface in later patches. Cache allocation is a sub-feature of Resource Director Technology (RDT) or Platform Shared resource control which provides support to control Platform shared resources like L3 cache. Cache Allocation Technology provides a way for the Software (OS/VMM) to restrict cache allocation to a defined 'subset' of cache which may be overlapping with other 'subsets'. This feature is used when allocating a line in cache ie when pulling new data into the cache. The tasks are grouped into CLOS (class of service). OS uses MSR writes to indicate the CLOSid of the thread when scheduling in and to indicate the cache capacity associated with the CLOSid. Currently cache allocation is supported for L3 cache. More information can be found in the Intel SDM June 2015, Volume 3, section 17.16. Signed-off-by: Vikas Shivappa <vikas.shivappa@linux.intel.com> Signed-off-by: Fenghua Yu <fenghua.yu@intel.com> Reviewed-by: Tony Luck <tony.luck@intel.com> --- Documentation/x86/intel_rdt.txt | 109 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 Documentation/x86/intel_rdt.txt diff --git a/Documentation/x86/intel_rdt.txt b/Documentation/x86/intel_rdt.txt new file mode 100644 index 0000000..05ec819 --- /dev/null +++ b/Documentation/x86/intel_rdt.txt @@ -0,0 +1,109 @@ + Intel RDT + --------- + +Copyright (C) 2014 Intel Corporation +Written by vikas.shivappa@linux.intel.com + +CONTENTS: +========= + +1. Cache Allocation Technology + 1.1 What is RDT and Cache allocation ? + 1.2 Why is Cache allocation needed ? + 1.3 Cache allocation implementation overview + 1.4 Assignment of CBM and CLOS + 1.5 Scheduling and Context Switch + +1. Cache Allocation Technology +=================================== + +1.1 What is RDT and Cache allocation +------------------------------------ + +Cache allocation is a sub-feature of Resource Director Technology (RDT) +Allocation or Platform Shared resource control which provides support to +control Platform shared resources like L3 cache. Currently L3 Cache is +the only resource that is supported in RDT. More information can be +found in the Intel SDM June 2015, Volume 3, section 17.16. + +Cache Allocation Technology provides a way for the Software (OS/VMM) to +restrict cache allocation to a defined 'subset' of cache which may be +overlapping with other 'subsets'. This feature is used when allocating a +line in cache ie when pulling new data into the cache. The programming +of the h/w is done via programming MSRs. + +The different cache subsets are identified by CLOS identifier (class of +service) and each CLOS has a CBM (cache bit mask). The CBM is a +contiguous set of bits which defines the amount of cache resource that +is available for each 'subset'. + +1.2 Why is Cache allocation needed +---------------------------------- + +In todays new processors the number of cores is continuously increasing +especially in large scale usage models where VMs are used like +webservers and datacenters. The number of cores increase the number of +threads or workloads that can simultaneously be run. When +multi-threaded-applications, VMs, workloads run concurrently they +compete for shared resources including L3 cache. + +The architecture also allows dynamically changing these subsets during +runtime to further optimize the performance of the higher priority +application with minimal degradation to the low priority app. +Additionally, resources can be rebalanced for system throughput benefit. + +This technique may be useful in managing large computer server systems +with large L3 cache, in the cloud and container context. Examples may be +large servers running instances of webservers or database servers. In +such complex systems, these subsets can be used for more careful placing +of the available cache resources by a centralized root accessible +interface. + +A specific use case may be to solve the noisy neighbour issue when a app +which is constantly copying data like streaming app is using large +amount of cache which could have otherwise been used by a high priority +computing application. Using the cache allocation feature, the streaming +application can be confined to use a smaller cache and the high priority +application be awarded a larger amount of cache space. + +1.3 Cache allocation implementation Overview +-------------------------------------------- + +Kernel has a new field in the task_struct called 'closid' which +represents the Class of service ID of the task. + +There is a 1:1 CLOSid <-> CBM (capacity bit mask) mapping. A CLOS (Class +of service) is represented by a CLOSid. Each closid would have one CBM +and would just represent one cache 'subset'. The tasks would get to +fill the L3 cache represented by the capacity bit mask or CBM. + +The APIs to manage the closid and CBM can be used to develop user +interfaces. + +1.4 Assignment of CBM, CLOS +--------------------------- + +The framework provides APIs to manage the closid and CBM which can be +used to develop user/kernel mode interfaces. + +1.5 Scheduling and Context Switch +--------------------------------- + +During context switch kernel implements this by writing the CLOSid of +the task to the CPU's IA32_PQR_ASSOC MSR. The MSR is only written when +there is a change in the CLOSid for the CPU in order to minimize the +latency incurred during context switch. + +The following considerations are done for the PQR MSR write so that it +has minimal impact on scheduling hot path: + - This path doesn't exist on any non-intel platforms. + - On Intel platforms, this would not exist by default unless INTEL_RDT + is enabled. + - remains a no-op when INTEL_RDT is enabled and intel hardware does + not support the feature. + - When feature is available, does not do MSR write till the user + starts using the feature *and* assigns a new cache capacity mask. + - per cpu PQR values are cached and the MSR write is only done when + there is a task with different PQR is scheduled on the CPU. Typically + if the task groups are bound to be scheduled on a set of CPUs, the + number of MSR writes is greatly reduced. -- 2.5.0
[toc] | [prev] | [next] | [standalone]
| From | "Fenghua Yu" <fenghua.yu@intel.com> |
|---|---|
| Date | 2016-09-08 09:10 +0200 |
| Subject | [PATCH v2 19/33] magic number for resctrl file system |
| Message-ID | <sf1Dd-2F3-61@gated-at.bofh.it> |
| In reply to | #1478824 |
From: Fenghua Yu <fenghua.yu@intel.com> Signed-off-by: Fenghua Yu <fenghua.yu@intel.com> Reviewed-by: Tony Luck <tony.luck@intel.com> --- include/uapi/linux/magic.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/uapi/linux/magic.h b/include/uapi/linux/magic.h index e398bea..33f1d64 100644 --- a/include/uapi/linux/magic.h +++ b/include/uapi/linux/magic.h @@ -57,6 +57,8 @@ #define CGROUP_SUPER_MAGIC 0x27e0eb #define CGROUP2_SUPER_MAGIC 0x63677270 +#define RDTGROUP_SUPER_MAGIC 0x7655821 + #define STACK_END_MAGIC 0x57AC6E9D -- 2.5.0
[toc] | [prev] | [next] | [standalone]
| From | Thomas Gleixner <tglx@linutronix.de> |
|---|---|
| Date | 2016-09-08 12:50 +0200 |
| Subject | Re: [PATCH v2 19/33] magic number for resctrl file system |
| Message-ID | <sf545-4HL-5@gated-at.bofh.it> |
| In reply to | #1478851 |
On Thu, 8 Sep 2016, Fenghua Yu wrote: $subject lacks a subsystem prefix ...
[toc] | [prev] | [next] | [standalone]
| From | Borislav Petkov <bp@alien8.de> |
|---|---|
| Date | 2016-09-08 12:50 +0200 |
| Subject | Re: [PATCH v2 19/33] magic number for resctrl file system |
| Message-ID | <sf545-4HL-13@gated-at.bofh.it> |
| In reply to | #1479072 |
On Thu, Sep 08, 2016 at 12:41:27PM +0200, Thomas Gleixner wrote:
> On Thu, 8 Sep 2016, Fenghua Yu wrote:
>
> $subject lacks a subsystem prefix ...
... and a commit message.
--
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
[toc] | [prev] | [next] | [standalone]
| From | "Fenghua Yu" <fenghua.yu@intel.com> |
|---|---|
| Date | 2016-09-08 09:10 +0200 |
| Subject | [PATCH v2 21/33] x86/intel_rdt_rdtgroup.h: Header for user interface |
| Message-ID | <sf1Dd-2F3-67@gated-at.bofh.it> |
| In reply to | #1478824 |
From: Fenghua Yu <fenghua.yu@intel.com>
This is header file for user interface file intel_rdt_rdtgroup.c.
Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
Reviewed-by: Tony Luck <tony.luck@intel.com>
---
arch/x86/include/asm/intel_rdt_rdtgroup.h | 150 ++++++++++++++++++++++++++++++
1 file changed, 150 insertions(+)
create mode 100644 arch/x86/include/asm/intel_rdt_rdtgroup.h
diff --git a/arch/x86/include/asm/intel_rdt_rdtgroup.h b/arch/x86/include/asm/intel_rdt_rdtgroup.h
new file mode 100644
index 0000000..3703964
--- /dev/null
+++ b/arch/x86/include/asm/intel_rdt_rdtgroup.h
@@ -0,0 +1,150 @@
+#ifndef _RDT_PGROUP_H
+#define _RDT_PGROUP_H
+#define MAX_RDTGROUP_TYPE_NAMELEN 32
+#define MAX_RDTGROUP_ROOT_NAMELEN 64
+#define MAX_RFTYPE_NAME 64
+
+#include <linux/kernfs.h>
+#include <asm/intel_rdt.h>
+
+extern void rdtgroup_exit(struct task_struct *tsk);
+
+/* cftype->flags */
+enum {
+ RFTYPE_WORLD_WRITABLE = (1 << 4),/* (DON'T USE FOR NEW FILES) S_IWUGO */
+
+ /* internal flags, do not use outside rdtgroup core proper */
+ __RFTYPE_ONLY_ON_DFL = (1 << 16),/* only on default hierarchy */
+ __RFTYPE_NOT_ON_DFL = (1 << 17),/* not on default hierarchy */
+};
+
+#define CACHE_LEVEL3 3
+
+struct cache_resource {
+ u64 *cbm;
+ u64 *cbm2;
+ int *closid;
+ int *refcnt;
+};
+
+struct rdt_resource {
+ bool valid;
+ int closid[MAX_CACHE_DOMAINS];
+ /* Add more resources here. */
+};
+
+struct rdtgroup {
+ struct kernfs_node *kn; /* rdtgroup kernfs entry */
+
+ struct rdtgroup_root *root;
+
+ struct list_head rdtgroup_list;
+
+ atomic_t refcount;
+ struct cpumask cpu_mask;
+ char schema[1024];
+
+ struct rdt_resource resource;
+
+ /* ids of the ancestors at each level including self */
+ int ancestor_ids[];
+};
+
+struct rftype {
+ /*
+ * By convention, the name should begin with the name of the
+ * subsystem, followed by a period. Zero length string indicates
+ * end of cftype array.
+ */
+ char name[MAX_CFTYPE_NAME];
+ unsigned long private;
+
+ /*
+ * The maximum length of string, excluding trailing nul, that can
+ * be passed to write. If < PAGE_SIZE-1, PAGE_SIZE-1 is assumed.
+ */
+ size_t max_write_len;
+
+ /* CFTYPE_* flags */
+ unsigned int flags;
+
+ /*
+ * Fields used for internal bookkeeping. Initialized automatically
+ * during registration.
+ */
+ struct kernfs_ops *kf_ops;
+
+ /*
+ * read_u64() is a shortcut for the common case of returning a
+ * single integer. Use it in place of read()
+ */
+ u64 (*read_u64)(struct rftype *rft);
+ /*
+ * read_s64() is a signed version of read_u64()
+ */
+ s64 (*read_s64)(struct rftype *rft);
+
+ /* generic seq_file read interface */
+ int (*seq_show)(struct seq_file *sf, void *v);
+
+ /* optional ops, implement all or none */
+ void *(*seq_start)(struct seq_file *sf, loff_t *ppos);
+ void *(*seq_next)(struct seq_file *sf, void *v, loff_t *ppos);
+ void (*seq_stop)(struct seq_file *sf, void *v);
+
+ /*
+ * write_u64() is a shortcut for the common case of accepting
+ * a single integer (as parsed by simple_strtoull) from
+ * userspace. Use in place of write(); return 0 or error.
+ */
+ int (*write_u64)(struct rftype *rft, u64 val);
+ /*
+ * write_s64() is a signed version of write_u64()
+ */
+ int (*write_s64)(struct rftype *rft, s64 val);
+
+ /*
+ * write() is the generic write callback which maps directly to
+ * kernfs write operation and overrides all other operations.
+ * Maximum write size is determined by ->max_write_len. Use
+ * of_css/cft() to access the associated css and cft.
+ */
+ ssize_t (*write)(struct kernfs_open_file *of,
+ char *buf, size_t nbytes, loff_t off);
+};
+
+struct rdtgroup_root {
+ struct kernfs_root *kf_root;
+
+ /* Unique id for this hierarchy. */
+ int hierarchy_id;
+
+ /* The root rdtgroup. Root is destroyed on its release. */
+ struct rdtgroup rdtgrp;
+
+ /* Number of rdtgroups in the hierarchy */
+ atomic_t nr_rdtgrps;
+
+ /* Hierarchy-specific flags */
+ unsigned int flags;
+
+ /* IDs for rdtgroups in this hierarchy */
+ struct idr rdtgroup_idr;
+
+ /* The name for this hierarchy - may be empty */
+ char name[MAX_RDTGROUP_ROOT_NAMELEN];
+};
+
+/* get rftype from of */
+static inline struct rftype *of_rft(struct kernfs_open_file *of)
+{
+ return of->kn->priv;
+}
+
+/* get rftype from seq_file */
+static inline struct rftype *seq_rft(struct seq_file *seq)
+{
+ return of_rft(seq->private);
+}
+
+#endif
--
2.5.0
[toc] | [prev] | [next] | [standalone]
| From | Thomas Gleixner <tglx@linutronix.de> |
|---|---|
| Date | 2016-09-08 14:50 +0200 |
| Subject | Re: [PATCH v2 21/33] x86/intel_rdt_rdtgroup.h: Header for user interface |
| Message-ID | <sf6Wf-5Sk-43@gated-at.bofh.it> |
| In reply to | #1478852 |
On Thu, 8 Sep 2016, Fenghua Yu wrote:
> From: Fenghua Yu <fenghua.yu@intel.com>
>
> This is header file for user interface file intel_rdt_rdtgroup.c.
Really useful information complementary to $subject - NOT!
And again you introduce stuff without an implementation. How the hell is
that useful? It's just annoying having to lookup this patch when reviewing
the one which adds the actual code ....
> +#define MAX_RDTGROUP_TYPE_NAMELEN 32
> +#define MAX_RDTGROUP_ROOT_NAMELEN 64
> +#define MAX_RFTYPE_NAME 64
> +
> +#include <linux/kernfs.h>
> +#include <asm/intel_rdt.h>
> +
> +extern void rdtgroup_exit(struct task_struct *tsk);
> +
> +/* cftype->flags */
> +enum {
> + RFTYPE_WORLD_WRITABLE = (1 << 4),/* (DON'T USE FOR NEW FILES) S_IWUGO */
Huch? What's the point of this?
> +
> + /* internal flags, do not use outside rdtgroup core proper */
> + __RFTYPE_ONLY_ON_DFL = (1 << 16),/* only on default hierarchy */
> + __RFTYPE_NOT_ON_DFL = (1 << 17),/* not on default hierarchy */
> +};
> +
> +#define CACHE_LEVEL3 3
> +
> +struct cache_resource {
> + u64 *cbm;
> + u64 *cbm2;
> + int *closid;
> + int *refcnt;
> +};
Some more undocumented structs.
> +
> +struct rdt_resource {
> + bool valid;
> + int closid[MAX_CACHE_DOMAINS];
> + /* Add more resources here. */
> +};
> +
> +struct rdtgroup {
> + struct kernfs_node *kn; /* rdtgroup kernfs entry */
I told you before not to use tail comments and of course you comment the
obvious and not anything else. We have kerneldoc for this.
> +struct rftype {
> + /*
> + * By convention, the name should begin with the name of the
> + * subsystem, followed by a period. Zero length string indicates
> + * end of cftype array.
> + */
See above.
> + char name[MAX_CFTYPE_NAME];
> + unsigned long private;
And please align the struct members proper. Reading this is a PITA.
Thanks,
tglx
[toc] | [prev] | [next] | [standalone]
| From | "Fenghua Yu" <fenghua.yu@intel.com> |
|---|---|
| Date | 2016-09-08 09:10 +0200 |
| Subject | [PATCH v2 26/33] Task fork and exit for rdtgroup |
| Message-ID | <sf1Dd-2F3-69@gated-at.bofh.it> |
| In reply to | #1478824 |
From: Fenghua Yu <fenghua.yu@intel.com>
When a task is forked, it inherites its parent rdtgroup. The task
can be moved to other rdtgroup during its run time.
When the task exits, it's deleted from it's current rdtgroup's task
list.
Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
Reviewed-by: Tony Luck <tony.luck@intel.com>
---
arch/x86/kernel/cpu/intel_rdt_rdtgroup.c | 22 ++++++++++++++++++++++
kernel/exit.c | 2 ++
kernel/fork.c | 2 ++
3 files changed, 26 insertions(+)
diff --git a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
index 7842194..acea62c 100644
--- a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
+++ b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
@@ -956,3 +956,25 @@ int __init rdtgroup_init(void)
return 0;
}
+
+void rdtgroup_fork(struct task_struct *child)
+{
+ struct rdtgroup *rdtgrp;
+
+ INIT_LIST_HEAD(&child->rg_list);
+ if (!rdtgroup_mounted)
+ return;
+
+ mutex_lock(&rdtgroup_mutex);
+
+ rdtgrp = current->rdtgroup;
+ if (!rdtgrp)
+ goto out;
+
+ list_add_tail(&child->rg_list, &rdtgrp->pset.tasks);
+ child->rdtgroup = rdtgrp;
+ atomic_inc(&rdtgrp->refcount);
+
+out:
+ mutex_unlock(&rdtgroup_mutex);
+}
diff --git a/kernel/exit.c b/kernel/exit.c
index 091a78b..270ede6 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -54,6 +54,7 @@
#include <linux/writeback.h>
#include <linux/shm.h>
#include <linux/kcov.h>
+#include <linux/resctrl.h>
#include <asm/uaccess.h>
#include <asm/unistd.h>
@@ -837,6 +838,7 @@ void do_exit(long code)
perf_event_exit_task(tsk);
cgroup_exit(tsk);
+ rdtgroup_exit(tsk);
/*
* FIXME: do that only when needed, using sched_exit tracepoint
diff --git a/kernel/fork.c b/kernel/fork.c
index beb3172..79bfc99 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -76,6 +76,7 @@
#include <linux/compiler.h>
#include <linux/sysctl.h>
#include <linux/kcov.h>
+#include <linux/resctrl.h>
#include <asm/pgtable.h>
#include <asm/pgalloc.h>
@@ -1426,6 +1427,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
p->io_context = NULL;
p->audit_context = NULL;
cgroup_fork(p);
+ rdtgroup_fork(p);
#ifdef CONFIG_NUMA
p->mempolicy = mpol_dup(p->mempolicy);
if (IS_ERR(p->mempolicy)) {
--
2.5.0
[toc] | [prev] | [next] | [standalone]
| From | Thomas Gleixner <tglx@linutronix.de> |
|---|---|
| Date | 2016-09-08 21:50 +0200 |
| Subject | Re: [PATCH v2 26/33] Task fork and exit for rdtgroup |
| Message-ID | <sfduG-1wx-13@gated-at.bofh.it> |
| In reply to | #1478853 |
On Thu, 8 Sep 2016, Fenghua Yu wrote:
>
> cgroup_exit(tsk);
> + rdtgroup_exit(tsk);
So this actually does:
> +void rdtgroup_exit(struct task_struct *tsk)
> +{
> +
> + if (!list_empty(&tsk->rg_list)) {
> + struct rdtgroup *rdtgrp = tsk->rdtgroup;
> +
> + list_del_init(&tsk->rg_list);
> + tsk->rdtgroup = NULL;
> + atomic_dec(&rdtgrp->refcount);
> + }
> +}
with complete lack of locking .....
Brilliant stuff that.
tglx
[toc] | [prev] | [next] | [standalone]
| From | "Fenghua Yu" <fenghua.yu@intel.com> |
|---|---|
| Date | 2016-09-08 09:10 +0200 |
| Subject | [PATCH v2 18/33] sched.h: Add rg_list and rdtgroup in task_struct |
| Message-ID | <sf1Dd-2F3-71@gated-at.bofh.it> |
| In reply to | #1478824 |
From: Fenghua Yu <fenghua.yu@intel.com>
rg_list is linked list to connect to other tasks in a rdtgroup.
The point of rdtgroup allows the task to access its own rdtgroup directly.
Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
Reviewed-by: Tony Luck <tony.luck@intel.com>
---
include/linux/sched.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 62c68e5..4b1dce0 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1766,6 +1766,9 @@ struct task_struct {
/* cg_list protected by css_set_lock and tsk->alloc_lock */
struct list_head cg_list;
#endif
+#ifdef CONFIG_INTEL_RDT
+ struct rdtgroup *rdtgroup;
+#endif
#ifdef CONFIG_FUTEX
struct robust_list_head __user *robust_list;
#ifdef CONFIG_COMPAT
--
2.5.0
[toc] | [prev] | [next] | [standalone]
| From | Thomas Gleixner <tglx@linutronix.de> |
|---|---|
| Date | 2016-09-08 12:40 +0200 |
| Subject | Re: [PATCH v2 18/33] sched.h: Add rg_list and rdtgroup in task_struct |
| Message-ID | <sf4Up-4Eh-11@gated-at.bofh.it> |
| In reply to | #1478854 |
On Thu, 8 Sep 2016, Fenghua Yu wrote:
> From: Fenghua Yu <fenghua.yu@intel.com>
>
> rg_list is linked list to connect to other tasks in a rdtgroup.
There is no rg_list in this patch ....
> The point of rdtgroup allows the task to access its own rdtgroup directly.
The point?
Thanks,
tglx
> Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
> Reviewed-by: Tony Luck <tony.luck@intel.com>
> ---
> include/linux/sched.h | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/include/linux/sched.h b/include/linux/sched.h
> index 62c68e5..4b1dce0 100644
> --- a/include/linux/sched.h
> +++ b/include/linux/sched.h
> @@ -1766,6 +1766,9 @@ struct task_struct {
> /* cg_list protected by css_set_lock and tsk->alloc_lock */
> struct list_head cg_list;
> #endif
> +#ifdef CONFIG_INTEL_RDT
> + struct rdtgroup *rdtgroup;
> +#endif
> #ifdef CONFIG_FUTEX
> struct robust_list_head __user *robust_list;
> #ifdef CONFIG_COMPAT
> --
> 2.5.0
>
>
[toc] | [prev] | [next] | [standalone]
| From | "Fenghua Yu" <fenghua.yu@intel.com> |
|---|---|
| Date | 2016-09-08 09:10 +0200 |
| Subject | [PATCH v2 02/33] Documentation, ABI: Add a document entry for cache id |
| Message-ID | <sf1Dd-2F3-63@gated-at.bofh.it> |
| In reply to | #1478824 |
From: Fenghua Yu <fenghua.yu@intel.com> Add an ABI document entry for /sys/devices/system/cpu/cpu*/cache/index*/id. Signed-off-by: Fenghua Yu <fenghua.yu@intel.com> Reviewed-by: Tony Luck <tony.luck@intel.com> Acked-by: Borislav Petkov <bp@suse.com> --- Documentation/ABI/testing/sysfs-devices-system-cpu | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-devices-system-cpu b/Documentation/ABI/testing/sysfs-devices-system-cpu index 4987417..d5d99dc 100644 --- a/Documentation/ABI/testing/sysfs-devices-system-cpu +++ b/Documentation/ABI/testing/sysfs-devices-system-cpu @@ -272,6 +272,23 @@ Description: Parameters for the CPU cache attributes the modified cache line is written to main memory only when it is replaced + +What: /sys/devices/system/cpu/cpu*/cache/index*/id +Date: July 2016 +Contact: Linux kernel mailing list <linux-kernel@vger.kernel.org> +Description: Cache id + + The id identifies a hardware cache of the system within a given + cache index in a set of cache indices. The "index" name is + simply a nomenclature from CPUID's leaf 4 which enumerates all + caches on the system by referring to each one as a cache index. + The (cache index, cache id) pair is unique for the whole + system. + + Currently id is implemented on x86. On other platforms, id is + not enabled yet. + + What: /sys/devices/system/cpu/cpuX/cpufreq/throttle_stats /sys/devices/system/cpu/cpuX/cpufreq/throttle_stats/turbo_stat /sys/devices/system/cpu/cpuX/cpufreq/throttle_stats/sub_turbo_stat -- 2.5.0
[toc] | [prev] | [next] | [standalone]
Page 3 of 4 — ← Prev page 1 2 [3] 4 Next page →
Back to top | Article view | linux.kernel
csiph-web