]> xenbits.xensource.com Git - people/liuw/freebsd.git/commitdiff
- Consistently use PROC_ASSERT_HELD() to verify that a process' hold count
authormarkj <markj@FreeBSD.org>
Sun, 8 Nov 2015 01:38:56 +0000 (01:38 +0000)
committermarkj <markj@FreeBSD.org>
Sun, 8 Nov 2015 01:38:56 +0000 (01:38 +0000)
  is non-zero.
- Include the process address in the PROC_ASSERT_HELD() and
  PROC_ASSERT_NOT_HELD() assertion messages so that the corresponding
  process can be found easily when debugging.

MFC after: 1 week

sys/fs/procfs/procfs_dbregs.c
sys/fs/procfs/procfs_fpregs.c
sys/kern/sys_process.c
sys/sys/proc.h

index de5dc769e46752c1a23663765f4c1a94b49a98ca..1598443bce9024537e6c6ab72df5b15e78bb1e03 100644 (file)
@@ -98,7 +98,7 @@ procfs_doprocdbregs(PFS_FILL_ARGS)
                return (0);
 
        PROC_LOCK(p);
-       KASSERT(p->p_lock > 0, ("proc not held"));
+       PROC_ASSERT_HELD(p);
        if (p_candebug(td, p) != 0) {
                PROC_UNLOCK(p);
                return (EPERM);
index c89c8e7e6017c6c6cf75d0f9628939f14530e201..d2f01535eb5774f2194ed1b520132ef6ed0a3dc9 100644 (file)
@@ -92,7 +92,7 @@ procfs_doprocfpregs(PFS_FILL_ARGS)
                return (0);
 
        PROC_LOCK(p);
-       KASSERT(p->p_lock > 0, ("proc not held"));
+       PROC_ASSERT_HELD(p);
        if (p_candebug(td, p)) {
                PROC_UNLOCK(p);
                return (EPERM);
index 47fbbc1a7889d9565575a7998980d19a48f262e6..89769418d634b6bdf5d743be59e60e06ac25d70b 100644 (file)
@@ -251,8 +251,7 @@ proc_rwmem(struct proc *p, struct uio *uio)
         * curthread but we can't assert that.)  This keeps the process
         * from exiting out from under us until this operation completes.
         */
-       KASSERT(p->p_lock >= 1, ("%s: process %p (pid %d) not held", __func__,
-           p, p->p_pid));
+       PROC_ASSERT_HELD(p);
 
        /*
         * The map we want...
index eff28b40365bed4fc34fca43fe02b4ad4b642001..90effa6d3909c8d4f825ca783dbdf96675a66330 100644 (file)
@@ -824,13 +824,13 @@ extern pid_t pid_max;
 #define        _PHOLD(p) do {                                                  \
        PROC_LOCK_ASSERT((p), MA_OWNED);                                \
        KASSERT(!((p)->p_flag & P_WEXIT) || (p) == curproc,             \
-           ("PHOLD of exiting process"));                              \
+           ("PHOLD of exiting process %p", p));                        \
        (p)->p_lock++;                                                  \
        if (((p)->p_flag & P_INMEM) == 0)                               \
                faultin((p));                                           \
 } while (0)
-#define PROC_ASSERT_HELD(p) do {                                       \
-       KASSERT((p)->p_lock > 0, ("process not held"));                 \
+#define        PROC_ASSERT_HELD(p) do {                                        \
+       KASSERT((p)->p_lock > 0, ("process %p not held", p));           \
 } while (0)
 
 #define        PRELE(p) do {                                                   \
@@ -845,8 +845,8 @@ extern pid_t pid_max;
        if (((p)->p_flag & P_WEXIT) && (p)->p_lock == 0)                \
                wakeup(&(p)->p_lock);                                   \
 } while (0)
-#define PROC_ASSERT_NOT_HELD(p) do {                                   \
-       KASSERT((p)->p_lock == 0, ("process held"));                    \
+#define        PROC_ASSERT_NOT_HELD(p) do {                                    \
+       KASSERT((p)->p_lock == 0, ("process %p held", p));              \
 } while (0)
 
 #define        PROC_UPDATE_COW(p) do {                                         \