[Pkg-ofed-commits] [libfabric] 43/123: prov/psm: correctly handle overlapped local buffers in atomics
Ana Beatriz Guerrero López
ana at moszumanska.debian.org
Sat Oct 22 12:28:28 UTC 2016
This is an automated email from the git hooks/post-receive script.
ana pushed a commit to annotated tag v1.1.1
in repository libfabric.
commit feb4c9e155211a5f31c5e4b41003289c8c354305
Author: Jianxin Xiong <jianxin.xiong at intel.com>
Date: Tue Sep 8 15:28:29 2015 -0700
prov/psm: correctly handle overlapped local buffers in atomics
Atomic operations may have more than one local buffers (source,
result, compare). The existing code writes to the result buffer
before performing operations that use the source and compare
buffer. This doesn't work correctly If the source or compare
buffer overlaps with the the result buffer.
Signed-off-by: Jianxin Xiong <jianxin.xiong at intel.com>
---
prov/psm/src/psmx_atomic.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/prov/psm/src/psmx_atomic.c b/prov/psm/src/psmx_atomic.c
index 7fba417..6ad5dac 100644
--- a/prov/psm/src/psmx_atomic.c
+++ b/prov/psm/src/psmx_atomic.c
@@ -132,10 +132,12 @@ static pthread_mutex_t psmx_atomic_lock = PTHREAD_MUTEX_INITIALIZER;
TYPE *d = (dst); \
TYPE *s = (src); \
TYPE *r = (res); \
+ TYPE tmp; \
pthread_mutex_lock(&psmx_atomic_lock); \
for (i=0; i<(cnt); i++) {\
- r[i] = d[i]; \
+ tmp = d[i]; \
OP(d[i],s[i]); \
+ r[i] = tmp; \
} \
pthread_mutex_unlock(&psmx_atomic_lock); \
} while (0)
@@ -147,11 +149,13 @@ static pthread_mutex_t psmx_atomic_lock = PTHREAD_MUTEX_INITIALIZER;
TYPE *s = (src); \
TYPE *c = (cmp); \
TYPE *r = (res); \
+ TYPE tmp; \
pthread_mutex_lock(&psmx_atomic_lock); \
for (i=0; i<(cnt); i++) { \
- r[i] = d[i]; \
+ tmp = d[i]; \
if (c[i] CMP_OP d[i]) \
d[i] = s[i]; \
+ r[i] = tmp; \
} \
pthread_mutex_unlock(&psmx_atomic_lock); \
} while (0)
@@ -163,10 +167,12 @@ static pthread_mutex_t psmx_atomic_lock = PTHREAD_MUTEX_INITIALIZER;
TYPE *s = (src); \
TYPE *c = (cmp); \
TYPE *r = (res); \
+ TYPE tmp; \
pthread_mutex_lock(&psmx_atomic_lock); \
for (i=0; i<(cnt); i++) { \
- r[i] = d[i]; \
+ tmp = d[i]; \
d[i] = (s[i] & c[i]) | (d[i] & ~c[i]); \
+ r[i] = tmp; \
} \
pthread_mutex_unlock(&psmx_atomic_lock); \
} while (0)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ofed/libfabric.git
More information about the Pkg-ofed-commits
mailing list