Re: [PATCH v8 18/24] mm: Provide speculative fault infrastructure

From: Laurent Dufour
Date: Mon Mar 05 2018 - 05:50:40 EST


Hi Jordan,

Thanks for reporting this.

On 26/02/2018 18:16, Daniel Jordan wrote:
> Hi Laurent,
>
> This series doesn't build for me[*] when CONFIG_TRANSPARENT_HUGEPAGE is unset.
>
> The problem seems to be that the BUILD_BUG() version of pmd_same is called in
> pte_map_lock:
>
> On 02/16/2018 10:25 AM, Laurent Dufour wrote:
>> +static bool pte_map_lock(struct vm_fault *vmf)
>> +{
> ...snip...
>> +ÂÂÂ if (!pmd_same(pmdval, vmf->orig_pmd))
>> +ÂÂÂÂÂÂÂ goto out;
>
> Since SPF can now call pmd_same without THP, maybe the way to fix it is just
>
> diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
> index 2cfa3075d148..e130692db24a 100644
> --- a/include/asm-generic/pgtable.h
> +++ b/include/asm-generic/pgtable.h
> @@ -375,7 +375,8 @@ static inline int pte_unused(pte_t pte)
> Â#endif
> Â
> Â#ifndef __HAVE_ARCH_PMD_SAME
> -#ifdef CONFIG_TRANSPARENT_HUGEPAGE
> +#if defined(CONFIG_TRANSPARENT_HUGEPAGE) || \
> +ÂÂÂ defined(CONFIG_SPECULATIVE_PAGE_FAULT)
> Âstatic inline int pmd_same(pmd_t pmd_a, pmd_t pmd_b)
> Â{
> ÂÂÂÂÂÂÂ return pmd_val(pmd_a) == pmd_val(pmd_b);

We can't fix that this way because some architectures define their own
pmd_same() function (like ppc64), thus forcing the define here will be useless
since __HAVE_ARCH_PMD_SAME is set in that case.

The right way to fix that is to _not check_ for the PMD value in pte_spinlock()
when CONFIG_TRANSPARENT_HUGEPAGE is not set since there is no risk of
collapsing operation in our back if THP are disabled.

I'll fix that in the next version.

Laurent.

> ?
>
> Daniel
>
>
> [*]Â The errors are:
>
> In file included from /home/dmjordan/src/linux/include/linux/kernel.h:10:0,
> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ from /home/dmjordan/src/linux/include/linux/list.h:9,
> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ from /home/dmjordan/src/linux/include/linux/smp.h:12,
> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ from /home/dmjordan/src/linux/include/linux/kernel_stat.h:5,
> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ from /home/dmjordan/src/linux/mm/memory.c:41:
> In function âpmd_same.isra.104â,
> ÂÂÂ inlined from âpte_map_lockâ at /home/dmjordan/src/linux/mm/memory.c:2380:7:
> /home/dmjordan/src/linux/include/linux/compiler.h:324:38: error: call to
> â__compiletime_assert_391â declared with attribute error: BUILD_BUG failed
> Â _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ ^
> /home/dmjordan/src/linux/include/linux/compiler.h:304:4: note: in definition of
> macro â__compiletime_assertâ
> ÂÂÂ prefix ## suffix();ÂÂÂ \
> ÂÂÂ ^~~~~~
> /home/dmjordan/src/linux/include/linux/compiler.h:324:2: note: in expansion of
> macro â_compiletime_assertâ
> Â _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
> Â ^~~~~~~~~~~~~~~~~~~
> /home/dmjordan/src/linux/include/linux/build_bug.h:45:37: note: in expansion of
> macro âcompiletime_assertâ
> Â#define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ ^~~~~~~~~~~~~~~~~~
> /home/dmjordan/src/linux/include/linux/build_bug.h:79:21: note: in expansion of
> macro âBUILD_BUG_ON_MSGâ
> Â#define BUILD_BUG() BUILD_BUG_ON_MSG(1, "BUILD_BUG failed")
> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ ^~~~~~~~~~~~~~~~
> /home/dmjordan/src/linux/include/asm-generic/pgtable.h:391:2: note: in
> expansion of macro âBUILD_BUGâ
> Â BUILD_BUG();
> Â ^~~~~~~~~
> Â CCÂÂÂÂÂ block/elevator.o
> Â CCÂÂÂÂÂ crypto/crypto_wq.o
> In function âpmd_same.isra.104â,
> ÂÂÂ inlined from âpte_spinlockâ at /home/dmjordan/src/linux/mm/memory.c:2326:7,
> ÂÂÂ inlined from âhandle_pte_faultâ at
> /home/dmjordan/src/linux/mm/memory.c:4181:7:
> /home/dmjordan/src/linux/include/linux/compiler.h:324:38: error: call to
> â__compiletime_assert_391â declared with attribute error: BUILD_BUG failed
> Â _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ ^
> /home/dmjordan/src/linux/include/linux/compiler.h:304:4: note: in definition of
> macro â__compiletime_assertâ
> ÂÂÂ prefix ## suffix();ÂÂÂ \
> ÂÂÂ ^~~~~~
> /home/dmjordan/src/linux/include/linux/compiler.h:324:2: note: in expansion of
> macro â_compiletime_assertâ
> Â _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
> Â ^~~~~~~~~~~~~~~~~~~
> /home/dmjordan/src/linux/include/linux/build_bug.h:45:37: note: in expansion of
> macro âcompiletime_assertâ
> Â#define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ ^~~~~~~~~~~~~~~~~~
> /home/dmjordan/src/linux/include/linux/build_bug.h:79:21: note: in expansion of
> macro âBUILD_BUG_ON_MSGâ
> Â#define BUILD_BUG() BUILD_BUG_ON_MSG(1, "BUILD_BUG failed")
> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ ^~~~~~~~~~~~~~~~
> /home/dmjordan/src/linux/include/asm-generic/pgtable.h:391:2: note: in
> expansion of macro âBUILD_BUGâ
> Â BUILD_BUG();
> Â ^~~~~~~~~
> ...
> make[2]: *** [/home/dmjordan/src/linux/scripts/Makefile.build:316: mm/memory.o]
> Error 1
> make[1]: *** [/home/dmjordan/src/linux/Makefile:1047: mm] Error 2
>