2002-10-19 19:34:30

by Bill Davidsen

[permalink] [raw]
Subject: Any hope of fixing shutdown power off for SMP?

I've beaten this dead horse before, but it still irks me that Linux can't
power down an SMP system. People claim that it can't be done safely, but
maybe somone can reverse engineer NT if we aren't up to the job.

Every once in a while a power fail will leave the systems on UPS, and at
some point it's needed to shut them down before the UPS is dead. You don't
want that, since if the power comes up and then drops during boot it may
hose filesystems. So I want the system really down while the UPS has a
fair bit of power left.

The only suggestion I got was to install NT, put a powerdown in the
startup directory, use lilo -R to reboot in NT, then do a reboot.
Wonderful. What I'm actually doing is rebooting a UP kernel and checking
in rc.local for only one processor, in which case I power down. That
works, but it's ugly!

Is it really that hard to shutdown all CPUs but one, then power down?

--
bill davidsen <[email protected]>
CTO, TMR Associates, Inc
Doing interesting things with little computers since 1979.


2002-10-20 05:31:30

by jurriaan

[permalink] [raw]
Subject: Re: Any hope of fixing shutdown power off for SMP?

From: Bill Davidsen <[email protected]>
Date: Sat, Oct 19, 2002 at 03:40:22PM -0400
> I've beaten this dead horse before, but it still irks me that Linux can't
> power down an SMP system. People claim that it can't be done safely, but
> maybe somone can reverse engineer NT if we aren't up to the job.
>
I'm trying to find out the same. So far:

2.5.43 will power down my smp VP6 board if I replace the BUG() calls in
arch/i386/kernel/apm.c with warnings. Somehow, the kernel doesn't
succesfully schedule itself to run on CPU 0. However, for my bios that
isn't needed.

2.5.44 doesn't work yet, since there's something funky going on with the
global_device_list() in drivers/base/power.c; the list is some kind of
loop when shutting down. I'm trying to find out what is happening there.
If you really need it working now, I'd be tempted to #if 0 out the whole
thing - at that point, my drives are unmounted and I don't really mind
what state the devices go down in when removing power in a few seconds.

> Every once in a while a power fail will leave the systems on UPS, and at
> some point it's needed to shut them down before the UPS is dead. You don't
> want that, since if the power comes up and then drops during boot it may
> hose filesystems. So I want the system really down while the UPS has a
> fair bit of power left.
>
> The only suggestion I got was to install NT, put a powerdown in the
> startup directory, use lilo -R to reboot in NT, then do a reboot.
> Wonderful. What I'm actually doing is rebooting a UP kernel and checking
> in rc.local for only one processor, in which case I power down. That
> works, but it's ugly!
>
> Is it really that hard to shutdown all CPUs but one, then power down?
>
No, but it just doesn't work yet :-)

Jurriaan
--
I am the fingernail that scrapes the chalkboard of your soul
Darkwing Duck
GNU/Linux 2.5.41 SMP/ReiserFS 2x1380 bogomips load av: 2.34 2.71 2.00

2002-10-20 23:45:04

by J.A. Magallon

[permalink] [raw]
Subject: Re: Any hope of fixing shutdown power off for SMP?


On 2002.10.20 Jurriaan wrote:
>From: Bill Davidsen <[email protected]>
>Date: Sat, Oct 19, 2002 at 03:40:22PM -0400
>> I've beaten this dead horse before, but it still irks me that Linux can't
>> power down an SMP system. People claim that it can't be done safely, but
>> maybe somone can reverse engineer NT if we aren't up to the job.
>>
>I'm trying to find out the same. So far:
>

There are patches both in the -ac and -aa tree to make smp kernels shut
down properly, even to support full APM if you have enough luck. shutdown
works fine on my smp box...

--
J.A. Magallon <[email protected]> \ Software is like sex:
werewolf.able.es \ It's better when it's free
Mandrake Linux release 9.1 (Cooker) for i586
Linux 2.4.20-pre11-jam1 (gcc 3.2 (Mandrake Linux 9.0 3.2-2mdk))

2002-10-21 00:47:01

by Bill Davidsen

[permalink] [raw]
Subject: Re: Any hope of fixing shutdown power off for SMP?

On Mon, 21 Oct 2002, J.A. Magallon wrote:

>
> On 2002.10.20 Jurriaan wrote:
> >From: Bill Davidsen <[email protected]>
> >Date: Sat, Oct 19, 2002 at 03:40:22PM -0400
> >> I've beaten this dead horse before, but it still irks me that Linux can't
> >> power down an SMP system. People claim that it can't be done safely, but
> >> maybe somone can reverse engineer NT if we aren't up to the job.
> >>
> >I'm trying to find out the same. So far:
> >
>
> There are patches both in the -ac and -aa tree to make smp kernels shut
> down properly, even to support full APM if you have enough luck. shutdown
> works fine on my smp box...

I'm kind of out of time to play any more, I think I'm going to leave
2.5.43 where it is (lots of stuff not working), send the patches to -mm3
and think about 2.5.44. That should be less volatile since Linus is out.

I can't get apm to even load, it whines in depmod about missing stuff, and
I've got about two days of my so-called vacation in what I do hve working,
so a good time to call it a version.

Thanks for the pointer, I'll try -aa and -ac kernels again at .44.

--
bill davidsen <[email protected]>
CTO, TMR Associates, Inc
Doing interesting things with little computers since 1979.

2002-10-21 00:57:24

by J.A. Magallon

[permalink] [raw]
Subject: Re: Any hope of fixing shutdown power off for SMP?


On 2002.10.21 Bill Davidsen wrote:
>On Mon, 21 Oct 2002, J.A. Magallon wrote:
>
>>
>> On 2002.10.20 Jurriaan wrote:
>> >From: Bill Davidsen <[email protected]>
>> >Date: Sat, Oct 19, 2002 at 03:40:22PM -0400
>> >> I've beaten this dead horse before, but it still irks me that Linux can't
>> >> power down an SMP system. People claim that it can't be done safely, but
>> >> maybe somone can reverse engineer NT if we aren't up to the job.
>> >>
>> >I'm trying to find out the same. So far:
>> >
>>
>> There are patches both in the -ac and -aa tree to make smp kernels shut
>> down properly, even to support full APM if you have enough luck. shutdown
>> works fine on my smp box...
>
>I'm kind of out of time to play any more, I think I'm going to leave
>2.5.43 where it is (lots of stuff not working), send the patches to -mm3
>and think about 2.5.44. That should be less volatile since Linus is out.
>
>I can't get apm to even load, it whines in depmod about missing stuff, and
>I've got about two days of my so-called vacation in what I do hve working,
>so a good time to call it a version.
>
>Thanks for the pointer, I'll try -aa and -ac kernels again at .44.
>

Oops, you talk about 2.5...
My pointers were about 2.4. Anyways, perhaps it is the same problem. Both
trees did not shutdown properly because shutdown waited inifinitely for
the apm task to schedule on cpu 0 due to bad interaction with O1
scheduler.

--
J.A. Magallon <[email protected]> \ Software is like sex:
werewolf.able.es \ It's better when it's free
Mandrake Linux release 9.1 (Cooker) for i586
Linux 2.4.20-pre11-jam1 (gcc 3.2 (Mandrake Linux 9.0 3.2-2mdk))

2002-10-21 02:34:29

by Bill Davidsen

[permalink] [raw]
Subject: Re: Any hope of fixing shutdown power off for SMP?

On Mon, 21 Oct 2002, J.A. Magallon wrote:

>
> On 2002.10.21 Bill Davidsen wrote:

> >I'm kind of out of time to play any more, I think I'm going to leave
> >2.5.43 where it is (lots of stuff not working), send the patches to -mm3
> >and think about 2.5.44. That should be less volatile since Linus is out.
> >
> >I can't get apm to even load, it whines in depmod about missing stuff, and
> >I've got about two days of my so-called vacation in what I do hve working,
> >so a good time to call it a version.
> >
> >Thanks for the pointer, I'll try -aa and -ac kernels again at .44.
> >
>
> Oops, you talk about 2.5...
> My pointers were about 2.4. Anyways, perhaps it is the same problem. Both
> trees did not shutdown properly because shutdown waited inifinitely for
> the apm task to schedule on cpu 0 due to bad interaction with O1
> scheduler.

I got a patch for that which *almost* works. The disks spin down, but the
console is still there. But when I hit the power button I don't have to
hold it, the system goes down like a rock, so it's doing more than it did.

In uni mode it goes all the way down, and I'm not sure the patch is quite
right, I just haven't had time to fight with it. Every once in a while I
have to do some work to keep the lights on.

--
bill davidsen <[email protected]>
CTO, TMR Associates, Inc
Doing interesting things with little computers since 1979.

2002-10-21 02:39:39

by Bill Davidsen

[permalink] [raw]
Subject: Re: Any hope of fixing shutdown power off for SMP?

On Sun, 20 Oct 2002, Jurriaan wrote:

> From: Bill Davidsen <[email protected]>
> Date: Sat, Oct 19, 2002 at 03:40:22PM -0400
> > I've beaten this dead horse before, but it still irks me that Linux can't
> > power down an SMP system. People claim that it can't be done safely, but
> > maybe somone can reverse engineer NT if we aren't up to the job.
> >
> I'm trying to find out the same. So far:
>
> 2.5.43 will power down my smp VP6 board if I replace the BUG() calls in
> arch/i386/kernel/apm.c with warnings. Somehow, the kernel doesn't
> succesfully schedule itself to run on CPU 0. However, for my bios that
> isn't needed.
>
Are you using the real-mode call? Perhaps I should try NOT doing that, and
see if it solves the problem. That used to be the solution, but things
change.

--
bill davidsen <[email protected]>
CTO, TMR Associates, Inc
Doing interesting things with little computers since 1979.

2002-10-21 06:52:56

by Rob Landley

[permalink] [raw]
Subject: Re: Any hope of fixing shutdown power off for SMP?

On Sunday 20 October 2002 21:45, Bill Davidsen wrote:
> On Sun, 20 Oct 2002, Jurriaan wrote:
> > From: Bill Davidsen <[email protected]>
> > Date: Sat, Oct 19, 2002 at 03:40:22PM -0400
> >
> > > I've beaten this dead horse before, but it still irks me that Linux
> > > can't power down an SMP system. People claim that it can't be done
> > > safely, but maybe somone can reverse engineer NT if we aren't up to the
> > > job.
> >
> > I'm trying to find out the same. So far:
> >
> > 2.5.43 will power down my smp VP6 board if I replace the BUG() calls in
> > arch/i386/kernel/apm.c with warnings. Somehow, the kernel doesn't
> > succesfully schedule itself to run on CPU 0. However, for my bios that
> > isn't needed.
>
> Are you using the real-mode call? Perhaps I should try NOT doing that, and
> see if it solves the problem. That used to be the solution, but things
> change.

None of my systems will power down on UP if I enable the "local apic support
on uniprocessors" option.

Something about the APIC code prevents the power down from occuring. The
symptoms are as you describe: the drives spin down, and the power goes off
immediately if you press the button (instead of having to hold it down), but
the power doesn't go off by itself.

Works fine if I compile without local APIC support.

Rob

2002-10-21 11:12:09

by Alan

[permalink] [raw]
Subject: Re: Any hope of fixing shutdown power off for SMP?

On Mon, 2002-10-21 at 02:58, Rob Landley wrote:
> None of my systems will power down on UP if I enable the "local apic support
> on uniprocessors" option.

Its a very common BIOS problem. Some work was done on switching back
from APIC in this situation but its not really proved sufficient - I
still dont understand why. With 2.5 we have ACPI thats now getting
actually usable and that should let the power off stuff beging to do the
right thing

2002-10-21 20:37:25

by Bill Davidsen

[permalink] [raw]
Subject: Re: Any hope of fixing shutdown power off for SMP?

On Sun, 20 Oct 2002, Rob Landley wrote:

> On Sunday 20 October 2002 21:45, Bill Davidsen wrote:
> > On Sun, 20 Oct 2002, Jurriaan wrote:

> > > 2.5.43 will power down my smp VP6 board if I replace the BUG() calls in
> > > arch/i386/kernel/apm.c with warnings. Somehow, the kernel doesn't
> > > succesfully schedule itself to run on CPU 0. However, for my bios that
> > > isn't needed.
> >
> > Are you using the real-mode call? Perhaps I should try NOT doing that, and
> > see if it solves the problem. That used to be the solution, but things
> > change.
>
> None of my systems will power down on UP if I enable the "local apic support
> on uniprocessors" option.
>
> Something about the APIC code prevents the power down from occuring. The
> symptoms are as you describe: the drives spin down, and the power goes off
> immediately if you press the button (instead of having to hold it down), but
> the power doesn't go off by itself.
>
> Works fine if I compile without local APIC support.

Hum, and you can quote me on that. I don't have that particular problem at
all, my problem is only with SMP. And on several machines I note that the
code to lock up SMP machines unless you use "noapic" isn't compatible with
2.4, haven't had the lockup yet. Wish that would migrate back to 2.4!

Anyway, my kernels are SMP, and if I boot "nosmp" they work fine with
every APIC in sight enabled. This may or may not be the same problem, you
could build an SMP kernel and boot it "nosmp" with APIC on and see what
that does (if you're curious).

--
bill davidsen <[email protected]>
CTO, TMR Associates, Inc
Doing interesting things with little computers since 1979.

2002-10-22 00:08:58

by Rob Landley

[permalink] [raw]
Subject: Re: Any hope of fixing shutdown power off for SMP?

On Monday 21 October 2002 15:41, Bill Davidsen wrote:
> On Sun, 20 Oct 2002, Rob Landley wrote:
> > On Sunday 20 October 2002 21:45, Bill Davidsen wrote:
> > > On Sun, 20 Oct 2002, Jurriaan wrote:
> > > > 2.5.43 will power down my smp VP6 board if I replace the BUG() calls
> > > > in arch/i386/kernel/apm.c with warnings. Somehow, the kernel doesn't
> > > > succesfully schedule itself to run on CPU 0. However, for my bios
> > > > that isn't needed.
> > >
> > > Are you using the real-mode call? Perhaps I should try NOT doing that,
> > > and see if it solves the problem. That used to be the solution, but
> > > things change.
> >
> > None of my systems will power down on UP if I enable the "local apic
> > support on uniprocessors" option.
> >
> > Something about the APIC code prevents the power down from occuring. The
> > symptoms are as you describe: the drives spin down, and the power goes
> > off immediately if you press the button (instead of having to hold it
> > down), but the power doesn't go off by itself.
> >
> > Works fine if I compile without local APIC support.
>
> Hum, and you can quote me on that. I don't have that particular problem at
> all, my problem is only with SMP.

SMP machines have the APIC enabled by default. Hence the problem sounds like
it's (at least being triggered by) the APIC code.

> Anyway, my kernels are SMP, and if I boot "nosmp" they work fine with
> every APIC in sight enabled. This may or may not be the same problem, you
> could build an SMP kernel and boot it "nosmp" with APIC on and see what
> that does (if you're curious).

Dunno. The boxen I currently manage are UP (cheaper that way), so I don't
actually need the APIC, so I switched it off and life went on. Alan Cox
seems to be of the opinion that bios bugs are involved, which should come as
no surprise. :)

Rob