Regarding Linux kernel SMP and task switching CPU
When a task is moved from one CPU to another, are there platform specific functions that are called to detect change ?
are there platform specific functions that are called to detect change ? What is it that you wish to do with this?
- Are you thinking of modifying the thread migration logic before a thread is migrated? - Are you looking to trace such thread migrations across CPUs after they happen? - Something else?... regards CVS
On Sun, Jul 12, 2020 at 7:00 AM CVS <cvs268@gmail.com> wrote:
are there platform specific functions that are called to detect change ? What is it that you wish to do with this?
I am doing porting work; I would like to be able to update mm_struct->context when a task migrates to another CPU. Another related question to this topic is: can the same mm_struct be used by two tasks running each on a different CPU ? if yes, I would probably need to make mm_struct->context an array so that it can hold information for each CPU.
- Are you thinking of modifying the thread migration logic before a thread is migrated? - Are you looking to trace such thread migrations across CPUs after they happen? - Something else?...
regards CVS
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
On Sun, 12 Jul 2020 12:24:46 -0400, William Tambe said:
On Sun, Jul 12, 2020 at 7:00 AM CVS <cvs268@gmail.com> wrote:
are there platform specific functions that are called to detect change ? What is it that you wish to do with this?
I am doing porting work; I would like to be able to update mm_struct->context when a task migrates to another CPU.
That shouldn't be a big issue - there should already be architecture independent code that calls a function to do this sort of thing on task migration, and all you have to do is provide a "Here's how the actual update is done on the Wombat architecture" function in the appropriate place in the arch/ tree.
participants (3)
-
CVS -
Valdis Klētnieks -
William Tambe