From mboxrd@z Thu Jan 1 00:00:00 1970 From: Suresh Siddha Subject: Re: smp.c && barriers (Was: [PATCH 1/4] generic-smp: remove single ipi fallback for smp_call_function_many()) Date: Thu, 19 Feb 2009 14:00:24 -0800 Message-ID: <1235080824.14523.19.camel@vayu> References: <20090216231946.GA12009@redhat.com> <1234862974.4744.31.camel@laptop> <20090217101130.GA8660@wotan.suse.de> <1234866453.4744.58.camel@laptop> <20090217112657.GE26402@wotan.suse.de> <1234923702.29823.7.camel@vayu> <20090218135945.GC23125@wotan.suse.de> <1234982620.29823.22.camel@vayu> <20090218191757.GD8889@elte.hu> <1235001314.14523.2.camel@vayu> <20090219122031.GC1703@elte.hu> Reply-To: Suresh Siddha Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit Return-path: Received: from mga14.intel.com ([143.182.124.37]:49259 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752141AbZBSWBw (ORCPT ); Thu, 19 Feb 2009 17:01:52 -0500 In-Reply-To: <20090219122031.GC1703@elte.hu> Sender: linux-arch-owner@vger.kernel.org List-ID: To: Ingo Molnar Cc: Nick Piggin , Peter Zijlstra , Oleg Nesterov , Jens Axboe , Linus Torvalds , "Paul E. McKenney" , Rusty Russell , Steven Rostedt , "linux-kernel@vger.kernel.org" , "linux-arch@vger.kernel.org" On Thu, 2009-02-19 at 04:20 -0800, Ingo Molnar wrote: > Could you please refresh this patch to latest tip:master? The > APIC drivers moved to arch/x86/kernel/apic/. Appended the refreshed patch. Thanks. --- From: Suresh Siddha Subject: x86: move smp_mb() in flush tlb path to x2apic specific 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. And hence move smp_mb() in x86 flush tlb path to x2apic specific paths. Signed-off-by: Suresh Siddha --- diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c index 3f7df23..c54fffe 100644 --- a/arch/x86/kernel/apic/x2apic_cluster.c +++ b/arch/x86/kernel/apic/x2apic_cluster.c @@ -63,6 +63,13 @@ static void x2apic_send_IPI_mask(const struct cpumask *mask, int vector) unsigned long query_cpu; unsigned long flags; + /* + * Make previous memory operations globally visible before + * sending the IPI. We need a serializing instruction or mfence + * for this. + */ + smp_mb(); + local_irq_save(flags); for_each_cpu(query_cpu, mask) { __x2apic_send_IPI_dest( @@ -79,6 +86,13 @@ static void unsigned long query_cpu; unsigned long flags; + /* + * Make previous memory operations globally visible before + * sending the IPI. We need a serializing instruction or mfence + * for this. + */ + smp_mb(); + local_irq_save(flags); for_each_cpu(query_cpu, mask) { if (query_cpu == this_cpu) @@ -96,6 +110,13 @@ static void x2apic_send_IPI_allbutself(int vector) unsigned long query_cpu; unsigned long flags; + /* + * Make previous memory operations globally visible before + * sending the IPI. We need a serializing instruction or mfence + * for this. + */ + smp_mb(); + 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 d2d52eb..84cc2f3 100644 --- a/arch/x86/kernel/apic/x2apic_phys.c +++ b/arch/x86/kernel/apic/x2apic_phys.c @@ -58,6 +58,13 @@ static void x2apic_send_IPI_mask(const struct cpumask *mask, int vector) unsigned long query_cpu; unsigned long flags; + /* + * Make previous memory operations globally visible before + * sending the IPI. We need a serializing instruction or mfence + * for this. + */ + smp_mb(); + local_irq_save(flags); for_each_cpu(query_cpu, mask) { __x2apic_send_IPI_dest(per_cpu(x86_cpu_to_apicid, query_cpu), @@ -73,6 +80,13 @@ static void unsigned long query_cpu; unsigned long flags; + /* + * Make previous memory operations globally visible before + * sending the IPI. We need a serializing instruction or mfence + * for this. + */ + smp_mb(); + local_irq_save(flags); for_each_cpu(query_cpu, mask) { if (query_cpu != this_cpu) @@ -89,6 +103,13 @@ static void x2apic_send_IPI_allbutself(int vector) unsigned long query_cpu; unsigned long flags; + /* + * Make previous memory operations globally visible before + * sending the IPI. We need a serializing instruction or mfence + * for this. + */ + smp_mb(); + 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. */