2003-07-01 06:05:57

by Raghava Raju

[permalink] [raw]
Subject: To make a function get executed on cpu2


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


2003-07-01 16:30:36

by Zwane Mwaikambo

[permalink] [raw]
Subject: Re: To make a function get executed on cpu2

On Mon, 30 Jun 2003, Raghava Raju wrote:

> 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
--
function.linuxpower.ca

2003-07-02 09:50:00

by Herbert Xu

[permalink] [raw]
Subject: Re: To make a function get executed on cpu2

Zwane Mwaikambo <[email protected]> wrote:
> On Mon, 30 Jun 2003, Raghava Raju wrote:
>
>> 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

Surely you can emulate it using smp_call_function and make it return
straight away if it runs on the wrong CPU.
--
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

2003-07-02 11:59:06

by Zwane Mwaikambo

[permalink] [raw]
Subject: Re: To make a function get executed on cpu2

On Wed, 2 Jul 2003, Herbert Xu wrote:

> 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
--
function.linuxpower.ca

2003-07-02 12:05:38

by Dave Jones

[permalink] [raw]
Subject: Re: To make a function get executed on cpu2

On Wed, Jul 02, 2003 at 08:02:19AM -0400, Zwane Mwaikambo wrote:
> On Wed, 2 Jul 2003, Herbert Xu wrote:
>
> > 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

2003-07-02 12:26:22

by Zwane Mwaikambo

[permalink] [raw]
Subject: Re: To make a function get executed on cpu2

On Wed, 2 Jul 2003, Dave Jones wrote:

> 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
--
function.linuxpower.ca