Date: Fri, 11 May 2018 06:59:54 +0000 (UTC) From: Mateusz Guzik <mjg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r333483 - head/sys/kern Message-ID: <201805110659.w4B6xsan032676@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mjg Date: Fri May 11 06:59:54 2018 New Revision: 333483 URL: https://svnweb.freebsd.org/changeset/base/333483 Log: rmlock: partially depessimize lock/unlock fastpath Previusly the slow path was folded in and partially jumped over in the common case. Modified: head/sys/kern/kern_rmlock.c Modified: head/sys/kern/kern_rmlock.c ============================================================================== --- head/sys/kern/kern_rmlock.c Fri May 11 06:55:02 2018 (r333482) +++ head/sys/kern/kern_rmlock.c Fri May 11 06:59:54 2018 (r333483) @@ -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 *tr * 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 * 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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201805110659.w4B6xsan032676>