Re: [RFC PATCH 5/5] mm, page_alloc: Introduce ZONELIST_FALLBACK_SAME_TYPE fallback list
From: Xishi Qiu
Date: Wed Apr 24 2019 - 23:26:17 EST
Hi Fan Du,
I think we should change the print in mminit_verify_zonelist too.
This patch changes the order of ZONELIST_FALLBACK, so the default numa policy can
alloc DRAM first, then PMEM, right?
Thanks,
Xishi Qiu
> OnÂsystemÂwithÂheterogeneousÂmemory,ÂreasonableÂfallÂbackÂlistsÂwoulÂbe:
> a.ÂNoÂfallÂback,ÂstickÂtoÂcurrentÂrunningÂnode.
> b.ÂFallÂbackÂtoÂotherÂnodesÂofÂtheÂsameÂtypeÂorÂdifferentÂtype
> ÂÂÂe.g.ÂDRAMÂnodeÂ0Â->ÂDRAMÂnodeÂ1Â->ÂPMEMÂnodeÂ2Â->ÂPMEMÂnodeÂ3
> c.ÂFallÂbackÂtoÂotherÂnodesÂofÂtheÂsameÂtypeÂonly.
> ÂÂÂe.g.ÂDRAMÂnodeÂ0Â->ÂDRAMÂnodeÂ1
>
> a.ÂisÂalreadyÂinÂplace,ÂpreviousÂpatchÂimplementÂb.ÂprovidingÂwayÂto
> satisfyÂmemoryÂrequestÂasÂbestÂeffortÂbyÂdefault.ÂAndÂthisÂpatchÂof
> writingÂbuildÂc.ÂtoÂfallbackÂtoÂtheÂsameÂnodeÂtypeÂwhenÂuserÂspecify
> GFP_SAME_NODE_TYPEÂonly.
>
> Signed-off-by:ÂFanÂDuÂ<fan.du@xxxxxxxxx>
> ---
> Âinclude/linux/gfp.hÂÂÂÂ|ÂÂ7Â+++++++
> Âinclude/linux/mmzone.hÂ|ÂÂ1Â+
> Âmm/page_alloc.cÂÂÂÂÂÂÂÂ|Â15Â+++++++++++++++
> Â3ÂfilesÂchanged,Â23Âinsertions(+)
>
> diffÂ--gitÂa/include/linux/gfp.hÂb/include/linux/gfp.h
> indexÂfdab7de..ca5fdfcÂ100644
> ---Âa/include/linux/gfp.h
> +++Âb/include/linux/gfp.h
> @@Â-44,6Â+44,8Â@@
> Â#else
> Â#defineÂ___GFP_NOLOCKDEPÂ0
> Â#endif
> +#defineÂ___GFP_SAME_NODE_TYPEÂ0x1000000u
> +
> Â/*ÂIfÂtheÂaboveÂareÂmodified,Â__GFP_BITS_SHIFTÂmayÂneedÂupdatingÂ*/
> Â
> Â/*
> @@Â-215,6Â+217,7Â@@
> Â
> Â/*ÂDisableÂlockdepÂforÂGFPÂcontextÂtrackingÂ*/
> Â#defineÂ__GFP_NOLOCKDEPÂ((__forceÂgfp_t)___GFP_NOLOCKDEP)
> +#defineÂ__GFP_SAME_NODE_TYPEÂ((__forceÂgfp_t)___GFP_SAME_NODE_TYPE)
> Â
> Â/*ÂRoomÂforÂNÂ__GFP_FOOÂbitsÂ*/
> Â#defineÂ__GFP_BITS_SHIFTÂ(23Â+ÂIS_ENABLED(CONFIG_LOCKDEP))
> @@Â-301,6Â+304,8Â@@
> ÂÂÂÂÂ__GFP_NOMEMALLOCÂ|Â__GFP_NOWARN)Â&Â~__GFP_RECLAIM)
> Â#defineÂGFP_TRANSHUGEÂ(GFP_TRANSHUGE_LIGHTÂ|Â__GFP_DIRECT_RECLAIM)
> Â
> +#defineÂGFP_SAME_NODE_TYPEÂ(__GFP_SAME_NODE_TYPE)
> +
> Â/*ÂConvertÂGFPÂflagsÂtoÂtheirÂcorrespondingÂmigrateÂtypeÂ*/
> Â#defineÂGFP_MOVABLE_MASKÂ(__GFP_RECLAIMABLE|__GFP_MOVABLE)
> Â#defineÂGFP_MOVABLE_SHIFTÂ3
> @@Â-438,6Â+443,8Â@@ÂstaticÂinlineÂintÂgfp_zonelist(gfp_tÂflags)
> Â#ifdefÂCONFIG_NUMA
> ÂÂifÂ(unlikely(flagsÂ&Â__GFP_THISNODE))
> ÂÂÂreturnÂZONELIST_NOFALLBACK;
> +ÂifÂ(unlikely(flagsÂ&Â__GFP_SAME_NODE_TYPE))
> +ÂÂreturnÂZONELIST_FALLBACK_SAME_TYPE;
> Â#endif
> ÂÂreturnÂZONELIST_FALLBACK;
> Â}
> diffÂ--gitÂa/include/linux/mmzone.hÂb/include/linux/mmzone.h
> indexÂ8c37e1c..2f8603eÂ100644
> ---Âa/include/linux/mmzone.h
> +++Âb/include/linux/mmzone.h
> @@Â-583,6Â+583,7Â@@ÂstaticÂinlineÂboolÂzone_intersects(structÂzoneÂ*zone,
> Â
> ÂenumÂ{
> ÂÂZONELIST_FALLBACK,Â/*ÂzonelistÂwithÂfallbackÂ*/
> +ÂZONELIST_FALLBACK_SAME_TYPE,Â/*ÂzonelistÂwithÂfallbackÂtoÂtheÂsameÂtypeÂnodeÂ*/
> Â#ifdefÂCONFIG_NUMA
> ÂÂ/*
> ÂÂÂ*ÂTheÂNUMAÂzonelistsÂareÂdoubledÂbecauseÂweÂneedÂzonelistsÂthat
> diffÂ--gitÂa/mm/page_alloc.cÂb/mm/page_alloc.c
> indexÂa408a91..de797921Â100644
> ---Âa/mm/page_alloc.c
> +++Âb/mm/page_alloc.c
> @@Â-5448,6Â+5448,21Â@@ÂstaticÂvoidÂbuild_zonelists_in_node_order(pg_data_tÂ*pgdat,ÂintÂ*node_order,
> ÂÂ}
> ÂÂzonerefs->zoneÂ=ÂNULL;
> ÂÂzonerefs->zone_idxÂ=Â0;
> +
> +ÂzonerefsÂ=Âpgdat->node_zonelists[ZONELIST_FALLBACK_SAME_TYPE]._zonerefs;
> +
> +ÂforÂ(iÂ=Â0;ÂiÂ<Ânr_nodes;Âi++)Â{
> +ÂÂintÂnr_zones;
> +
> +ÂÂpg_data_tÂ*nodeÂ=ÂNODE_DATA(node_order[i]);
> +
> +ÂÂifÂ(!is_node_same_type(node->node_id,Âpgdat->node_id))
> +ÂÂÂcontinue;
> +ÂÂnr_zonesÂ=Âbuild_zonerefs_node(node,Âzonerefs);
> +ÂÂzonerefsÂ+=Ânr_zones;
> +Â}
> +Âzonerefs->zoneÂ=ÂNULL;
> +Âzonerefs->zone_idxÂ=Â0;
> Â}
> Â
> Â/*
> --Â
> 1.8.3.1
>
>