2005-05-30 15:25:44

by jayush luniya

[permalink] [raw]
Subject: HOTPLUG CPU Support for SMT

Hi,

I have been looking at the CONFIG_HOTPLUG_CPU option
in the Linux Kernel. The option works for IA64, PPP64,
S390 architectures. I am doing my research on SMT
architecture and want to write a kernel module that
can dynamically enable/disable SMT, so that I can
switch between uniprocessor mode and SMT mode. So is
it possible to use the CONFIG_HOTPLUG_CPU option to
dynamically enable/disable a logical processor by
performing a logical removal of the CPU since the
hardware does not support CPU hotplugging? Also I
would like to know how efficient such an
implementation would be?

I would really appreciate if anyone could provide me
suggestions and any specific patches related to this
work.

Regards,
Jayush.

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com


2005-05-30 16:48:12

by Zwane Mwaikambo

[permalink] [raw]
Subject: Re: HOTPLUG CPU Support for SMT

On Mon, 30 May 2005, jayush luniya wrote:

> I have been looking at the CONFIG_HOTPLUG_CPU option
> in the Linux Kernel. The option works for IA64, PPP64,
> S390 architectures. I am doing my research on SMT
> architecture and want to write a kernel module that
> can dynamically enable/disable SMT, so that I can
> switch between uniprocessor mode and SMT mode. So is
> it possible to use the CONFIG_HOTPLUG_CPU option to
> dynamically enable/disable a logical processor by
> performing a logical removal of the CPU since the
> hardware does not support CPU hotplugging? Also I
> would like to know how efficient such an
> implementation would be?
>
> I would really appreciate if anyone could provide me
> suggestions and any specific patches related to this
> work.

Yes, older 2.6-mm kernel (2.6.10-mm) trees have the "toy" i386 hotplug
cpu implementation which does what you want.

2005-05-30 21:31:29

by Rutger Nijlunsing

[permalink] [raw]
Subject: Re: HOTPLUG CPU Support for SMT

On Mon, May 30, 2005 at 08:25:34AM -0700, jayush luniya wrote:
> Hi,
>
> I have been looking at the CONFIG_HOTPLUG_CPU option
> in the Linux Kernel. The option works for IA64, PPP64,
> S390 architectures. I am doing my research on SMT
> architecture and want to write a kernel module that
> can dynamically enable/disable SMT, so that I can
> switch between uniprocessor mode and SMT mode. So is
> it possible to use the CONFIG_HOTPLUG_CPU option to
> dynamically enable/disable a logical processor by
> performing a logical removal of the CPU since the
> hardware does not support CPU hotplugging? Also I
> would like to know how efficient such an
> implementation would be?
>
> I would really appreciate if anyone could provide me
> suggestions and any specific patches related to this
> work.

An easy way would be to use sched_setaffinity() and bind all processes
to one processor.

--
Rutger Nijlunsing

2005-05-31 05:17:21

by Srivatsa Vaddagiri

[permalink] [raw]
Subject: Re: HOTPLUG CPU Support for SMT

On Mon, May 30, 2005 at 04:50:27PM +0000, Zwane Mwaikambo wrote:
> Yes, older 2.6-mm kernel (2.6.10-mm) trees have the "toy" i386 hotplug
> cpu implementation which does what you want.

AFAIK in the i386 "toy" implementation, when a CPU is offlined, it stops
taking interrupts and stops running tasks, but it _still_ executes a while
loop in the context of its idle task (with IRQs disabled). The loop
is exited when we have to bring online the CPU again. What this means is
I don't think by offlining the CPU, we are removing any activity associated
with the corresponding h/w thread.

Maybe the toy implementation could be modified to take care of it? Something
like lowering the priority of the h/w thread so that it consumes minimal
CPU resources to execute its while loop.

--


Thanks and Regards,
Srivatsa Vaddagiri,
Linux Technology Center,
IBM Software Labs,
Bangalore, INDIA - 560017

2005-05-31 14:31:03

by Zwane Mwaikambo

[permalink] [raw]
Subject: Re: HOTPLUG CPU Support for SMT

On Tue, 31 May 2005, Srivatsa Vaddagiri wrote:

> On Mon, May 30, 2005 at 04:50:27PM +0000, Zwane Mwaikambo wrote:
> > Yes, older 2.6-mm kernel (2.6.10-mm) trees have the "toy" i386 hotplug
> > cpu implementation which does what you want.
>
> AFAIK in the i386 "toy" implementation, when a CPU is offlined, it stops
> taking interrupts and stops running tasks, but it _still_ executes a while
> loop in the context of its idle task (with IRQs disabled). The loop
> is exited when we have to bring online the CPU again. What this means is
> I don't think by offlining the CPU, we are removing any activity associated
> with the corresponding h/w thread.
>
> Maybe the toy implementation could be modified to take care of it? Something
> like lowering the priority of the h/w thread so that it consumes minimal
> CPU resources to execute its while loop.

A cpu_relax() there would help greatly and essentially "drops" the
priority of the processor executing it (since 'pause' is a hint that that
logical processor would like to yield execution resources), although there
would still be traffic due to accessing get_cpu_var, which should be minimal as
it'll be at most 1 non shared cacheline so you could account for it in the
statement of errors. I used to have a personal implementation for one of
the systems i use which does a hlt in that loop and i wake up the
procsesor via IPI. So perhaps some kernel hacking might be required
(albeit minimal) ;)

Zwane