* build failure in linux-next
@ 2012-03-01 16:11 Mark Salter
2012-03-01 17:02 ` Siddhesh Poyarekar
0 siblings, 1 reply; 7+ messages in thread
From: Mark Salter @ 2012-03-01 16:11 UTC (permalink / raw)
To: linux-next; +Cc: linux-kernel, siddhesh.poyarekar, Andrew Morton
In linux-next, this breaks nommu builds:
commit b8665bd461ecdc561e7c95d039567d0a79208226
Author: Siddhesh Poyarekar <siddhesh.poyarekar@gmail•com>
Date: Sat Feb 25 12:28:09 2012 +1100
procfs: mark thread stack correctly in proc/<pid>/maps
I think this was merged into linux-next from the -mm tree.
There are unbalanced parens in fs/proc/task_nommu.c which leads to this
when building:
fs/proc/task_nommu.c: In function 'nommu_vma_show':
fs/proc/task_nommu.c:177:2: warning: no return statement in function returning non-void
fs/proc/task_nommu.c: At top level:
fs/proc/task_nommu.c:179:14: error: expected ')' before '\xa'
fs/proc/task_nommu.c:180:2: error: expected identifier or '(' before 'return'
fs/proc/task_nommu.c:181:1: error: expected identifier or '(' before '}' token
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: build failure in linux-next
2012-03-01 16:11 build failure in linux-next Mark Salter
@ 2012-03-01 17:02 ` Siddhesh Poyarekar
2012-03-01 22:01 ` Mark Salter
0 siblings, 1 reply; 7+ messages in thread
From: Siddhesh Poyarekar @ 2012-03-01 17:02 UTC (permalink / raw)
To: Mark Salter; +Cc: linux-next, linux-kernel, Andrew Morton
On Thu, Mar 1, 2012 at 9:41 PM, Mark Salter <msalter@redhat•com> wrote:
> In linux-next, this breaks nommu builds:
>
> commit b8665bd461ecdc561e7c95d039567d0a79208226
> Author: Siddhesh Poyarekar <siddhesh.poyarekar@gmail•com>
> Date: Sat Feb 25 12:28:09 2012 +1100
>
> procfs: mark thread stack correctly in proc/<pid>/maps
>
> I think this was merged into linux-next from the -mm tree.
>
> There are unbalanced parens in fs/proc/task_nommu.c which leads to this
> when building:
>
> fs/proc/task_nommu.c: In function 'nommu_vma_show':
> fs/proc/task_nommu.c:177:2: warning: no return statement in function returning non-void
> fs/proc/task_nommu.c: At top level:
> fs/proc/task_nommu.c:179:14: error: expected ')' before '\xa'
> fs/proc/task_nommu.c:180:2: error: expected identifier or '(' before 'return'
> fs/proc/task_nommu.c:181:1: error: expected identifier or '(' before '}' token
>
Sorry about that. My latest patch submission to procfs happens to fix this:
https://lkml.org/lkml/2012/3/1/4
Do you need a separate submission that fixes just this build failure?
--
Siddhesh Poyarekar
http://siddhesh.in
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: build failure in linux-next
2012-03-01 17:02 ` Siddhesh Poyarekar
@ 2012-03-01 22:01 ` Mark Salter
0 siblings, 0 replies; 7+ messages in thread
From: Mark Salter @ 2012-03-01 22:01 UTC (permalink / raw)
To: Siddhesh Poyarekar; +Cc: linux-next, linux-kernel, Andrew Morton
On Thu, 2012-03-01 at 22:32 +0530, Siddhesh Poyarekar wrote:
> Sorry about that. My latest patch submission to procfs happens to fix this:
>
> https://lkml.org/lkml/2012/3/1/4
>
> Do you need a separate submission that fixes just this build failure?
>
Thanks. No.
^ permalink raw reply [flat|nested] 7+ messages in thread
* build failure in linux-next
@ 2012-03-21 14:36 Mark Salter
2012-03-21 14:59 ` Andrea Arcangeli
2012-03-21 15:02 ` Stephen Rothwell
0 siblings, 2 replies; 7+ messages in thread
From: Mark Salter @ 2012-03-21 14:36 UTC (permalink / raw)
To: aarcange; +Cc: linux-kernel, linux-next
I'm seeing a build failure in linux-next:
CC init/main.o
In file included from /es/linux/linux-next/arch/c6x/include/asm/pgtable.h:76:0,
from /es/linux/linux-next/include/linux/mm.h:44,
from /es/linux/linux-next/include/linux/ring_buffer.h:5,
from /es/linux/linux-next/include/linux/ftrace_event.h:4,
from /es/linux/linux-next/include/trace/syscall.h:6,
from /es/linux/linux-next/include/linux/syscalls.h:78,
from /es/linux/linux-next/init/main.c:16:
/es/linux/linux-next/include/asm-generic/pgtable.h: In function 'pmd_none_or_trans_huge_or_clear_bad':
/es/linux/linux-next/include/asm-generic/pgtable.h:476:4: error: implicit declaration of function 'pmd_clear_bad' [-Werror=implicit-function-declaration]
This patch added some functions to asm-generic/pgtable.h which should
have been placed in the CONFIG_MMU conditional block:
Author: Andrea Arcangeli <aarcange@redhat•com>
Date: Wed Mar 21 10:48:00 2012 +1100
mm: thp: fix pmd_bad() triggering in code paths holding mmap_sem read mode
The following patch fixes the build problem for me:
diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
index 202c010..8ba3ba5 100644
--- a/include/asm-generic/pgtable.h
+++ b/include/asm-generic/pgtable.h
@@ -342,6 +342,64 @@ static inline void ptep_modify_prot_commit(struct mm_struct *mm,
__ptep_modify_prot_commit(mm, addr, ptep, pte);
}
#endif /* __HAVE_ARCH_PTEP_MODIFY_PROT_TRANSACTION */
+
+/*
+ * This function is meant to be used by sites walking pagetables with
+ * the mmap_sem hold in read mode to protect against MADV_DONTNEED and
+ * transhuge page faults. MADV_DONTNEED can convert a transhuge pmd
+ * into a null pmd and the transhuge page fault can convert a null pmd
+ * into an hugepmd or into a regular pmd (if the hugepage allocation
+ * fails). While holding the mmap_sem in read mode the pmd becomes
+ * stable and stops changing under us only if it's not null and not a
+ * transhuge pmd. When those races occurs and this function makes a
+ * difference vs the standard pmd_none_or_clear_bad, the result is
+ * undefined so behaving like if the pmd was none is safe (because it
+ * can return none anyway). The compiler level barrier() is critically
+ * important to compute the two checks atomically on the same pmdval.
+ */
+static inline int pmd_none_or_trans_huge_or_clear_bad(pmd_t *pmd)
+{
+ /* depend on compiler for an atomic pmd read */
+ pmd_t pmdval = *pmd;
+ /*
+ * The barrier will stabilize the pmdval in a register or on
+ * the stack so that it will stop changing under the code.
+ */
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
+ barrier();
+#endif
+ if (pmd_none(pmdval))
+ return 1;
+ if (unlikely(pmd_bad(pmdval))) {
+ if (!pmd_trans_huge(pmdval))
+ pmd_clear_bad(pmd);
+ return 1;
+ }
+ return 0;
+}
+
+/*
+ * This is a noop if Transparent Hugepage Support is not built into
+ * the kernel. Otherwise it is equivalent to
+ * pmd_none_or_trans_huge_or_clear_bad(), and shall only be called in
+ * places that already verified the pmd is not none and they want to
+ * walk ptes while holding the mmap sem in read mode (write mode don't
+ * need this). If THP is not enabled, the pmd can't go away under the
+ * code even if MADV_DONTNEED runs, but if THP is enabled we need to
+ * run a pmd_trans_unstable before walking the ptes after
+ * split_huge_page_pmd returns (because it may have run when the pmd
+ * become null, but then a page fault can map in a THP and not a
+ * regular page).
+ */
+static inline int pmd_trans_unstable(pmd_t *pmd)
+{
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
+ return pmd_none_or_trans_huge_or_clear_bad(pmd);
+#else
+ return 0;
+#endif
+}
+
#endif /* CONFIG_MMU */
/*
@@ -444,63 +502,6 @@ static inline int pmd_write(pmd_t pmd)
#endif /* __HAVE_ARCH_PMD_WRITE */
#endif
-/*
- * This function is meant to be used by sites walking pagetables with
- * the mmap_sem hold in read mode to protect against MADV_DONTNEED and
- * transhuge page faults. MADV_DONTNEED can convert a transhuge pmd
- * into a null pmd and the transhuge page fault can convert a null pmd
- * into an hugepmd or into a regular pmd (if the hugepage allocation
- * fails). While holding the mmap_sem in read mode the pmd becomes
- * stable and stops changing under us only if it's not null and not a
- * transhuge pmd. When those races occurs and this function makes a
- * difference vs the standard pmd_none_or_clear_bad, the result is
- * undefined so behaving like if the pmd was none is safe (because it
- * can return none anyway). The compiler level barrier() is critically
- * important to compute the two checks atomically on the same pmdval.
- */
-static inline int pmd_none_or_trans_huge_or_clear_bad(pmd_t *pmd)
-{
- /* depend on compiler for an atomic pmd read */
- pmd_t pmdval = *pmd;
- /*
- * The barrier will stabilize the pmdval in a register or on
- * the stack so that it will stop changing under the code.
- */
-#ifdef CONFIG_TRANSPARENT_HUGEPAGE
- barrier();
-#endif
- if (pmd_none(pmdval))
- return 1;
- if (unlikely(pmd_bad(pmdval))) {
- if (!pmd_trans_huge(pmdval))
- pmd_clear_bad(pmd);
- return 1;
- }
- return 0;
-}
-
-/*
- * This is a noop if Transparent Hugepage Support is not built into
- * the kernel. Otherwise it is equivalent to
- * pmd_none_or_trans_huge_or_clear_bad(), and shall only be called in
- * places that already verified the pmd is not none and they want to
- * walk ptes while holding the mmap sem in read mode (write mode don't
- * need this). If THP is not enabled, the pmd can't go away under the
- * code even if MADV_DONTNEED runs, but if THP is enabled we need to
- * run a pmd_trans_unstable before walking the ptes after
- * split_huge_page_pmd returns (because it may have run when the pmd
- * become null, but then a page fault can map in a THP and not a
- * regular page).
- */
-static inline int pmd_trans_unstable(pmd_t *pmd)
-{
-#ifdef CONFIG_TRANSPARENT_HUGEPAGE
- return pmd_none_or_trans_huge_or_clear_bad(pmd);
-#else
- return 0;
-#endif
-}
-
#endif /* !__ASSEMBLY__ */
#endif /* _ASM_GENERIC_PGTABLE_H */
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: build failure in linux-next
2012-03-21 14:36 Mark Salter
@ 2012-03-21 14:59 ` Andrea Arcangeli
2012-03-21 15:07 ` Stephen Rothwell
2012-03-21 15:02 ` Stephen Rothwell
1 sibling, 1 reply; 7+ messages in thread
From: Andrea Arcangeli @ 2012-03-21 14:59 UTC (permalink / raw)
To: Mark Salter; +Cc: linux-kernel, linux-next
Hi,
On Wed, Mar 21, 2012 at 10:36:14AM -0400, Mark Salter wrote:
> I'm seeing a build failure in linux-next:
>
> CC init/main.o
> In file included from /es/linux/linux-next/arch/c6x/include/asm/pgtable.h:76:0,
> from /es/linux/linux-next/include/linux/mm.h:44,
> from /es/linux/linux-next/include/linux/ring_buffer.h:5,
> from /es/linux/linux-next/include/linux/ftrace_event.h:4,
> from /es/linux/linux-next/include/trace/syscall.h:6,
> from /es/linux/linux-next/include/linux/syscalls.h:78,
> from /es/linux/linux-next/init/main.c:16:
> /es/linux/linux-next/include/asm-generic/pgtable.h: In function 'pmd_none_or_trans_huge_or_clear_bad':
> /es/linux/linux-next/include/asm-generic/pgtable.h:476:4: error: implicit declaration of function 'pmd_clear_bad' [-Werror=implicit-function-declaration]
>
>
> This patch added some functions to asm-generic/pgtable.h which should
> have been placed in the CONFIG_MMU conditional block:
>
> Author: Andrea Arcangeli <aarcange@redhat•com>
> Date: Wed Mar 21 10:48:00 2012 +1100
>
> mm: thp: fix pmd_bad() triggering in code paths holding mmap_sem read mode
>
>
> The following patch fixes the build problem for me:
Thanks for noticing this problem.
>
> diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
> index 202c010..8ba3ba5 100644
> --- a/include/asm-generic/pgtable.h
> +++ b/include/asm-generic/pgtable.h
> @@ -342,6 +342,64 @@ static inline void ptep_modify_prot_commit(struct mm_struct *mm,
> __ptep_modify_prot_commit(mm, addr, ptep, pte);
> }
> #endif /* __HAVE_ARCH_PTEP_MODIFY_PROT_TRANSACTION */
> +
> +/*
> + * This function is meant to be used by sites walking pagetables with
> + * the mmap_sem hold in read mode to protect against MADV_DONTNEED and
> + * transhuge page faults. MADV_DONTNEED can convert a transhuge pmd
> + * into a null pmd and the transhuge page fault can convert a null pmd
> + * into an hugepmd or into a regular pmd (if the hugepage allocation
> + * fails). While holding the mmap_sem in read mode the pmd becomes
> + * stable and stops changing under us only if it's not null and not a
> + * transhuge pmd. When those races occurs and this function makes a
> + * difference vs the standard pmd_none_or_clear_bad, the result is
> + * undefined so behaving like if the pmd was none is safe (because it
> + * can return none anyway). The compiler level barrier() is critically
> + * important to compute the two checks atomically on the same pmdval.
> + */
> +static inline int pmd_none_or_trans_huge_or_clear_bad(pmd_t *pmd)
> +{
> + /* depend on compiler for an atomic pmd read */
> + pmd_t pmdval = *pmd;
> + /*
> + * The barrier will stabilize the pmdval in a register or on
> + * the stack so that it will stop changing under the code.
> + */
> +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
> + barrier();
> +#endif
> + if (pmd_none(pmdval))
> + return 1;
> + if (unlikely(pmd_bad(pmdval))) {
> + if (!pmd_trans_huge(pmdval))
> + pmd_clear_bad(pmd);
Problem is, this fixes MMU=n but it'll break x86 with MMU=y and THP=n.
These functions shall be placed after pmd_trans_huge you see at the
end of asm-generic/pgtable.h .
The simplest fix is that you add #ifdef CONFIG_MMU around it instead
of moving (I guess you can keep pmd_trans_huge and the rest at the end
of the file inside CONFIG_MMU too as it shall never be called as it
all takes pmds/ptes as parameter).
Thanks,
Andrea
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: build failure in linux-next
2012-03-21 14:36 Mark Salter
2012-03-21 14:59 ` Andrea Arcangeli
@ 2012-03-21 15:02 ` Stephen Rothwell
1 sibling, 0 replies; 7+ messages in thread
From: Stephen Rothwell @ 2012-03-21 15:02 UTC (permalink / raw)
To: Mark Salter; +Cc: aarcange, linux-kernel, linux-next, Andrew Morton
[-- Attachment #1: Type: text/plain, Size: 6826 bytes --]
[cc: akpm]
On Wed, 21 Mar 2012 10:36:14 -0400 Mark Salter <msalter@redhat•com> wrote:
>
> I'm seeing a build failure in linux-next:
>
> CC init/main.o
> In file included from /es/linux/linux-next/arch/c6x/include/asm/pgtable.h:76:0,
> from /es/linux/linux-next/include/linux/mm.h:44,
> from /es/linux/linux-next/include/linux/ring_buffer.h:5,
> from /es/linux/linux-next/include/linux/ftrace_event.h:4,
> from /es/linux/linux-next/include/trace/syscall.h:6,
> from /es/linux/linux-next/include/linux/syscalls.h:78,
> from /es/linux/linux-next/init/main.c:16:
> /es/linux/linux-next/include/asm-generic/pgtable.h: In function 'pmd_none_or_trans_huge_or_clear_bad':
> /es/linux/linux-next/include/asm-generic/pgtable.h:476:4: error: implicit declaration of function 'pmd_clear_bad' [-Werror=implicit-function-declaration]
>
>
> This patch added some functions to asm-generic/pgtable.h which should
> have been placed in the CONFIG_MMU conditional block:
>
> Author: Andrea Arcangeli <aarcange@redhat•com>
> Date: Wed Mar 21 10:48:00 2012 +1100
>
> mm: thp: fix pmd_bad() triggering in code paths holding mmap_sem read mode
>
>
> The following patch fixes the build problem for me:
>
> diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
> index 202c010..8ba3ba5 100644
> --- a/include/asm-generic/pgtable.h
> +++ b/include/asm-generic/pgtable.h
> @@ -342,6 +342,64 @@ static inline void ptep_modify_prot_commit(struct mm_struct *mm,
> __ptep_modify_prot_commit(mm, addr, ptep, pte);
> }
> #endif /* __HAVE_ARCH_PTEP_MODIFY_PROT_TRANSACTION */
> +
> +/*
> + * This function is meant to be used by sites walking pagetables with
> + * the mmap_sem hold in read mode to protect against MADV_DONTNEED and
> + * transhuge page faults. MADV_DONTNEED can convert a transhuge pmd
> + * into a null pmd and the transhuge page fault can convert a null pmd
> + * into an hugepmd or into a regular pmd (if the hugepage allocation
> + * fails). While holding the mmap_sem in read mode the pmd becomes
> + * stable and stops changing under us only if it's not null and not a
> + * transhuge pmd. When those races occurs and this function makes a
> + * difference vs the standard pmd_none_or_clear_bad, the result is
> + * undefined so behaving like if the pmd was none is safe (because it
> + * can return none anyway). The compiler level barrier() is critically
> + * important to compute the two checks atomically on the same pmdval.
> + */
> +static inline int pmd_none_or_trans_huge_or_clear_bad(pmd_t *pmd)
> +{
> + /* depend on compiler for an atomic pmd read */
> + pmd_t pmdval = *pmd;
> + /*
> + * The barrier will stabilize the pmdval in a register or on
> + * the stack so that it will stop changing under the code.
> + */
> +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
> + barrier();
> +#endif
> + if (pmd_none(pmdval))
> + return 1;
> + if (unlikely(pmd_bad(pmdval))) {
> + if (!pmd_trans_huge(pmdval))
> + pmd_clear_bad(pmd);
> + return 1;
> + }
> + return 0;
> +}
> +
> +/*
> + * This is a noop if Transparent Hugepage Support is not built into
> + * the kernel. Otherwise it is equivalent to
> + * pmd_none_or_trans_huge_or_clear_bad(), and shall only be called in
> + * places that already verified the pmd is not none and they want to
> + * walk ptes while holding the mmap sem in read mode (write mode don't
> + * need this). If THP is not enabled, the pmd can't go away under the
> + * code even if MADV_DONTNEED runs, but if THP is enabled we need to
> + * run a pmd_trans_unstable before walking the ptes after
> + * split_huge_page_pmd returns (because it may have run when the pmd
> + * become null, but then a page fault can map in a THP and not a
> + * regular page).
> + */
> +static inline int pmd_trans_unstable(pmd_t *pmd)
> +{
> +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
> + return pmd_none_or_trans_huge_or_clear_bad(pmd);
> +#else
> + return 0;
> +#endif
> +}
> +
> #endif /* CONFIG_MMU */
>
> /*
> @@ -444,63 +502,6 @@ static inline int pmd_write(pmd_t pmd)
> #endif /* __HAVE_ARCH_PMD_WRITE */
> #endif
>
> -/*
> - * This function is meant to be used by sites walking pagetables with
> - * the mmap_sem hold in read mode to protect against MADV_DONTNEED and
> - * transhuge page faults. MADV_DONTNEED can convert a transhuge pmd
> - * into a null pmd and the transhuge page fault can convert a null pmd
> - * into an hugepmd or into a regular pmd (if the hugepage allocation
> - * fails). While holding the mmap_sem in read mode the pmd becomes
> - * stable and stops changing under us only if it's not null and not a
> - * transhuge pmd. When those races occurs and this function makes a
> - * difference vs the standard pmd_none_or_clear_bad, the result is
> - * undefined so behaving like if the pmd was none is safe (because it
> - * can return none anyway). The compiler level barrier() is critically
> - * important to compute the two checks atomically on the same pmdval.
> - */
> -static inline int pmd_none_or_trans_huge_or_clear_bad(pmd_t *pmd)
> -{
> - /* depend on compiler for an atomic pmd read */
> - pmd_t pmdval = *pmd;
> - /*
> - * The barrier will stabilize the pmdval in a register or on
> - * the stack so that it will stop changing under the code.
> - */
> -#ifdef CONFIG_TRANSPARENT_HUGEPAGE
> - barrier();
> -#endif
> - if (pmd_none(pmdval))
> - return 1;
> - if (unlikely(pmd_bad(pmdval))) {
> - if (!pmd_trans_huge(pmdval))
> - pmd_clear_bad(pmd);
> - return 1;
> - }
> - return 0;
> -}
> -
> -/*
> - * This is a noop if Transparent Hugepage Support is not built into
> - * the kernel. Otherwise it is equivalent to
> - * pmd_none_or_trans_huge_or_clear_bad(), and shall only be called in
> - * places that already verified the pmd is not none and they want to
> - * walk ptes while holding the mmap sem in read mode (write mode don't
> - * need this). If THP is not enabled, the pmd can't go away under the
> - * code even if MADV_DONTNEED runs, but if THP is enabled we need to
> - * run a pmd_trans_unstable before walking the ptes after
> - * split_huge_page_pmd returns (because it may have run when the pmd
> - * become null, but then a page fault can map in a THP and not a
> - * regular page).
> - */
> -static inline int pmd_trans_unstable(pmd_t *pmd)
> -{
> -#ifdef CONFIG_TRANSPARENT_HUGEPAGE
> - return pmd_none_or_trans_huge_or_clear_bad(pmd);
> -#else
> - return 0;
> -#endif
> -}
> -
> #endif /* !__ASSEMBLY__ */
>
> #endif /* _ASM_GENERIC_PGTABLE_H */
>
>
--
Cheers,
Stephen Rothwell sfr@canb•auug.org.au
[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: build failure in linux-next
2012-03-21 14:59 ` Andrea Arcangeli
@ 2012-03-21 15:07 ` Stephen Rothwell
0 siblings, 0 replies; 7+ messages in thread
From: Stephen Rothwell @ 2012-03-21 15:07 UTC (permalink / raw)
To: Andrea Arcangeli; +Cc: Mark Salter, linux-kernel, linux-next, Andrew Morton
[-- Attachment #1: Type: text/plain, Size: 3977 bytes --]
[Cc: akpm]
On Wed, 21 Mar 2012 15:59:34 +0100 Andrea Arcangeli <aarcange@redhat•com> wrote:
>
> On Wed, Mar 21, 2012 at 10:36:14AM -0400, Mark Salter wrote:
> > I'm seeing a build failure in linux-next:
> >
> > CC init/main.o
> > In file included from /es/linux/linux-next/arch/c6x/include/asm/pgtable.h:76:0,
> > from /es/linux/linux-next/include/linux/mm.h:44,
> > from /es/linux/linux-next/include/linux/ring_buffer.h:5,
> > from /es/linux/linux-next/include/linux/ftrace_event.h:4,
> > from /es/linux/linux-next/include/trace/syscall.h:6,
> > from /es/linux/linux-next/include/linux/syscalls.h:78,
> > from /es/linux/linux-next/init/main.c:16:
> > /es/linux/linux-next/include/asm-generic/pgtable.h: In function 'pmd_none_or_trans_huge_or_clear_bad':
> > /es/linux/linux-next/include/asm-generic/pgtable.h:476:4: error: implicit declaration of function 'pmd_clear_bad' [-Werror=implicit-function-declaration]
> >
> >
> > This patch added some functions to asm-generic/pgtable.h which should
> > have been placed in the CONFIG_MMU conditional block:
> >
> > Author: Andrea Arcangeli <aarcange@redhat•com>
> > Date: Wed Mar 21 10:48:00 2012 +1100
> >
> > mm: thp: fix pmd_bad() triggering in code paths holding mmap_sem read mode
> >
> >
> > The following patch fixes the build problem for me:
>
> Thanks for noticing this problem.
>
>
>
> >
> > diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
> > index 202c010..8ba3ba5 100644
> > --- a/include/asm-generic/pgtable.h
> > +++ b/include/asm-generic/pgtable.h
> > @@ -342,6 +342,64 @@ static inline void ptep_modify_prot_commit(struct mm_struct *mm,
> > __ptep_modify_prot_commit(mm, addr, ptep, pte);
> > }
> > #endif /* __HAVE_ARCH_PTEP_MODIFY_PROT_TRANSACTION */
> > +
> > +/*
> > + * This function is meant to be used by sites walking pagetables with
> > + * the mmap_sem hold in read mode to protect against MADV_DONTNEED and
> > + * transhuge page faults. MADV_DONTNEED can convert a transhuge pmd
> > + * into a null pmd and the transhuge page fault can convert a null pmd
> > + * into an hugepmd or into a regular pmd (if the hugepage allocation
> > + * fails). While holding the mmap_sem in read mode the pmd becomes
> > + * stable and stops changing under us only if it's not null and not a
> > + * transhuge pmd. When those races occurs and this function makes a
> > + * difference vs the standard pmd_none_or_clear_bad, the result is
> > + * undefined so behaving like if the pmd was none is safe (because it
> > + * can return none anyway). The compiler level barrier() is critically
> > + * important to compute the two checks atomically on the same pmdval.
> > + */
> > +static inline int pmd_none_or_trans_huge_or_clear_bad(pmd_t *pmd)
> > +{
> > + /* depend on compiler for an atomic pmd read */
> > + pmd_t pmdval = *pmd;
> > + /*
> > + * The barrier will stabilize the pmdval in a register or on
> > + * the stack so that it will stop changing under the code.
> > + */
> > +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
> > + barrier();
> > +#endif
> > + if (pmd_none(pmdval))
> > + return 1;
> > + if (unlikely(pmd_bad(pmdval))) {
> > + if (!pmd_trans_huge(pmdval))
> > + pmd_clear_bad(pmd);
>
> Problem is, this fixes MMU=n but it'll break x86 with MMU=y and THP=n.
>
> These functions shall be placed after pmd_trans_huge you see at the
> end of asm-generic/pgtable.h .
>
> The simplest fix is that you add #ifdef CONFIG_MMU around it instead
> of moving (I guess you can keep pmd_trans_huge and the rest at the end
> of the file inside CONFIG_MMU too as it shall never be called as it
> all takes pmds/ptes as parameter).
>
> Thanks,
> Andrea
--
Cheers,
Stephen Rothwell sfr@canb•auug.org.au
http://www.canb.auug.org.au/~sfr/
[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-03-21 15:07 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-01 16:11 build failure in linux-next Mark Salter
2012-03-01 17:02 ` Siddhesh Poyarekar
2012-03-01 22:01 ` Mark Salter
-- strict thread matches above, loose matches on Subject: below --
2012-03-21 14:36 Mark Salter
2012-03-21 14:59 ` Andrea Arcangeli
2012-03-21 15:07 ` Stephen Rothwell
2012-03-21 15:02 ` Stephen Rothwell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox