Re: [PATCH] mm: Only re-generate demotion targets when a numa node changes its N_CPU state

From: Baolin Wang
Date: Thu Mar 10 2022 - 01:23:44 EST


Hi Oscar,

On 3/10/2022 1:48 PM, Oscar Salvador wrote:
On Thu, Mar 10, 2022 at 08:39:53AM +0800, Huang, Ying wrote:
We need to call set_migration_target_nodes() during system boot
somewhere, either here or in init_mm_internals().

Hi Huang Ying,

vmstat_cpu_online() already gets called during boot:

static struct cpuhp_step cpuhp_hp_states[] = {
...
#ifdef CONFIG_SMP
[CPUHP_CREATE_THREADS]= {
.name = "threads:prepare",
.startup.single = smpboot_create_threads,
.teardown.single = NULL,
.cant_stop = true,
},
...

smpboot_create_threads
__smpboot_create_thread
smpboot_thread_fn
ht->thread_fn()
cpuhp_thread_fun
cpuhp_invoke_callback
vmstat_cpu_online

That for every CPU that is brought up during boot.

So unless I am missing something, I would say we are already covered
there, right?

I've tested your patch, unfortunately it can not work. It already set the node with N_CPU state in init_cpu_node_state() earlier, so in vmstat_cpu_online() ,the sentence 'if(!node_state(cpu_to_node(cpu), N_CPU))' is always false, which means it will not call set_migration_target_nodes().

Like Huang Ying said, we should call set_migration_target_nodes() in migrate_on_reclaim_init() or init_mm_internals().