diff options
author | glebius <glebius@FreeBSD.org> | 2016-07-05 18:47:17 +0000 |
---|---|---|
committer | glebius <glebius@FreeBSD.org> | 2016-07-05 18:47:17 +0000 |
commit | 2b2f782761e357aa9465b153228751f4d2214e11 (patch) | |
tree | df89f7538deb1b0f07dc825f3cc07f66e10f14a1 /sys/sys/callout.h | |
parent | 0417c9be8f05eff0acea3a2e28199529d66ca4c3 (diff) | |
download | FreeBSD-src-2b2f782761e357aa9465b153228751f4d2214e11.zip FreeBSD-src-2b2f782761e357aa9465b153228751f4d2214e11.tar.gz |
The paradigm of a callout is that it has three consequent states:
not scheduled -> scheduled -> running -> not scheduled. The API and the
manual page assume that, some comments in the code assume that, and looks
like some contributors to the code also did. The problem is that this
paradigm isn't true. A callout can be scheduled and running at the same
time, which makes API description ambigouous. In such case callout_stop()
family of functions/macros should return 1 and 0 at the same time, since it
successfully unscheduled future callout but the current one is running.
Before this change we returned 1 in such a case, with an exception that
if running callout was migrating we returned 0, unless CS_MIGRBLOCK was
specified.
With this change, we now return 0 in case if future callout was unscheduled,
but another one is still in action, indicating to API users that resources
are not yet safe to be freed.
However, the sleepqueue code relies on getting 1 return code in that case,
and there already was CS_MIGRBLOCK flag, that covered one of the edge cases.
In the new return path we will also use this flag, to keep sleepqueue safe.
Since the flag CS_MIGRBLOCK doesn't block migration and now isn't limited to
migration edge case, rename it to CS_EXECUTING.
This change fixes panics on a high loaded TCP server.
Reviewed by: jch, hselasky, rrs, kib
Approved by: re (gjb)
Differential Revision: https://reviews.freebsd.org/D7042
Diffstat (limited to 'sys/sys/callout.h')
-rw-r--r-- | sys/sys/callout.h | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/sys/sys/callout.h b/sys/sys/callout.h index 689b547..d308d70 100644 --- a/sys/sys/callout.h +++ b/sys/sys/callout.h @@ -64,9 +64,8 @@ struct callout_handle { /* 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 */ +#define CS_EXECUTING 0x0002 /* Positive return value indicates that + the callout was executing */ #ifdef _KERNEL /* |