Re: [PATCH v6] mm: Proactive compaction

From: Nitin Gupta
Date: Mon Jun 15 2020 - 10:34:10 EST


On 6/15/20 7:25 AM, Oleksandr Natalenko wrote:
> On Mon, Jun 15, 2020 at 10:29:01AM +0200, Oleksandr Natalenko wrote:
>> Just to let you know, this fails to compile for me with THP disabled on
>> v5.8-rc1:
>>
>> CC mm/compaction.o
>> In file included from ./include/linux/dev_printk.h:14,
>> from ./include/linux/device.h:15,
>> from ./include/linux/node.h:18,
>> from ./include/linux/cpu.h:17,
>> from mm/compaction.c:11:
>> In function âfragmentation_score_zoneâ,
>> inlined from â__compact_finishedâ at mm/compaction.c:1982:11,
>> inlined from âcompact_zoneâ at mm/compaction.c:2062:8:
>> ./include/linux/compiler.h:392:38: error: call to â__compiletime_assert_397â declared with attribute error: BUILD_BUG failed
>> 392 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>> | ^
>> ./include/linux/compiler.h:373:4: note: in definition of macro â__compiletime_assertâ
>> 373 | prefix ## suffix(); \
>> | ^~~~~~
>> ./include/linux/compiler.h:392:2: note: in expansion of macro â_compiletime_assertâ
>> 392 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>> | ^~~~~~~~~~~~~~~~~~~
>> ./include/linux/build_bug.h:39:37: note: in expansion of macro âcompiletime_assertâ
>> 39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
>> | ^~~~~~~~~~~~~~~~~~
>> ./include/linux/build_bug.h:59:21: note: in expansion of macro âBUILD_BUG_ON_MSGâ
>> 59 | #define BUILD_BUG() BUILD_BUG_ON_MSG(1, "BUILD_BUG failed")
>> | ^~~~~~~~~~~~~~~~
>> ./include/linux/huge_mm.h:319:28: note: in expansion of macro âBUILD_BUGâ
>> 319 | #define HPAGE_PMD_SHIFT ({ BUILD_BUG(); 0; })
>> | ^~~~~~~~~
>> ./include/linux/huge_mm.h:115:26: note: in expansion of macro âHPAGE_PMD_SHIFTâ
>> 115 | #define HPAGE_PMD_ORDER (HPAGE_PMD_SHIFT-PAGE_SHIFT)
>> | ^~~~~~~~~~~~~~~
>> mm/compaction.c:64:32: note: in expansion of macro âHPAGE_PMD_ORDERâ
>> 64 | #define COMPACTION_HPAGE_ORDER HPAGE_PMD_ORDER
>> | ^~~~~~~~~~~~~~~
>> mm/compaction.c:1898:28: note: in expansion of macro âCOMPACTION_HPAGE_ORDERâ
>> 1898 | extfrag_for_order(zone, COMPACTION_HPAGE_ORDER);
>> | ^~~~~~~~~~~~~~~~~~~~~~
>> In function âfragmentation_score_zoneâ,
>> inlined from âkcompactdâ at mm/compaction.c:1918:12:
>> ./include/linux/compiler.h:392:38: error: call to â__compiletime_assert_397â declared with attribute error: BUILD_BUG failed
>> 392 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>> | ^
>> ./include/linux/compiler.h:373:4: note: in definition of macro â__compiletime_assertâ
>> 373 | prefix ## suffix(); \
>> | ^~~~~~
>> ./include/linux/compiler.h:392:2: note: in expansion of macro â_compiletime_assertâ
>> 392 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>> | ^~~~~~~~~~~~~~~~~~~
>> ./include/linux/build_bug.h:39:37: note: in expansion of macro âcompiletime_assertâ
>> 39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
>> | ^~~~~~~~~~~~~~~~~~
>> ./include/linux/build_bug.h:59:21: note: in expansion of macro âBUILD_BUG_ON_MSGâ
>> 59 | #define BUILD_BUG() BUILD_BUG_ON_MSG(1, "BUILD_BUG failed")
>> | ^~~~~~~~~~~~~~~~
>> ./include/linux/huge_mm.h:319:28: note: in expansion of macro âBUILD_BUGâ
>> 319 | #define HPAGE_PMD_SHIFT ({ BUILD_BUG(); 0; })
>> | ^~~~~~~~~
>> ./include/linux/huge_mm.h:115:26: note: in expansion of macro âHPAGE_PMD_SHIFTâ
>> 115 | #define HPAGE_PMD_ORDER (HPAGE_PMD_SHIFT-PAGE_SHIFT)
>> | ^~~~~~~~~~~~~~~
>> mm/compaction.c:64:32: note: in expansion of macro âHPAGE_PMD_ORDERâ
>> 64 | #define COMPACTION_HPAGE_ORDER HPAGE_PMD_ORDER
>> | ^~~~~~~~~~~~~~~
>> mm/compaction.c:1898:28: note: in expansion of macro âCOMPACTION_HPAGE_ORDERâ
>> 1898 | extfrag_for_order(zone, COMPACTION_HPAGE_ORDER);
>> | ^~~~~~~~~~~~~~~~~~~~~~
>> In function âfragmentation_score_zoneâ,
>> inlined from âkcompactdâ at mm/compaction.c:1918:12:
>> ./include/linux/compiler.h:392:38: error: call to â__compiletime_assert_397â declared with attribute error: BUILD_BUG failed
>> 392 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>> | ^
>> ./include/linux/compiler.h:373:4: note: in definition of macro â__compiletime_assertâ
>> 373 | prefix ## suffix(); \
>> | ^~~~~~
>> ./include/linux/compiler.h:392:2: note: in expansion of macro â_compiletime_assertâ
>> 392 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>> | ^~~~~~~~~~~~~~~~~~~
>> ./include/linux/build_bug.h:39:37: note: in expansion of macro âcompiletime_assertâ
>> 39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
>> | ^~~~~~~~~~~~~~~~~~
>> ./include/linux/build_bug.h:59:21: note: in expansion of macro âBUILD_BUG_ON_MSGâ
>> 59 | #define BUILD_BUG() BUILD_BUG_ON_MSG(1, "BUILD_BUG failed")
>> | ^~~~~~~~~~~~~~~~
>> ./include/linux/huge_mm.h:319:28: note: in expansion of macro âBUILD_BUGâ
>> 319 | #define HPAGE_PMD_SHIFT ({ BUILD_BUG(); 0; })
>> | ^~~~~~~~~
>> ./include/linux/huge_mm.h:115:26: note: in expansion of macro âHPAGE_PMD_SHIFTâ
>> 115 | #define HPAGE_PMD_ORDER (HPAGE_PMD_SHIFT-PAGE_SHIFT)
>> | ^~~~~~~~~~~~~~~
>> mm/compaction.c:64:32: note: in expansion of macro âHPAGE_PMD_ORDERâ
>> 64 | #define COMPACTION_HPAGE_ORDER HPAGE_PMD_ORDER
>> | ^~~~~~~~~~~~~~~
>> mm/compaction.c:1898:28: note: in expansion of macro âCOMPACTION_HPAGE_ORDERâ
>> 1898 | extfrag_for_order(zone, COMPACTION_HPAGE_ORDER);
>> | ^~~~~~~~~~~~~~~~~~~~~~
>> In function âfragmentation_score_zoneâ,
>> inlined from âkcompactdâ at mm/compaction.c:1918:12:
>> ./include/linux/compiler.h:392:38: error: call to â__compiletime_assert_397â declared with attribute error: BUILD_BUG failed
>> 392 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>> | ^
>> ./include/linux/compiler.h:373:4: note: in definition of macro â__compiletime_assertâ
>> 373 | prefix ## suffix(); \
>> | ^~~~~~
>> ./include/linux/compiler.h:392:2: note: in expansion of macro â_compiletime_assertâ
>> 392 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>> | ^~~~~~~~~~~~~~~~~~~
>> ./include/linux/build_bug.h:39:37: note: in expansion of macro âcompiletime_assertâ
>> 39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
>> | ^~~~~~~~~~~~~~~~~~
>> ./include/linux/build_bug.h:59:21: note: in expansion of macro âBUILD_BUG_ON_MSGâ
>> 59 | #define BUILD_BUG() BUILD_BUG_ON_MSG(1, "BUILD_BUG failed")
>> | ^~~~~~~~~~~~~~~~
>> ./include/linux/huge_mm.h:319:28: note: in expansion of macro âBUILD_BUGâ
>> 319 | #define HPAGE_PMD_SHIFT ({ BUILD_BUG(); 0; })
>> | ^~~~~~~~~
>> ./include/linux/huge_mm.h:115:26: note: in expansion of macro âHPAGE_PMD_SHIFTâ
>> 115 | #define HPAGE_PMD_ORDER (HPAGE_PMD_SHIFT-PAGE_SHIFT)
>> | ^~~~~~~~~~~~~~~
>> mm/compaction.c:64:32: note: in expansion of macro âHPAGE_PMD_ORDERâ
>> 64 | #define COMPACTION_HPAGE_ORDER HPAGE_PMD_ORDER
>> | ^~~~~~~~~~~~~~~
>> mm/compaction.c:1898:28: note: in expansion of macro âCOMPACTION_HPAGE_ORDERâ
>> 1898 | extfrag_for_order(zone, COMPACTION_HPAGE_ORDER);
>> | ^~~~~~~~~~~~~~~~~~~~~~
>> make[1]: *** [scripts/Makefile.build:281: mm/compaction.o] Error 1
>> make: *** [Makefile:1764: mm] Error 2
>>
>
> What about doing this:
>
> diff --git a/mm/compaction.c b/mm/compaction.c
> index 0d4f91dfb801..ac2030814edb 100644
> --- a/mm/compaction.c
> +++ b/mm/compaction.c
> @@ -60,7 +60,7 @@ static const int HPAGE_FRAG_CHECK_INTERVAL_MSEC = 500;
> * calculates external fragmentation, which is used as
> * the "fragmentation score" of a node/zone.
> */
> -#if defined HPAGE_PMD_ORDER
> +#if defined CONFIG_TRANSPARENT_HUGEPAGE
> #define COMPACTION_HPAGE_ORDER HPAGE_PMD_ORDER
> #elif defined HUGETLB_PAGE_ORDER
> #define COMPACTION_HPAGE_ORDER HUGETLB_PAGE_ORDER
>
> ?
>

Yes, this looks good. I will send out a v7 patch soon with this change.

Thanks,
Nitin