mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Fenghua Yu" <fenghua.yu@intel.com>
To: "Thomas Gleixner" <tglx@linutronix.de>
Cc: "H. Peter Anvin" <h.peter.anvin@intel.com>,
	"Ingo Molnar" <mingo@elte.hu>,
	"Marcelo Tosatti" <mtosatti@redhat.com>,
	"Tony Luck" <tony.luck@intel.com>,
	"Ravi V Shankar" <ravi.v.shankar@intel.com>,
	"Sai Prakhya" <sai.praneeth.prakhya@intel.com>,
	"Vikas Shivappa" <vikas.shivappa@linux.intel.com>,
	"linux-kernel" <linux-kernel@vger.kernel.org>,
	"x86" <x86@kernel.org>, "Fenghua Yu" <fenghua.yu@intel.com>
Subject: [PATCH] x86/intel_rdt.c: Disable preempt for intel_rdt_sched_in() in move_myself()
Date: Wed, 30 Nov 2016 13:41:43 -0800	[thread overview]
Message-ID: <1480542103-44892-1-git-send-email-fenghua.yu@intel.com> (raw)

From: Fenghua Yu <fenghua.yu@intel.com>

intel_rdt_sched_in() calls this_cpu_ptr() read and write pqr_state and
update PQR_ASSOC on current cpu. If execution of the function is preempted
and switched to another CPU, the results are wrong. If 
CONFIG_DEBUG_PREEMPT is turned on, the issue is reported as
"BUG: smp_processor_id() running in preemptible code." when moving a task
to a rdtgroup in move_myself().

Disable preempt before intel_rdt_sched_in() and eanble preempt after
the function in move_myself() to solve the issue.

Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
---
 arch/x86/kernel/cpu/intel_rdt_rdtgroup.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/x86/include/asm/intel_rdt.h b/arch/x86/include/asm/intel_rdt.h
index 6e90e87..eaaa765 100644
--- a/arch/x86/include/asm/intel_rdt.h
+++ b/arch/x86/include/asm/intel_rdt.h
@@ -192,6 +192,9 @@ 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.
+ * - Caller needs to disable preempt before calling this function.
+ *   The function doesn't check preemptible. Scheduler hot path
+ *   disables preempt already.
  */
 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..9c6f732 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);
 	}
 
+	get_cpu();
 	/* update PQR_ASSOC MSR to make resource group go into effect */
 	intel_rdt_sched_in();
+	put_cpu();
 
 	kfree(callback);
 }

             reply	other threads:[~2016-11-30 21:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-30 21:41 Fenghua Yu [this message]
2016-11-30 22:10 ` Thomas Gleixner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1480542103-44892-1-git-send-email-fenghua.yu@intel.com \
    --to=fenghua.yu@intel.com \
    --cc=h.peter.anvin@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=mtosatti@redhat.com \
    --cc=ravi.v.shankar@intel.com \
    --cc=sai.praneeth.prakhya@intel.com \
    --cc=tglx@linutronix.de \
    --cc=tony.luck@intel.com \
    --cc=vikas.shivappa@linux.intel.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®