summaryrefslogtreecommitdiffstats
path: root/sys/sys/callout.h
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2016-03-02 18:46:17 +0000
committerkib <kib@FreeBSD.org>2016-03-02 18:46:17 +0000
commit486320aac47a70ba38fa073d099952762d964f7b (patch)
treec0a34461afd95f99062c6c31c7238d7d0e7e763c /sys/sys/callout.h
parenta45b6b4d9cfa0c7046106013d930f98c3df904d4 (diff)
downloadFreeBSD-src-486320aac47a70ba38fa073d099952762d964f7b.zip
FreeBSD-src-486320aac47a70ba38fa073d099952762d964f7b.tar.gz
If callout_stop_safe() noted that the callout is currently executing,
but next invocation is cancelled while migrating, sleepq_check_timeout() needs to be informed that the callout is stopped. Otherwise the thread switches off CPU and never become runnable, since running callout could have already raced with us, while the migrating and cancelled callout could be one which is expected to set TDP_TIMOFAIL flag for us. This contradicts with the expected behaviour of callout_stop() for other callers, which e.g. decrement references from the callout callbacks. Add a new flag CS_MIGRBLOCK requesting report of the situation as 'successfully stopped'. Reviewed by: jhb (previous version) Tested by: cognet, pho PR: 200992 Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D5221
Diffstat (limited to 'sys/sys/callout.h')
-rw-r--r--sys/sys/callout.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/sys/sys/callout.h b/sys/sys/callout.h
index 3e71c87..689b547 100644
--- a/sys/sys/callout.h
+++ b/sys/sys/callout.h
@@ -62,6 +62,12 @@ struct callout_handle {
struct callout *callout;
};
+/* Flags for callout_stop_safe() */
+#define CS_DRAIN 0x0001 /* callout_drain(), wait allowed */
+#define CS_MIGRBLOCK 0x0002 /* Block migration, return value
+ indicates that the callout was
+ executing */
+
#ifdef _KERNEL
/*
* Note the flags field is actually *two* fields. The c_flags
@@ -81,7 +87,7 @@ struct callout_handle {
*/
#define callout_active(c) ((c)->c_flags & CALLOUT_ACTIVE)
#define callout_deactivate(c) ((c)->c_flags &= ~CALLOUT_ACTIVE)
-#define callout_drain(c) _callout_stop_safe(c, 1, NULL)
+#define callout_drain(c) _callout_stop_safe(c, CS_DRAIN, NULL)
void callout_init(struct callout *, int);
void _callout_init_lock(struct callout *, struct lock_object *, int);
#define callout_init_mtx(c, mtx, flags) \
OpenPOWER on IntegriCloud