Messages in this thread | | | Date | Mon, 27 Jun 2022 09:11:10 +0200 | From | Peter Zijlstra <> | Subject | Re: re. Spurious wakeup on a newly created kthread |
| |
On Mon, Jun 27, 2022 at 12:01:04AM +0000, Wedson Almeida Filho wrote: > On Sat, Jun 24, 2022 at 07:19:27PM -0500, Eric W. Biederman wrote: > > > > Further it is necessary for Peter Zijlstra's rewrite of the kernel > > freezer. As anything that isn't a special stop state (which > > TASK_UNINTERRUPTIBLE is not) will receive a spurious wake up on when > > thawed out. > > Do you know if the current (i.e., prior to the rewrite) kernel freezer > also sends spurious wakeups when thawing tasks?
Current freezer can thaw at random points in time, even before SMP bringup if you're unlucky. And yes, I think it can induce 'spurious' wakeups as well.
But really; like Linus already said upsteam, every wait loop *MUST* already be able to deal with spurious wakeups. This is why pretty much every wait primitive we have looks like:
for (;;) { set_current_state(state); if (cond) break; schedule(); } __set_current_state(RUNNING);
Which is immune to random wake-ups since it need @cond to make progress. *NEVER* rely on just the wakeup itself for progress, that's buggy as heck in lots of ways.
There are a few exceptions, but they all require special wait states and much carefulness.
| |