Introduce SCHEDULER_STOPPED_TD for use when the thread pointer was already read

Sprinkle in few places.
This commit is contained in:
Mateusz Guzik 2017-02-17 06:45:04 +00:00
parent 7a457115a9
commit 91fa47076d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=313859
3 changed files with 13 additions and 9 deletions

View File

@ -122,7 +122,7 @@ _cv_wait(struct cv *cvp, struct lock_object *lock)
"Waiting on \"%s\"", cvp->cv_description);
class = LOCK_CLASS(lock);
if (SCHEDULER_STOPPED())
if (SCHEDULER_STOPPED_TD(td))
return;
sleepq_lock(cvp);
@ -176,7 +176,7 @@ _cv_wait_unlock(struct cv *cvp, struct lock_object *lock)
("cv_wait_unlock cannot be used with Giant"));
class = LOCK_CLASS(lock);
if (SCHEDULER_STOPPED()) {
if (SCHEDULER_STOPPED_TD(td)) {
class->lc_unlock(lock);
return;
}
@ -227,7 +227,7 @@ _cv_wait_sig(struct cv *cvp, struct lock_object *lock)
"Waiting on \"%s\"", cvp->cv_description);
class = LOCK_CLASS(lock);
if (SCHEDULER_STOPPED())
if (SCHEDULER_STOPPED_TD(td))
return (0);
sleepq_lock(cvp);
@ -287,7 +287,7 @@ _cv_timedwait_sbt(struct cv *cvp, struct lock_object *lock, sbintime_t sbt,
"Waiting on \"%s\"", cvp->cv_description);
class = LOCK_CLASS(lock);
if (SCHEDULER_STOPPED())
if (SCHEDULER_STOPPED_TD(td))
return (0);
sleepq_lock(cvp);
@ -349,7 +349,7 @@ _cv_timedwait_sig_sbt(struct cv *cvp, struct lock_object *lock,
"Waiting on \"%s\"", cvp->cv_description);
class = LOCK_CLASS(lock);
if (SCHEDULER_STOPPED())
if (SCHEDULER_STOPPED_TD(td))
return (0);
sleepq_lock(cvp);

View File

@ -162,7 +162,7 @@ _sleep(void *ident, struct lock_object *lock, int priority,
else
class = NULL;
if (SCHEDULER_STOPPED()) {
if (SCHEDULER_STOPPED_TD(td)) {
if (lock != NULL && priority & PDROP)
class->lc_unlock(lock);
return (0);
@ -250,7 +250,7 @@ msleep_spin_sbt(void *ident, struct mtx *mtx, const char *wmesg,
KASSERT(ident != NULL, ("msleep_spin_sbt: NULL ident"));
KASSERT(TD_IS_RUNNING(td), ("msleep_spin_sbt: curthread not running"));
if (SCHEDULER_STOPPED())
if (SCHEDULER_STOPPED_TD(td))
return (0);
sleepq_lock(ident);
@ -411,7 +411,7 @@ mi_switch(int flags, struct thread *newtd)
*/
if (kdb_active)
kdb_switch();
if (SCHEDULER_STOPPED())
if (SCHEDULER_STOPPED_TD(td))
return;
if (flags & SW_VOL) {
td->td_ru.ru_nvcsw++;

View File

@ -128,7 +128,11 @@ void kassert_panic(const char *fmt, ...) __printflike(1, 2);
* Otherwise, the kernel will deadlock since the scheduler isn't
* going to run the thread that holds any lock we need.
*/
#define SCHEDULER_STOPPED() __predict_false(curthread->td_stopsched)
#define SCHEDULER_STOPPED_TD(td) ({ \
MPASS((td) == curthread); \
__predict_false((td)->td_stopsched); \
})
#define SCHEDULER_STOPPED() SCHEDULER_STOPPED_TD(curthread)
/*
* Align variables.