Standard linux assignment of processes to CPUs depends on Xenomai Config
Hi everybody,
I just noted another very interesting thing.
When I have the Xenomai support built directly into the kernel (no modules), the Linux scheduler assigns all Linux tasks to CPU 0 (I have a SMP with a Dual Core CPU). Using e.g. taskset I can of course force tasks to run on CPU 1 but it will not be done automatically.
However, when I use modules for the Xenomai stuff, the Linux scheduler assigns the tasks to both available CPUs...
This behaviour looks very strange to me...
My setup: Kernel 2.6.19.2, SMP, Pentium 4 D, Xenomai 2.3. + COW patches. Any idea on this?!?
Thanks and regards
Mathias
Signature · 9 lines
Mathias Koehrer [email protected] Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT JETZT bei Arcor: günstig und schnell mit DSL - das All-Inclusive-Paket für clevere Doppel-Sparer, nur 44,85 € inkl. DSL- und ISDN-Grundgebühr! http://www.arcor.de/rd/emf-dsl-2
Quoted 8 lines · M. Koehrer
Hi everybody,
I just noted another very interesting thing.
When I have the Xenomai support built directly into the kernel (no modules), the Linux scheduler assigns all Linux tasks to CPU 0 (I have a SMP with a Dual Core CPU). Using e.g. taskset I can of course force tasks to run on CPU 1 but it will not be done automatically.
Quoted 6 lines
However, when I use modules for the Xenomai stuff, the Linux scheduler assigns the tasks to both available CPUs...
This behaviour looks very strange to me...
My setup: Kernel 2.6.19.2, SMP, Pentium 4 D, Xenomai 2.3. + COW patches. Any idea on this?!?
Mathias, mind to re-check if this behaviour persists with latest SVN (v2.3.x and/or trunk) and I-pipe 1.7-02? If yes, please file a short bug report to
https://gna.org/bugs/?group=xenomai
so that it doesn't get lost (we plan to manage non-trivial bug-tracking increasingly via that channel).
I consider this a non-critical issue. Still, it has to be understood and probably fixed.
Jan
Hi,
I suppose, that's what happens.
__xeno_sys_init() (./ksrc/nucleus/module.c) which is module_init() and when compiled in -> initcall()
calls xnarch_init() (./include/asm-i386/bits/init.h)
This one amongst other things does
...
#ifdef CONFIG_SMP
/* Make sure the init sequence is kept on the same CPU when
running as a module. */
set_cpus_allowed(current, cpumask_of_cpu(0));#endif /* CONFIG_SMP */
In fact, "running as a module" seems to be a bit misleading here. Then another macro should be used in addition, MODULE or how it's called.
Now guess who is a "current" here? It's "init" (pid 0).
init() -> do_basic_setup() -> do_initcalls() -> ... -> __xeno_sys_init() -> xnarch_init()
"init" is a first process to run and all the rest will inherit its "cpus_allowed" field.
That's it.
Signature · 2 lines
Best regards, Dmitry Adamushko
Hi!
I am very busy this week, I can do a check next week. However, it looks as Dmitry aleady got a clue to that issue...
Regards
Mathias
Quoted 36 lines
Hi,
I suppose, that's what happens.
__xeno_sys_init()(./ksrc/nucleus/module.c) which ismodule_init()and when compiled in ->initcall()calls
xnarch_init()(./include/asm-i386/bits/init.h)This one amongst other things does
...
#ifdef CONFIG_SMP /* Make sure the init sequence is kept on the same CPU when running as a module. */ set_cpus_allowed(current, cpumask_of_cpu(0));#endif /*
CONFIG_SMP*/In fact, "running as a module" seems to be a bit misleading here. Then another macro should be used in addition, MODULE or how it's called.
Now guess who is a "current" here? It's "init" (pid 0).
init()->do_basic_setup()->do_initcalls()-> ... ->__xeno_sys_init()->xnarch_init()"init" is a first process to run and all the rest will inherit its "
cpus_allowed" field.That's it.
Signature · 2 lines
Best regards, Dmitry Adamushko
Signature · 9 lines
Mathias Koehrer [email protected] Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT JETZT bei Arcor: günstig und schnell mit DSL - das All-Inclusive-Paket für clevere Doppel-Sparer, nur 44,85 € inkl. DSL- und ISDN-Grundgebühr! http://www.arcor.de/rd/emf-dsl-2
Quoted 24 lines · Dmitry Adamushko
Hi,
I suppose, that's what happens.
__xeno_sys_init()(./ksrc/nucleus/module.c) which ismodule_init()and when compiled in ->initcall()calls
xnarch_init()(./include/asm-i386/bits/init.h)This one amongst other things does
...
#ifdef CONFIG_SMP /* Make sure the init sequence is kept on the same CPU when running as a module. */ set_cpus_allowed(current, cpumask_of_cpu(0));#endif /*
CONFIG_SMP*/In fact, "running as a module" seems to be a bit misleading here. Then another macro should be used in addition, MODULE or how it's called.
Now guess who is a "current" here? It's "init" (pid 0).
Quoted 8 lines
init()->do_basic_setup()->do_initcalls()-> ... ->__xeno_sys_init()->xnarch_init()"init" is a first process to run and all the rest will inherit its "
cpus_allowed" field.That's it.
Eh, that's what I call a nice one Dmitry. This is the perfect example of legacy code stabbing us in the back. We should indeed definitely check for MODULE && SMP.
Signature · 1 line
Philippe.
Quoted 31 lines · Philippe Gerum
Quoted 30 lines · Dmitry Adamushko
Hi,
I suppose, that's what happens.
__xeno_sys_init()(./ksrc/nucleus/module.c) which ismodule_init()and when compiled in ->initcall()calls
xnarch_init()(./include/asm-i386/bits/init.h)This one amongst other things does
...
#ifdef CONFIG_SMP /* Make sure the init sequence is kept on the same CPU when running as a module. */ set_cpus_allowed(current, cpumask_of_cpu(0));#endif /*
CONFIG_SMP*/In fact, "running as a module" seems to be a bit misleading here. Then another macro should be used in addition, MODULE or how it's called.
Now guess who is a "current" here? It's "init" (pid 0).
init()->do_basic_setup()->do_initcalls()-> ... ->__xeno_sys_init()->xnarch_init()"init" is a first process to run and all the rest will inherit its "
cpus_allowed" field.
Quoted 6 lines
Quoted 2 lines
That's it.
Eh, that's what I call a nice one Dmitry. This is the perfect example of legacy code stabbing us in the back. We should indeed definitely check for MODULE && SMP.
Yep, as the very least. But even in this case, it's not very nice that via cpus_allowed we affect - scheduling-wise - a process which loads xeno modules and all its children as It's likely to be a shell. I haven't looked for further details now but isn't it possible to restore the actual state of "cpus_allowed" right after the init sequence has been done?
Quoted 4 lines
--
Philippe.
Signature · 2 lines
Best regards, Dmitry Adamushko
Quoted 35 lines · Dmitry Adamushko
Quoted 34 lines · Philippe Gerum
Quoted 32 lines · Dmitry Adamushko
Hi,
I suppose, that's what happens.
__xeno_sys_init()(./ksrc/nucleus/module.c) which ismodule_init()and when compiled in ->initcall()calls
xnarch_init()(./include/asm-i386/bits/init.h)This one amongst other things does
...
#ifdef CONFIG_SMP /* Make sure the init sequence is kept on the same CPU when running as a module. */ set_cpus_allowed(current, cpumask_of_cpu(0));#endif /*
CONFIG_SMP*/In fact, "running as a module" seems to be a bit misleading here. Then another macro should be used in addition, MODULE or how it's called.
Now guess who is a "current" here? It's "init" (pid 0).
init()->do_basic_setup()->do_initcalls()-> ... ->__xeno_sys_init()->xnarch_init()"init" is a first process to run and all the rest will inherit its "
cpus_allowed" field.That's it.
Quoted 7 lines
Quoted 3 lines
Eh, that's what I call a nice one Dmitry. This is the perfect example of legacy code stabbing us in the back. We should indeed definitely check for MODULE && SMP.
Yep, as the very least. But even in this case, it's not very nice that via
cpus_allowedwe affect - scheduling-wise - a process which loads xeno modules and all its children as It's likely to be a shell.
It's insmod.
Quoted 4 lines
I haven't looked for further details now but isn't it possible to restore the actual state of "
cpus_allowed" right after the init sequence has been done?
Not sure, unless we explicitely ask the I-pipe to notify us when module_inits terminate.
Quoted 6 lines
Quoted 4 lines
--
Philippe.
Signature · 1 line
Philippe.
Quoted 27 lines · Philippe Gerum
Quoted 26 lines · Dmitry Adamushko
Quoted 25 lines
Quoted 13 lines
...
#ifdef CONFIG_SMP /* Make sure the init sequence is kept on the same CPU when running as a module. */ set_cpus_allowed(current, cpumask_of_cpu(0));#endif /*
CONFIG_SMP*/In fact, "running as a module" seems to be a bit misleading here. Then another macro should be used in addition, MODULE or how it's called.
Now guess who is a "current" here? It's "init" (pid 0).
Quoted 8 lines
init()->do_basic_setup()->do_initcalls()-> ... ->__xeno_sys_init()->xnarch_init()"init" is a first process to run and all the rest will inherit its "
cpus_allowed" field.That's it.
Eh, that's what I call a nice one Dmitry. This is the perfect example of legacy code stabbing us in the back. We should indeed definitely check for MODULE && SMP.
Quoted 5 lines
Quoted 3 lines
Yep, as the very least. But even in this case, it's not very nice that via
cpus_allowedwe affect - scheduling-wise - a process which loads xeno modules and all its children as It's likely to be a shell.It's insmod.
Oh yep :) Don't think it's a problem then. SMP && MODULE should be ok.
Quoted 3 lines
--
Philippe.
Signature · 2 lines
Best regards, Dmitry Adamushko
Quoted 28 lines · Dmitry Adamushko
Quoted 27 lines · Philippe Gerum
Quoted 26 lines · Dmitry Adamushko
Quoted 25 lines
Quoted 13 lines
...
#ifdef CONFIG_SMP /* Make sure the init sequence is kept on the same CPU when running as a module. */ set_cpus_allowed(current, cpumask_of_cpu(0));#endif /*
CONFIG_SMP*/In fact, "running as a module" seems to be a bit misleading here. Then another macro should be used in addition, MODULE or how it's called.
Now guess who is a "current" here? It's "init" (pid 0).
Quoted 8 lines
init()->do_basic_setup()->do_initcalls()-> ... ->__xeno_sys_init()->xnarch_init()"init" is a first process to run and all the rest will inherit its "
cpus_allowed" field.That's it.
Eh, that's what I call a nice one Dmitry. This is the perfect example of legacy code stabbing us in the back. We should indeed definitely check for MODULE && SMP.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Yep, as the very least. But even in this case, it's not very nice that via
cpus_allowedwe affect - scheduling-wise - a process which loads xeno modules and all its children as It's likely to be a shell.It's insmod.
Oh yep :) Don't think it's a problem then. SMP && MODULE should be ok.
Fixed, thanks.
Quoted 4 lines
Quoted 3 lines
--
Philippe.
Signature · 1 line
Philippe.