Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 18 May 2020 09:12:13 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r361181 - stable/11/sys/compat/linuxkpi/common/include/asm
Message-ID:  <202005180912.04I9CDIH056880@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hselasky
Date: Mon May 18 09:12:13 2020
New Revision: 361181
URL: https://svnweb.freebsd.org/changeset/base/361181

Log:
  MFC r360127:
  Implement the atomic fetch add unless functions for the LinuxKPI.
  
  Sponsored by:	Mellanox Technologies

Modified:
  stable/11/sys/compat/linuxkpi/common/include/asm/atomic-long.h
  stable/11/sys/compat/linuxkpi/common/include/asm/atomic.h
  stable/11/sys/compat/linuxkpi/common/include/asm/atomic64.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/compat/linuxkpi/common/include/asm/atomic-long.h
==============================================================================
--- stable/11/sys/compat/linuxkpi/common/include/asm/atomic-long.h	Mon May 18 09:11:41 2020	(r361180)
+++ stable/11/sys/compat/linuxkpi/common/include/asm/atomic-long.h	Mon May 18 09:12:13 2020	(r361181)
@@ -118,6 +118,20 @@ atomic_long_add_unless(atomic_long_t *v, long a, long 
 }
 
 static inline long
+atomic_long_fetch_add_unless(atomic_long_t *v, long a, long u)
+{
+	long c = atomic_long_read(v);
+
+	for (;;) {
+		if (unlikely(c == u))
+			break;
+		if (likely(atomic_fcmpset_long(&v->counter, &c, c + a)))
+			break;
+	}
+	return (c);
+}
+
+static inline long
 atomic_long_dec_and_test(atomic_long_t *v)
 {
 	long i = atomic_long_add(-1, v);

Modified: stable/11/sys/compat/linuxkpi/common/include/asm/atomic.h
==============================================================================
--- stable/11/sys/compat/linuxkpi/common/include/asm/atomic.h	Mon May 18 09:11:41 2020	(r361180)
+++ stable/11/sys/compat/linuxkpi/common/include/asm/atomic.h	Mon May 18 09:12:13 2020	(r361181)
@@ -119,6 +119,20 @@ atomic_add_unless(atomic_t *v, int a, int u)
 	return (c != u);
 }
 
+static inline int
+atomic_fetch_add_unless(atomic_t *v, int a, int u)
+{
+	int c = atomic_read(v);
+
+	for (;;) {
+		if (unlikely(c == u))
+			break;
+		if (likely(atomic_fcmpset_int(&v->counter, &c, c + a)))
+			break;
+	}
+	return (c);
+}
+
 static inline void
 atomic_clear_mask(unsigned int mask, atomic_t *v)
 {

Modified: stable/11/sys/compat/linuxkpi/common/include/asm/atomic64.h
==============================================================================
--- stable/11/sys/compat/linuxkpi/common/include/asm/atomic64.h	Mon May 18 09:11:41 2020	(r361180)
+++ stable/11/sys/compat/linuxkpi/common/include/asm/atomic64.h	Mon May 18 09:12:13 2020	(r361181)
@@ -104,6 +104,20 @@ atomic64_add_unless(atomic64_t *v, int64_t a, int64_t 
 }
 
 static inline int64_t
+atomic64_fetch_add_unless(atomic64_t *v, int64_t a, int64_t u)
+{
+	int64_t c = atomic64_read(v);
+
+	for (;;) {
+		if (unlikely(c == u))
+			break;
+		if (likely(atomic_fcmpset_64(&v->counter, &c, c + a)))
+			break;
+	}
+	return (c);
+}
+
+static inline int64_t
 atomic64_xchg(atomic64_t *v, int64_t i)
 {
 #if defined(__i386__) || defined(__amd64__) || \



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202005180912.04I9CDIH056880>