aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/kern_switch.c
diff options
context:
space:
mode:
authorMatt Macy <mmacy@FreeBSD.org>2018-07-03 01:55:09 +0000
committerMatt Macy <mmacy@FreeBSD.org>2018-07-03 01:55:09 +0000
commit6443773dab50613cf44754f6f0a5f587fa11b1d4 (patch)
tree8f51571b4f19809c6f6fe29121a3f8a409d425f3 /sys/kern/kern_switch.c
parent28acc09dc08bd9b0da13089dd9abedd497f9732e (diff)
downloadsrc-6443773dab50613cf44754f6f0a5f587fa11b1d4.tar.gz
src-6443773dab50613cf44754f6f0a5f587fa11b1d4.zip
make critical_{enter, exit} inline
Avoid pulling in all of the <sys/proc.h> dependencies by automatically generating a stripped down thread_lite exporting only the fields of interest. The field declarations are type checked against the original and the offsets of the generated result is automatically checked. kib has expressed disagreement and would have preferred to simply use genassym style offsets (which loses type check enforcement). jhb has expressed dislike of it due to header pollution and a duplicate structure. He would have preferred to just have defined thread in _thread.h. Nonetheless, he admits that this is the only viable solution at the moment. The impetus for this came from mjg's D15331: "Inline critical_enter/exit for amd64" Reviewed by: jeff Differential Revision: https://reviews.freebsd.org/D16078
Notes
Notes: svn path=/head/; revision=335879
Diffstat (limited to 'sys/kern/kern_switch.c')
-rw-r--r--sys/kern/kern_switch.c27
1 files changed, 11 insertions, 16 deletions
diff --git a/sys/kern/kern_switch.c b/sys/kern/kern_switch.c
index ee7d65d8b261..254c4ffd2674 100644
--- a/sys/kern/kern_switch.c
+++ b/sys/kern/kern_switch.c
@@ -199,17 +199,17 @@ choosethread(void)
* the function call itself, for most cases.
*/
void
-critical_enter(void)
+critical_enter_KBI(void)
{
- struct thread *td;
-
- td = curthread;
- td->td_critnest++;
+#ifdef KTR
+ struct thread *td = curthread;
+#endif
+ critical_enter();
CTR4(KTR_CRITICAL, "critical_enter by thread %p (%ld, %s) to %d", td,
(long)td->td_proc->p_pid, td->td_name, td->td_critnest);
}
-static void __noinline
+void __noinline
critical_exit_preempt(void)
{
struct thread *td;
@@ -245,17 +245,12 @@ critical_exit_preempt(void)
}
void
-critical_exit(void)
+critical_exit_KBI(void)
{
- struct thread *td;
-
- td = curthread;
- KASSERT(td->td_critnest != 0,
- ("critical_exit: td_critnest == 0"));
- td->td_critnest--;
- __compiler_membar();
- if (__predict_false(td->td_owepreempt))
- critical_exit_preempt();
+#ifdef KTR
+ struct thread *td = curthread;
+#endif
+ critical_exit();
CTR4(KTR_CRITICAL, "critical_exit by thread %p (%ld, %s) to %d", td,
(long)td->td_proc->p_pid, td->td_name, td->td_critnest);
}