aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVikas Shivappa <vikas.shivappa@linux.intel.com>2017-07-25 17:14:23 -0400
committerThomas Gleixner <tglx@linutronix.de>2017-08-01 16:41:19 -0400
commit0583020456cea9fcf43b84bb13a41eab059ae0a8 (patch)
tree135c5ab8a6f67d182af0db45b492bbe96f3fe83d
parentf01d7d51f577b5dc0fa5919ab8a9228e2bf49f3e (diff)
x86/intel_rdt: Change file names to accommodate RDT monitor code
Because the "perf cqm" and resctrl code were separately added and indivdually configurable, there seem to be separate context switch code and also things on global .h which are not really needed. Move only the scheduling specific code and definitions to <asm/intel_rdt_sched.h> and the put all the other declarations to a local intel_rdt.h. h/t to Reinette Chatre for pointing out that we should separate the public interfaces used by other parts of the kernel from private objects shared between the various files comprising RDT. No functional change. Signed-off-by: Vikas Shivappa <vikas.shivappa@linux.intel.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: ravi.v.shankar@intel.com Cc: tony.luck@intel.com Cc: fenghua.yu@intel.com Cc: peterz@infradead.org Cc: eranian@google.com Cc: vikas.shivappa@intel.com Cc: ak@linux.intel.com Cc: davidcc@google.com Cc: reinette.chatre@intel.com Link: http://lkml.kernel.org/r/1501017287-28083-5-git-send-email-vikas.shivappa@linux.intel.com
-rw-r--r--MAINTAINERS2
-rw-r--r--arch/x86/include/asm/intel_rdt_common.h25
-rw-r--r--arch/x86/include/asm/intel_rdt_sched.h72
-rw-r--r--arch/x86/kernel/cpu/intel_rdt.c5
-rw-r--r--arch/x86/kernel/cpu/intel_rdt.h (renamed from arch/x86/include/asm/intel_rdt.h)43
-rw-r--r--arch/x86/kernel/cpu/intel_rdt_rdtgroup.c4
-rw-r--r--arch/x86/kernel/cpu/intel_rdt_schemata.c2
-rw-r--r--arch/x86/kernel/process_32.c2
-rw-r--r--arch/x86/kernel/process_64.c2
9 files changed, 81 insertions, 76 deletions
diff --git a/MAINTAINERS b/MAINTAINERS
index f66488dfdbc9..cbbc79a81dea 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -11103,7 +11103,7 @@ M: Fenghua Yu <fenghua.yu@intel.com>
11103L: linux-kernel@vger.kernel.org 11103L: linux-kernel@vger.kernel.org
11104S: Supported 11104S: Supported
11105F: arch/x86/kernel/cpu/intel_rdt* 11105F: arch/x86/kernel/cpu/intel_rdt*
11106F: arch/x86/include/asm/intel_rdt* 11106F: arch/x86/include/asm/intel_rdt_sched.h
11107F: Documentation/x86/intel_rdt* 11107F: Documentation/x86/intel_rdt*
11108 11108
11109READ-COPY UPDATE (RCU) 11109READ-COPY UPDATE (RCU)
diff --git a/arch/x86/include/asm/intel_rdt_common.h b/arch/x86/include/asm/intel_rdt_common.h
deleted file mode 100644
index c95321870842..000000000000
--- a/arch/x86/include/asm/intel_rdt_common.h
+++ /dev/null
@@ -1,25 +0,0 @@
1#ifndef _ASM_X86_INTEL_RDT_COMMON_H
2#define _ASM_X86_INTEL_RDT_COMMON_H
3
4#define MSR_IA32_PQR_ASSOC 0x0c8f
5
6/**
7 * struct intel_pqr_state - State cache for the PQR MSR
8 * @rmid: The cached Resource Monitoring ID
9 * @closid: The cached Class Of Service ID
10 *
11 * The upper 32 bits of MSR_IA32_PQR_ASSOC contain closid and the
12 * lower 10 bits rmid. The update to MSR_IA32_PQR_ASSOC always
13 * contains both parts, so we need to cache them.
14 *
15 * The cache also helps to avoid pointless updates if the value does
16 * not change.
17 */
18struct intel_pqr_state {
19 u32 rmid;
20 u32 closid;
21};
22
23DECLARE_PER_CPU(struct intel_pqr_state, pqr_state);
24
25#endif /* _ASM_X86_INTEL_RDT_COMMON_H */
diff --git a/arch/x86/include/asm/intel_rdt_sched.h b/arch/x86/include/asm/intel_rdt_sched.h
new file mode 100644
index 000000000000..62a70bc85bce
--- /dev/null
+++ b/arch/x86/include/asm/intel_rdt_sched.h
@@ -0,0 +1,72 @@
1#ifndef _ASM_X86_INTEL_RDT_SCHED_H
2#define _ASM_X86_INTEL_RDT_SCHED_H
3
4#ifdef CONFIG_INTEL_RDT
5
6#include <linux/sched.h>
7#include <linux/jump_label.h>
8
9#define IA32_PQR_ASSOC 0x0c8f
10
11/**
12 * struct intel_pqr_state - State cache for the PQR MSR
13 * @rmid: The cached Resource Monitoring ID
14 * @closid: The cached Class Of Service ID
15 *
16 * The upper 32 bits of IA32_PQR_ASSOC contain closid and the
17 * lower 10 bits rmid. The update to IA32_PQR_ASSOC always
18 * contains both parts, so we need to cache them.
19 *
20 * The cache also helps to avoid pointless updates if the value does
21 * not change.
22 */
23struct intel_pqr_state {
24 u32 rmid;
25 u32 closid;
26};
27
28DECLARE_PER_CPU(struct intel_pqr_state, pqr_state);
29DECLARE_PER_CPU_READ_MOSTLY(int, cpu_closid);
30DECLARE_STATIC_KEY_FALSE(rdt_enable_key);
31
32/*
33 * intel_rdt_sched_in() - Writes the task's CLOSid to IA32_PQR_MSR
34 *
35 * Following considerations are made so that this has minimal impact
36 * on scheduler hot path:
37 * - This will stay as no-op unless we are running on an Intel SKU
38 * which supports resource control and we enable by mounting the
39 * resctrl file system.
40 * - Caches the per cpu CLOSid values and does the MSR write only
41 * when a task with a different CLOSid is scheduled in.
42 *
43 * Must be called with preemption disabled.
44 */
45static inline void intel_rdt_sched_in(void)
46{
47 if (static_branch_likely(&rdt_enable_key)) {
48 struct intel_pqr_state *state = this_cpu_ptr(&pqr_state);
49 int closid;
50
51 /*
52 * If this task has a closid assigned, use it.
53 * Else use the closid assigned to this cpu.
54 */
55 closid = current->closid;
56 if (closid == 0)
57 closid = this_cpu_read(cpu_closid);
58
59 if (closid != state->closid) {
60 state->closid = closid;
61 wrmsr(IA32_PQR_ASSOC, state->rmid, closid);
62 }
63 }
64}
65
66#else
67
68static inline void intel_rdt_sched_in(void) {}
69
70#endif /* CONFIG_INTEL_RDT */
71
72#endif /* _ASM_X86_INTEL_RDT_SCHED_H */
diff --git a/arch/x86/kernel/cpu/intel_rdt.c b/arch/x86/kernel/cpu/intel_rdt.c
index 989a997fce47..08872e9e09c3 100644
--- a/arch/x86/kernel/cpu/intel_rdt.c
+++ b/arch/x86/kernel/cpu/intel_rdt.c
@@ -30,7 +30,8 @@
30#include <linux/cpuhotplug.h> 30#include <linux/cpuhotplug.h>
31 31
32#include <asm/intel-family.h> 32#include <asm/intel-family.h>
33#include <asm/intel_rdt.h> 33#include <asm/intel_rdt_sched.h>
34#include "intel_rdt.h"
34 35
35#define MAX_MBA_BW 100u 36#define MAX_MBA_BW 100u
36#define MBA_IS_LINEAR 0x4 37#define MBA_IS_LINEAR 0x4
@@ -455,7 +456,7 @@ static void clear_closid(int cpu)
455 456
456 per_cpu(cpu_closid, cpu) = 0; 457 per_cpu(cpu_closid, cpu) = 0;
457 state->closid = 0; 458 state->closid = 0;
458 wrmsr(MSR_IA32_PQR_ASSOC, state->rmid, 0); 459 wrmsr(IA32_PQR_ASSOC, state->rmid, 0);
459} 460}
460 461
461static int intel_rdt_online_cpu(unsigned int cpu) 462static int intel_rdt_online_cpu(unsigned int cpu)
diff --git a/arch/x86/include/asm/intel_rdt.h b/arch/x86/kernel/cpu/intel_rdt.h
index ae1efc3609d3..0e4852d68faf 100644
--- a/arch/x86/include/asm/intel_rdt.h
+++ b/arch/x86/kernel/cpu/intel_rdt.h
@@ -1,14 +1,10 @@
1#ifndef _ASM_X86_INTEL_RDT_H 1#ifndef _ASM_X86_INTEL_RDT_H
2#define _ASM_X86_INTEL_RDT_H 2#define _ASM_X86_INTEL_RDT_H
3 3
4#ifdef CONFIG_INTEL_RDT
5
6#include <linux/sched.h> 4#include <linux/sched.h>
7#include <linux/kernfs.h> 5#include <linux/kernfs.h>
8#include <linux/jump_label.h> 6#include <linux/jump_label.h>
9 7
10#include <asm/intel_rdt_common.h>
11
12#define IA32_L3_QOS_CFG 0xc81 8#define IA32_L3_QOS_CFG 0xc81
13#define IA32_L3_CBM_BASE 0xc90 9#define IA32_L3_CBM_BASE 0xc90
14#define IA32_L2_CBM_BASE 0xd10 10#define IA32_L2_CBM_BASE 0xd10
@@ -244,43 +240,4 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
244int rdtgroup_schemata_show(struct kernfs_open_file *of, 240int rdtgroup_schemata_show(struct kernfs_open_file *of,
245 struct seq_file *s, void *v); 241 struct seq_file *s, void *v);
246 242
247/*
248 * intel_rdt_sched_in() - Writes the task's CLOSid to IA32_PQR_MSR
249 *
250 * Following considerations are made so that this has minimal impact
251 * on scheduler hot path:
252 * - This will stay as no-op unless we are running on an Intel SKU
253 * which supports resource control and we enable by mounting the
254 * resctrl file system.
255 * - Caches the per cpu CLOSid values and does the MSR write only
256 * when a task with a different CLOSid is scheduled in.
257 *
258 * Must be called with preemption disabled.
259 */
260static inline void intel_rdt_sched_in(void)
261{
262 if (static_branch_likely(&rdt_enable_key)) {
263 struct intel_pqr_state *state = this_cpu_ptr(&pqr_state);
264 int closid;
265
266 /*
267 * If this task has a closid assigned, use it.
268 * Else use the closid assigned to this cpu.
269 */
270 closid = current->closid;
271 if (closid == 0)
272 closid = this_cpu_read(cpu_closid);
273
274 if (closid != state->closid) {
275 state->closid = closid;
276 wrmsr(MSR_IA32_PQR_ASSOC, state->rmid, closid);
277 }
278 }
279}
280
281#else
282
283static inline void intel_rdt_sched_in(void) {}
284
285#endif /* CONFIG_INTEL_RDT */
286#endif /* _ASM_X86_INTEL_RDT_H */ 243#endif /* _ASM_X86_INTEL_RDT_H */
diff --git a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
index 9257bd9dc664..fab88117ae5f 100644
--- a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
+++ b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
@@ -32,8 +32,8 @@
32 32
33#include <uapi/linux/magic.h> 33#include <uapi/linux/magic.h>
34 34
35#include <asm/intel_rdt.h> 35#include <asm/intel_rdt_sched.h>
36#include <asm/intel_rdt_common.h> 36#include "intel_rdt.h"
37 37
38DEFINE_STATIC_KEY_FALSE(rdt_enable_key); 38DEFINE_STATIC_KEY_FALSE(rdt_enable_key);
39struct kernfs_root *rdt_root; 39struct kernfs_root *rdt_root;
diff --git a/arch/x86/kernel/cpu/intel_rdt_schemata.c b/arch/x86/kernel/cpu/intel_rdt_schemata.c
index 406d7a6532f9..8cef1c8e223a 100644
--- a/arch/x86/kernel/cpu/intel_rdt_schemata.c
+++ b/arch/x86/kernel/cpu/intel_rdt_schemata.c
@@ -26,7 +26,7 @@
26#include <linux/kernfs.h> 26#include <linux/kernfs.h>
27#include <linux/seq_file.h> 27#include <linux/seq_file.h>
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <asm/intel_rdt.h> 29#include "intel_rdt.h"
30 30
31/* 31/*
32 * Check whether MBA bandwidth percentage value is correct. The value is 32 * Check whether MBA bandwidth percentage value is correct. The value is
diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
index c6d6dc5f8bb2..22802162eeb9 100644
--- a/arch/x86/kernel/process_32.c
+++ b/arch/x86/kernel/process_32.c
@@ -56,7 +56,7 @@
56#include <asm/debugreg.h> 56#include <asm/debugreg.h>
57#include <asm/switch_to.h> 57#include <asm/switch_to.h>
58#include <asm/vm86.h> 58#include <asm/vm86.h>
59#include <asm/intel_rdt.h> 59#include <asm/intel_rdt_sched.h>
60#include <asm/proto.h> 60#include <asm/proto.h>
61 61
62void __show_regs(struct pt_regs *regs, int all) 62void __show_regs(struct pt_regs *regs, int all)
diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index c3169be4c596..77a35c817b2b 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -52,7 +52,7 @@
52#include <asm/switch_to.h> 52#include <asm/switch_to.h>
53#include <asm/xen/hypervisor.h> 53#include <asm/xen/hypervisor.h>
54#include <asm/vdso.h> 54#include <asm/vdso.h>
55#include <asm/intel_rdt.h> 55#include <asm/intel_rdt_sched.h>
56#include <asm/unistd.h> 56#include <asm/unistd.h>
57#ifdef CONFIG_IA32_EMULATION 57#ifdef CONFIG_IA32_EMULATION
58/* Not included via unistd.h */ 58/* Not included via unistd.h */