All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Arnd Bergmann' <arnd@kernel.org>, Will Deacon <will@kernel.org>,
	"Peter Zijlstra" <peterz@infradead.org>,
	Arnd Bergmann <arnd@arndb.de>, Matt Evans <mev@rivosinc.com>
Cc: Boqun Feng <boqun.feng@gmail.com>,
	Mark Rutland <mark.rutland@arm.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-arch@vger.kernel.org" <linux-arch@vger.kernel.org>
Subject: RE: [PATCH] asm-generic: avoid __generic_cmpxchg_local warnings
Date: Thu, 2 Mar 2023 16:40:00 +0000	[thread overview]
Message-ID: <60996fd3604b403ab67e8f73854264ee@AcuMS.aculab.com> (raw)
In-Reply-To: <20230302090032.3740505-1-arnd@kernel.org>

...
> I had another look at why the cast is even needed for atomic_cmpxchg(),
> and as Matt describes the problem here is that atomic_t contains a
> signed 'int', but cmpxchg() takes an 'unsigned long' argument, and
> converting between the two leads to a 64-bit sign-extension of
> negative 32-bit atomics.

How about:
	signed_var + 0u + 0ull;

Converts 32bit signed to 64bit unsigned without sign extension.
Compiler will throw it all away if not needed.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)


      reply	other threads:[~2023-03-02 16:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-02  9:00 [PATCH] asm-generic: avoid __generic_cmpxchg_local warnings Arnd Bergmann
2023-03-02 16:40 ` David Laight [this message]

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=60996fd3604b403ab67e8f73854264ee@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=arnd@arndb.de \
    --cc=arnd@kernel.org \
    --cc=boqun.feng@gmail.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mev@rivosinc.com \
    --cc=peterz@infradead.org \
    --cc=will@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.