All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gerald Schaefer <gerald.schaefer@de.ibm.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org,
	schwidefsky@de.ibm.com, Ingo Molnar <mingo@elte.hu>,
	"David S. Miller" <davem@davemloft.net>,
	Tony Luck <tony.luck@intel.com>,
	Paul Mackerras <paulus@samba.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Paul Mundt <lethal@linux-sh.org>
Subject: [PATCH 2/3] hugetlbfs: add missing TLB flush to hugetlb_cow()
Date: Wed, 02 Apr 2008 16:29:05 +0200	[thread overview]
Message-ID: <1207146546.4980.14.camel@localhost.localdomain> (raw)
In-Reply-To: <1207145843.4980.7.camel@localhost.localdomain>

Subject: [PATCH 2/3] hugetlbfs: add missing TLB flush to hugetlb_cow()

From: Gerald Schaefer <gerald.schaefer@de.ibm.com>

A cow break on a hugetlbfs page with page_count > 1 will set a new pte
with set_huge_pte_at(), w/o any tlb flush operation. The old pte will
remain in the tlb and subsequent write access to the page will result
in a page fault loop, for as long as it may take until the tlb is
flushed from somewhere else.
This patch introduces an architecture-specific huge_ptep_clear_flush()
function, which is called before the the set_huge_pte_at() in
hugetlb_cow().

NOTE: This is just a nop on all architectures for now, there will be an
s390 implementation with our large page patch later. Other architectures
should define their own huge_ptep_clear_flush() if needed.

Acked-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Gerald Schaefer <gerald.schaefer@de.ibm.com>
---

 include/asm-ia64/hugetlb.h    |    2 ++
 include/asm-powerpc/hugetlb.h |    2 ++
 include/asm-sh/hugetlb.h      |    2 ++
 include/asm-sparc64/hugetlb.h |    2 ++
 include/asm-x86/hugetlb.h     |    2 ++
 mm/hugetlb.c                  |    1 +
 6 files changed, 11 insertions(+)

Index: linux-2.6.25-rc7/mm/hugetlb.c
===================================================================
--- linux-2.6.25-rc7.orig/mm/hugetlb.c
+++ linux-2.6.25-rc7/mm/hugetlb.c
@@ -864,6 +864,7 @@ static int hugetlb_cow(struct mm_struct 
 	ptep = huge_pte_offset(mm, address & HPAGE_MASK);
 	if (likely(pte_same(*ptep, pte))) {
 		/* Break COW */
+		huge_ptep_clear_flush(vma, address, ptep);
 		set_huge_pte_at(mm, address, ptep,
 				make_huge_pte(vma, new_page, 1));
 		/* Make the old page be freed below */
Index: linux-2.6.25-rc7/include/asm-ia64/hugetlb.h
===================================================================
--- linux-2.6.25-rc7.orig/include/asm-ia64/hugetlb.h
+++ linux-2.6.25-rc7/include/asm-ia64/hugetlb.h
@@ -18,4 +18,6 @@ int prepare_hugepage_range(unsigned long
 
 #define hugetlb_prefault_arch_hook(mm)		do { } while (0)
 
+#define huge_ptep_clear_flush(vma, addr, ptep)	do { } while (0)
+
 #endif /* _ASM_IA64_HUGETLB_H */
Index: linux-2.6.25-rc7/include/asm-powerpc/hugetlb.h
===================================================================
--- linux-2.6.25-rc7.orig/include/asm-powerpc/hugetlb.h
+++ linux-2.6.25-rc7/include/asm-powerpc/hugetlb.h
@@ -32,4 +32,6 @@ pte_t huge_ptep_get_and_clear(struct mm_
 
 #define hugetlb_prefault_arch_hook(mm)		do { } while (0)
 
+#define huge_ptep_clear_flush(vma, addr, ptep)	do { } while (0)
+
 #endif /* _ASM_POWERPC_HUGETLB_H */
Index: linux-2.6.25-rc7/include/asm-sh/hugetlb.h
===================================================================
--- linux-2.6.25-rc7.orig/include/asm-sh/hugetlb.h
+++ linux-2.6.25-rc7/include/asm-sh/hugetlb.h
@@ -25,4 +25,6 @@ static inline int prepare_hugepage_range
 
 #define hugetlb_prefault_arch_hook(mm)		do { } while (0)
 
+#define huge_ptep_clear_flush(vma, addr, ptep)	do { } while (0)
+
 #endif /* _ASM_SH_HUGETLB_H */
Index: linux-2.6.25-rc7/include/asm-sparc64/hugetlb.h
===================================================================
--- linux-2.6.25-rc7.orig/include/asm-sparc64/hugetlb.h
+++ linux-2.6.25-rc7/include/asm-sparc64/hugetlb.h
@@ -27,4 +27,6 @@ pte_t huge_ptep_get_and_clear(struct mm_
 
 void hugetlb_prefault_arch_hook(struct mm_struct *mm);
 
+#define huge_ptep_clear_flush(vma, addr, ptep)	do { } while (0)
+
 #endif /* _ASM_SPARC64_HUGETLB_H */
Index: linux-2.6.25-rc7/include/asm-x86/hugetlb.h
===================================================================
--- linux-2.6.25-rc7.orig/include/asm-x86/hugetlb.h
+++ linux-2.6.25-rc7/include/asm-x86/hugetlb.h
@@ -25,4 +25,6 @@ static inline int prepare_hugepage_range
 
 #define hugetlb_prefault_arch_hook(mm)		do { } while (0)
 
+#define huge_ptep_clear_flush(vma, addr, ptep)	do { } while (0)
+
 #endif /* _ASM_X86_HUGETLB_H */



  parent reply	other threads:[~2008-04-02 14:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-02 14:17 [PATCH 0/3] hugetlbfs: cleanup and new primitives for s390 Gerald Schaefer
2008-04-02 14:26 ` [PATCH 1/3] hugetlbfs: architecture header cleanup Gerald Schaefer
2008-04-02 17:42   ` Dave Hansen
2008-04-02 19:07     ` Heiko Carstens
2008-04-03 21:43   ` Andrew Morton
2008-04-02 14:29 ` Gerald Schaefer [this message]
2008-04-03 21:49   ` [PATCH 2/3] hugetlbfs: add missing TLB flush to hugetlb_cow() Andrew Morton
2008-04-02 14:38 ` [PATCH 3/3] hugetlbfs: common code update for s390 Gerald Schaefer
  -- strict thread matches above, loose matches on Subject: below --
2008-04-04 16:45 [PATCH 0/3] hugetlbfs: cleanup and new primitives for s390, v3 Gerald Schaefer
2008-04-04 16:51 ` [PATCH 2/3] hugetlbfs: add missing TLB flush to hugetlb_cow() Gerald Schaefer

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=1207146546.4980.14.camel@localhost.localdomain \
    --to=gerald.schaefer@de.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=lethal@linux-sh.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=paulus@samba.org \
    --cc=schwidefsky@de.ibm.com \
    --cc=tglx@linutronix.de \
    --cc=tony.luck@intel.com \
    /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.