Date: Tue, 29 Oct 2019 17:19:36 +0000 (UTC) From: Gleb Smirnoff <glebius@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r354147 - head/sys/sys Message-ID: <201910291719.x9THJaIf006900@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: glebius Date: Tue Oct 29 17:19:36 2019 New Revision: 354147 URL: https://svnweb.freebsd.org/changeset/base/354147 Log: Augment macros that manipulate td_no_sleeping with assertions to check underleak and overflow of the counter. Reviewed by: kib Modified: head/sys/sys/proc.h Modified: head/sys/sys/proc.h ============================================================================== --- head/sys/sys/proc.h Tue Oct 29 16:51:12 2019 (r354146) +++ head/sys/sys/proc.h Tue Oct 29 17:19:36 2019 (r354147) @@ -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)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201910291719.x9THJaIf006900>