]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
MFC r367440: epoch: support non-preemptible epochs checking in_epoch()
authorKyle Evans <kevans@FreeBSD.org>
Sat, 14 Nov 2020 01:55:54 +0000 (01:55 +0000)
committerKyle Evans <kevans@FreeBSD.org>
Sat, 14 Nov 2020 01:55:54 +0000 (01:55 +0000)
commit3e31ba6b4430b2e830405792b1b75010e1f1226a
tree2cdbe0d6dd72b3b195669d88b3f9fdc318d76d8f
parentbb80a0a8f8fe8e16b38bb939e6ca0e6933610892
MFC r367440: epoch: support non-preemptible epochs checking in_epoch()

Previously, non-preemptible epochs could not check; in_epoch() would always
fail, usually because non-preemptible epochs don't imply THREAD_NO_SLEEPING.

For default epochs, it's easy enough to verify that we're in the given
epoch: if we're in a critical section and our record for the given epoch
is active, then we're in it.

This patch also adds some additional INVARIANTS bookkeeping. Notably, we set
and check the recorded thread in epoch_enter/epoch_exit to try and catch
some edge-cases for the caller. It also checks upon freeing that none of the
records had a thread in the epoch, which may make it a little easier to
diagnose some improper use if epoch_free() took place while some other
thread was inside.

This version differs slightly from what was just previously reviewed by the
below-listed, in that in_epoch() will assert that no CPU has this thread
recorded even if it *is* currently in a critical section. This is intended
to catch cases where the caller might have somehow messed up critical
section nesting, we can catch both if they exited the critical section or if
they exited, migrated, then re-entered (on the wrong CPU).
sys/kern/subr_epoch.c