Rewrite subr_sleepqueue.c use of callouts to not depend on the
authorkib <kib@FreeBSD.org>
Thu, 28 Jul 2016 09:09:55 +0000 (09:09 +0000)
committerkib <kib@FreeBSD.org>
Thu, 28 Jul 2016 09:09:55 +0000 (09:09 +0000)
commit8fc564dae0232e844d7b35c659eec63578c1f9e0
tree0e99563ff142f24fc5f302f6a42aee9a60a3bb48
parent2b85baaf404d8cf43c3721444df679978ba7717c
Rewrite subr_sleepqueue.c use of callouts to not depend on the
specifics of callout KPI.  Esp., do not depend on the exact interface
of callout_stop(9) return values.

The main change is that instead of requiring precise callouts, code
maintains absolute time to wake up.  Callouts now should ensure that a
wake occurs at the requested moment, but we can tolerate both run-away
callout, and callout_stop(9) lying about running callout either way.

As consequence, it removes the constant source of the bugs where
sleepq_check_timeout() causes uninterruptible thread state where the
thread is detached from CPU, see e.g. r234952 and r296320.

Patch also removes dual meaning of the TDF_TIMEOUT flag, making code
(IMO much) simpler to reason about.

Tested by: pho
Reviewed by: jhb
Sponsored by: The FreeBSD Foundation
MFC after: 1 month
Differential revision: https://reviews.freebsd.org/D7137
sys/ddb/db_ps.c
sys/kern/kern_thread.c
sys/kern/subr_sleepqueue.c
sys/sys/proc.h