summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2002-11-08 19:00:17 +0000
committerrwatson <rwatson@FreeBSD.org>2002-11-08 19:00:17 +0000
commit551263d9d4002f712d593776676a9ea50a04cf2d (patch)
treebb1b1d9947625f618e2a321ff0eb85de1e4b9c53 /sys
parent9f2614d473d60813762faa3db456be08015cd4b8 (diff)
downloadFreeBSD-src-551263d9d4002f712d593776676a9ea50a04cf2d.zip
FreeBSD-src-551263d9d4002f712d593776676a9ea50a04cf2d.tar.gz
To reduce per-return overhead of userret(), call into
mac_thread_userret() only if PS_MACPEND is set in the process AST mask. This avoids the cost of the entry point in the common case, but requires policies interested in the userret event to set the flag (protected by the scheduler lock) if they do want the event. Since all the policies that we're working with which use mac_thread_userret() use the entry point only selectively to perform operations deferred for locking reasons, this maintains the desired semantics. Approved by: re Requested by: bde Obtained from: TrustedBSD Project Sponsored by: DARPA, Network Associates Laboratories
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/subr_trap.c11
-rw-r--r--sys/sys/proc.h1
2 files changed, 8 insertions, 4 deletions
diff --git a/sys/kern/subr_trap.c b/sys/kern/subr_trap.c
index 9f8bed0..61052d3 100644
--- a/sys/kern/subr_trap.c
+++ b/sys/kern/subr_trap.c
@@ -90,10 +90,6 @@ userret(td, frame, oticks)
mtx_unlock(&Giant);
#endif
-#ifdef MAC
- mac_thread_userret(td);
-#endif
-
/*
* Let the scheduler adjust our priority etc.
*/
@@ -184,6 +180,9 @@ ast(struct trapframe *framep)
flags = ke->ke_flags;
sflag = p->p_sflag;
p->p_sflag &= ~(PS_ALRMPEND | PS_NEEDSIGCHK | PS_PROFPEND | PS_XCPU);
+#ifdef MAC
+ p->p_sflag &= ~PS_MACPEND;
+#endif
ke->ke_flags &= ~(KEF_ASTPENDING | KEF_NEEDRESCHED | KEF_OWEUPC);
cnt.v_soft++;
prticks = 0;
@@ -238,6 +237,10 @@ ast(struct trapframe *framep)
}
PROC_UNLOCK(p);
}
+#ifdef MAC
+ if (sflag & PS_MACPEND)
+ mac_thread_userret(td);
+#endif
if (flags & KEF_NEEDRESCHED) {
mtx_lock_spin(&sched_lock);
sched_prio(td, kg->kg_user_pri);
diff --git a/sys/sys/proc.h b/sys/sys/proc.h
index aa824d3..dd129de 100644
--- a/sys/sys/proc.h
+++ b/sys/sys/proc.h
@@ -646,6 +646,7 @@ struct proc {
#define PS_SWAPPING 0x00200 /* Process is being swapped. */
#define PS_NEEDSIGCHK 0x02000 /* Process may need signal delivery. */
#define PS_SWAPPINGIN 0x04000 /* Swapin in progress. */
+#define PS_MACPEND 0x08000 /* Ast()-based MAC event pending. */
/* used only in legacy conversion code */
#define SIDL 1 /* Process being created by fork. */
OpenPOWER on IntegriCloud