kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* Regarding Linux kernel SMP and task switching CPU
@ 2020-07-09 11:01 William Tambe
  2020-07-12 11:00 ` CVS
  0 siblings, 1 reply; 5+ messages in thread
From: William Tambe @ 2020-07-09 11:01 UTC (permalink / raw)
  To: kernelnewbies

When a task is moved from one CPU to another, are there platform
specific functions that are called to detect change ?

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Regarding Linux kernel SMP and task switching CPU
  2020-07-09 11:01 Regarding Linux kernel SMP and task switching CPU William Tambe
@ 2020-07-12 11:00 ` CVS
  2020-07-12 16:24   ` William Tambe
  0 siblings, 1 reply; 5+ messages in thread
From: CVS @ 2020-07-12 11:00 UTC (permalink / raw)
  To: William Tambe; +Cc: Kernel Newbies

> 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

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Regarding Linux kernel SMP and task switching CPU
  2020-07-12 11:00 ` CVS
@ 2020-07-12 16:24   ` William Tambe
  2020-07-12 17:00     ` CVS
  2020-07-13  4:20     ` Valdis Klētnieks
  0 siblings, 2 replies; 5+ messages in thread
From: William Tambe @ 2020-07-12 16:24 UTC (permalink / raw)
  To: CVS; +Cc: Kernel Newbies

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

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Regarding Linux kernel SMP and task switching CPU
  2020-07-12 16:24   ` William Tambe
@ 2020-07-12 17:00     ` CVS
  2020-07-13  4:20     ` Valdis Klētnieks
  1 sibling, 0 replies; 5+ messages in thread
From: CVS @ 2020-07-12 17:00 UTC (permalink / raw)
  To: William Tambe; +Cc: Kernel Newbies

> 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

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Regarding Linux kernel SMP and task switching CPU
  2020-07-12 16:24   ` William Tambe
  2020-07-12 17:00     ` CVS
@ 2020-07-13  4:20     ` Valdis Klētnieks
  1 sibling, 0 replies; 5+ messages in thread
From: Valdis Klētnieks @ 2020-07-13  4:20 UTC (permalink / raw)
  To: William Tambe; +Cc: CVS, Kernel Newbies


[-- Attachment #1.1: Type: text/plain, Size: 679 bytes --]

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.


[-- Attachment #1.2: Type: application/pgp-signature, Size: 832 bytes --]

[-- Attachment #2: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-07-13  4:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-09 11:01 Regarding Linux kernel SMP and task switching CPU William Tambe
2020-07-12 11:00 ` CVS
2020-07-12 16:24   ` William Tambe
2020-07-12 17:00     ` CVS
2020-07-13  4:20     ` Valdis Klētnieks

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).