"Aneesh Kumar K.V" <aneesh.kumar@xxxxxxxxxxxxx> writes: > "Huang, Ying" <ying.huang@xxxxxxxxx> writes: > >> Aneesh Kumar K V <aneesh.kumar@xxxxxxxxxxxxx> writes: >> >>> On 7/26/22 9:33 AM, Huang, Ying wrote: >>>> "Aneesh Kumar K.V" <aneesh.kumar@xxxxxxxxxxxxx> writes: [snip] >>>>> >>>>> +static struct memory_tier *__node_get_memory_tier(int node) >>>>> +{ >>>>> + struct memory_tier *memtier; >>>>> + >>>>> + list_for_each_entry(memtier, &memory_tiers, list) { >>>>> + if (node_isset(node, memtier->nodelist)) >>>>> + return memtier; >>>>> + } >>>>> + return NULL; >>>>> +} >>>>> + >>>>> +static void init_node_memory_tier(int node) >>>> >>>> set_node_memory_tier()? >>> >>> That was done based on feedback from Alistair >>> >>> https://lore.kernel.org/linux-mm/87h73iapg1.fsf@nvdebian.thelocal >>> >>>> >>>>> +{ >>>>> + int perf_level; >>>>> + struct memory_tier *memtier; >>>>> + >>>>> + mutex_lock(&memory_tier_lock); >>>>> + >>>>> + memtier = __node_get_memory_tier(node); >>>>> + if (!memtier) { >>>>> + perf_level = node_devices[node]->perf_level; >>>>> + memtier = find_create_memory_tier(perf_level); >>>>> + node_set(node, memtier->nodelist); >>>>> + } >> >> It's related to Alistair's comments too. When will memtier != NULL >> here? We may need just VM_WARN_ON() here? > > When the platform driver sets memory tier directly. With the old code > it can happen when dax/kmem register a node to a memory tier. With > memory_type proposal this can happen if the node is part of memory > type that is already added to a memory tier. Let's look at what it looks like with memory_type in place. Best Regards, Huang, Ying >> >>>>> + mutex_unlock(&memory_tier_lock); >>>>> +} >>>>> + [snip]