svn commit: r312945 - stable/11/sys/kern
Konstantin Belousov
kib at FreeBSD.org
Sun Jan 29 10:33:44 UTC 2017
Author: kib
Date: Sun Jan 29 10:33:42 2017
New Revision: 312945
URL: https://svnweb.freebsd.org/changeset/base/312945
Log:
MFC r312647:
Add comments explaining unobvious td_critnest adjustments in
critical_exit().
Modified:
stable/11/sys/kern/kern_switch.c
Directory Properties:
stable/11/ (props changed)
Modified: stable/11/sys/kern/kern_switch.c
==============================================================================
--- stable/11/sys/kern/kern_switch.c Sun Jan 29 03:34:49 2017 (r312944)
+++ stable/11/sys/kern/kern_switch.c Sun Jan 29 10:33:42 2017 (r312945)
@@ -206,7 +206,22 @@ critical_exit(void)
if (td->td_critnest == 1) {
td->td_critnest = 0;
+
+ /*
+ * Interrupt handlers execute critical_exit() on
+ * leave, and td_owepreempt may be left set by an
+ * interrupt handler only when td_critnest > 0. If we
+ * are decrementing td_critnest from 1 to 0, read
+ * td_owepreempt after decrementing, to not miss the
+ * preempt. Disallow compiler to reorder operations.
+ */
+ __compiler_membar();
if (td->td_owepreempt && !kdb_active) {
+ /*
+ * Microoptimization: we committed to switch,
+ * disable preemption in interrupt handlers
+ * while spinning for the thread lock.
+ */
td->td_critnest = 1;
thread_lock(td);
td->td_critnest--;
More information about the svn-src-stable
mailing list