Regarding Linux kernel SMP and task switching CPU

CVS cvs268 at gmail.com
Sun Jul 12 13:00:32 EDT 2020


> update mm_struct->context when a task migrates to another CPU
You might be able to do that using rq->prev_mm or  rq->active_mm
in move_queued_task() and ttwu_remote() functions...

Reference :
https://elixir.bootlin.com/linux/v5.7.8/source/kernel/sched/core.c#L1472
https://elixir.bootlin.com/linux/v5.7.8/source/kernel/sched/core.c#L2257

...however, i begin to cringe as I started to write the above.
Why? Because it sounds like a hack to me! :-)

> update mm_struct->context when a task migrates to another CPU
So, again, why do you want to do this?

BTW, in the interest of saving time, let us practice 5-Whys
(Reference: https://en.wikipedia.org/wiki/Five_whys)
and jump straight to the actual use-case / final problem
that you are trying to solve ...and work ahead from there.

May be there are pre-existing cleaner approaches to your problem
that do NOT involve fiddling with the Linux kernel internals.

regards
CVS



More information about the Kernelnewbies mailing list