aboutsummaryrefslogtreecommitdiff
path: root/sys/sys/proc.h
diff options
context:
space:
mode:
authorGleb Smirnoff <glebius@FreeBSD.org>2019-10-29 17:19:36 +0000
committerGleb Smirnoff <glebius@FreeBSD.org>2019-10-29 17:19:36 +0000
commit46e64474701fed52dc20a2366e204dd6aa26c3f6 (patch)
tree3330505f6bba9f80cde75adc54970af280e8a96f /sys/sys/proc.h
parentf1eeb689abb911c3c531286d07f3511ed42878c9 (diff)
downloadsrc-46e64474701fed52dc20a2366e204dd6aa26c3f6.tar.gz
src-46e64474701fed52dc20a2366e204dd6aa26c3f6.zip
Augment macros that manipulate td_no_sleeping with assertions to check
underleak and overflow of the counter. Reviewed by: kib
Notes
Notes: svn path=/head/; revision=354147
Diffstat (limited to 'sys/sys/proc.h')
-rw-r--r--sys/sys/proc.h15
1 files changed, 10 insertions, 5 deletions
diff --git a/sys/sys/proc.h b/sys/sys/proc.h
index 54dea8d89018..7be1941416be 100644
--- a/sys/sys/proc.h
+++ b/sys/sys/proc.h
@@ -246,8 +246,7 @@ struct thread {
u_char td_lend_user_pri; /* (t) Lend user pri. */
/* Cleared during fork1() */
-#define td_startzero td_epochnest
- u_char td_epochnest; /* (k) Epoch nest counter. */
+#define td_startzero td_flags
int td_flags; /* (t) TDF_* flags. */
int td_inhibitors; /* (t) Why can not run. */
int td_pflags; /* (k) Private thread (TDP_*) flags. */
@@ -299,7 +298,7 @@ struct thread {
struct vm_map_entry *td_map_def_user; /* (k) Deferred entries. */
pid_t td_dbg_forked; /* (c) Child pid for debugger. */
u_int td_vp_reserv; /* (k) Count of reserved vnodes. */
- int td_no_sleeping; /* (k) Sleeping disabled count. */
+ u_int td_no_sleeping; /* (k) Sleeping disabled count. */
void *td_su; /* (k) FFS SU private */
sbintime_t td_sleeptimo; /* (t) Sleep timeout. */
int td_rtcgen; /* (s) rtc_generation of abs. sleep */
@@ -948,9 +947,15 @@ extern pid_t pid_max;
#define thread_safetoswapout(td) ((td)->td_flags & TDF_CANSWAP)
/* Control whether or not it is safe for curthread to sleep. */
-#define THREAD_NO_SLEEPING() ((curthread)->td_no_sleeping++)
+#define THREAD_NO_SLEEPING() do { \
+ curthread->td_no_sleeping++; \
+ MPASS(curthread->td_no_sleeping > 0); \
+} while (0)
-#define THREAD_SLEEPING_OK() ((curthread)->td_no_sleeping--)
+#define THREAD_SLEEPING_OK() do { \
+ MPASS(curthread->td_no_sleeping > 0); \
+ curthread->td_no_sleeping--; \
+} while (0)
#define THREAD_CAN_SLEEP() ((curthread)->td_no_sleeping == 0)