Skip to contentSkip to conversation

To make a function get executed on cpu2

DISCUSSION Raghava Raju 4 participants 6 messages Jul 1, 2003 – Jul 2, 2003

lore
Share & tools
lore
#0 lore raw

Hi,

In multicpu systems in kernel version 2.4.19, how can we specify that a function be executed on a cpu of our choice(say cpu_2). Moreover if I call a function from cpu_1 to be executed on cpu_2, I dont want to wait in cpu_1 until complete execution of function on cpu_2 . Is it possible?????

Any example would be really helpful. Please mail back to [email protected].

Regards
Raghava.

__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

#1 lore raw
Quoted 9 lines · Raghava Raju

In multicpu systems in kernel version 2.4.19, how can we specify that a function be executed on a cpu of our choice(say cpu_2). Moreover if I call a function from cpu_1 to be executed on cpu_2, I dont want to wait in cpu_1 until complete execution of function on cpu_2 . Is it possible?????

Any example would be really helpful. Please mail back to [email protected].

You can't really do it portably across all architectures, Alpha has smp_call_function_on_cpu which would allow you to do this. If you're really desperate you could always do something like the following;

http://www.osdl.org/projects/irqapi/results/patch-cpu_hotplug-smp_call_function_on_cpu_i386

Good luck,
Zwane

Signature · 1 line
function.linuxpower.ca
#2 lore raw
Quoted 9 lines · Zwane Mwaikambo
Quoted 7 lines · Raghava Raju

In multicpu systems in kernel version 2.4.19, how can we specify that a function be executed on a cpu of our choice(say cpu_2). Moreover if I call a function from cpu_1 to be executed on cpu_2, I dont want to wait in cpu_1 until complete execution of function on cpu_2 . Is it possible?????

Quoted 5 lines
Quoted 2 lines

Any example would be really helpful. Please mail back to [email protected].

You can't really do it portably across all architectures, Alpha has smp_call_function_on_cpu which would allow you to do this. If you're

Surely you can emulate it using smp_call_function and make it return straight away if it runs on the wrong CPU.

Signature · 4 lines
Debian GNU/Linux 3.0 is out! ( http://www.debian.org/ )
Email:  Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
#3 lore raw
Quoted 2 lines · Herbert Xu

Surely you can emulate it using smp_call_function and make it return straight away if it runs on the wrong CPU.

Yes you can, i thought about the same thing, but it simply generates unecessary APIC bus traffic and just sounds horrid. Not to mention it doesn't sound all that friendly on larger systems. But if you're using smp_call_function you're not really all that speed critical anyway, so this should suffice.

Zwane

Signature · 1 line
function.linuxpower.ca
#4 lore raw
Quoted 8 lines · Zwane Mwaikambo
Quoted 2 lines · Herbert Xu

Surely you can emulate it using smp_call_function and make it return straight away if it runs on the wrong CPU.

Yes you can, i thought about the same thing, but it simply generates unecessary APIC bus traffic and just sounds horrid. Not to mention it doesn't sound all that friendly on larger systems.

See do_cpuid in arch/i386/kernel/cpuid.c for an example of how to do this properly. It's a bit icky, but works. I've considered writing a generic run_on_cpu() when I did the on_each_cpu() stuff, but asides from cpuid.c, msr.c was the only other case I could find from a quick grep around that really cared, so it didn't seem worth the effort.

Dave

#5 lore raw
Quoted 5 lines · Dave Jones

See do_cpuid in arch/i386/kernel/cpuid.c for an example of how to do this properly. It's a bit icky, but works. I've considered writing a generic run_on_cpu() when I did the on_each_cpu() stuff, but asides from cpuid.c, msr.c was the only other case I could find from a quick grep around that really cared, so it didn't seem worth the effort.

I wrote come code which required such and ended up doing something similar. I also reckoned the actual function was generic enough i can't possibly be the only person needing such.

Zwane

Signature · 1 line
function.linuxpower.ca