- Consistently use PROC_ASSERT_HELD() to verify that a process' hold count

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
This commit is contained in:
Mark Johnston 2015-11-08 01:38:56 +00:00
parent 7e78597f04
commit d28713378a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=290530
4 changed files with 8 additions and 9 deletions

View File

@ -98,7 +98,7 @@ procfs_doprocdbregs(PFS_FILL_ARGS)
return (0); return (0);
PROC_LOCK(p); PROC_LOCK(p);
KASSERT(p->p_lock > 0, ("proc not held")); PROC_ASSERT_HELD(p);
if (p_candebug(td, p) != 0) { if (p_candebug(td, p) != 0) {
PROC_UNLOCK(p); PROC_UNLOCK(p);
return (EPERM); return (EPERM);

View File

@ -92,7 +92,7 @@ procfs_doprocfpregs(PFS_FILL_ARGS)
return (0); return (0);
PROC_LOCK(p); PROC_LOCK(p);
KASSERT(p->p_lock > 0, ("proc not held")); PROC_ASSERT_HELD(p);
if (p_candebug(td, p)) { if (p_candebug(td, p)) {
PROC_UNLOCK(p); PROC_UNLOCK(p);
return (EPERM); return (EPERM);

View File

@ -251,8 +251,7 @@ proc_rwmem(struct proc *p, struct uio *uio)
* curthread but we can't assert that.) This keeps the process * curthread but we can't assert that.) This keeps the process
* from exiting out from under us until this operation completes. * from exiting out from under us until this operation completes.
*/ */
KASSERT(p->p_lock >= 1, ("%s: process %p (pid %d) not held", __func__, PROC_ASSERT_HELD(p);
p, p->p_pid));
/* /*
* The map we want... * The map we want...

View File

@ -824,13 +824,13 @@ extern pid_t pid_max;
#define _PHOLD(p) do { \ #define _PHOLD(p) do { \
PROC_LOCK_ASSERT((p), MA_OWNED); \ PROC_LOCK_ASSERT((p), MA_OWNED); \
KASSERT(!((p)->p_flag & P_WEXIT) || (p) == curproc, \ KASSERT(!((p)->p_flag & P_WEXIT) || (p) == curproc, \
("PHOLD of exiting process")); \ ("PHOLD of exiting process %p", p)); \
(p)->p_lock++; \ (p)->p_lock++; \
if (((p)->p_flag & P_INMEM) == 0) \ if (((p)->p_flag & P_INMEM) == 0) \
faultin((p)); \ faultin((p)); \
} while (0) } while (0)
#define PROC_ASSERT_HELD(p) do { \ #define PROC_ASSERT_HELD(p) do { \
KASSERT((p)->p_lock > 0, ("process not held")); \ KASSERT((p)->p_lock > 0, ("process %p not held", p)); \
} while (0) } while (0)
#define PRELE(p) do { \ #define PRELE(p) do { \
@ -845,8 +845,8 @@ extern pid_t pid_max;
if (((p)->p_flag & P_WEXIT) && (p)->p_lock == 0) \ if (((p)->p_flag & P_WEXIT) && (p)->p_lock == 0) \
wakeup(&(p)->p_lock); \ wakeup(&(p)->p_lock); \
} while (0) } while (0)
#define PROC_ASSERT_NOT_HELD(p) do { \ #define PROC_ASSERT_NOT_HELD(p) do { \
KASSERT((p)->p_lock == 0, ("process held")); \ KASSERT((p)->p_lock == 0, ("process %p held", p)); \
} while (0) } while (0)
#define PROC_UPDATE_COW(p) do { \ #define PROC_UPDATE_COW(p) do { \