Racing power management

From: John Fremlin (chief@bandits.org)
Date: Wed Mar 07 2001 - 16:13:11 EST


 Jeff Garzik <jgarzik@mandrakesoft.com> writes:

> John Fremlin wrote:
> > Why not set up the device driver to handle PM events itself. See
> > Documentation/pm.txt under Driver Interface.
>
> For PCI drivers, you implement the ::suspend and ::remove hooks.
>
> > I have a race free version of pm_send_all if you want it.
>
> Is this the same thing that is in 2.4.3-pre3?

Aarrgh. Looks like Alan Cox got his version in kernel first. (I did
write mine before.)

If I am not mistaken there is one (hypothetical) race still remaining
in Alan's version. Last time I checked the only code doing pm_send_all
was in the i386 APM driver (and so of course there is no chance of any
race at all even with the old version, if I understand correctly).

But suppose there were another pm_send_all caller. APM would decide to
user suspend and call pm_send_all asking for a SUSPEND to check it was
allowed to. While this is happening some clueless loser decides to
pm_send_all RESUME for whatever reason. This loser has to wait until
the APM pm_send_all finishes, but hypothetically and if I am not
mistaken, his pm_send_all RESUME could get in just after the APM
pm_send_all finished and just before APM made the physical BIOS call
to suspend the machine. This would screw stuff up of course.

You may say, this is rather improbable if not impossible, but it does
suggest that it would be a good idea to have locking wrapping
pm_send_all and the hardware machine suspend request. Cue: John's
pmpolicy patch.

Unfortunately, my patch adds another thing as well: /sbin/powermanager
so it got (is getting) trampled on by a lot of people who didn't like
that idea. If anybody wants the race free PM by itself, I can factor
out that bit.

-- 

http://www.penguinpowered.com/~vii - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Wed Mar 07 2001 - 21:00:24 EST