svn commit: r329055 - user/jeff/numa/sys/kern
Jeff Roberson
jeff at FreeBSD.org
Fri Feb 9 00:38:51 UTC 2018
Author: jeff
Date: Fri Feb 9 00:38:50 2018
New Revision: 329055
URL: https://svnweb.freebsd.org/changeset/base/329055
Log:
Eliminate the use of cmpxchg for bufspace management. This eliminates the
time wasted by fighting cmpxchg loops.
Modified:
user/jeff/numa/sys/kern/vfs_bio.c
Modified: user/jeff/numa/sys/kern/vfs_bio.c
==============================================================================
--- user/jeff/numa/sys/kern/vfs_bio.c Fri Feb 9 00:36:55 2018 (r329054)
+++ user/jeff/numa/sys/kern/vfs_bio.c Fri Feb 9 00:38:50 2018 (r329055)
@@ -535,12 +535,12 @@ bufspace_reserve(struct bufdomain *bd, int size, bool
limit = bd->bd_maxbufspace;
else
limit = bd->bd_hibufspace;
- do {
- space = bd->bd_bufspace;
- new = space + size;
- if (new > limit)
- return (ENOSPC);
- } while (atomic_cmpset_long(&bd->bd_bufspace, space, new) == 0);
+ space = atomic_fetchadd_long(&bd->bd_bufspace, size);
+ new = space + size;
+ if (new > limit) {
+ atomic_subtract_long(&bd->bd_bufspace, size);
+ return (ENOSPC);
+ }
/* Wake up the daemon on the transition. */
if (space < bd->bd_bufspacethresh && new >= bd->bd_bufspacethresh)
More information about the svn-src-user
mailing list