* [PATCH v2] x86/intel_rdt: Call intel_rdt_sched_in() with preemption disabled
@ 2016-12-01 20:55 Fenghua Yu
2016-12-02 0:18 ` [tip:x86/cache] " tip-bot for Fenghua Yu
0 siblings, 1 reply; 2+ messages in thread
From: Fenghua Yu @ 2016-12-01 20:55 UTC (permalink / raw)
To: Thomas Gleixner
Cc: H. Peter Anvin, Ingo Molnar, Marcelo Tosatti, Tony Luck,
Ravi V Shankar, Sai Prakhya, Vikas Shivappa, linux-kernel, x86,
Fenghua Yu
From: Fenghua Yu <fenghua.yu@intel.com>
intel_rdt_sched_in() must be called with preemption disabled because the
function accesses percpu variables (pqr_state and closid).
If a task moves itself via move_myself() preemption is enabled, which
violates the calling convention and can result in incorrect closid
selection when the task gets preempted or migrated.
Add the required protection and a comment about the calling convention.
Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
---
arch/x86/include/asm/intel_rdt.h | 2 ++
arch/x86/kernel/cpu/intel_rdt_rdtgroup.c | 2 ++
2 files changed, 4 insertions(+)
diff --git a/arch/x86/include/asm/intel_rdt.h b/arch/x86/include/asm/intel_rdt.h
index 6e90e87..95ce5c8 100644
--- a/arch/x86/include/asm/intel_rdt.h
+++ b/arch/x86/include/asm/intel_rdt.h
@@ -192,6 +192,8 @@ int rdtgroup_schemata_show(struct kernfs_open_file *of,
* resctrl file system.
* - Caches the per cpu CLOSid values and does the MSR write only
* when a task with a different CLOSid is scheduled in.
+ *
+ * Must be called with preemption disabled.
*/
static inline void intel_rdt_sched_in(void)
{
diff --git a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
index fb8e03e..1afd3f3 100644
--- a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
+++ b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
@@ -326,8 +326,10 @@ static void move_myself(struct callback_head *head)
kfree(rdtgrp);
}
+ preempt_disable();
/* update PQR_ASSOC MSR to make resource group go into effect */
intel_rdt_sched_in();
+ preempt_enable();
kfree(callback);
}
--
2.5.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* [tip:x86/cache] x86/intel_rdt: Call intel_rdt_sched_in() with preemption disabled
2016-12-01 20:55 [PATCH v2] x86/intel_rdt: Call intel_rdt_sched_in() with preemption disabled Fenghua Yu
@ 2016-12-02 0:18 ` tip-bot for Fenghua Yu
0 siblings, 0 replies; 2+ messages in thread
From: tip-bot for Fenghua Yu @ 2016-12-02 0:18 UTC (permalink / raw)
To: linux-tip-commits
Cc: vikas.shivappa, mingo, tony.luck, mtosatti, sai.praneeth.prakhya,
tglx, h.peter.anvin, ravi.v.shankar, hpa, linux-kernel,
fenghua.yu
Commit-ID: 74fcdae1a7fdf30de5413ccc1eca271415d01124
Gitweb: http://git.kernel.org/tip/74fcdae1a7fdf30de5413ccc1eca271415d01124
Author: Fenghua Yu <fenghua.yu@intel.com>
AuthorDate: Thu, 1 Dec 2016 12:55:14 -0800
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 2 Dec 2016 01:13:02 +0100
x86/intel_rdt: Call intel_rdt_sched_in() with preemption disabled
intel_rdt_sched_in() must be called with preemption disabled because the
function accesses percpu variables (pqr_state and closid).
If a task moves itself via move_myself() preemption is enabled, which
violates the calling convention and can result in incorrect closid
selection when the task gets preempted or migrated.
Add the required protection and a comment about the calling convention.
Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
Cc: "Ravi V Shankar" <ravi.v.shankar@intel.com>
Cc: "Tony Luck" <tony.luck@intel.com>
Cc: "Marcelo Tosatti" <mtosatti@redhat.com>
Cc: "Sai Prakhya" <sai.praneeth.prakhya@intel.com>
Cc: "Vikas Shivappa" <vikas.shivappa@linux.intel.com>
Cc: "H. Peter Anvin" <h.peter.anvin@intel.com>
Link: http://lkml.kernel.org/r/1480625714-54246-1-git-send-email-fenghua.yu@intel.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
arch/x86/include/asm/intel_rdt.h | 2 ++
arch/x86/kernel/cpu/intel_rdt_rdtgroup.c | 2 ++
2 files changed, 4 insertions(+)
diff --git a/arch/x86/include/asm/intel_rdt.h b/arch/x86/include/asm/intel_rdt.h
index 6e90e87..95ce5c8 100644
--- a/arch/x86/include/asm/intel_rdt.h
+++ b/arch/x86/include/asm/intel_rdt.h
@@ -192,6 +192,8 @@ int rdtgroup_schemata_show(struct kernfs_open_file *of,
* resctrl file system.
* - Caches the per cpu CLOSid values and does the MSR write only
* when a task with a different CLOSid is scheduled in.
+ *
+ * Must be called with preemption disabled.
*/
static inline void intel_rdt_sched_in(void)
{
diff --git a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
index fb8e03e..1afd3f3 100644
--- a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
+++ b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
@@ -326,8 +326,10 @@ static void move_myself(struct callback_head *head)
kfree(rdtgrp);
}
+ preempt_disable();
/* update PQR_ASSOC MSR to make resource group go into effect */
intel_rdt_sched_in();
+ preempt_enable();
kfree(callback);
}
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-12-02 0:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-01 20:55 [PATCH v2] x86/intel_rdt: Call intel_rdt_sched_in() with preemption disabled Fenghua Yu
2016-12-02 0:18 ` [tip:x86/cache] " tip-bot for Fenghua Yu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome