Date: Fri, 9 Feb 2018 00:38:51 +0000 (UTC) From: Jeff Roberson <jeff@FreeBSD.org> To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r329055 - user/jeff/numa/sys/kern Message-ID: <201802090038.w190cprh064554@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201802090038.w190cprh064554>