[Gta04-owner] Kernel update for gta04
NeilBrown
neilb at suse.de
Sun Jul 8 13:39:21 CEST 2012
On Sun, 08 Jul 2012 13:30:00 +0200 Neil Jerram <neil at ossau.homelinux.net>
wrote:
> NeilBrown <neilb at suse.de> writes:
>
> > Neither.
> > To get race-free suspend you need support in the kernel and in user-space.
> > The kernel side requires that wakeup-events identify themselves. Last I
> > checked, *nothing* in the kernel identifies as a "wakeup source". My kernel
> > changes told the power-button, aux-button, RTC alarm and 3G interrupt to
> > identify themselves as wakeup sources.
> >
> > The user-space side is what I was trying to outline here.
>
> Ah, many thanks for explaining that, and to Radek for the LWN link.
>
> >> > The simplest way to avoid races with suspend is:
> >> > - read /sys/power/wakeup_count and record the number
> >> > - final check that no buttons are pressed etc
> >> > - write the recorded number to /sys/power/wakeup_count
> >> > - If that succeeds, write "mem" to /sys/power/state
>
> But isn't it obvious that (1) there's still a window here, between the
> last two lines, and (2) this could and should all be handled within the
> kernel?
1/ no. When you write a number successfully to wakeup_count it changes the
behaviour of writing 'mem' to 'state' slightly. It means that any wakeup
event should abort that suspend. If you don't write to wakeup_count, then
wakeup events won't abort the suspend.
i.e. the semantics are defined to close the race.
2/ again, no. The 'final check' must be in use-space. The kernel doesn't
keep track of whether wakeup events have been consumed by user-space.
Doing that was considered but it introduces too many more problems.
>
> > As of 3.5 there is code in the kernel which does the core part of this.
> > Whether that is easier or harder to use remains to be seen. It was added
> > because that is more like how Android works.
>
> So in 3.5 the race is correctly handled within the kernel, and the user
> space complexity disappears again?
There is still complexity in user-space, it is just different.
To work with in-kernel autosuspend you need to use 'epoll' to listen for
wakeup events, and use a new magic flag that instigates the required
handshake with the kernel.
Achieving race-free suspend requires a certain amount of complexity. You can
move it around a bit, but you cannot get rid of it completely.
NeilBrown
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 828 bytes
Desc: not available
URL: <http://lists.goldelico.com/pipermail/gta04-owner/attachments/20120708/154e0dda/attachment.bin>
More information about the Gta04-owner
mailing list