public inbox for linux-arch@vger.kernel.org
 help / color / mirror / Atom feed
From: Suresh Siddha <suresh.b.siddha@intel.com>
To: Nick Piggin <npiggin@suse.de>
Cc: Ingo Molnar <mingo@elte.hu>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Oleg Nesterov <oleg@redhat.com>,
	Jens Axboe <jens.axboe@oracle.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
	Rusty Russell <rusty@rustcorp.com.au>,
	Steven Rostedt <rostedt@goodmis.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-arch@vger.kernel.org" <linux-arch@vger.kernel.org>,
	"steiner@sgi.com" <steiner@sgi.com>
Subject: Re: smp.c && barriers (Was: [PATCH 1/4] generic-smp: remove single ipi fallback for smp_call_function_many())
Date: Tue, 17 Mar 2009 10:16:54 -0800	[thread overview]
Message-ID: <1237313814.27006.203.camel@localhost.localdomain> (raw)
In-Reply-To: <20090225033230.GA4611@wotan.suse.de>

On Tue, 2009-02-24 at 19:32 -0800, Nick Piggin wrote:
> Just if I may add something -- I would probably slightly prefer if
> you explicitly used an sfence or other serializing instruction rather
> than smp_mb(). Maybe call it wrmsr_fence() or something.

I was planning to send a cleanup patch doing this, but looks like Ingo
never took the original patch. Here it is appended. Ingo, please
consider.

thanks,
suresh
---

From: Suresh Siddha <suresh.b.siddha@intel.com>
Subject: x86: Add x2apic_wrmsr_fence() to x2apic flush tlb paths

uncached MMIO accesses for xapic are inherently serializing and hence
we don't need explicit barriers for xapic IPI paths.

x2apic MSR writes/reads don't have serializing semantics and hence need
a serializing instruction or mfence, to make all the previous memory
stores globally visisble before the x2apic msr write for IPI.

Add x2apic_wrmsr_fence() in flush tlb path to x2apic specific paths.

Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
---

diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
index 394d177..cfc0871 100644
--- a/arch/x86/include/asm/apic.h
+++ b/arch/x86/include/asm/apic.h
@@ -108,6 +108,16 @@ extern void native_apic_icr_write(u32 low, u32 id);
 extern u64 native_apic_icr_read(void);
 
 #ifdef CONFIG_X86_X2APIC
+/*
+ * Make previous memory operations globally visible before
+ * sending the IPI through x2apic wrmsr. We need a serializing instruction or
+ * mfence for this.
+ */
+static inline void x2apic_wrmsr_fence(void)
+{
+	asm volatile("mfence":::"memory");
+}
+
 static inline void native_apic_msr_write(u32 reg, u32 v)
 {
 	if (reg == APIC_DFR || reg == APIC_ID || reg == APIC_LDR ||
diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
index 8fb87b6..4a903e2 100644
--- a/arch/x86/kernel/apic/x2apic_cluster.c
+++ b/arch/x86/kernel/apic/x2apic_cluster.c
@@ -57,6 +57,8 @@ static void x2apic_send_IPI_mask(const struct cpumask *mask, int vector)
 	unsigned long query_cpu;
 	unsigned long flags;
 
+	x2apic_wrmsr_fence();
+
 	local_irq_save(flags);
 	for_each_cpu(query_cpu, mask) {
 		__x2apic_send_IPI_dest(
@@ -73,6 +75,8 @@ static void
 	unsigned long query_cpu;
 	unsigned long flags;
 
+	x2apic_wrmsr_fence();
+
 	local_irq_save(flags);
 	for_each_cpu(query_cpu, mask) {
 		if (query_cpu == this_cpu)
@@ -90,6 +94,8 @@ static void x2apic_send_IPI_allbutself(int vector)
 	unsigned long query_cpu;
 	unsigned long flags;
 
+	x2apic_wrmsr_fence();
+
 	local_irq_save(flags);
 	for_each_online_cpu(query_cpu) {
 		if (query_cpu == this_cpu)
diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
index 23625b9..a284359 100644
--- a/arch/x86/kernel/apic/x2apic_phys.c
+++ b/arch/x86/kernel/apic/x2apic_phys.c
@@ -58,6 +58,8 @@ static void x2apic_send_IPI_mask(const struct cpumask *mask, int vector)
 	unsigned long query_cpu;
 	unsigned long flags;
 
+	x2apic_wrmsr_fence();
+
 	local_irq_save(flags);
 	for_each_cpu(query_cpu, mask) {
 		__x2apic_send_IPI_dest(per_cpu(x86_cpu_to_apicid, query_cpu),
@@ -73,6 +75,8 @@ static void
 	unsigned long query_cpu;
 	unsigned long flags;
 
+	x2apic_wrmsr_fence();
+
 	local_irq_save(flags);
 	for_each_cpu(query_cpu, mask) {
 		if (query_cpu != this_cpu)
@@ -89,6 +93,8 @@ static void x2apic_send_IPI_allbutself(int vector)
 	unsigned long query_cpu;
 	unsigned long flags;
 
+	x2apic_wrmsr_fence();
+
 	local_irq_save(flags);
 	for_each_online_cpu(query_cpu) {
 		if (query_cpu == this_cpu)
diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
index a654d59..821e970 100644
--- a/arch/x86/mm/tlb.c
+++ b/arch/x86/mm/tlb.c
@@ -187,11 +187,6 @@ static void flush_tlb_others_ipi(const struct cpumask *cpumask,
 		       cpumask, cpumask_of(smp_processor_id()));
 
 	/*
-	 * Make the above memory operations globally visible before
-	 * sending the IPI.
-	 */
-	smp_mb();
-	/*
 	 * We have to send the IPI only to
 	 * CPUs affected.
 	 */

      parent reply	other threads:[~2009-03-17 18:17 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20090216204902.GA6924@redhat.com>
     [not found] ` <1234818201.30178.386.camel@laptop>
     [not found]   ` <20090216213205.GA9098@redhat.com>
     [not found]     ` <1234820704.30178.396.camel@laptop>
     [not found]       ` <20090216220214.GA10093@redhat.com>
     [not found]         ` <1234823097.30178.406.camel@laptop>
     [not found]           ` <20090216231946.GA12009@redhat.com>
     [not found]             ` <1234862974.4744.31.camel@laptop>
     [not found]               ` <20090217101130.GA8660@wotan.suse.de>
     [not found]                 ` <1234866453.4744.58.camel@laptop>
2009-02-17 11:26                   ` Q: smp.c && barriers (Was: [PATCH 1/4] generic-smp: remove single ipi fallback for smp_call_function_many()) Nick Piggin
2009-02-17 11:48                     ` Peter Zijlstra
2009-02-17 15:51                     ` Paul E. McKenney
2009-02-18  2:15                       ` Suresh Siddha
2009-02-18  2:40                         ` Paul E. McKenney
2009-02-17 19:28                     ` Q: " Oleg Nesterov
2009-02-17 21:32                       ` Paul E. McKenney
2009-02-17 21:45                         ` Oleg Nesterov
2009-02-17 22:39                           ` Paul E. McKenney
2009-02-18 13:52                             ` Nick Piggin
2009-02-18 16:09                               ` Linus Torvalds
2009-02-18 16:21                                 ` Ingo Molnar
2009-02-18 16:21                                   ` Ingo Molnar
2009-02-18 16:33                                   ` Linus Torvalds
2009-02-18 16:58                                     ` Ingo Molnar
2009-02-18 17:05                                       ` Ingo Molnar
2009-02-18 17:10                                         ` Ingo Molnar
2009-02-18 17:17                                           ` Linus Torvalds
2009-02-18 17:23                                             ` Ingo Molnar
2009-02-18 17:14                                         ` Linus Torvalds
2009-02-18 17:47                                           ` Ingo Molnar
2009-02-18 18:33                                           ` Suresh Siddha
2009-02-18 16:37                                   ` Gleb Natapov
2009-02-19  0:12                                 ` Nick Piggin
2009-02-19  6:47                                 ` Benjamin Herrenschmidt
2009-02-19 13:11                                   ` Nick Piggin
2009-02-19 13:11                                     ` Nick Piggin
2009-02-19 15:06                                     ` Ingo Molnar
2009-02-19 21:49                                       ` Benjamin Herrenschmidt
2009-02-18  2:21                     ` Suresh Siddha
2009-02-18 13:59                       ` Nick Piggin
2009-02-18 16:19                         ` Linus Torvalds
2009-02-18 16:23                           ` Ingo Molnar
2009-02-18 18:43                         ` Suresh Siddha
2009-02-18 19:17                           ` Ingo Molnar
2009-02-18 23:55                             ` Suresh Siddha
2009-02-19 12:20                               ` Ingo Molnar
2009-02-19 12:29                                 ` Nick Piggin
2009-02-19 12:45                                   ` Ingo Molnar
2009-02-19 22:00                                 ` Suresh Siddha
2009-02-20 10:56                                   ` Ingo Molnar
2009-02-20 18:56                                     ` Suresh Siddha
2009-02-20 18:56                                       ` Suresh Siddha
2009-02-20 19:40                                       ` Ingo Molnar
2009-02-20 23:28                                       ` Jack Steiner
2009-02-25  3:32                                       ` Nick Piggin
2009-02-25 12:47                                         ` Ingo Molnar
2009-02-25 18:25                                         ` Luck, Tony
2009-03-17 18:16                                         ` Suresh Siddha [this message]

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=1237313814.27006.203.camel@localhost.localdomain \
    --to=suresh.b.siddha@intel.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=jens.axboe@oracle.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=npiggin@suse.de \
    --cc=oleg@redhat.com \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=rostedt@goodmis.org \
    --cc=rusty@rustcorp.com.au \
    --cc=steiner@sgi.com \
    --cc=torvalds@linux-foundation.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