svn commit: r365962 - stable/12/sys/kern
Hans Petter Selasky
hselasky at FreeBSD.org
Mon Sep 21 18:22:00 UTC 2020
Author: hselasky
Date: Mon Sep 21 18:21:59 2020
New Revision: 365962
URL: https://svnweb.freebsd.org/changeset/base/365962
Log:
MFC r365237:
Micro optimise _callout_stop_safe() by removing dead code.
The CS_DRAIN flag cannot be set at the same time like the async-drain function
pointer is set. These are orthogonal features. Assert this at the beginning
of the function.
Before:
if (flags & CS_DRAIN) {
/* FALLTHROUGH */
} else if (xxx) {
return yyy;
}
if (drain) {
zzz = drain;
}
After:
if (flags & CS_DRAIN) {
/* FALLTHROUGH */
} else if (xxx) {
return yyy;
} else {
if (drain) {
zzz = drain;
}
}
Reviewed by: markj@
Tested by: callout_test
Differential Revision: https://reviews.freebsd.org/D26285
Sponsored by: Mellanox Technologies // NVIDIA Networking
Modified:
stable/12/sys/kern/kern_timeout.c
Directory Properties:
stable/12/ (props changed)
Modified: stable/12/sys/kern/kern_timeout.c
==============================================================================
--- stable/12/sys/kern/kern_timeout.c Mon Sep 21 18:19:48 2020 (r365961)
+++ stable/12/sys/kern/kern_timeout.c Mon Sep 21 18:21:59 2020 (r365962)
@@ -1188,6 +1188,9 @@ _callout_stop_safe(struct callout *c, int flags, callo
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, c->c_lock,
"calling %s", __func__);
+ KASSERT((flags & CS_DRAIN) == 0 || drain == NULL,
+ ("Cannot set drain callback and CS_DRAIN flag at the same time"));
+
/*
* Some old subsystems don't hold Giant while running a callout_stop(),
* so just discard this check for the moment.
@@ -1383,11 +1386,12 @@ again:
}
CC_UNLOCK(cc);
return ((flags & CS_EXECUTING) != 0);
- }
- CTR3(KTR_CALLOUT, "failed to stop %p func %p arg %p",
- c, c->c_func, c->c_arg);
- if (drain) {
- cc_exec_drain(cc, direct) = drain;
+ } else {
+ CTR3(KTR_CALLOUT, "failed to stop %p func %p arg %p",
+ c, c->c_func, c->c_arg);
+ if (drain) {
+ cc_exec_drain(cc, direct) = drain;
+ }
}
KASSERT(!sq_locked, ("sleepqueue chain still locked"));
cancelled = ((flags & CS_EXECUTING) != 0);
More information about the svn-src-all
mailing list