Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Issue 18984012: Refine atomic operations for Linux/ARM. (Closed)

Created:
7 years, 5 months ago by digit1
Modified:
7 years, 5 months ago
CC:
chromium-reviews, erikwright+watch_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Visibility:
Public.

Description

Refine atomic operations for Linux/ARM. This patch comes from recent discussions from the following review link: https://chromiumcodereview.appspot.com/16109010/ In a nutshell: - Using the "cmp" instruction, instead of "teq" is better for recent ARM CPUs. - Fix a tiny typo. - Fix the ARMv5 implementation of Release_CompareAndSwap() since the old one could return without performing any memory barrier when prev_value != old_value. It's not clear whether the old behaviour is desirable because client code could naively assume the function always perform a release operation, even in case of failure. BUG=234215 Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=211013

Patch Set 1 #

Patch Set 2 : remove empty line #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+13 lines, -6 lines) Patch
M base/atomicops_internals_arm_gcc.h View 1 3 chunks +13 lines, -6 lines 1 comment Download

Messages

Total messages: 6 (0 generated)
digit1
7 years, 5 months ago (2013-07-10 21:39:03 UTC) #1
Mark Mentovai
LGTM
7 years, 5 months ago (2013-07-10 21:49:44 UTC) #2
JF
lgtm
7 years, 5 months ago (2013-07-10 21:51:26 UTC) #3
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/digit@chromium.org/18984012/2001
7 years, 5 months ago (2013-07-10 22:01:44 UTC) #4
commit-bot: I haz the power
Change committed as 211013
7 years, 5 months ago (2013-07-11 03:52:58 UTC) #5
Dmitry Vyukov
7 years, 5 months ago (2013-07-15 14:42:32 UTC) #6
Message was sent while issue was closed.
https://chromiumcodereview.appspot.com/18984012/diff/2001/base/atomicops_inte...
File base/atomicops_internals_arm_gcc.h (right):

https://chromiumcodereview.appspot.com/18984012/diff/2001/base/atomicops_inte...
base/atomicops_internals_arm_gcc.h:245: return Acquire_CompareAndSwap(ptr,
old_value, new_value);
A failing Release_CompareAndSwap() does not need any memory barriers. Release
makes sense only when an acquire operation loads the value stored by side effect
of the release operation. A failing release CAS does not mutate anything, so
nobody can possibly observe it's side effect.

See the relevant part of the C++ standard:

29.6.5/21
Effects: Atomically, compares the contents of the memory pointed to by object or
by this for equality
with that in expected, and if true, replaces the contents of the memory pointed
to by object or by
this with that in desired, and if false, updates the contents of the memory in
expected with the
contents of the memory pointed to by object or by this. Further, if the
comparison is true, memory
is affected according to the value of success, and if the comparison is false,
memory is affected
according to the value of failure. When only one memory_order argument is
supplied, the value of
success is order, and the value of failure is order except that a value of
memory_order_acq_rel
shall be replaced by the value memory_order_acquire and a value of
memory_order_release shall
be replaced by the value memory_order_relaxed. If the operation returns true,
these operations are
atomic read-modify-write operations (1.10). Otherwise, these operations are
atomic load operations.

Powered by Google App Engine
This is Rietveld 408576698