LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 0/3] hugetlbfs: cleanup and new primitives for s390
@ 2008-04-02 14:17 Gerald Schaefer
2008-04-02 14:26 ` [PATCH 1/3] hugetlbfs: architecture header cleanup Gerald Schaefer
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Gerald Schaefer @ 2008-04-02 14:17 UTC (permalink / raw)
To: Andrew Morton
Cc: linux-kernel, linux-s390, schwidefsky, Ingo Molnar,
David S. Miller, Tony Luck, Paul Mackerras, Thomas Gleixner,
Paul Mundt
On Tue, 2008-04-01 at 15:31 -0700, Andrew Morton wrote:
> > As there were no objections so far, which would be the right tree for
> > this to get it upstream?
>
> -mm, I suppose.
>
> But all the patcehs had the same title and I'd prefer to not have to
> invent your patch titles for you.
This patchset cleans up hugetlbfs architecture headers and adds new
primitives as preparation for the s390 large page support. Most notably
we found that we need to add a new tlb flush for the copy-on-write of
a large page (patch #2). We think that this is a bug, but obviously one
that hasn't shown up so far on any of the other large page architectures.
--
Gerald Schaefer
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 1/3] hugetlbfs: architecture header cleanup
2008-04-02 14:17 [PATCH 0/3] hugetlbfs: cleanup and new primitives for s390 Gerald Schaefer
@ 2008-04-02 14:26 ` Gerald Schaefer
2008-04-02 17:42 ` Dave Hansen
2008-04-03 21:43 ` Andrew Morton
2008-04-02 14:29 ` [PATCH 2/3] hugetlbfs: add missing TLB flush to hugetlb_cow() Gerald Schaefer
2008-04-02 14:38 ` [PATCH 3/3] hugetlbfs: common code update for s390 Gerald Schaefer
2 siblings, 2 replies; 11+ messages in thread
From: Gerald Schaefer @ 2008-04-02 14:26 UTC (permalink / raw)
To: Andrew Morton
Cc: linux-kernel, linux-s390, schwidefsky, Ingo Molnar,
David S. Miller, Tony Luck, Paul Mackerras, Thomas Gleixner,
Paul Mundt
Subject: [PATCH 1/3] hugetlbfs: architecture header cleanup
From: Gerald Schaefer <gerald.schaefer@de.ibm.com>
This patch moves all architecture functions for hugetlb to architecture
header files (include/asm-foo/hugetlb.h). It also removes (!)
ARCH_HAS_HUGEPAGE_ONLY_RANGE, ARCH_HAS_HUGETLB_FREE_PGD_RANGE,
ARCH_HAS_PREPARE_HUGEPAGE_RANGE, ARCH_HAS_SETCLEAR_HUGE_PTE and
ARCH_HAS_HUGETLB_PREFAULT_HOOK.
Cross-Compile tests on the affected architectures (and one unaffected)
worked fine, but I had no cross-compiler for sh.
Acked-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Gerald Schaefer <gerald.schaefer@de.ibm.com>
---
include/asm-ia64/hugetlb.h | 21 +++++++++++++++++++
include/asm-ia64/page.h | 6 -----
include/asm-powerpc/hugetlb.h | 35 +++++++++++++++++++++++++++++++
include/asm-powerpc/page_64.h | 7 ------
include/asm-sh/hugetlb.h | 28 +++++++++++++++++++++++++
include/asm-sparc64/hugetlb.h | 30 +++++++++++++++++++++++++++
include/asm-sparc64/page.h | 2 -
include/asm-x86/hugetlb.h | 28 +++++++++++++++++++++++++
include/linux/hugetlb.h | 46 ------------------------------------------
9 files changed, 143 insertions(+), 60 deletions(-)
Index: linux-2.6.25-rc7/include/asm-ia64/hugetlb.h
===================================================================
--- /dev/null
+++ linux-2.6.25-rc7/include/asm-ia64/hugetlb.h
@@ -0,0 +1,21 @@
+#ifndef _ASM_IA64_HUGETLB_H
+#define _ASM_IA64_HUGETLB_H
+
+#include <asm/page.h>
+
+
+#define is_hugepage_only_range(mm, addr, len) \
+ (REGION_NUMBER(addr) == RGN_HPAGE || \
+ REGION_NUMBER((addr)+(len)-1) == RGN_HPAGE)
+
+void hugetlb_free_pgd_range(struct mmu_gather **tlb, unsigned long addr,
+ unsigned long end, unsigned long floor,
+ unsigned long ceiling);
+int prepare_hugepage_range(unsigned long addr, unsigned long len);
+
+#define set_huge_pte_at(mm, addr, ptep, pte) set_pte_at(mm, addr, ptep, pte)
+#define huge_ptep_get_and_clear(mm, addr, ptep) ptep_get_and_clear(mm, addr, ptep)
+
+#define hugetlb_prefault_arch_hook(mm) do { } while (0)
+
+#endif /* _ASM_IA64_HUGETLB_H */
Index: linux-2.6.25-rc7/include/asm-sh/hugetlb.h
===================================================================
--- /dev/null
+++ linux-2.6.25-rc7/include/asm-sh/hugetlb.h
@@ -0,0 +1,28 @@
+#ifndef _ASM_SH_HUGETLB_H
+#define _ASM_SH_HUGETLB_H
+
+#include <asm/page.h>
+
+
+#define is_hugepage_only_range(mm, addr, len) 0
+#define hugetlb_free_pgd_range free_pgd_range
+
+/*
+ * If the arch doesn't supply something else, assume that hugepage
+ * size aligned regions are ok without further preparation.
+ */
+static inline int prepare_hugepage_range(unsigned long addr, unsigned long len)
+{
+ if (len & ~HPAGE_MASK)
+ return -EINVAL;
+ if (addr & ~HPAGE_MASK)
+ return -EINVAL;
+ return 0;
+}
+
+#define set_huge_pte_at(mm, addr, ptep, pte) set_pte_at(mm, addr, ptep, pte)
+#define huge_ptep_get_and_clear(mm, addr, ptep) ptep_get_and_clear(mm, addr, ptep)
+
+#define hugetlb_prefault_arch_hook(mm) do { } while (0)
+
+#endif /* _ASM_SH_HUGETLB_H */
Index: linux-2.6.25-rc7/include/asm-sparc64/hugetlb.h
===================================================================
--- /dev/null
+++ linux-2.6.25-rc7/include/asm-sparc64/hugetlb.h
@@ -0,0 +1,30 @@
+#ifndef _ASM_SPARC64_HUGETLB_H
+#define _ASM_SPARC64_HUGETLB_H
+
+#include <asm/page.h>
+
+
+#define is_hugepage_only_range(mm, addr, len) 0
+#define hugetlb_free_pgd_range free_pgd_range
+
+/*
+ * If the arch doesn't supply something else, assume that hugepage
+ * size aligned regions are ok without further preparation.
+ */
+static inline int prepare_hugepage_range(unsigned long addr, unsigned long len)
+{
+ if (len & ~HPAGE_MASK)
+ return -EINVAL;
+ if (addr & ~HPAGE_MASK)
+ return -EINVAL;
+ return 0;
+}
+
+void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
+ pte_t *ptep, pte_t pte);
+pte_t huge_ptep_get_and_clear(struct mm_struct *mm, unsigned long addr,
+ pte_t *ptep);
+
+void hugetlb_prefault_arch_hook(struct mm_struct *mm);
+
+#endif /* _ASM_SPARC64_HUGETLB_H */
Index: linux-2.6.25-rc7/include/asm-x86/hugetlb.h
===================================================================
--- /dev/null
+++ linux-2.6.25-rc7/include/asm-x86/hugetlb.h
@@ -0,0 +1,28 @@
+#ifndef _ASM_X86_HUGETLB_H
+#define _ASM_X86_HUGETLB_H
+
+#include <asm/page.h>
+
+
+#define is_hugepage_only_range(mm, addr, len) 0
+#define hugetlb_free_pgd_range free_pgd_range
+
+/*
+ * If the arch doesn't supply something else, assume that hugepage
+ * size aligned regions are ok without further preparation.
+ */
+static inline int prepare_hugepage_range(unsigned long addr, unsigned long len)
+{
+ if (len & ~HPAGE_MASK)
+ return -EINVAL;
+ if (addr & ~HPAGE_MASK)
+ return -EINVAL;
+ return 0;
+}
+
+#define set_huge_pte_at(mm, addr, ptep, pte) set_pte_at(mm, addr, ptep, pte)
+#define huge_ptep_get_and_clear(mm, addr, ptep) ptep_get_and_clear(mm, addr, ptep)
+
+#define hugetlb_prefault_arch_hook(mm) do { } while (0)
+
+#endif /* _ASM_X86_HUGETLB_H */
Index: linux-2.6.25-rc7/include/linux/hugetlb.h
===================================================================
--- linux-2.6.25-rc7.orig/include/linux/hugetlb.h
+++ linux-2.6.25-rc7/include/linux/hugetlb.h
@@ -8,6 +8,7 @@
#include <linux/mempolicy.h>
#include <linux/shm.h>
#include <asm/tlbflush.h>
+#include <asm/hugetlb.h>
struct ctl_table;
@@ -51,51 +52,6 @@ int pmd_huge(pmd_t pmd);
void hugetlb_change_protection(struct vm_area_struct *vma,
unsigned long address, unsigned long end, pgprot_t newprot);
-#ifndef ARCH_HAS_HUGEPAGE_ONLY_RANGE
-#define is_hugepage_only_range(mm, addr, len) 0
-#endif
-
-#ifndef ARCH_HAS_HUGETLB_FREE_PGD_RANGE
-#define hugetlb_free_pgd_range free_pgd_range
-#else
-void hugetlb_free_pgd_range(struct mmu_gather **tlb, unsigned long addr,
- unsigned long end, unsigned long floor,
- unsigned long ceiling);
-#endif
-
-#ifndef ARCH_HAS_PREPARE_HUGEPAGE_RANGE
-/*
- * If the arch doesn't supply something else, assume that hugepage
- * size aligned regions are ok without further preparation.
- */
-static inline int prepare_hugepage_range(unsigned long addr, unsigned long len)
-{
- if (len & ~HPAGE_MASK)
- return -EINVAL;
- if (addr & ~HPAGE_MASK)
- return -EINVAL;
- return 0;
-}
-#else
-int prepare_hugepage_range(unsigned long addr, unsigned long len);
-#endif
-
-#ifndef ARCH_HAS_SETCLEAR_HUGE_PTE
-#define set_huge_pte_at(mm, addr, ptep, pte) set_pte_at(mm, addr, ptep, pte)
-#define huge_ptep_get_and_clear(mm, addr, ptep) ptep_get_and_clear(mm, addr, ptep)
-#else
-void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
- pte_t *ptep, pte_t pte);
-pte_t huge_ptep_get_and_clear(struct mm_struct *mm, unsigned long addr,
- pte_t *ptep);
-#endif
-
-#ifndef ARCH_HAS_HUGETLB_PREFAULT_HOOK
-#define hugetlb_prefault_arch_hook(mm) do { } while (0)
-#else
-void hugetlb_prefault_arch_hook(struct mm_struct *mm);
-#endif
-
#else /* !CONFIG_HUGETLB_PAGE */
static inline int is_vm_hugetlb_page(struct vm_area_struct *vma)
Index: linux-2.6.25-rc7/include/asm-powerpc/hugetlb.h
===================================================================
--- /dev/null
+++ linux-2.6.25-rc7/include/asm-powerpc/hugetlb.h
@@ -0,0 +1,35 @@
+#ifndef _ASM_POWERPC_HUGETLB_H
+#define _ASM_POWERPC_HUGETLB_H
+
+#include <asm/page.h>
+
+
+extern int is_hugepage_only_range(struct mm_struct *m,
+ unsigned long addr,
+ unsigned long len);
+
+void hugetlb_free_pgd_range(struct mmu_gather **tlb, unsigned long addr,
+ unsigned long end, unsigned long floor,
+ unsigned long ceiling);
+
+/*
+ * If the arch doesn't supply something else, assume that hugepage
+ * size aligned regions are ok without further preparation.
+ */
+static inline int prepare_hugepage_range(unsigned long addr, unsigned long len)
+{
+ if (len & ~HPAGE_MASK)
+ return -EINVAL;
+ if (addr & ~HPAGE_MASK)
+ return -EINVAL;
+ return 0;
+}
+
+void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
+ pte_t *ptep, pte_t pte);
+pte_t huge_ptep_get_and_clear(struct mm_struct *mm, unsigned long addr,
+ pte_t *ptep);
+
+#define hugetlb_prefault_arch_hook(mm) do { } while (0)
+
+#endif /* _ASM_POWERPC_HUGETLB_H */
Index: linux-2.6.25-rc7/include/asm-ia64/page.h
===================================================================
--- linux-2.6.25-rc7.orig/include/asm-ia64/page.h
+++ linux-2.6.25-rc7/include/asm-ia64/page.h
@@ -54,9 +54,6 @@
# define HPAGE_MASK (~(HPAGE_SIZE - 1))
# define HAVE_ARCH_HUGETLB_UNMAPPED_AREA
-# define ARCH_HAS_HUGEPAGE_ONLY_RANGE
-# define ARCH_HAS_PREPARE_HUGEPAGE_RANGE
-# define ARCH_HAS_HUGETLB_FREE_PGD_RANGE
#endif /* CONFIG_HUGETLB_PAGE */
#ifdef __ASSEMBLY__
@@ -153,9 +150,6 @@ typedef union ia64_va {
# define htlbpage_to_page(x) (((unsigned long) REGION_NUMBER(x) << 61) \
| (REGION_OFFSET(x) >> (HPAGE_SHIFT-PAGE_SHIFT)))
# define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)
-# define is_hugepage_only_range(mm, addr, len) \
- (REGION_NUMBER(addr) == RGN_HPAGE || \
- REGION_NUMBER((addr)+(len)-1) == RGN_HPAGE)
extern unsigned int hpage_shift;
#endif
Index: linux-2.6.25-rc7/include/asm-powerpc/page_64.h
===================================================================
--- linux-2.6.25-rc7.orig/include/asm-powerpc/page_64.h
+++ linux-2.6.25-rc7/include/asm-powerpc/page_64.h
@@ -128,11 +128,6 @@ extern void slice_init_context(struct mm
extern void slice_set_user_psize(struct mm_struct *mm, unsigned int psize);
#define slice_mm_new_context(mm) ((mm)->context.id == 0)
-#define ARCH_HAS_HUGEPAGE_ONLY_RANGE
-extern int is_hugepage_only_range(struct mm_struct *m,
- unsigned long addr,
- unsigned long len);
-
#endif /* __ASSEMBLY__ */
#else
#define slice_init()
@@ -146,8 +141,6 @@ do { \
#ifdef CONFIG_HUGETLB_PAGE
-#define ARCH_HAS_HUGETLB_FREE_PGD_RANGE
-#define ARCH_HAS_SETCLEAR_HUGE_PTE
#define HAVE_ARCH_HUGETLB_UNMAPPED_AREA
#endif /* !CONFIG_HUGETLB_PAGE */
Index: linux-2.6.25-rc7/include/asm-sparc64/page.h
===================================================================
--- linux-2.6.25-rc7.orig/include/asm-sparc64/page.h
+++ linux-2.6.25-rc7/include/asm-sparc64/page.h
@@ -39,8 +39,6 @@
#define HPAGE_SIZE (_AC(1,UL) << HPAGE_SHIFT)
#define HPAGE_MASK (~(HPAGE_SIZE - 1UL))
#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)
-#define ARCH_HAS_SETCLEAR_HUGE_PTE
-#define ARCH_HAS_HUGETLB_PREFAULT_HOOK
#define HAVE_ARCH_HUGETLB_UNMAPPED_AREA
#endif
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 2/3] hugetlbfs: add missing TLB flush to hugetlb_cow()
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 14:29 ` Gerald Schaefer
2008-04-03 21:49 ` Andrew Morton
2008-04-02 14:38 ` [PATCH 3/3] hugetlbfs: common code update for s390 Gerald Schaefer
2 siblings, 1 reply; 11+ messages in thread
From: Gerald Schaefer @ 2008-04-02 14:29 UTC (permalink / raw)
To: Andrew Morton
Cc: linux-kernel, linux-s390, schwidefsky, Ingo Molnar,
David S. Miller, Tony Luck, Paul Mackerras, Thomas Gleixner,
Paul Mundt
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 */
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 3/3] hugetlbfs: common code update for s390
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 14:29 ` [PATCH 2/3] hugetlbfs: add missing TLB flush to hugetlb_cow() Gerald Schaefer
@ 2008-04-02 14:38 ` Gerald Schaefer
2 siblings, 0 replies; 11+ messages in thread
From: Gerald Schaefer @ 2008-04-02 14:38 UTC (permalink / raw)
To: Andrew Morton
Cc: linux-kernel, linux-s390, schwidefsky, Ingo Molnar,
David S. Miller, Tony Luck, Paul Mackerras, Thomas Gleixner,
Paul Mundt
Subject: [PATCH 3/3] hugetlbfs: common code update for s390
From: Gerald Schaefer <gerald.schaefer@de.ibm.com>
Huge ptes have a special type on s390 and cannot be handled with the
standard pte functions in certain cases. This patch adds some new
architecture-specific definitions and functions to hugetlb common code,
as a prerequisite for the s390 large page support. They won't affect
other architectures.
Acked-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Gerald Schaefer <gerald.schaefer@de.ibm.com>
---
include/asm-ia64/hugetlb.h | 11 +++++++++++
include/asm-powerpc/hugetlb.h | 11 +++++++++++
include/asm-sh/hugetlb.h | 11 +++++++++++
include/asm-sparc64/hugetlb.h | 11 +++++++++++
include/asm-x86/hugetlb.h | 11 +++++++++++
mm/hugetlb.c | 36 +++++++++++++++++++++---------------
6 files changed, 76 insertions(+), 15 deletions(-)
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
@@ -129,6 +129,7 @@ static void update_and_free_page(struct
}
set_compound_page_dtor(page, NULL);
set_page_refcounted(page);
+ arch_release_hugepage(page);
__free_pages(page, HUGETLB_PAGE_ORDER);
}
@@ -198,6 +199,10 @@ static struct page *alloc_fresh_huge_pag
htlb_alloc_mask|__GFP_COMP|__GFP_THISNODE|__GFP_NOWARN,
HUGETLB_PAGE_ORDER);
if (page) {
+ if (arch_prepare_hugepage(page)) {
+ __free_pages(page, HUGETLB_PAGE_ORDER);
+ return 0;
+ }
set_compound_page_dtor(page, free_huge_page);
spin_lock(&hugetlb_lock);
nr_huge_pages++;
@@ -707,7 +712,7 @@ static pte_t make_huge_pte(struct vm_are
entry =
pte_mkwrite(pte_mkdirty(mk_pte(page, vma->vm_page_prot)));
} else {
- entry = pte_wrprotect(mk_pte(page, vma->vm_page_prot));
+ entry = huge_pte_wrprotect(mk_pte(page, vma->vm_page_prot));
}
entry = pte_mkyoung(entry);
entry = pte_mkhuge(entry);
@@ -720,8 +725,8 @@ static void set_huge_ptep_writable(struc
{
pte_t entry;
- entry = pte_mkwrite(pte_mkdirty(*ptep));
- if (ptep_set_access_flags(vma, address, ptep, entry, 1)) {
+ entry = pte_mkwrite(pte_mkdirty(huge_ptep_get(ptep)));
+ if (huge_ptep_set_access_flags(vma, address, ptep, entry, 1)) {
update_mmu_cache(vma, address, entry);
}
}
@@ -751,10 +756,10 @@ int copy_hugetlb_page_range(struct mm_st
spin_lock(&dst->page_table_lock);
spin_lock(&src->page_table_lock);
- if (!pte_none(*src_pte)) {
+ if (!huge_pte_none(huge_ptep_get(src_pte))) {
if (cow)
- ptep_set_wrprotect(src, addr, src_pte);
- entry = *src_pte;
+ huge_ptep_set_wrprotect(src, addr, src_pte);
+ entry = huge_ptep_get(src_pte);
ptepage = pte_page(entry);
get_page(ptepage);
set_huge_pte_at(dst, addr, dst_pte, entry);
@@ -798,7 +803,7 @@ void __unmap_hugepage_range(struct vm_ar
continue;
pte = huge_ptep_get_and_clear(mm, address, ptep);
- if (pte_none(pte))
+ if (huge_pte_none(pte))
continue;
page = pte_page(pte);
@@ -862,7 +867,7 @@ static int hugetlb_cow(struct mm_struct
spin_lock(&mm->page_table_lock);
ptep = huge_pte_offset(mm, address & HPAGE_MASK);
- if (likely(pte_same(*ptep, pte))) {
+ if (likely(pte_same(huge_ptep_get(ptep), pte))) {
/* Break COW */
huge_ptep_clear_flush(vma, address, ptep);
set_huge_pte_at(mm, address, ptep,
@@ -932,7 +937,7 @@ retry:
goto backout;
ret = 0;
- if (!pte_none(*ptep))
+ if (!huge_pte_none(huge_ptep_get(ptep)))
goto backout;
new_pte = make_huge_pte(vma, page, ((vma->vm_flags & VM_WRITE)
@@ -974,8 +979,8 @@ int hugetlb_fault(struct mm_struct *mm,
* the same page in the page cache.
*/
mutex_lock(&hugetlb_instantiation_mutex);
- entry = *ptep;
- if (pte_none(entry)) {
+ entry = huge_ptep_get(ptep);
+ if (huge_pte_none(entry)) {
ret = hugetlb_no_page(mm, vma, address, ptep, write_access);
mutex_unlock(&hugetlb_instantiation_mutex);
return ret;
@@ -985,7 +990,7 @@ int hugetlb_fault(struct mm_struct *mm,
spin_lock(&mm->page_table_lock);
/* Check for a racing update before calling hugetlb_cow */
- if (likely(pte_same(entry, *ptep)))
+ if (likely(pte_same(entry, huge_ptep_get(ptep))))
if (write_access && !pte_write(entry))
ret = hugetlb_cow(mm, vma, address, ptep, entry);
spin_unlock(&mm->page_table_lock);
@@ -1015,7 +1020,8 @@ int follow_hugetlb_page(struct mm_struct
*/
pte = huge_pte_offset(mm, vaddr & HPAGE_MASK);
- if (!pte || pte_none(*pte) || (write && !pte_write(*pte))) {
+ if (!pte || huge_pte_none(huge_ptep_get(pte)) ||
+ (write && !pte_write(huge_ptep_get(pte)))) {
int ret;
spin_unlock(&mm->page_table_lock);
@@ -1031,7 +1037,7 @@ int follow_hugetlb_page(struct mm_struct
}
pfn_offset = (vaddr & ~HPAGE_MASK) >> PAGE_SHIFT;
- page = pte_page(*pte);
+ page = pte_page(huge_ptep_get(pte));
same_page:
if (pages) {
get_page(page);
@@ -1080,7 +1086,7 @@ void hugetlb_change_protection(struct vm
continue;
if (huge_pmd_unshare(mm, &address, ptep))
continue;
- if (!pte_none(*ptep)) {
+ if (!huge_pte_none(huge_ptep_get(ptep))) {
pte = huge_ptep_get_and_clear(mm, address, ptep);
pte = pte_mkhuge(pte_modify(pte, newprot));
set_huge_pte_at(mm, address, ptep, pte);
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,6 +18,17 @@ int prepare_hugepage_range(unsigned long
#define hugetlb_prefault_arch_hook(mm) do { } while (0)
+#define huge_pte_none(pte) pte_none(pte)
+#define huge_pte_wrprotect(pte) pte_wrprotect(pte)
+#define huge_ptep_set_wrprotect(mm, addr, ptep) \
+ ptep_set_wrprotect(mm, addr, ptep)
+#define huge_ptep_set_access_flags(vma, addr, ptep, pte, dirty) \
+ ptep_set_access_flags(vma, addr, ptep, pte, dirty)
+#define huge_ptep_get(ptep) (*ptep)
+
+#define arch_prepare_hugepage(page) 0
+#define arch_release_hugepage(page) 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,6 +32,17 @@ pte_t huge_ptep_get_and_clear(struct mm_
#define hugetlb_prefault_arch_hook(mm) do { } while (0)
+#define huge_pte_none(pte) pte_none(pte)
+#define huge_pte_wrprotect(pte) pte_wrprotect(pte)
+#define huge_ptep_set_wrprotect(mm, addr, ptep) \
+ ptep_set_wrprotect(mm, addr, ptep)
+#define huge_ptep_set_access_flags(vma, addr, ptep, pte, dirty) \
+ ptep_set_access_flags(vma, addr, ptep, pte, dirty)
+#define huge_ptep_get(ptep) (*ptep)
+
+#define arch_prepare_hugepage(page) 0
+#define arch_release_hugepage(page) 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,6 +25,17 @@ static inline int prepare_hugepage_range
#define hugetlb_prefault_arch_hook(mm) do { } while (0)
+#define huge_pte_none(pte) pte_none(pte)
+#define huge_pte_wrprotect(pte) pte_wrprotect(pte)
+#define huge_ptep_set_wrprotect(mm, addr, ptep) \
+ ptep_set_wrprotect(mm, addr, ptep)
+#define huge_ptep_set_access_flags(vma, addr, ptep, pte, dirty) \
+ ptep_set_access_flags(vma, addr, ptep, pte, dirty)
+#define huge_ptep_get(ptep) (*ptep)
+
+#define arch_prepare_hugepage(page) 0
+#define arch_release_hugepage(page) 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,6 +27,17 @@ pte_t huge_ptep_get_and_clear(struct mm_
void hugetlb_prefault_arch_hook(struct mm_struct *mm);
+#define huge_pte_none(pte) pte_none(pte)
+#define huge_pte_wrprotect(pte) pte_wrprotect(pte)
+#define huge_ptep_set_wrprotect(mm, addr, ptep) \
+ ptep_set_wrprotect(mm, addr, ptep)
+#define huge_ptep_set_access_flags(vma, addr, ptep, pte, dirty) \
+ ptep_set_access_flags(vma, addr, ptep, pte, dirty)
+#define huge_ptep_get(ptep) (*ptep)
+
+#define arch_prepare_hugepage(page) 0
+#define arch_release_hugepage(page) do { } while (0)
+
#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,6 +25,17 @@ static inline int prepare_hugepage_range
#define hugetlb_prefault_arch_hook(mm) do { } while (0)
+#define huge_pte_none(pte) pte_none(pte)
+#define huge_pte_wrprotect(pte) pte_wrprotect(pte)
+#define huge_ptep_set_wrprotect(mm, addr, ptep) \
+ ptep_set_wrprotect(mm, addr, ptep)
+#define huge_ptep_set_access_flags(vma, addr, ptep, pte, dirty) \
+ ptep_set_access_flags(vma, addr, ptep, pte, dirty)
+#define huge_ptep_get(ptep) (*ptep)
+
+#define arch_prepare_hugepage(page) 0
+#define arch_release_hugepage(page) do { } while (0)
+
#define huge_ptep_clear_flush(vma, addr, ptep) do { } while (0)
#endif /* _ASM_X86_HUGETLB_H */
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/3] hugetlbfs: architecture header cleanup
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
1 sibling, 1 reply; 11+ messages in thread
From: Dave Hansen @ 2008-04-02 17:42 UTC (permalink / raw)
To: Gerald Schaefer
Cc: Andrew Morton, linux-kernel, linux-s390, schwidefsky,
Ingo Molnar, David S. Miller, Tony Luck, Paul Mackerras,
Thomas Gleixner, Paul Mundt
On Wed, 2008-04-02 at 16:26 +0200, Gerald Schaefer wrote:
>
> include/asm-ia64/hugetlb.h | 21 +++++++++++++++++++
> include/asm-ia64/page.h | 6 -----
> include/asm-powerpc/hugetlb.h | 35 +++++++++++++++++++++++++++++++
> include/asm-powerpc/page_64.h | 7 ------
> include/asm-sh/hugetlb.h | 28 +++++++++++++++++++++++++
> include/asm-sparc64/hugetlb.h | 30 +++++++++++++++++++++++++++
> include/asm-sparc64/page.h | 2 -
> include/asm-x86/hugetlb.h | 28 +++++++++++++++++++++++++
> include/linux/hugetlb.h | 46 ------------------------------------------
The way I read this, you took some arch-independent bits, like
prepare_hugepage_range(), and copied them to several architectures. How
is this a cleanup? Can they really not share common code?
-- Dave
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/3] hugetlbfs: architecture header cleanup
2008-04-02 17:42 ` Dave Hansen
@ 2008-04-02 19:07 ` Heiko Carstens
0 siblings, 0 replies; 11+ messages in thread
From: Heiko Carstens @ 2008-04-02 19:07 UTC (permalink / raw)
To: Dave Hansen
Cc: Gerald Schaefer, Andrew Morton, linux-kernel, linux-s390,
schwidefsky, Ingo Molnar, David S. Miller, Tony Luck,
Paul Mackerras, Thomas Gleixner, Paul Mundt
On Wed, Apr 02, 2008 at 10:42:56AM -0700, Dave Hansen wrote:
>
> On Wed, 2008-04-02 at 16:26 +0200, Gerald Schaefer wrote:
> >
> > include/asm-ia64/hugetlb.h | 21 +++++++++++++++++++
> > include/asm-ia64/page.h | 6 -----
> > include/asm-powerpc/hugetlb.h | 35 +++++++++++++++++++++++++++++++
> > include/asm-powerpc/page_64.h | 7 ------
> > include/asm-sh/hugetlb.h | 28 +++++++++++++++++++++++++
> > include/asm-sparc64/hugetlb.h | 30 +++++++++++++++++++++++++++
> > include/asm-sparc64/page.h | 2 -
> > include/asm-x86/hugetlb.h | 28 +++++++++++++++++++++++++
> > include/linux/hugetlb.h | 46 ------------------------------------------
>
> The way I read this, you took some arch-independent bits, like
> prepare_hugepage_range(), and copied them to several architectures. How
> is this a cleanup? Can they really not share common code?
This question has been raised before. See: http://lkml.org/lkml/2008/3/28/267 .
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/3] hugetlbfs: architecture header cleanup
2008-04-02 14:26 ` [PATCH 1/3] hugetlbfs: architecture header cleanup Gerald Schaefer
2008-04-02 17:42 ` Dave Hansen
@ 2008-04-03 21:43 ` Andrew Morton
1 sibling, 0 replies; 11+ messages in thread
From: Andrew Morton @ 2008-04-03 21:43 UTC (permalink / raw)
To: Gerald Schaefer
Cc: linux-kernel, linux-s390, schwidefsky, mingo, davem, tony.luck,
paulus, tglx, lethal
On Wed, 02 Apr 2008 16:26:55 +0200
Gerald Schaefer <gerald.schaefer@de.ibm.com> wrote:
> Subject: [PATCH 1/3] hugetlbfs: architecture header cleanup
>
> From: Gerald Schaefer <gerald.schaefer@de.ibm.com>
>
> This patch moves all architecture functions for hugetlb to architecture
> header files (include/asm-foo/hugetlb.h). It also removes (!)
> ARCH_HAS_HUGEPAGE_ONLY_RANGE, ARCH_HAS_HUGETLB_FREE_PGD_RANGE,
> ARCH_HAS_PREPARE_HUGEPAGE_RANGE, ARCH_HAS_SETCLEAR_HUGE_PTE and
> ARCH_HAS_HUGETLB_PREFAULT_HOOK.
>
> Cross-Compile tests on the affected architectures (and one unaffected)
> worked fine, but I had no cross-compiler for sh.
>
This text explains what the patch does but not why it does it. Always provide
both, please. That way people will stop asking why this:
>
> include/asm-ia64/hugetlb.h | 21 +++++++++++++++++++
> include/asm-ia64/page.h | 6 -----
> include/asm-powerpc/hugetlb.h | 35 +++++++++++++++++++++++++++++++
> include/asm-powerpc/page_64.h | 7 ------
> include/asm-sh/hugetlb.h | 28 +++++++++++++++++++++++++
> include/asm-sparc64/hugetlb.h | 30 +++++++++++++++++++++++++++
> include/asm-sparc64/page.h | 2 -
> include/asm-x86/hugetlb.h | 28 +++++++++++++++++++++++++
> include/linux/hugetlb.h | 46 ------------------------------------------
> 9 files changed, 143 insertions(+), 60 deletions(-)
is the way it is.
> Index: linux-2.6.25-rc7/include/asm-ia64/hugetlb.h
> ===================================================================
> --- /dev/null
> +++ linux-2.6.25-rc7/include/asm-ia64/hugetlb.h
> @@ -0,0 +1,21 @@
> +#ifndef _ASM_IA64_HUGETLB_H
> +#define _ASM_IA64_HUGETLB_H
> +
> +#include <asm/page.h>
> +
> +
> +#define is_hugepage_only_range(mm, addr, len) \
> + (REGION_NUMBER(addr) == RGN_HPAGE || \
> + REGION_NUMBER((addr)+(len)-1) == RGN_HPAGE)
> +
> +void hugetlb_free_pgd_range(struct mmu_gather **tlb, unsigned long addr,
> + unsigned long end, unsigned long floor,
> + unsigned long ceiling);
> +int prepare_hugepage_range(unsigned long addr, unsigned long len);
> +
> +#define set_huge_pte_at(mm, addr, ptep, pte) set_pte_at(mm, addr, ptep, pte)
> +#define huge_ptep_get_and_clear(mm, addr, ptep) ptep_get_and_clear(mm, addr, ptep)
> +
> +#define hugetlb_prefault_arch_hook(mm) do { } while (0)
> +
> +#endif /* _ASM_IA64_HUGETLB_H */
> Index: linux-2.6.25-rc7/include/asm-sh/hugetlb.h
> ===================================================================
> --- /dev/null
> +++ linux-2.6.25-rc7/include/asm-sh/hugetlb.h
> @@ -0,0 +1,28 @@
> +#ifndef _ASM_SH_HUGETLB_H
> +#define _ASM_SH_HUGETLB_H
> +
> +#include <asm/page.h>
> +
> +
> +#define is_hugepage_only_range(mm, addr, len) 0
> +#define hugetlb_free_pgd_range free_pgd_range
> +
> +/*
> + * If the arch doesn't supply something else, assume that hugepage
> + * size aligned regions are ok without further preparation.
> + */
> +static inline int prepare_hugepage_range(unsigned long addr, unsigned long len)
> +{
> + if (len & ~HPAGE_MASK)
> + return -EINVAL;
> + if (addr & ~HPAGE_MASK)
> + return -EINVAL;
> + return 0;
> +}
> +
> +#define set_huge_pte_at(mm, addr, ptep, pte) set_pte_at(mm, addr, ptep, pte)
> +#define huge_ptep_get_and_clear(mm, addr, ptep) ptep_get_and_clear(mm, addr, ptep)
> +
> +#define hugetlb_prefault_arch_hook(mm) do { } while (0)
urgh. I wouldn't say the result of this "cleanup" is very clean.
Basically all the macros there should be zapped and turned into inlines.
That will happen to fix the bug in ia64's is_hugepage_only_range(), which
presently references its arg once or twice, and will do bad things if
called with an expression-with-side-effects.
> +
> +#endif /* _ASM_SH_HUGETLB_H */
> Index: linux-2.6.25-rc7/include/asm-sparc64/hugetlb.h
> ===================================================================
> --- /dev/null
> +++ linux-2.6.25-rc7/include/asm-sparc64/hugetlb.h
> @@ -0,0 +1,30 @@
> +#ifndef _ASM_SPARC64_HUGETLB_H
> +#define _ASM_SPARC64_HUGETLB_H
> +
> +#include <asm/page.h>
> +
> +
> +#define is_hugepage_only_range(mm, addr, len) 0
This is bad too, because it can lead to unused-var warnings if compiled
with suitable config combinations.
So basically the existing hugetlb arch support code needs a big de-macro
crapectomy. But your patch has gone and massively duplicated the existing
crap, making that decrapectomy larger and harder.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/3] hugetlbfs: add missing TLB flush to hugetlb_cow()
2008-04-02 14:29 ` [PATCH 2/3] hugetlbfs: add missing TLB flush to hugetlb_cow() Gerald Schaefer
@ 2008-04-03 21:49 ` Andrew Morton
0 siblings, 0 replies; 11+ messages in thread
From: Andrew Morton @ 2008-04-03 21:49 UTC (permalink / raw)
To: Gerald Schaefer
Cc: linux-kernel, linux-s390, schwidefsky, mingo, davem, tony.luck,
paulus, tglx, lethal
On Wed, 02 Apr 2008 16:29:05 +0200
Gerald Schaefer <gerald.schaefer@de.ibm.com> wrote:
> 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.
>
> +#define huge_ptep_clear_flush(vma, addr, ptep) do { } while (0)
> +#define huge_ptep_clear_flush(vma, addr, ptep) do { } while (0)
> +#define huge_ptep_clear_flush(vma, addr, ptep) do { } while (0)
> +#define huge_ptep_clear_flush(vma, addr, ptep) do { } while (0)
> +#define huge_ptep_clear_flush(vma, addr, ptep) do { } while (0)
Again, the problem here is that the macro doesn't have typechecking so I
can merrily add
huge_ptep_clear_flush(some_u64, some_struct_ntfs_inode, some_undefined_variable)
and the compiler will just swallow it, depending on config options. An
inline solves this.
And the macro can lead to unused-variable warnings because the macro
doesn't count as a reference of its args. An inline solves this too.
There is almost never any need to put any code in macros ever. Please make
it a last resort, not a first one.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/3] hugetlbfs: architecture header cleanup
2008-04-08 3:59 ` Andrew Morton
@ 2008-04-09 11:35 ` Martin Schwidefsky
0 siblings, 0 replies; 11+ messages in thread
From: Martin Schwidefsky @ 2008-04-09 11:35 UTC (permalink / raw)
To: Andrew Morton
Cc: Gerald Schaefer, linux-kernel, linux-s390, Ingo Molnar,
David S. Miller, Tony Luck, Paul Mackerras, Thomas Gleixner,
Paul Mundt
On Mon, 2008-04-07 at 20:59 -0700, Andrew Morton wrote:
> Seem that git-s390 is currently carrying the old versions of these patches.
>
> I'll drop git-s390. Which will presumably kick off a cascade of droppages
> due to git-s390 versus git-kvm damage control. All of which will need to
> be undropped in some fashion when those trees come to their senses. Ho
> hum.
Yes, git-s390 wasn't updated for a few days. I've dropped all the
hugetlbfs patches since the version we will push upstream depends on the
cleanup which will go in over -mm. I keep the fingers crossed that the
git-s390 now works again.
--
blue skies,
Martin.
"Reality continues to ruin my life." - Calvin.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/3] hugetlbfs: architecture header cleanup
2008-04-04 16:49 ` [PATCH 1/3] hugetlbfs: architecture header cleanup Gerald Schaefer
@ 2008-04-08 3:59 ` Andrew Morton
2008-04-09 11:35 ` Martin Schwidefsky
0 siblings, 1 reply; 11+ messages in thread
From: Andrew Morton @ 2008-04-08 3:59 UTC (permalink / raw)
To: Gerald Schaefer
Cc: linux-kernel, linux-s390, schwidefsky, Ingo Molnar,
David S. Miller, Tony Luck, Paul Mackerras, Thomas Gleixner,
Paul Mundt
On Fri, 04 Apr 2008 18:49:50 +0200 Gerald Schaefer <gerald.schaefer@de.ibm.com> wrote:
> Subject: [PATCH 1/3] hugetlbfs: architecture header cleanup
>
> From: Gerald Schaefer <gerald.schaefer@de.ibm.com>
>
> This patch moves all architecture functions for hugetlb to architecture
> header files (include/asm-foo/hugetlb.h) and converts all macros to inline
> functions. It also removes (!) ARCH_HAS_HUGEPAGE_ONLY_RANGE,
> ARCH_HAS_HUGETLB_FREE_PGD_RANGE, ARCH_HAS_PREPARE_HUGEPAGE_RANGE,
> ARCH_HAS_SETCLEAR_HUGE_PTE and ARCH_HAS_HUGETLB_PREFAULT_HOOK.
>
> Getting rid of the ARCH_HAS_xxx #ifdef and macro fugliness should increase
> readability and maintainability, at the price of some code duplication.
> An asm-generic common part would have reduced the loc, but we would end up
> with new ARCH_HAS_xxx defines eventually.
>
> Acked-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
> Signed-off-by: Gerald Schaefer <gerald.schaefer@de.ibm.com>
> ---
>
> include/asm-ia64/hugetlb.h | 37 +++++++++++++++++++++++++++++++
> include/asm-ia64/page.h | 6 -----
> include/asm-powerpc/hugetlb.h | 37 +++++++++++++++++++++++++++++++
> include/asm-powerpc/page_64.h | 7 ------
> include/asm-sh/hugetlb.h | 49 ++++++++++++++++++++++++++++++++++++++++++
> include/asm-sparc64/hugetlb.h | 42 ++++++++++++++++++++++++++++++++++++
> include/asm-sparc64/page.h | 2 -
> include/asm-x86/hugetlb.h | 49 ++++++++++++++++++++++++++++++++++++++++++
> include/linux/hugetlb.h | 46 ---------------------------------------
Seem that git-s390 is currently carrying the old versions of these patches.
I'll drop git-s390. Which will presumably kick off a cascade of droppages
due to git-s390 versus git-kvm damage control. All of which will need to
be undropped in some fashion when those trees come to their senses. Ho
hum.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 1/3] hugetlbfs: architecture header cleanup
2008-04-04 16:45 [PATCH 0/3] hugetlbfs: cleanup and new primitives for s390, v3 Gerald Schaefer
@ 2008-04-04 16:49 ` Gerald Schaefer
2008-04-08 3:59 ` Andrew Morton
0 siblings, 1 reply; 11+ messages in thread
From: Gerald Schaefer @ 2008-04-04 16:49 UTC (permalink / raw)
To: Andrew Morton
Cc: linux-kernel, linux-s390, schwidefsky, Ingo Molnar,
David S. Miller, Tony Luck, Paul Mackerras, Thomas Gleixner,
Paul Mundt
Subject: [PATCH 1/3] hugetlbfs: architecture header cleanup
From: Gerald Schaefer <gerald.schaefer@de.ibm.com>
This patch moves all architecture functions for hugetlb to architecture
header files (include/asm-foo/hugetlb.h) and converts all macros to inline
functions. It also removes (!) ARCH_HAS_HUGEPAGE_ONLY_RANGE,
ARCH_HAS_HUGETLB_FREE_PGD_RANGE, ARCH_HAS_PREPARE_HUGEPAGE_RANGE,
ARCH_HAS_SETCLEAR_HUGE_PTE and ARCH_HAS_HUGETLB_PREFAULT_HOOK.
Getting rid of the ARCH_HAS_xxx #ifdef and macro fugliness should increase
readability and maintainability, at the price of some code duplication.
An asm-generic common part would have reduced the loc, but we would end up
with new ARCH_HAS_xxx defines eventually.
Acked-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Gerald Schaefer <gerald.schaefer@de.ibm.com>
---
include/asm-ia64/hugetlb.h | 37 +++++++++++++++++++++++++++++++
include/asm-ia64/page.h | 6 -----
include/asm-powerpc/hugetlb.h | 37 +++++++++++++++++++++++++++++++
include/asm-powerpc/page_64.h | 7 ------
include/asm-sh/hugetlb.h | 49 ++++++++++++++++++++++++++++++++++++++++++
include/asm-sparc64/hugetlb.h | 42 ++++++++++++++++++++++++++++++++++++
include/asm-sparc64/page.h | 2 -
include/asm-x86/hugetlb.h | 49 ++++++++++++++++++++++++++++++++++++++++++
include/linux/hugetlb.h | 46 ---------------------------------------
9 files changed, 215 insertions(+), 60 deletions(-)
Index: linux-2.6.25-rc8/include/asm-ia64/hugetlb.h
===================================================================
--- /dev/null
+++ linux-2.6.25-rc8/include/asm-ia64/hugetlb.h
@@ -0,0 +1,37 @@
+#ifndef _ASM_IA64_HUGETLB_H
+#define _ASM_IA64_HUGETLB_H
+
+#include <asm/page.h>
+
+
+void hugetlb_free_pgd_range(struct mmu_gather **tlb, unsigned long addr,
+ unsigned long end, unsigned long floor,
+ unsigned long ceiling);
+
+int prepare_hugepage_range(unsigned long addr, unsigned long len);
+
+static inline int is_hugepage_only_range(struct mm_struct *mm,
+ unsigned long addr,
+ unsigned long len)
+{
+ return (REGION_NUMBER(addr) == RGN_HPAGE ||
+ REGION_NUMBER((addr)+(len)-1) == RGN_HPAGE);
+}
+
+static inline void hugetlb_prefault_arch_hook(struct mm_struct *mm)
+{
+}
+
+static inline void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
+ pte_t *ptep, pte_t pte)
+{
+ set_pte_at(mm, addr, ptep, pte);
+}
+
+static inline pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
+ unsigned long addr, pte_t *ptep)
+{
+ return ptep_get_and_clear(mm, addr, ptep);
+}
+
+#endif /* _ASM_IA64_HUGETLB_H */
Index: linux-2.6.25-rc8/include/asm-sh/hugetlb.h
===================================================================
--- /dev/null
+++ linux-2.6.25-rc8/include/asm-sh/hugetlb.h
@@ -0,0 +1,49 @@
+#ifndef _ASM_SH_HUGETLB_H
+#define _ASM_SH_HUGETLB_H
+
+#include <asm/page.h>
+
+
+static inline int is_hugepage_only_range(struct mm_struct *mm,
+ unsigned long addr,
+ unsigned long len) {
+ return 0;
+}
+
+/*
+ * If the arch doesn't supply something else, assume that hugepage
+ * size aligned regions are ok without further preparation.
+ */
+static inline int prepare_hugepage_range(unsigned long addr, unsigned long len)
+{
+ if (len & ~HPAGE_MASK)
+ return -EINVAL;
+ if (addr & ~HPAGE_MASK)
+ return -EINVAL;
+ return 0;
+}
+
+static inline void hugetlb_prefault_arch_hook(struct mm_struct *mm) {
+}
+
+static inline void hugetlb_free_pgd_range(struct mmu_gather **tlb,
+ unsigned long addr, unsigned long end,
+ unsigned long floor,
+ unsigned long ceiling)
+{
+ free_pgd_range(tlb, addr, end, floor, ceiling);
+}
+
+static inline void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
+ pte_t *ptep, pte_t pte)
+{
+ set_pte_at(mm, addr, ptep, pte);
+}
+
+static inline pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
+ unsigned long addr, pte_t *ptep)
+{
+ return ptep_get_and_clear(mm, addr, ptep);
+}
+
+#endif /* _ASM_SH_HUGETLB_H */
Index: linux-2.6.25-rc8/include/asm-sparc64/hugetlb.h
===================================================================
--- /dev/null
+++ linux-2.6.25-rc8/include/asm-sparc64/hugetlb.h
@@ -0,0 +1,42 @@
+#ifndef _ASM_SPARC64_HUGETLB_H
+#define _ASM_SPARC64_HUGETLB_H
+
+#include <asm/page.h>
+
+
+void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
+ pte_t *ptep, pte_t pte);
+
+pte_t huge_ptep_get_and_clear(struct mm_struct *mm, unsigned long addr,
+ pte_t *ptep);
+
+void hugetlb_prefault_arch_hook(struct mm_struct *mm);
+
+static inline int is_hugepage_only_range(struct mm_struct *mm,
+ unsigned long addr,
+ unsigned long len) {
+ return 0;
+}
+
+/*
+ * If the arch doesn't supply something else, assume that hugepage
+ * size aligned regions are ok without further preparation.
+ */
+static inline int prepare_hugepage_range(unsigned long addr, unsigned long len)
+{
+ if (len & ~HPAGE_MASK)
+ return -EINVAL;
+ if (addr & ~HPAGE_MASK)
+ return -EINVAL;
+ return 0;
+}
+
+static inline void hugetlb_free_pgd_range(struct mmu_gather **tlb,
+ unsigned long addr, unsigned long end,
+ unsigned long floor,
+ unsigned long ceiling)
+{
+ free_pgd_range(tlb, addr, end, floor, ceiling);
+}
+
+#endif /* _ASM_SPARC64_HUGETLB_H */
Index: linux-2.6.25-rc8/include/asm-x86/hugetlb.h
===================================================================
--- /dev/null
+++ linux-2.6.25-rc8/include/asm-x86/hugetlb.h
@@ -0,0 +1,49 @@
+#ifndef _ASM_X86_HUGETLB_H
+#define _ASM_X86_HUGETLB_H
+
+#include <asm/page.h>
+
+
+static inline int is_hugepage_only_range(struct mm_struct *mm,
+ unsigned long addr,
+ unsigned long len) {
+ return 0;
+}
+
+/*
+ * If the arch doesn't supply something else, assume that hugepage
+ * size aligned regions are ok without further preparation.
+ */
+static inline int prepare_hugepage_range(unsigned long addr, unsigned long len)
+{
+ if (len & ~HPAGE_MASK)
+ return -EINVAL;
+ if (addr & ~HPAGE_MASK)
+ return -EINVAL;
+ return 0;
+}
+
+static inline void hugetlb_prefault_arch_hook(struct mm_struct *mm) {
+}
+
+static inline void hugetlb_free_pgd_range(struct mmu_gather **tlb,
+ unsigned long addr, unsigned long end,
+ unsigned long floor,
+ unsigned long ceiling)
+{
+ free_pgd_range(tlb, addr, end, floor, ceiling);
+}
+
+static inline void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
+ pte_t *ptep, pte_t pte)
+{
+ set_pte_at(mm, addr, ptep, pte);
+}
+
+static inline pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
+ unsigned long addr, pte_t *ptep)
+{
+ return ptep_get_and_clear(mm, addr, ptep);
+}
+
+#endif /* _ASM_X86_HUGETLB_H */
Index: linux-2.6.25-rc8/include/linux/hugetlb.h
===================================================================
--- linux-2.6.25-rc8.orig/include/linux/hugetlb.h
+++ linux-2.6.25-rc8/include/linux/hugetlb.h
@@ -8,6 +8,7 @@
#include <linux/mempolicy.h>
#include <linux/shm.h>
#include <asm/tlbflush.h>
+#include <asm/hugetlb.h>
struct ctl_table;
@@ -51,51 +52,6 @@ int pmd_huge(pmd_t pmd);
void hugetlb_change_protection(struct vm_area_struct *vma,
unsigned long address, unsigned long end, pgprot_t newprot);
-#ifndef ARCH_HAS_HUGEPAGE_ONLY_RANGE
-#define is_hugepage_only_range(mm, addr, len) 0
-#endif
-
-#ifndef ARCH_HAS_HUGETLB_FREE_PGD_RANGE
-#define hugetlb_free_pgd_range free_pgd_range
-#else
-void hugetlb_free_pgd_range(struct mmu_gather **tlb, unsigned long addr,
- unsigned long end, unsigned long floor,
- unsigned long ceiling);
-#endif
-
-#ifndef ARCH_HAS_PREPARE_HUGEPAGE_RANGE
-/*
- * If the arch doesn't supply something else, assume that hugepage
- * size aligned regions are ok without further preparation.
- */
-static inline int prepare_hugepage_range(unsigned long addr, unsigned long len)
-{
- if (len & ~HPAGE_MASK)
- return -EINVAL;
- if (addr & ~HPAGE_MASK)
- return -EINVAL;
- return 0;
-}
-#else
-int prepare_hugepage_range(unsigned long addr, unsigned long len);
-#endif
-
-#ifndef ARCH_HAS_SETCLEAR_HUGE_PTE
-#define set_huge_pte_at(mm, addr, ptep, pte) set_pte_at(mm, addr, ptep, pte)
-#define huge_ptep_get_and_clear(mm, addr, ptep) ptep_get_and_clear(mm, addr, ptep)
-#else
-void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
- pte_t *ptep, pte_t pte);
-pte_t huge_ptep_get_and_clear(struct mm_struct *mm, unsigned long addr,
- pte_t *ptep);
-#endif
-
-#ifndef ARCH_HAS_HUGETLB_PREFAULT_HOOK
-#define hugetlb_prefault_arch_hook(mm) do { } while (0)
-#else
-void hugetlb_prefault_arch_hook(struct mm_struct *mm);
-#endif
-
#else /* !CONFIG_HUGETLB_PAGE */
static inline int is_vm_hugetlb_page(struct vm_area_struct *vma)
Index: linux-2.6.25-rc8/include/asm-powerpc/hugetlb.h
===================================================================
--- /dev/null
+++ linux-2.6.25-rc8/include/asm-powerpc/hugetlb.h
@@ -0,0 +1,37 @@
+#ifndef _ASM_POWERPC_HUGETLB_H
+#define _ASM_POWERPC_HUGETLB_H
+
+#include <asm/page.h>
+
+
+int is_hugepage_only_range(struct mm_struct *mm, unsigned long addr,
+ unsigned long len);
+
+void hugetlb_free_pgd_range(struct mmu_gather **tlb, unsigned long addr,
+ unsigned long end, unsigned long floor,
+ unsigned long ceiling);
+
+void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
+ pte_t *ptep, pte_t pte);
+
+pte_t huge_ptep_get_and_clear(struct mm_struct *mm, unsigned long addr,
+ pte_t *ptep);
+
+/*
+ * If the arch doesn't supply something else, assume that hugepage
+ * size aligned regions are ok without further preparation.
+ */
+static inline int prepare_hugepage_range(unsigned long addr, unsigned long len)
+{
+ if (len & ~HPAGE_MASK)
+ return -EINVAL;
+ if (addr & ~HPAGE_MASK)
+ return -EINVAL;
+ return 0;
+}
+
+static inline void hugetlb_prefault_arch_hook(struct mm_struct *mm)
+{
+}
+
+#endif /* _ASM_POWERPC_HUGETLB_H */
Index: linux-2.6.25-rc8/include/asm-ia64/page.h
===================================================================
--- linux-2.6.25-rc8.orig/include/asm-ia64/page.h
+++ linux-2.6.25-rc8/include/asm-ia64/page.h
@@ -54,9 +54,6 @@
# define HPAGE_MASK (~(HPAGE_SIZE - 1))
# define HAVE_ARCH_HUGETLB_UNMAPPED_AREA
-# define ARCH_HAS_HUGEPAGE_ONLY_RANGE
-# define ARCH_HAS_PREPARE_HUGEPAGE_RANGE
-# define ARCH_HAS_HUGETLB_FREE_PGD_RANGE
#endif /* CONFIG_HUGETLB_PAGE */
#ifdef __ASSEMBLY__
@@ -153,9 +150,6 @@ typedef union ia64_va {
# define htlbpage_to_page(x) (((unsigned long) REGION_NUMBER(x) << 61) \
| (REGION_OFFSET(x) >> (HPAGE_SHIFT-PAGE_SHIFT)))
# define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)
-# define is_hugepage_only_range(mm, addr, len) \
- (REGION_NUMBER(addr) == RGN_HPAGE || \
- REGION_NUMBER((addr)+(len)-1) == RGN_HPAGE)
extern unsigned int hpage_shift;
#endif
Index: linux-2.6.25-rc8/include/asm-powerpc/page_64.h
===================================================================
--- linux-2.6.25-rc8.orig/include/asm-powerpc/page_64.h
+++ linux-2.6.25-rc8/include/asm-powerpc/page_64.h
@@ -128,11 +128,6 @@ extern void slice_init_context(struct mm
extern void slice_set_user_psize(struct mm_struct *mm, unsigned int psize);
#define slice_mm_new_context(mm) ((mm)->context.id == 0)
-#define ARCH_HAS_HUGEPAGE_ONLY_RANGE
-extern int is_hugepage_only_range(struct mm_struct *m,
- unsigned long addr,
- unsigned long len);
-
#endif /* __ASSEMBLY__ */
#else
#define slice_init()
@@ -146,8 +141,6 @@ do { \
#ifdef CONFIG_HUGETLB_PAGE
-#define ARCH_HAS_HUGETLB_FREE_PGD_RANGE
-#define ARCH_HAS_SETCLEAR_HUGE_PTE
#define HAVE_ARCH_HUGETLB_UNMAPPED_AREA
#endif /* !CONFIG_HUGETLB_PAGE */
Index: linux-2.6.25-rc8/include/asm-sparc64/page.h
===================================================================
--- linux-2.6.25-rc8.orig/include/asm-sparc64/page.h
+++ linux-2.6.25-rc8/include/asm-sparc64/page.h
@@ -39,8 +39,6 @@
#define HPAGE_SIZE (_AC(1,UL) << HPAGE_SHIFT)
#define HPAGE_MASK (~(HPAGE_SIZE - 1UL))
#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)
-#define ARCH_HAS_SETCLEAR_HUGE_PTE
-#define ARCH_HAS_HUGETLB_PREFAULT_HOOK
#define HAVE_ARCH_HUGETLB_UNMAPPED_AREA
#endif
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2008-04-09 11:37 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 2/3] hugetlbfs: add missing TLB flush to hugetlb_cow() Gerald Schaefer
2008-04-03 21:49 ` Andrew Morton
2008-04-02 14:38 ` [PATCH 3/3] hugetlbfs: common code update for s390 Gerald Schaefer
2008-04-04 16:45 [PATCH 0/3] hugetlbfs: cleanup and new primitives for s390, v3 Gerald Schaefer
2008-04-04 16:49 ` [PATCH 1/3] hugetlbfs: architecture header cleanup Gerald Schaefer
2008-04-08 3:59 ` Andrew Morton
2008-04-09 11:35 ` Martin Schwidefsky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).