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 MFC after: 1 week Sponsored by: Mellanox Technologies // NVIDIA Networking
This commit is contained in:
parent
72d849c761
commit
0d0053d7ed
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=365237
@ -1075,6 +1075,9 @@ _callout_stop_safe(struct callout *c, int flags, callout_func_t *drain)
|
||||
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.
|
||||
@ -1270,11 +1273,12 @@ _callout_stop_safe(struct callout *c, int flags, callout_func_t *drain)
|
||||
}
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user