2008-08-28 17:34:12

by Leisner, Martin

[permalink] [raw]
Subject: FW: [linux-pm] select with timeout across S3

The behavior of linux (in both 2.4.x and 2.6.x) is when the processor
sleeps, timeouts on select don't take into account the sleep time,
only the run time.

For example, this program should pause for 10 minutes -- however
if we go into S3 in the middle its pausing for (10 minutes + time in
S3)

I saw this on both 2.6.20 and 2.6.22...

marty

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Pavel
Machek
Sent: Thursday, August 28, 2008 10:30 AM
To: Leisner, Martin
Cc: [email protected]
Subject: Re: [linux-pm] select with timeout across S3

On Wed 2008-08-27 15:23:13, Leisner, Martin wrote:
> What's a good way to "wait" across a transition to/from processor
sleep
> (acpi S3 or other means)?
>
>
> It seems the timeouts on select(2) only deal with with time correctly
> when the processor is awake -- when the processor is sleeping its not
> subtracted from the request...
>
> The desirable behavior out of select would be for it to timeout
whenever
> the system wakes up if the desired interval has elapsed...

That sounds like a bug. Can you write small demo program and post it
to lkml?

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures)
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm


Attachments:
select.c (194.00 B)
select.c

2008-08-28 20:57:54

by Andreas Mohr

[permalink] [raw]
Subject: Re: [linux-pm] select with timeout across S3

Hi,

dito.

This also happened to me a couple (4?) months ago, likely on 2.6.24 or
2.6.25.
And for me it had the "very nice" effect of not obeying DHCP lease time,
with a red-faced IT guy appearing in my door the next morning thusly... ;)

>From examining it more closely, it was rather obvious that select timeout
happened maybe 10 hours later than it should have (with 12h lease time),
due to hitting nightly S2R about two hours into the lease time.
Annoying, to say the least.

I think I then privately asked some timer guy about it, but I didn't get
a reply.

The DHCP client to hit this was pump, IIRC (can re-check).

Andreas Mohr

2009-01-27 09:15:56

by Pavel Machek

[permalink] [raw]
Subject: Re: FW: [linux-pm] select with timeout across S3

> I don't see a behavior change in the current kernels.
>
> Select(2) timeouts only count the time the machine is up -- not sleeping...
>
> I had a patch for 2.6.20 that I tried (it modified schedule_timeout) --
> it didn't do anything useful in 2.6.27-rc5.

Do you have some code to demonstrate that? We may want to fix this one
some day...
Pavel

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html