On 8/6/24 01:59, Frederic Weisbecker wrote: > On Mon, Aug 05, 2024 at 11:25:59PM +0200, Vlastimil Babka wrote: >> > It's too bad we don't have a way to have a cpumask_possible_of_node(). I've >> > looked into the guts of numa but that doesn't look easy to do. >> >> That was my impression as well. Maybe not even possible because exact cpu >> ids might not be pre-determined like this? > > Probably. > >> >> > Or there could be kthread_set_preferred_node()... ? >> >> Possible instead of the callback idea suggested above? >> kthreads_hotplug_update() could check if this is set and construct the mask >> accordingly. > > Or even better, callers of kthread_create_on_node() with actual node passed > (!NUMA_NO_NODE) can be preferrably affined to the corresponding node by default > unless told otherwise (that is unless kthread_bind() or > kthread_set_preferred_affinity() has been called before the first wake up, and > that includes kthread_create_on_cpu()). Sounds logical and great! > There are a few callers concerned: kswapd, kcompactd, some drivers: > drivers/block/mtip32xx/mtip32xx.c, drivers/firmware/stratix10-svc.c, > kernel/dma/map_benchmark.c, net/sunrpc/svc.c > > After all kthread_create_on_cpu() affines to the corresponding CPU. So > it sounds natural that kthread_create_on_node() affines to the corresponding > node. Yes. > And then it's handled on hotplug just as a special case of preferred affinity. > > Or is there something that wouldn't make that work? Hopefully not. > Thanks. > > >> >> > Thanks. >> > >> >> >> >> > Thanks. >> >> >>