All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Hansen <dave@sr71.net>
To: Anthony Iliopoulos <anthony.iliopoulos@huawei.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
	x86@kernel.org, linux-kernel@vger.kernel.org,
	"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	Shay Goikhman <shay.goikhman@huawei.com>,
	Paul Mundt <paul.mundt@huawei.com>,
	Carlos Villavieja <villavieja@hps.utexas.edu>,
	Nacho Navarro <nacho.navarro@bsc.es>,
	Avi Mendelson <avi.mendelson@tce.technion.ac.il>,
	Yoav Etsion <yetsion@tce.technion.ac.il>,
	Gerald Schaefer <gerald.schaefer@de.ibm.com>,
	David Gibson <david@gibson.dropbear.id.au>,
	linux-arch <linux-arch@vger.kernel.org>
Subject: Re: [PATCH] x86, hugetlb: add missing TLB page invalidation for hugetlb_cow()
Date: Wed, 14 May 2014 10:24:34 -0700	[thread overview]
Message-ID: <5373A6D2.9050304@sr71.net> (raw)
In-Reply-To: <20140515170035.GA15779@server-36.huawei.corp>

On 05/15/2014 10:00 AM, Anthony Iliopoulos wrote:
> I have actually also wondered about another related thing:
> even when we actually do invalidate the page, there may still be a
> race between a thread on a core that reads the page in some tight
> loop (e.g. on a spinlock), and the page fault handler running on
> a different core, at the point where the pte is set. Since we
> invalidate the page via the TLB shootdowns *before* we update
> the pte (this is true for all do_wp_page(), do_huge_pmd_wp_page()
> as well as hugetlb_cow()), there may be some tiny window where the
> thread might re-read the page before the pte is set.

Don't forget about the "clear" part.  ptep_clear_flush() does:

        pte = ptep_get_and_clear(mm, address, ptep);
        if (pte_accessible(mm, pte))
                flush_tlb_page(vma, address);

so it makes the pte !present and guarantees that any other CPUs looking
at it after the flush but before the set_pte() will also end up in the
page fault handler, and they'll wait until the first fault has finished
with the page tables.

  reply	other threads:[~2014-05-14 17:24 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-14  9:29 [PATCH] x86, hugetlb: add missing TLB page invalidation for hugetlb_cow() Anthony Iliopoulos
2014-05-13 22:44 ` Dave Hansen
2014-05-15 17:00   ` Anthony Iliopoulos
2014-05-15 17:00     ` Anthony Iliopoulos
2014-05-14 17:24     ` Dave Hansen [this message]
2014-05-15  7:05     ` Oren Twaig
2014-05-17  9:24       ` Anthony Iliopoulos
2014-05-17  9:24         ` Anthony Iliopoulos
2014-05-13 23:36 ` [tip:x86/urgent] x86, mm, hugetlb: Add " tip-bot for Anthony Iliopoulos

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=5373A6D2.9050304@sr71.net \
    --to=dave@sr71.net \
    --cc=anthony.iliopoulos@huawei.com \
    --cc=avi.mendelson@tce.technion.ac.il \
    --cc=david@gibson.dropbear.id.au \
    --cc=gerald.schaefer@de.ibm.com \
    --cc=hpa@zytor.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=nacho.navarro@bsc.es \
    --cc=paul.mundt@huawei.com \
    --cc=shay.goikhman@huawei.com \
    --cc=tglx@linutronix.de \
    --cc=villavieja@hps.utexas.edu \
    --cc=x86@kernel.org \
    --cc=yetsion@tce.technion.ac.il \
    /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.