aboutsummaryrefslogtreecommitdiff
path: root/sys/sys/proc.h
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2016-06-22 20:15:37 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2016-06-22 20:15:37 +0000
commit95e2409a3340831355c176614690be1c6fcff654 (patch)
treeb93b67f78dd4b76a5cb7b7bfdcbf832fecd4c737 /sys/sys/proc.h
parente5bf62aac7bcda7177e56f72eab478efbe413168 (diff)
downloadsrc-95e2409a3340831355c176614690be1c6fcff654.tar.gz
src-95e2409a3340831355c176614690be1c6fcff654.zip
Notes
Diffstat (limited to 'sys/sys/proc.h')
-rw-r--r--sys/sys/proc.h21
1 files changed, 20 insertions, 1 deletions
diff --git a/sys/sys/proc.h b/sys/sys/proc.h
index f124d8ff1d95..6d03062c822d 100644
--- a/sys/sys/proc.h
+++ b/sys/sys/proc.h
@@ -827,7 +827,20 @@ extern pid_t pid_max;
#define SESS_LOCKED(s) mtx_owned(&(s)->s_mtx)
#define SESS_LOCK_ASSERT(s, type) mtx_assert(&(s)->s_mtx, (type))
-/* Hold process U-area in memory, normally for ptrace/procfs work. */
+/*
+ * Non-zero p_lock ensures that:
+ * - exit1() is not performed until p_lock reaches zero;
+ * - the process' threads stack are not swapped out if they are currently
+ * not (P_INMEM).
+ *
+ * PHOLD() asserts that the process (except the current process) is
+ * not exiting, increments p_lock and swaps threads stacks into memory,
+ * if needed.
+ * _PHOLD() is same as PHOLD(), it takes the process locked.
+ * _PHOLD_LITE() also takes the process locked, but comparing with
+ * _PHOLD(), it only guarantees that exit1() is not executed,
+ * faultin() is not called.
+ */
#define PHOLD(p) do { \
PROC_LOCK(p); \
_PHOLD(p); \
@@ -841,6 +854,12 @@ extern pid_t pid_max;
if (((p)->p_flag & P_INMEM) == 0) \
faultin((p)); \
} while (0)
+#define _PHOLD_LITE(p) do { \
+ PROC_LOCK_ASSERT((p), MA_OWNED); \
+ KASSERT(!((p)->p_flag & P_WEXIT) || (p) == curproc, \
+ ("PHOLD of exiting process %p", p)); \
+ (p)->p_lock++; \
+} while (0)
#define PROC_ASSERT_HELD(p) do { \
KASSERT((p)->p_lock > 0, ("process %p not held", p)); \
} while (0)