svn commit: r273843 - head/sys/kern
Mateusz Guzik
mjg at FreeBSD.org
Thu Oct 30 05:21:13 UTC 2014
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))
More information about the svn-src-head
mailing list