On Thu, 4 Jul 2024 07:26:44 +0000 "Ho-Ren (Jack) Chuang" <horen.chuang@xxxxxxxxx> wrote: > The current memory tier initialization process is distributed across > two different functions, memory_tier_init() and memory_tier_late_init(). > This design is hard to maintain. Thus, this patch is proposed to reduce > the possible code paths by consolidating different > initialization patches into one. > > The earlier discussion with Jonathan and Ying is listed here: > https://lore.kernel.org/lkml/20240405150244.00004b49@xxxxxxxxxx/ > > If we want to put these two initializations together, they must be > placed together in the later function. Because only at that time, > the HMAT information will be ready, adist between nodes can be > calculated, and memory tiering can be established based on the adist. > So we position the initialization at memory_tier_init() to the > memory_tier_late_init() call. Moreover, it's natural to keep > memory_tier initialization in drivers at device_initcall() level. > > If we simply move the set_node_memory_tier() from memory_tier_init() > to late_initcall(), it will result in HMAT not registering > the mt_adistance_algorithm callback function, because > set_node_memory_tier() is not performed during the memory tiering > initialization phase, leading to a lack of correct default_dram > information. > > Therefore, we introduced a nodemask to pass the information of the > default DRAM nodes. The reason for not choosing to reuse > default_dram_type->nodes is that it is not clean enough. So in the end, > we use a __initdata variable, which is a variable that is released once > initialization is complete, including both CPU and memory nodes for HMAT > to iterate through. > > This patchset is based on commits <cf93be18fa1b> ("memory tier: create > CPUless memory tiers after obtaining HMAT info") and > <a72a30af550c> ("memory tier: dax/kmem: introduce an abstract layer for > finding, allocating, and putting memory types"): > [0/2] https://lkml.kernel.org/r/20240405000707.2670063-1-horenchuang@xxxxxxxxxxxxx > [1/2] https://lkml.kernel.org/r/20240405000707.2670063-2-horenchuang@xxxxxxxxxxxxx > [1/2] https://lkml.kernel.org/r/20240405000707.2670063-3-horenchuang@xxxxxxxxxxxxx > > Signed-off-by: Ho-Ren (Jack) Chuang <horenchuang@xxxxxxxxxxxxx> > Suggested-by: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx> LGTM Reviewed-by: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx>