Skip to contentSkip to conversation

x86/intel_rdt: Call intel_rdt_sched_in() with preemption disabled

PATCH New Fenghua Yu 2 participants 2 messages Dec 1, 2016 – Dec 2, 2016 x86

lore
Share & tools
lore

Fenghua Yu

author
#0 lore raw

PATCH v2 1/1 x86/intel_rdt: Call intel_rdt_sched_in() with preemption disabled

From: Fenghua Yu <[email protected]>

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.

---
 arch/x86/include/asm/intel_rdt.h         | 2 ++
 arch/x86/kernel/cpu/intel_rdt_rdtgroup.c | 2 ++
 2 files changed, 4 insertions(+)
arch/x86/include/asm/intel_rdt.h +2 -0
index 6e90e87..95ce5c8 100644
@@ -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)
 {
arch/x86/kernel/cpu/intel_rdt_rdtgroup.c +2 -0
index fb8e03e..1afd3f3 100644
@@ -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);
 }
Signature · 1 line
2.5.0
#1 lore raw
x86/intel_rdt: Call intel_rdt_sched_in() with preemption disabled
Commit-ID:  74fcdae1a7fdf30de5413ccc1eca271415d01124
Gitweb:     http://git.kernel.org/tip/74fcdae1a7fdf30de5413ccc1eca271415d01124
Author:     Fenghua Yu <[email protected]>
AuthorDate: Thu, 1 Dec 2016 12:55:14 -0800
Committer:  Thomas Gleixner <[email protected]>
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.

Cc "Ravi V Shankar" <[email protected]>
Cc "Tony Luck" <[email protected]>
Cc "Marcelo Tosatti" <[email protected]>
Cc "Sai Prakhya" <[email protected]>
Cc "Vikas Shivappa" <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
---
 arch/x86/include/asm/intel_rdt.h         | 2 ++
 arch/x86/kernel/cpu/intel_rdt_rdtgroup.c | 2 ++
 2 files changed, 4 insertions(+)
arch/x86/include/asm/intel_rdt.h +2 -0
index 6e90e87..95ce5c8 100644
@@ -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)
 {
arch/x86/kernel/cpu/intel_rdt_rdtgroup.c +2 -0
index fb8e03e..1afd3f3 100644
@@ -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);
 }