summaryrefslogtreecommitdiffstats
path: root/sys/sys
diff options
context:
space:
mode:
authordchagin <dchagin@FreeBSD.org>2016-01-09 14:08:10 +0000
committerdchagin <dchagin@FreeBSD.org>2016-01-09 14:08:10 +0000
commit939deb433656eadcd7e74873a32a38411367cdc8 (patch)
tree098f09b40a7709202e8662e68db796b52cf431ce /sys/sys
parent8120f17059427acef6857f4445f402c4646a266a (diff)
downloadFreeBSD-src-939deb433656eadcd7e74873a32a38411367cdc8.zip
FreeBSD-src-939deb433656eadcd7e74873a32a38411367cdc8.tar.gz
To facillitate an upcoming Linuxulator merging partially
MFC r275121 (by kib). Only merge the syntax changes from r275121, PROC_*LOCK() macros still lock the same proc spinlock. The process spin lock currently has the following distinct uses: - Threads lifetime cycle, in particular, counting of the threads in the process, and interlocking with process mutex and thread lock. The main reason of this is that turnstile locks are after thread locks, so you e.g. cannot unlock blockable mutex (think process mutex) while owning thread lock. - Virtual and profiling itimers, since the timers activation is done from the clock interrupt context. Replace the p_slock by p_itimmtx and PROC_ITIMLOCK(). - Profiling code (profil(2)), for similar reason. Replace the p_slock by p_profmtx and PROC_PROFLOCK(). - Resource usage accounting. Need for the spinlock there is subtle, my understanding is that spinlock blocks context switching for the current thread, which prevents td_runtime and similar fields from changing (updates are done at the mi_switch()). Replace the p_slock by p_statmtx and PROC_STATLOCK(). Discussed with: kib
Diffstat (limited to 'sys/sys')
-rw-r--r--sys/sys/proc.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/sys/sys/proc.h b/sys/sys/proc.h
index 5b441bc..cc21e48 100644
--- a/sys/sys/proc.h
+++ b/sys/sys/proc.h
@@ -616,6 +616,18 @@ struct proc {
#define PROC_SUNLOCK(p) mtx_unlock_spin(&(p)->p_slock)
#define PROC_SLOCK_ASSERT(p, type) mtx_assert(&(p)->p_slock, (type))
+#define PROC_STATLOCK(p) mtx_lock_spin(&(p)->p_slock)
+#define PROC_STATUNLOCK(p) mtx_unlock_spin(&(p)->p_slock)
+#define PROC_STATLOCK_ASSERT(p, type) mtx_assert(&(p)->p_slock, (type))
+
+#define PROC_ITIMLOCK(p) mtx_lock_spin(&(p)->p_slock)
+#define PROC_ITIMUNLOCK(p) mtx_unlock_spin(&(p)->p_slock)
+#define PROC_ITIMLOCK_ASSERT(p, type) mtx_assert(&(p)->p_slock, (type))
+
+#define PROC_PROFLOCK(p) mtx_lock_spin(&(p)->p_slock)
+#define PROC_PROFUNLOCK(p) mtx_unlock_spin(&(p)->p_slock)
+#define PROC_PROFLOCK_ASSERT(p, type) mtx_assert(&(p)->p_slock, (type))
+
/* These flags are kept in p_flag. */
#define P_ADVLOCK 0x00001 /* Process may hold a POSIX advisory lock. */
#define P_CONTROLT 0x00002 /* Has a controlling terminal. */
OpenPOWER on IntegriCloud