All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chen Gang <gang.chen@asianux.com>
To: Ralf Baechle <ralf@linux-mips.org>
Cc: "Jörn Engel" <joern@logfs.org>,
	"Chris Metcalf" <cmetcalf@tilera.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Linux-Arch <linux-arch@vger.kernel.org>,
	"Paul Gortmaker" <paul.gortmaker@windriver.com>
Subject: Re: [PATCH] arch: tile: include: asm: add cmpxchg64() definition
Date: Mon, 01 Jul 2013 10:08:51 +0800	[thread overview]
Message-ID: <51D0E4B3.6080402@asianux.com> (raw)
In-Reply-To: <20130628150941.GA22767@linux-mips.org>


Firstly thank you very much for replying quickly with details.

On 06/28/2013 11:09 PM, Ralf Baechle wrote:
> On Fri, Jun 28, 2013 at 09:51:35AM +0800, Chen Gang wrote:
> 
>> Need add cmpxchg64(), or will cause compiling issue.
>>
>> Just define it as cmpxchg(), since cmpxchg() can support 8 bytes.
>>
>> The related error (with allmodconfig):
>>
>>   drivers/block/blockconsole.c: In function ‘bcon_advance_console_bytes’:
>>   drivers/block/blockconsole.c:164:2: error: implicit declaration of function ‘cmpxchg64’ [-Werror=implicit-function-declaration]
>>
>> Signed-off-by: Chen Gang <gang.chen@asianux.com>
>> ---
>>  arch/tile/include/asm/cmpxchg.h |    2 ++
>>  1 files changed, 2 insertions(+), 0 deletions(-)
>>
>> diff --git a/arch/tile/include/asm/cmpxchg.h b/arch/tile/include/asm/cmpxchg.h
>> index 276f067..7688c28 100644
>> --- a/arch/tile/include/asm/cmpxchg.h
>> +++ b/arch/tile/include/asm/cmpxchg.h
>> @@ -68,6 +68,8 @@ extern unsigned long __cmpxchg_called_with_bad_pointer(void);
>>  
>>  #define tas(ptr) (xchg((ptr), 1))
>>  
>> +#define cmpxchg64(ptr, o, n)		cmpxchg((ptr), (o), (n))
> 
> that's broken.  cmpxchg64 is suposed to work on 64 bit operands ONLY.  This
> definition (used by MIPS and Alpha) will work properly:
> 

Oh, really it is. thanks.

> #define cmpxchg64(ptr, o, n)                                            \
> ({                                                                      \
> 	BUILD_BUG_ON(sizeof(*(ptr)) != 8);                              \
> 	cmpxchg((ptr), (o), (n));                                       \
> })
> 

I should follow it to send patch v2, thanks.

> This should cure blockconsole on Tile but not on MIPS.
> 
> struct blockconsole {
> ..
>            u64 console_bytes;
> ..
> };
> 
> static void bcon_advance_console_bytes(struct blockconsole *bc, int bytes)
> {
> 	u64 old, new;
> 	...
> 	} while (cmpxchg64(&bc->console_bytes, old, new) != old);
> }
> 
> So it's using cmpxchg64() to operate on 64 bit objects - but that's not
> going to work on every architecture.  Many 32 bit architectures only
> provide atomic operations that operate on 32 bit quantities.
> 

I guess your meaning is:

  cmpxchg64() should be an atomic operation.
  but on some of 32-bit architectures, they don't implement it as atomic
    (no lock protected, at least).
  it may cause issue on these 32-bit architectures.

Is it correct ?

If it is correct, I should continue to try to fix it.


Thanks.
-- 
Chen Gang

  reply	other threads:[~2013-07-01  2:08 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-26  4:25 [Suggestion] tile: include: asm: missing "feedback.h" file Chen Gang
2013-06-27 14:16 ` Chris Metcalf
2013-06-28  0:28   ` Chen Gang
2013-06-28  1:51     ` [PATCH] arch: tile: include: asm: add cmpxchg64() definition Chen Gang
2013-06-28 15:09       ` Ralf Baechle
2013-07-01  2:08         ` Chen Gang [this message]
2013-07-01  2:21           ` [PATCH v2] " Chen Gang
2013-07-17 16:46             ` Chris Metcalf
2013-07-18  0:02               ` Chen Gang

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=51D0E4B3.6080402@asianux.com \
    --to=gang.chen@asianux.com \
    --cc=cmetcalf@tilera.com \
    --cc=joern@logfs.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paul.gortmaker@windriver.com \
    --cc=ralf@linux-mips.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.