All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeremy Fitzhardinge <jeremy@goop.org>
To: Nick Piggin <npiggin@suse.de>
Cc: Avi Kivity <avi@redhat.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Linux Memory Management List <linux-mm@kvack.org>,
	the arch/x86 maintainers <x86@kernel.org>
Subject: [PATCH 2/2] xen: spin in xen_flush_tlb_others if a target cpu is in gup_fast()
Date: Fri, 27 Mar 2009 13:31:57 -0700	[thread overview]
Message-ID: <49CD37BD.1080102@goop.org> (raw)

get_user_pages_fast() relies on cross-cpu tlb flushes being a barrier
between clearing and setting a pte, and before freeing a pagetable page.

It normally implements this by disabling interrupts to suspend tlb flush
IPIs.  This doesn't work for us because we don't use kernel-visible
IPIs for tlb flushes, so just spin manually until none of our target
cpus are in gup_fast().

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>

diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index aa16ef4..b0523f8 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -50,6 +50,7 @@
 #include <asm/setup.h>
 #include <asm/paravirt.h>
 #include <asm/linkage.h>
+#include <asm/mmu.h>
 
 #include <asm/xen/hypercall.h>
 #include <asm/xen/hypervisor.h>
@@ -1334,6 +1335,14 @@ static void xen_flush_tlb_others(const struct cpumask *cpus,
 	MULTI_mmuext_op(mcs.mc, &args->op, 1, NULL, DOMID_SELF);
 
 	xen_mc_issue(PARAVIRT_LAZY_MMU);
+
+	/*
+	 * If we're racing with a get_user_pages_fast(), wait here
+	 * until it has finishes so that it can use cross-cpu tlb
+	 * flush as a barrier.
+	 */
+	while (cpus_intersects(*in_gup_cpumask, *cpus))
+		cpu_relax();
 }
 
 static unsigned long xen_read_cr3(void)



WARNING: multiple messages have this Message-ID (diff)
From: Jeremy Fitzhardinge <jeremy@goop.org>
To: Nick Piggin <npiggin@suse.de>
Cc: Avi Kivity <avi@redhat.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Linux Memory Management List <linux-mm@kvack.org>,
	the arch/x86 maintainers <x86@kernel.org>
Subject: [PATCH 2/2] xen: spin in xen_flush_tlb_others if a target cpu is in gup_fast()
Date: Fri, 27 Mar 2009 13:31:57 -0700	[thread overview]
Message-ID: <49CD37BD.1080102@goop.org> (raw)

get_user_pages_fast() relies on cross-cpu tlb flushes being a barrier
between clearing and setting a pte, and before freeing a pagetable page.

It normally implements this by disabling interrupts to suspend tlb flush
IPIs.  This doesn't work for us because we don't use kernel-visible
IPIs for tlb flushes, so just spin manually until none of our target
cpus are in gup_fast().

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>

diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index aa16ef4..b0523f8 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -50,6 +50,7 @@
 #include <asm/setup.h>
 #include <asm/paravirt.h>
 #include <asm/linkage.h>
+#include <asm/mmu.h>
 
 #include <asm/xen/hypercall.h>
 #include <asm/xen/hypervisor.h>
@@ -1334,6 +1335,14 @@ static void xen_flush_tlb_others(const struct cpumask *cpus,
 	MULTI_mmuext_op(mcs.mc, &args->op, 1, NULL, DOMID_SELF);
 
 	xen_mc_issue(PARAVIRT_LAZY_MMU);
+
+	/*
+	 * If we're racing with a get_user_pages_fast(), wait here
+	 * until it has finishes so that it can use cross-cpu tlb
+	 * flush as a barrier.
+	 */
+	while (cpus_intersects(*in_gup_cpumask, *cpus))
+		cpu_relax();
 }
 
 static unsigned long xen_read_cr3(void)


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

             reply	other threads:[~2009-03-27 20:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-27 20:31 Jeremy Fitzhardinge [this message]
2009-03-27 20:31 ` [PATCH 2/2] xen: spin in xen_flush_tlb_others if a target cpu is in gup_fast() Jeremy Fitzhardinge

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=49CD37BD.1080102@goop.org \
    --to=jeremy@goop.org \
    --cc=akpm@linux-foundation.org \
    --cc=avi@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=npiggin@suse.de \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.