From: Helge Deller <deller@gmx.de>
To: Carlos O'Donell <carlos@systemhalted.org>
Cc: linux-parisc@vger.kernel.org, John David Anglin <dave.anglin@nrc.ca>
Subject: Re: ldcw inline assembler patch
Date: Mon, 16 Jun 2008 23:06:44 +0200 [thread overview]
Message-ID: <4856D5E4.7090206@gmx.de> (raw)
In-Reply-To: <119aab440806161350w4d15c14ex735377b78f697fd8@mail.gmail.com>
Hi Carlos,
Carlos O'Donell wrote:
> On Sat, Jun 14, 2008 at 11:36 AM, Helge Deller <deller@gmx.de> wrote:
>> I'm wondering if this patch might help people who are seeing locking
>> problems on SMP boxes ?
>> Helge
>>
>> diff --git a/include/asm-parisc/system.h b/include/asm-parisc/system.h
>> index ee80c92..4752684 100644
>> --- a/include/asm-parisc/system.h
>> +++ b/include/asm-parisc/system.h
>> @@ -168,8 +168,9 @@ static inline void set_eiem(unsigned long val)
>> /* LDCW, the only atomic read-write operation PA-RISC has. *sigh*. */
>> #define __ldcw(a) ({ \
>> unsigned __ret; \
>> - __asm__ __volatile__(__LDCW " 0(%1),%0" \
>> - : "=r" (__ret) : "r" (a)); \
>> + __asm__ __volatile__(__LDCW " 0(%2),%0" \
>> + : "=r" (__ret), "=m" (*(a)) \
>> + : "r" (a), "m" (*(a)) ); \
>> __ret; \
>> })
>
> You don't want to do that, the compiler might hold "=m" (*(a)) in a
> temporary memory location.
>
> e.g.
> temp_mem = *a;
> reg2 = &temp_mem;
> ... operation ...
> *a = temp_mem;
>
> You would be atomic with regards to the store to temp_mem, but not a.
> Infact this could always be the case.
>
> I'm now of the opinion that we need a "memory" clobber in the original
> expression to prevent this from ever happening.
So, your proposal is (copy-and-pasted in here) the following ?
diff --git a/include/asm-parisc/system.h b/include/asm-parisc/system.h
index ee80c92..daeae39 100644
--- a/include/asm-parisc/system.h
+++ b/include/asm-parisc/system.h
@@ -169,7 +169,7 @@ static inline void set_eiem(unsigned long val)
#define __ldcw(a) ({ \
unsigned __ret; \
__asm__ __volatile__(__LDCW " 0(%1),%0" \
- : "=r" (__ret) : "r" (a)); \
+ : "=r" (__ret) : "r" (a) : "memory" ); \
__ret; \
})
next prev parent reply other threads:[~2008-06-16 21:06 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-14 15:36 ldcw inline assembler patch Helge Deller
2008-06-16 20:50 ` Carlos O'Donell
2008-06-16 21:06 ` Helge Deller [this message]
2008-06-16 21:54 ` Carlos O'Donell
2008-06-16 21:57 ` Kyle McMartin
2008-06-16 22:03 ` Kyle McMartin
2008-06-16 22:05 ` Matthew Wilcox
2008-06-16 22:14 ` Carlos O'Donell
2008-06-17 1:56 ` Carlos O'Donell
2008-06-17 3:34 ` Carlos O'Donell
2008-06-21 18:34 ` John David Anglin
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=4856D5E4.7090206@gmx.de \
--to=deller@gmx.de \
--cc=carlos@systemhalted.org \
--cc=dave.anglin@nrc.ca \
--cc=linux-parisc@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.