diff options
author | Mateusz Guzik <mjg@FreeBSD.org> | 2018-05-11 06:59:54 +0000 |
---|---|---|
committer | Mateusz Guzik <mjg@FreeBSD.org> | 2018-05-11 06:59:54 +0000 |
commit | 85c1b3c1cbb1a7eded29554a75ae8b21fc96c3cd (patch) | |
tree | 614ccd1479b4a526956de7b7217200ac6850cab5 /sys | |
parent | fe8c16cef1d6669074c262fbb7b55d301ca01d74 (diff) | |
download | src-85c1b3c1cbb1a7eded29554a75ae8b21fc96c3cd.tar.gz src-85c1b3c1cbb1a7eded29554a75ae8b21fc96c3cd.zip |
rmlock: partially depessimize lock/unlock fastpath
Previusly the slow path was folded in and partially jumped over in the
common case.
Notes
Notes:
svn path=/head/; revision=333483
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/kern_rmlock.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/sys/kern/kern_rmlock.c b/sys/kern/kern_rmlock.c index a77fa946e4bf..a82646095420 100644 --- a/sys/kern/kern_rmlock.c +++ b/sys/kern/kern_rmlock.c @@ -344,7 +344,7 @@ rm_sysinit(void *arg) rm_init_flags(args->ra_rm, args->ra_desc, args->ra_flags); } -static int +static __noinline int _rm_rlock_hard(struct rmlock *rm, struct rm_priotracker *tracker, int trylock) { struct pcpu *pc; @@ -459,15 +459,15 @@ _rm_rlock(struct rmlock *rm, struct rm_priotracker *tracker, int trylock) * Fast path to combine two common conditions into a single * conditional jump. */ - if (0 == (td->td_owepreempt | - CPU_ISSET(pc->pc_cpuid, &rm->rm_writecpus))) + if (__predict_true(0 == (td->td_owepreempt | + CPU_ISSET(pc->pc_cpuid, &rm->rm_writecpus)))) return (1); /* We do not have a read token and need to acquire one. */ return _rm_rlock_hard(rm, tracker, trylock); } -static void +static __noinline void _rm_unlock_hard(struct thread *td,struct rm_priotracker *tracker) { @@ -518,7 +518,7 @@ _rm_runlock(struct rmlock *rm, struct rm_priotracker *tracker) if (rm->lock_object.lo_flags & LO_SLEEPABLE) THREAD_SLEEPING_OK(); - if (0 == (td->td_owepreempt | tracker->rmp_flags)) + if (__predict_true(0 == (td->td_owepreempt | tracker->rmp_flags))) return; _rm_unlock_hard(td, tracker); |