2006-10-19 13:44:38

by Daniel Walker

[permalink] [raw]
Subject: Re: + i386-time-avoid-pit-smp-lockups.patch added to -mm tree

On Wed, 2006-10-11 at 14:26 -0700, [email protected] wrote:

> diff -puN arch/i386/kernel/i8253.c~i386-time-avoid-pit-smp-lockups arch/i386/kernel/i8253.c
> --- a/arch/i386/kernel/i8253.c~i386-time-avoid-pit-smp-lockups
> +++ a/arch/i386/kernel/i8253.c
> @@ -109,7 +109,7 @@ static struct clocksource clocksource_pi
>
> static int __init init_pit_clocksource(void)
> {
> - if (num_possible_cpus() > 4) /* PIT does not scale! */
> + if (num_possible_cpus() > 1) /* PIT does not scale! */
> return 0;
>

Can we ifdef some code here on CONFIG_SMP . It bugs me that there just
dead code laying around on smp systems.

Daniel


2006-10-19 13:47:24

by Andi Kleen

[permalink] [raw]
Subject: Re: + i386-time-avoid-pit-smp-lockups.patch added to -mm tree

On Thursday 19 October 2006 15:44, Daniel Walker wrote:
> On Wed, 2006-10-11 at 14:26 -0700, [email protected] wrote:
>
> > diff -puN arch/i386/kernel/i8253.c~i386-time-avoid-pit-smp-lockups arch/i386/kernel/i8253.c
> > --- a/arch/i386/kernel/i8253.c~i386-time-avoid-pit-smp-lockups
> > +++ a/arch/i386/kernel/i8253.c
> > @@ -109,7 +109,7 @@ static struct clocksource clocksource_pi
> >
> > static int __init init_pit_clocksource(void)
> > {
> > - if (num_possible_cpus() > 4) /* PIT does not scale! */
> > + if (num_possible_cpus() > 1) /* PIT does not scale! */
> > return 0;
> >
>
> Can we ifdef some code here on CONFIG_SMP . It bugs me that there just
> dead code laying around on smp systems.

The optimizer should optimize it all out since num_possible_cpus() is a 0
constant on UP.

-Andi

2006-10-19 13:57:10

by Daniel Walker

[permalink] [raw]
Subject: Re: + i386-time-avoid-pit-smp-lockups.patch added to -mm tree

On Thu, 2006-10-19 at 15:47 +0200, Andi Kleen wrote:
> On Thursday 19 October 2006 15:44, Daniel Walker wrote:
> > On Wed, 2006-10-11 at 14:26 -0700, [email protected] wrote:
> >
> > > diff -puN arch/i386/kernel/i8253.c~i386-time-avoid-pit-smp-lockups arch/i386/kernel/i8253.c
> > > --- a/arch/i386/kernel/i8253.c~i386-time-avoid-pit-smp-lockups
> > > +++ a/arch/i386/kernel/i8253.c
> > > @@ -109,7 +109,7 @@ static struct clocksource clocksource_pi
> > >
> > > static int __init init_pit_clocksource(void)
> > > {
> > > - if (num_possible_cpus() > 4) /* PIT does not scale! */
> > > + if (num_possible_cpus() > 1) /* PIT does not scale! */
> > > return 0;
> > >
> >
> > Can we ifdef some code here on CONFIG_SMP . It bugs me that there just
> > dead code laying around on smp systems.
>
> The optimizer should optimize it all out since num_possible_cpus() is a 0
> constant on UP.

You just mean the if statement above though? I was talking more about
the structure above this called "clocksource_pit" which isn't used on
SMP systems due to this code addition. AFAIK init_pit_clocksource()
could disappear along with the clocksource structure ..

Daniel

2006-10-19 14:05:45

by Andi Kleen

[permalink] [raw]
Subject: Re: + i386-time-avoid-pit-smp-lockups.patch added to -mm tree


> You just mean the if statement above though? I was talking more about
> the structure above this called "clocksource_pit" which isn't used on
> SMP systems due to this code addition. AFAIK init_pit_clocksource()
> could disappear along with the clocksource structure ..

It will end up as a int f() { return 0; }. Not very much overhead.

-Andi

2006-10-19 14:22:52

by Nick Piggin

[permalink] [raw]
Subject: Re: + i386-time-avoid-pit-smp-lockups.patch added to -mm tree

Daniel Walker wrote:
> On Thu, 2006-10-19 at 15:47 +0200, Andi Kleen wrote:
>
>>On Thursday 19 October 2006 15:44, Daniel Walker wrote:
>>
>>>On Wed, 2006-10-11 at 14:26 -0700, [email protected] wrote:
>>>
>>>
>>>>diff -puN arch/i386/kernel/i8253.c~i386-time-avoid-pit-smp-lockups arch/i386/kernel/i8253.c
>>>>--- a/arch/i386/kernel/i8253.c~i386-time-avoid-pit-smp-lockups
>>>>+++ a/arch/i386/kernel/i8253.c
>>>>@@ -109,7 +109,7 @@ static struct clocksource clocksource_pi
>>>>
>>>> static int __init init_pit_clocksource(void)
>>>> {
>>>>- if (num_possible_cpus() > 4) /* PIT does not scale! */
>>>>+ if (num_possible_cpus() > 1) /* PIT does not scale! */
>>>> return 0;
>>>>
>>>
>>>Can we ifdef some code here on CONFIG_SMP . It bugs me that there just
>>>dead code laying around on smp systems.
>>
>>The optimizer should optimize it all out since num_possible_cpus() is a 0
>>constant on UP.
>
>
> You just mean the if statement above though? I was talking more about
> the structure above this called "clocksource_pit" which isn't used on
> SMP systems due to this code addition. AFAIK init_pit_clocksource()
> could disappear along with the clocksource structure ..

An SMP kernel can boot on UP hardware, in which case I think
num_possible_cpus() will be 1, won't it?

--
SUSE Labs, Novell Inc.
Send instant messages to your online friends http://au.messenger.yahoo.com

2006-10-19 14:32:10

by Andi Kleen

[permalink] [raw]
Subject: Re: + i386-time-avoid-pit-smp-lockups.patch added to -mm tree


> An SMP kernel can boot on UP hardware, in which case I think
> num_possible_cpus() will be 1, won't it?

0 was a typo, i meant 1 for UP of course. 0 would be nonsensical.

-Andi

2006-10-19 14:49:03

by Nick Piggin

[permalink] [raw]
Subject: Re: + i386-time-avoid-pit-smp-lockups.patch added to -mm tree

Andi Kleen wrote:
>>An SMP kernel can boot on UP hardware, in which case I think
>>num_possible_cpus() will be 1, won't it?
>
>
> 0 was a typo, i meant 1 for UP of course. 0 would be nonsensical.

Sure, I realised that. For a UP kernel, the test will compile away.

But Daniel seems to say there is dead code that could be compiled
out for SMP kernels. I just don't think that is possible because the
SMP kernel can boot a UP system where num_possible_cpus() is 1.

--
SUSE Labs, Novell Inc.
Send instant messages to your online friends http://au.messenger.yahoo.com

2006-10-19 14:50:59

by Andi Kleen

[permalink] [raw]
Subject: Re: + i386-time-avoid-pit-smp-lockups.patch added to -mm tree

On Thursday 19 October 2006 16:48, Nick Piggin wrote:
> Andi Kleen wrote:
> >>An SMP kernel can boot on UP hardware, in which case I think
> >>num_possible_cpus() will be 1, won't it?
> >
> >
> > 0 was a typo, i meant 1 for UP of course. 0 would be nonsensical.
>
> Sure, I realised that. For a UP kernel, the test will compile away.
>
> But Daniel seems to say there is dead code that could be compiled
> out for SMP kernels. I just don't think that is possible because the
> SMP kernel can boot a UP system where num_possible_cpus() is 1.

I thought he meant !CONFIG_SMP kernels.

-Andi

2006-10-19 14:50:35

by Daniel Walker

[permalink] [raw]
Subject: Re: + i386-time-avoid-pit-smp-lockups.patch added to -mm tree

On Thu, 2006-10-19 at 16:05 +0200, Andi Kleen wrote:
> > You just mean the if statement above though? I was talking more about
> > the structure above this called "clocksource_pit" which isn't used on
> > SMP systems due to this code addition. AFAIK init_pit_clocksource()
> > could disappear along with the clocksource structure ..
>
> It will end up as a int f() { return 0; }. Not very much overhead.
>
> -Andi

Here's what I found ..

-rwxr-xr-x 1 dwalker engr 48252535 Oct 19 07:47 vmlinux
-rwxr-xr-x 1 dwalker engr 48249958 Oct 19 07:47 vmlinux.ifdef

So we're talking about ~2.5k of code including the pit_read and
clocksource structure.

Daniel

2006-10-19 15:01:56

by Daniel Walker

[permalink] [raw]
Subject: Re: + i386-time-avoid-pit-smp-lockups.patch added to -mm tree

On Thu, 2006-10-19 at 16:50 +0200, Andi Kleen wrote:
> On Thursday 19 October 2006 16:48, Nick Piggin wrote:
> > Andi Kleen wrote:
> > >>An SMP kernel can boot on UP hardware, in which case I think
> > >>num_possible_cpus() will be 1, won't it?
> > >
> > >
> > > 0 was a typo, i meant 1 for UP of course. 0 would be nonsensical.
> >
> > Sure, I realised that. For a UP kernel, the test will compile away.
> >
> > But Daniel seems to say there is dead code that could be compiled
> > out for SMP kernels. I just don't think that is possible because the
> > SMP kernel can boot a UP system where num_possible_cpus() is 1.
>
> I thought he meant !CONFIG_SMP kernels.

definitely CONFIG_SMP=y . The code block I quoted would disable the PIT
clocksource w/ more than one cpu. So the pit clocksource is just dead
weight on SMP systems. However, like Nick was saying it's possible to
boot CONFIG_SMP on a UP system, but removing the pit in that situation
may not hurt anything.

Daniel

2006-10-19 18:29:21

by john stultz

[permalink] [raw]
Subject: Re: + i386-time-avoid-pit-smp-lockups.patch added to -mm tree

On Thu, 2006-10-19 at 06:44 -0700, Daniel Walker wrote:
> On Wed, 2006-10-11 at 14:26 -0700, [email protected] wrote:
>
> > diff -puN arch/i386/kernel/i8253.c~i386-time-avoid-pit-smp-lockups arch/i386/kernel/i8253.c
> > --- a/arch/i386/kernel/i8253.c~i386-time-avoid-pit-smp-lockups
> > +++ a/arch/i386/kernel/i8253.c
> > @@ -109,7 +109,7 @@ static struct clocksource clocksource_pi
> >
> > static int __init init_pit_clocksource(void)
> > {
> > - if (num_possible_cpus() > 4) /* PIT does not scale! */
> > + if (num_possible_cpus() > 1) /* PIT does not scale! */
> > return 0;
> >
>
> Can we ifdef some code here on CONFIG_SMP . It bugs me that there just
> dead code laying around on smp systems.

I still want the pit to be available on SMP kernels that boot on UP
systems, so I don't think an ifdef will do it. Maybe it would be
possible to do some smp alternatives-like code removal on SMP systems?

thanks
-john