Date: Wed, 6 Jun 2018 15:31:47 +0000 (UTC) From: Hans Petter Selasky <hselasky@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334718 - head/sys/compat/linuxkpi/common/include/asm Message-ID: <201806061531.w56FVltF069783@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: hselasky Date: Wed Jun 6 15:31:47 2018 New Revision: 334718 URL: https://svnweb.freebsd.org/changeset/base/334718 Log: Rewrite code using atomic_fcmpset_int() in the LinuxKPI. Suggested by: mjg@ MFC after: 1 week Sponsored by: Mellanox Technologies Sponsored by: Limelight Networks Modified: head/sys/compat/linuxkpi/common/include/asm/atomic.h Modified: head/sys/compat/linuxkpi/common/include/asm/atomic.h ============================================================================== --- head/sys/compat/linuxkpi/common/include/asm/atomic.h Wed Jun 6 15:19:30 2018 (r334717) +++ head/sys/compat/linuxkpi/common/include/asm/atomic.h Wed Jun 6 15:31:47 2018 (r334718) @@ -239,15 +239,16 @@ static inline int atomic_dec_if_positive(atomic_t *v) { int retval; - int curr; + int old; - do { - curr = atomic_read(v); - retval = curr - 1; + old = atomic_read(v); + for (;;) { + retval = old - 1; if (unlikely(retval < 0)) break; - } while (!likely(atomic_cmpset_int(&v->counter, curr, retval))); - + if (likely(atomic_fcmpset_int(&v->counter, &old, retval))) + break; + } return (retval); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201806061531.w56FVltF069783>