RFC Freezer: Use wait queue instead of busy looping (updated)
Get series with b4
b4 am [email protected]Versions newest first
- v1 RFC Latest3 patches 7 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | Freezer: Use wait queue instead of busy loopingkernel/ | +33 | 1 reply | |
| 2/3 | Freezer: Measure the time of freezing taskskernel/ | +15 | 1 reply | |
| 3/3 | Freezer: Replace the timeoutkernel/ | +17 | 5 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [RFC][PATCH -mm 0/3] Freezer: Use wait queue instead of busy looping (updated)
Quoted 46 lines · Pavel Machek
Quoted 45 lines · Rafael J. Wysocki
Quoted 34 lines · Rafael J. Wysocki
Hi,
Quoted 25 lines · Pavel Machek
Hi!
Quoted 23 lines
Quoted 10 lines
Quoted 3 lines
refrigerator_calledis only reset aftertry_to_freeze_tasks()has found it equal to one. There is only a small window between checking it inwait_event_timeout()and resetting it,Yes.
Quoted 3 lines
but then we go to send freeze requests
to the remaining tasks and we count 'todo' from the start, so that shouldn't be a problem.Quoted 6 lines
... and we find the task which is not
frozen()yet, but which has already passed the "set condition and wakeup", increment todo, and wait for the event. If it was the last task, we will sleep until timeout.I agree, this is not fatal and unlikely, but still it is a race. I think it is better to move this code down, after
frozen_process().OK, I see your point. The updated patch is appended.
Quoted 3 lines
(offtopic: strictly speaking, we don't even need the "
refrigerator_called", we
only need thewait_queue_head_t.try_to_freeze_tasks()just adds the "current" to wq at the very start of the main loop).Quoted 5 lines
Quoted 1 line
Hmm, yes, I think so.
Ok, could we just do
schedule_timeout(HZ/10)or something, but when we _know_ we woke someone,wakeup()that task? No new variables, keep existing logic.Quoted 6 lines
The logic doesn't change that much. :-)
Quoted 1 line
That should still get most of the benefits, and be two liner, no?
Well, I think we can avoid using
refrigerator_called, if this is a problem, but the patch won't be a two liner.To be precise, we'd need to add current to the wait queue manually, which would require us to open code
wait_event_timeout(), more or less.
Quoted 7 lines
Quoted 2 lines
Still, maybe to many things are done in this patch at a time. I'll try to split it into smaller steps. :-)
Ok, whatever.
Hmm, you could be sneaky and send signals to refrigerator, that should trigger early return from
schedule_timeout()...
Hmm, did you mean *from* the refrigerator?
Quoted 1 line
<runs away, hides>
Well, that wasn't really necessary. ;-)
The three patches in the next messages are functionally equivalent to this one.
They do the following:
* make try_to_freeze_tasks() wait instead of busy looping
* make try_to_freeze_tasks() measure the time it takes to freeze tasks
* replace the timeout with counting "waits"
Greetings,
Rafael
Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth