* [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
2008-04-04 16:51 ` [PATCH 2/3] hugetlbfs: add missing TLB flush to hugetlb_cow() Gerald Schaefer
2008-04-04 17:02 ` [PATCH 3/3] hugetlbfs: common code update for s390 Gerald Schaefer
2 siblings, 1 reply; 6+ 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] 6+ 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; 6+ 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] 6+ 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; 6+ 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] 6+ messages in thread
* [PATCH 2/3] hugetlbfs: add missing TLB flush to hugetlb_cow()
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-04 16:51 ` Gerald Schaefer
2008-04-04 17:02 ` [PATCH 3/3] hugetlbfs: common code update for s390 Gerald Schaefer
2 siblings, 0 replies; 6+ messages in thread
From: Gerald Schaefer @ 2008-04-04 16:51 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().
ATTENTION: This is just a nop on all architectures for now, the s390
implementation will come 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 | 5 +++++
include/asm-powerpc/hugetlb.h | 5 +++++
include/asm-sh/hugetlb.h | 5 +++++
include/asm-sparc64/hugetlb.h | 5 +++++
include/asm-x86/hugetlb.h | 5 +++++
mm/hugetlb.c | 1 +
6 files changed, 26 insertions(+)
Index: linux-2.6.25-rc8/mm/hugetlb.c
===================================================================
--- linux-2.6.25-rc8.orig/mm/hugetlb.c
+++ linux-2.6.25-rc8/mm/hugetlb.c
@@ -875,6 +875,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-rc8/include/asm-ia64/hugetlb.h
===================================================================
--- linux-2.6.25-rc8.orig/include/asm-ia64/hugetlb.h
+++ linux-2.6.25-rc8/include/asm-ia64/hugetlb.h
@@ -34,4 +34,9 @@ static inline pte_t huge_ptep_get_and_cl
return ptep_get_and_clear(mm, addr, ptep);
}
+static inline void huge_ptep_clear_flush(struct vm_area_struct *vma,
+ unsigned long addr, pte_t *ptep)
+{
+}
+
#endif /* _ASM_IA64_HUGETLB_H */
Index: linux-2.6.25-rc8/include/asm-powerpc/hugetlb.h
===================================================================
--- linux-2.6.25-rc8.orig/include/asm-powerpc/hugetlb.h
+++ linux-2.6.25-rc8/include/asm-powerpc/hugetlb.h
@@ -34,4 +34,9 @@ static inline void hugetlb_prefault_arch
{
}
+static inline void huge_ptep_clear_flush(struct vm_area_struct *vma,
+ unsigned long addr, pte_t *ptep)
+{
+}
+
#endif /* _ASM_POWERPC_HUGETLB_H */
Index: linux-2.6.25-rc8/include/asm-sh/hugetlb.h
===================================================================
--- linux-2.6.25-rc8.orig/include/asm-sh/hugetlb.h
+++ linux-2.6.25-rc8/include/asm-sh/hugetlb.h
@@ -46,4 +46,9 @@ static inline pte_t huge_ptep_get_and_cl
return ptep_get_and_clear(mm, addr, ptep);
}
+static inline void huge_ptep_clear_flush(struct vm_area_struct *vma,
+ unsigned long addr, pte_t *ptep)
+{
+}
+
#endif /* _ASM_SH_HUGETLB_H */
Index: linux-2.6.25-rc8/include/asm-sparc64/hugetlb.h
===================================================================
--- linux-2.6.25-rc8.orig/include/asm-sparc64/hugetlb.h
+++ linux-2.6.25-rc8/include/asm-sparc64/hugetlb.h
@@ -39,4 +39,9 @@ static inline void hugetlb_free_pgd_rang
free_pgd_range(tlb, addr, end, floor, ceiling);
}
+static inline void huge_ptep_clear_flush(struct vm_area_struct *vma,
+ unsigned long addr, pte_t *ptep)
+{
+}
+
#endif /* _ASM_SPARC64_HUGETLB_H */
Index: linux-2.6.25-rc8/include/asm-x86/hugetlb.h
===================================================================
--- linux-2.6.25-rc8.orig/include/asm-x86/hugetlb.h
+++ linux-2.6.25-rc8/include/asm-x86/hugetlb.h
@@ -46,4 +46,9 @@ static inline pte_t huge_ptep_get_and_cl
return ptep_get_and_clear(mm, addr, ptep);
}
+static inline void huge_ptep_clear_flush(struct vm_area_struct *vma,
+ unsigned long addr, pte_t *ptep)
+{
+}
+
#endif /* _ASM_X86_HUGETLB_H */
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH 3/3] hugetlbfs: common code update for s390
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-04 16:51 ` [PATCH 2/3] hugetlbfs: add missing TLB flush to hugetlb_cow() Gerald Schaefer
@ 2008-04-04 17:02 ` Gerald Schaefer
2 siblings, 0 replies; 6+ messages in thread
From: Gerald Schaefer @ 2008-04-04 17:02 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, e.g. because of a different
location of the invalid bit. This patch adds some new architecture-
specific functions to hugetlb common code, as a prerequisite for the
s390 large page support.
This won't affect other architectures in functionality, but I need to
add some new dummy inline functions to the headers.
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-powerpc/hugetlb.h | 37 +++++++++++++++++++++++++++++++++++++
include/asm-sh/hugetlb.h | 37 +++++++++++++++++++++++++++++++++++++
include/asm-sparc64/hugetlb.h | 37 +++++++++++++++++++++++++++++++++++++
include/asm-x86/hugetlb.h | 37 +++++++++++++++++++++++++++++++++++++
mm/hugetlb.c | 36 +++++++++++++++++++++---------------
6 files changed, 206 insertions(+), 15 deletions(-)
Index: linux-2.6.25-rc8/mm/hugetlb.c
===================================================================
--- linux-2.6.25-rc8.orig/mm/hugetlb.c
+++ linux-2.6.25-rc8/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++;
@@ -718,7 +723,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);
@@ -731,8 +736,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);
}
}
@@ -762,10 +767,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);
@@ -809,7 +814,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);
@@ -873,7 +878,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,
@@ -943,7 +948,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)
@@ -985,8 +990,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;
@@ -996,7 +1001,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);
@@ -1026,7 +1031,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);
@@ -1042,7 +1048,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);
@@ -1091,7 +1097,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-rc8/include/asm-ia64/hugetlb.h
===================================================================
--- linux-2.6.25-rc8.orig/include/asm-ia64/hugetlb.h
+++ linux-2.6.25-rc8/include/asm-ia64/hugetlb.h
@@ -39,4 +39,41 @@ static inline void huge_ptep_clear_flush
{
}
+static inline int huge_pte_none(pte_t pte)
+{
+ return pte_none(pte);
+}
+
+static inline pte_t huge_pte_wrprotect(pte_t pte)
+{
+ return pte_wrprotect(pte);
+}
+
+static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,
+ unsigned long addr, pte_t *ptep)
+{
+ ptep_set_wrprotect(mm, addr, ptep);
+}
+
+static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma,
+ unsigned long addr, pte_t *ptep,
+ pte_t pte, int dirty)
+{
+ return ptep_set_access_flags(vma, addr, ptep, pte, dirty);
+}
+
+static inline pte_t huge_ptep_get(pte_t *ptep)
+{
+ return *ptep;
+}
+
+static inline int arch_prepare_hugepage(struct page *page)
+{
+ return 0;
+}
+
+static inline void arch_release_hugepage(struct page *page)
+{
+}
+
#endif /* _ASM_IA64_HUGETLB_H */
Index: linux-2.6.25-rc8/include/asm-powerpc/hugetlb.h
===================================================================
--- linux-2.6.25-rc8.orig/include/asm-powerpc/hugetlb.h
+++ linux-2.6.25-rc8/include/asm-powerpc/hugetlb.h
@@ -39,4 +39,41 @@ static inline void huge_ptep_clear_flush
{
}
+static inline int huge_pte_none(pte_t pte)
+{
+ return pte_none(pte);
+}
+
+static inline pte_t huge_pte_wrprotect(pte_t pte)
+{
+ return pte_wrprotect(pte);
+}
+
+static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,
+ unsigned long addr, pte_t *ptep)
+{
+ ptep_set_wrprotect(mm, addr, ptep);
+}
+
+static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma,
+ unsigned long addr, pte_t *ptep,
+ pte_t pte, int dirty)
+{
+ return ptep_set_access_flags(vma, addr, ptep, pte, dirty);
+}
+
+static inline pte_t huge_ptep_get(pte_t *ptep)
+{
+ return *ptep;
+}
+
+static inline int arch_prepare_hugepage(struct page *page)
+{
+ return 0;
+}
+
+static inline void arch_release_hugepage(struct page *page)
+{
+}
+
#endif /* _ASM_POWERPC_HUGETLB_H */
Index: linux-2.6.25-rc8/include/asm-sh/hugetlb.h
===================================================================
--- linux-2.6.25-rc8.orig/include/asm-sh/hugetlb.h
+++ linux-2.6.25-rc8/include/asm-sh/hugetlb.h
@@ -51,4 +51,41 @@ static inline void huge_ptep_clear_flush
{
}
+static inline int huge_pte_none(pte_t pte)
+{
+ return pte_none(pte);
+}
+
+static inline pte_t huge_pte_wrprotect(pte_t pte)
+{
+ return pte_wrprotect(pte);
+}
+
+static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,
+ unsigned long addr, pte_t *ptep)
+{
+ ptep_set_wrprotect(mm, addr, ptep);
+}
+
+static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma,
+ unsigned long addr, pte_t *ptep,
+ pte_t pte, int dirty)
+{
+ return ptep_set_access_flags(vma, addr, ptep, pte, dirty);
+}
+
+static inline pte_t huge_ptep_get(pte_t *ptep)
+{
+ return *ptep;
+}
+
+static inline int arch_prepare_hugepage(struct page *page)
+{
+ return 0;
+}
+
+static inline void arch_release_hugepage(struct page *page)
+{
+}
+
#endif /* _ASM_SH_HUGETLB_H */
Index: linux-2.6.25-rc8/include/asm-sparc64/hugetlb.h
===================================================================
--- linux-2.6.25-rc8.orig/include/asm-sparc64/hugetlb.h
+++ linux-2.6.25-rc8/include/asm-sparc64/hugetlb.h
@@ -44,4 +44,41 @@ static inline void huge_ptep_clear_flush
{
}
+static inline int huge_pte_none(pte_t pte)
+{
+ return pte_none(pte);
+}
+
+static inline pte_t huge_pte_wrprotect(pte_t pte)
+{
+ return pte_wrprotect(pte);
+}
+
+static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,
+ unsigned long addr, pte_t *ptep)
+{
+ ptep_set_wrprotect(mm, addr, ptep);
+}
+
+static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma,
+ unsigned long addr, pte_t *ptep,
+ pte_t pte, int dirty)
+{
+ return ptep_set_access_flags(vma, addr, ptep, pte, dirty);
+}
+
+static inline pte_t huge_ptep_get(pte_t *ptep)
+{
+ return *ptep;
+}
+
+static inline int arch_prepare_hugepage(struct page *page)
+{
+ return 0;
+}
+
+static inline void arch_release_hugepage(struct page *page)
+{
+}
+
#endif /* _ASM_SPARC64_HUGETLB_H */
Index: linux-2.6.25-rc8/include/asm-x86/hugetlb.h
===================================================================
--- linux-2.6.25-rc8.orig/include/asm-x86/hugetlb.h
+++ linux-2.6.25-rc8/include/asm-x86/hugetlb.h
@@ -51,4 +51,41 @@ static inline void huge_ptep_clear_flush
{
}
+static inline int huge_pte_none(pte_t pte)
+{
+ return pte_none(pte);
+}
+
+static inline pte_t huge_pte_wrprotect(pte_t pte)
+{
+ return pte_wrprotect(pte);
+}
+
+static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,
+ unsigned long addr, pte_t *ptep)
+{
+ ptep_set_wrprotect(mm, addr, ptep);
+}
+
+static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma,
+ unsigned long addr, pte_t *ptep,
+ pte_t pte, int dirty)
+{
+ return ptep_set_access_flags(vma, addr, ptep, pte, dirty);
+}
+
+static inline pte_t huge_ptep_get(pte_t *ptep)
+{
+ return *ptep;
+}
+
+static inline int arch_prepare_hugepage(struct page *page)
+{
+ return 0;
+}
+
+static inline void arch_release_hugepage(struct page *page)
+{
+}
+
#endif /* _ASM_X86_HUGETLB_H */
^ permalink raw reply [flat|nested] 6+ messages in thread