Skip to content
Snippets Groups Projects
Commit fb97aadf authored by Guy Zana's avatar Guy Zana
Browse files

callouts: perform wake() outside of lock.

given the scheduler state, wake() sometimes rescheduled the dispatcher thread
immidiately, and then it blocked on the mutex that is still held by the caller
of _callout_stop_safe_locked().

this patch does wake() outside of the lock to eliminated these spurious context
switches.
parent 41360613
No related branches found
No related tags found
No related merge requests found
......@@ -69,10 +69,14 @@ namespace callouts {
return (false);
}
void mark_have_work(void)
{
_have_work = true;
}
// wakes the dispatcher
void wake_dispatcher(void)
{
_have_work = true;
_callout_dispatcher->wake();
}
}
......@@ -225,9 +229,11 @@ int callout_reset_on(struct callout *c, u64 to_ticks, void (*fn)(void *),
c->c_flags |= (CALLOUT_PENDING | CALLOUT_ACTIVE);
callouts::add_callout(c);
callouts::wake_dispatcher();
callouts::mark_have_work();
callouts::unlock();
callouts::wake_dispatcher();
return result;
}
......@@ -248,6 +254,7 @@ int _callout_stop_safe_locked(struct callout *c, int is_drain)
// Wait for callout
callout_set_waiter(c, sched::thread::current());
callouts::mark_have_work();
callouts::wake_dispatcher();
sched::thread::wait_until(callouts::_callout_mutex, [&] {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment