svn commit: r247588 - in head/sys: dev/mps kern sys
John Baldwin
jhb at FreeBSD.org
Fri Mar 1 22:03:33 UTC 2013
Author: jhb
Date: Fri Mar 1 22:03:31 2013
New Revision: 247588
URL: http://svnweb.freebsd.org/changeset/base/247588
Log:
Replace the TDP_NOSLEEPING flag with a counter so that the
THREAD_NO_SLEEPING() and THREAD_SLEEPING_OK() macros can nest.
Reviewed by: attilio
Modified:
head/sys/dev/mps/mps.c
head/sys/kern/subr_sleepqueue.c
head/sys/kern/subr_trap.c
head/sys/sys/proc.h
head/sys/sys/rmlock.h
Modified: head/sys/dev/mps/mps.c
==============================================================================
--- head/sys/dev/mps/mps.c Fri Mar 1 21:59:23 2013 (r247587)
+++ head/sys/dev/mps/mps.c Fri Mar 1 22:03:31 2013 (r247588)
@@ -136,8 +136,8 @@ mps_diag_reset(struct mps_softc *sc,int
/*Force NO_SLEEP for threads prohibited to sleep
* e.a Thread from interrupt handler are prohibited to sleep.
- */
- if(curthread->td_pflags & TDP_NOSLEEPING)
+ */
+ if (curthread->td_no_sleeping != 0)
sleep_flag = NO_SLEEP;
/* Push the magic sequence */
@@ -469,8 +469,8 @@ mps_request_sync(struct mps_softc *sc, v
uint16_t *data16;
int i, count, ioc_sz, residual;
int sleep_flags = CAN_SLEEP;
-
- if(curthread->td_pflags & TDP_NOSLEEPING)
+
+ if (curthread->td_no_sleeping != 0)
sleep_flags = NO_SLEEP;
/* Step 1 */
Modified: head/sys/kern/subr_sleepqueue.c
==============================================================================
--- head/sys/kern/subr_sleepqueue.c Fri Mar 1 21:59:23 2013 (r247587)
+++ head/sys/kern/subr_sleepqueue.c Fri Mar 1 22:03:31 2013 (r247588)
@@ -296,8 +296,8 @@ sleepq_add(void *wchan, struct lock_obje
MPASS((queue >= 0) && (queue < NR_SLEEPQS));
/* If this thread is not allowed to sleep, die a horrible death. */
- KASSERT(!(td->td_pflags & TDP_NOSLEEPING),
- ("%s: td %p to sleep on wchan %p with TDP_NOSLEEPING on",
+ KASSERT(td->td_no_sleeping == 0,
+ ("%s: td %p to sleep on wchan %p with sleeping prohibited",
__func__, td, wchan));
/* Look up the sleep queue associated with the wait channel 'wchan'. */
Modified: head/sys/kern/subr_trap.c
==============================================================================
--- head/sys/kern/subr_trap.c Fri Mar 1 21:59:23 2013 (r247587)
+++ head/sys/kern/subr_trap.c Fri Mar 1 22:03:31 2013 (r247588)
@@ -158,7 +158,7 @@ userret(struct thread *td, struct trapfr
("userret: Returning with %d locks held", td->td_locks));
KASSERT((td->td_pflags & TDP_NOFAULTING) == 0,
("userret: Returning with pagefaults disabled"));
- KASSERT((td->td_pflags & TDP_NOSLEEPING) == 0,
+ KASSERT(td->td_no_sleeping == 0,
("userret: Returning with sleep disabled"));
KASSERT(td->td_pinned == 0 || (td->td_pflags & TDP_CALLCHAIN) != 0,
("userret: Returning with with pinned thread"));
Modified: head/sys/sys/proc.h
==============================================================================
--- head/sys/sys/proc.h Fri Mar 1 21:59:23 2013 (r247587)
+++ head/sys/sys/proc.h Fri Mar 1 22:03:31 2013 (r247588)
@@ -273,6 +273,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. */
#define td_endzero td_sigmask
/* Copied during fork1() or create_thread(). */
@@ -404,7 +405,7 @@ do { \
#define TDP_ALTSTACK 0x00000020 /* Have alternate signal stack. */
#define TDP_DEADLKTREAT 0x00000040 /* Lock aquisition - deadlock treatment. */
#define TDP_NOFAULTING 0x00000080 /* Do not handle page faults. */
-#define TDP_NOSLEEPING 0x00000100 /* Thread is not allowed to sleep on a sq. */
+#define TDP_UNUSED9 0x00000100 /* --available-- */
#define TDP_OWEUPC 0x00000200 /* Call addupc() at next AST. */
#define TDP_ITHREAD 0x00000400 /* Thread is an interrupt thread. */
#define TDP_SYNCIO 0x00000800 /* Local override, disable async i/o. */
@@ -790,17 +791,9 @@ 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() do { \
- KASSERT(!(curthread->td_pflags & TDP_NOSLEEPING), \
- ("nested no sleeping")); \
- curthread->td_pflags |= TDP_NOSLEEPING; \
-} while (0)
+#define THREAD_NO_SLEEPING() ((curthread)->td_no_sleeping++)
-#define THREAD_SLEEPING_OK() do { \
- KASSERT((curthread->td_pflags & TDP_NOSLEEPING), \
- ("nested sleeping ok")); \
- curthread->td_pflags &= ~TDP_NOSLEEPING; \
-} while (0)
+#define THREAD_SLEEPING_OK() ((curthread)->td_no_sleeping--)
#define PIDHASH(pid) (&pidhashtbl[(pid) & pidhash])
extern LIST_HEAD(pidhashhead, proc) *pidhashtbl;
Modified: head/sys/sys/rmlock.h
==============================================================================
--- head/sys/sys/rmlock.h Fri Mar 1 21:59:23 2013 (r247587)
+++ head/sys/sys/rmlock.h Fri Mar 1 22:03:31 2013 (r247588)
@@ -40,7 +40,7 @@
#ifdef _KERNEL
/*
- * Flags passed to rm_init(9).
+ * Flags passed to rm_init_flags(9).
*/
#define RM_NOWITNESS 0x00000001
#define RM_RECURSE 0x00000002
More information about the svn-src-head
mailing list