From: Vineet Gupta <Vineet.Gupta1@synopsys.com>
To: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"Peter Zijlstra" <peterz@infradead.org>
Cc: Alexey Brodkin <Alexey.Brodkin@synopsys.com>,
Will Deacon <will.deacon@arm.com>,
"linux-snps-arc@lists.infradead.org"
<linux-snps-arc@lists.infradead.org>
Subject: Re: [PATCH] ARCv2: Implement atomic64 based on LLOCKD/SCONDD instructions
Date: Thu, 8 Sep 2016 15:24:10 -0700 [thread overview]
Message-ID: <7012c761-a355-d830-22bf-48db96a12452@synopsys.com> (raw)
In-Reply-To: <1473362967-23750-1-git-send-email-vgupta@synopsys.com>
On 09/08/2016 12:29 PM, Vineet Gupta wrote:
> One thing I'm not sure of is the lack of explicit memory clobber in
> barrier-less ops e.g. atomic64_add() (BTW same is true for 32-bit
> atomic_add() as well). Per commit 398aa66827 ("ARM: 6212/1: atomic ops:
> add memory constraints to inline asm ") Will fixed ARM code by adding
> appropriate constraint to atomic64_add(). For ARC instead adding memory
> clobber to atomic64_set() does the trick (otherwise self-test is broked)
> This is on ARC we can't possibly use "m" in atomic64_add() since that make gcc
> emit register relative effective addresses which LLOCKD/SCONDD are not
> allowed by ISA
So interestingly my self-test run fine, but I had this oldish version stashed
somewhere which did something liek below and that clearly generates wrong code.
int my_test_atomic(void)
{
long v0 = 0x33333333;
long onestwos = 0x11112222;
atomic_t v = ATOMIC_INIT(v0);
long long r = v0;
int ret = 0;
atomic_set(&v, v0); r = v0;
atomic_add(onestwos, &v);
r += onestwos;
if (v.counter != r) { /* <------ */
ret = 3; /* error */
}
return ret;
}
key here is the check - if we access the atomic directly, I get error. If I use
atomic_read() which forces a reload due to volatile, things are hunky dory. So it
seems to me we don't need memory clobber or equivalent in barrier less atomics
except the set. Seems too fragile ?
-Vineet
next prev parent reply other threads:[~2016-09-08 22:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-08 19:29 Vineet Gupta
2016-09-08 22:24 ` Vineet Gupta [this message]
2016-09-09 7:40 ` Peter Zijlstra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7012c761-a355-d830-22bf-48db96a12452@synopsys.com \
--to=vineet.gupta1@synopsys.com \
--cc=Alexey.Brodkin@synopsys.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-snps-arc@lists.infradead.org \
--cc=peterz@infradead.org \
--cc=will.deacon@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®