summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authormarkj <markj@FreeBSD.org>2015-11-08 01:38:56 +0000
committermarkj <markj@FreeBSD.org>2015-11-08 01:38:56 +0000
commita7bb6eb7206346586b5a68c0fc588334dbdf1854 (patch)
treebb49368f6a2c64f93c8c74bd02d3172c0b4db5d1 /sys
parenta110d65fe331434ebd1f81308283a5fe86997bea (diff)
downloadFreeBSD-src-a7bb6eb7206346586b5a68c0fc588334dbdf1854.zip
FreeBSD-src-a7bb6eb7206346586b5a68c0fc588334dbdf1854.tar.gz
- 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
Diffstat (limited to 'sys')
-rw-r--r--sys/fs/procfs/procfs_dbregs.c2
-rw-r--r--sys/fs/procfs/procfs_fpregs.c2
-rw-r--r--sys/kern/sys_process.c3
-rw-r--r--sys/sys/proc.h10
4 files changed, 8 insertions, 9 deletions
diff --git a/sys/fs/procfs/procfs_dbregs.c b/sys/fs/procfs/procfs_dbregs.c
index de5dc76..1598443 100644
--- a/sys/fs/procfs/procfs_dbregs.c
+++ b/sys/fs/procfs/procfs_dbregs.c
@@ -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);
diff --git a/sys/fs/procfs/procfs_fpregs.c b/sys/fs/procfs/procfs_fpregs.c
index c89c8e7..d2f0153 100644
--- a/sys/fs/procfs/procfs_fpregs.c
+++ b/sys/fs/procfs/procfs_fpregs.c
@@ -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);
diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c
index 47fbbc1..8976941 100644
--- a/sys/kern/sys_process.c
+++ b/sys/kern/sys_process.c
@@ -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...
diff --git a/sys/sys/proc.h b/sys/sys/proc.h
index eff28b4..90effa6 100644
--- a/sys/sys/proc.h
+++ b/sys/sys/proc.h
@@ -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 { \
OpenPOWER on IntegriCloud