Date: Thu, 30 Oct 2014 05:21:13 +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: r273843 - head/sys/kern Message-ID: <201410300521.s9U5LDjD093001@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mjg Date: Thu Oct 30 05:21:12 2014 New Revision: 273843 URL: https://svnweb.freebsd.org/changeset/base/273843 Log: filedesc: microoptimize fget_unlocked by retrying obtaining reference count without restarting whole lookup Restart is only needed when fp was closed by current process, which is a much rarer event than ref/deref by some other thread. Modified: head/sys/kern/kern_descrip.c Modified: head/sys/kern/kern_descrip.c ============================================================================== --- head/sys/kern/kern_descrip.c Thu Oct 30 05:10:33 2014 (r273842) +++ head/sys/kern/kern_descrip.c Thu Oct 30 05:21:12 2014 (r273843) @@ -2359,6 +2359,7 @@ fget_unlocked(struct filedesc *fdp, int } } #endif + retry: count = fp->f_count; if (count == 0) { fdt = fdp->fd_files; @@ -2368,10 +2369,8 @@ fget_unlocked(struct filedesc *fdp, int * Use an acquire barrier to force re-reading of fdt so it is * refreshed for verification. */ - if (atomic_cmpset_acq_int(&fp->f_count, count, count + 1) == 0) { - fdt = fdp->fd_files; - continue; - } + if (atomic_cmpset_acq_int(&fp->f_count, count, count + 1) == 0) + goto retry; fdt = fdp->fd_files; #ifdef CAPABILITIES if (seq_consistent_nomb(fd_seq(fdt, fd), seq))
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201410300521.s9U5LDjD093001>