All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Vrabel <david.vrabel@citrix.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: Keir Fraser <keir@xen.org>,
	Ian Campbell <ian.campbell@citrix.com>,
	Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Jennifer Herbert <jennifer.herbert@citrix.com>,
	Tim Deegan <tim@xen.org>,
	xen-devel@lists.xenproject.org
Subject: Re: [PATCHv3 1/4] x86: provide xadd()
Date: Tue, 21 Apr 2015 14:15:57 +0100	[thread overview]
Message-ID: <55364D8D.4080908@citrix.com> (raw)
In-Reply-To: <553668C70200007800074480@mail.emea.novell.com>

On 21/04/15 14:12, Jan Beulich wrote:
>>>> On 21.04.15 at 14:36, <david.vrabel@citrix.com> wrote:
>> On 21/04/15 11:36, Jan Beulich wrote:
>>>>>> On 21.04.15 at 12:11, <david.vrabel@citrix.com> wrote:
>>>> +static always_inline unsigned long __xadd(
>>>> +    volatile void *ptr, unsigned long v, int size)
>>>> +{
>>>> +    switch ( size )
>>>> +    {
>>>> +    case 1:
>>>> +        asm volatile ( "lock; xaddb %b0,%1"
>>>> +                       : "+r" (v), "+m" (*__xg((volatile void *)ptr))
>>>> +                       :: "memory");
>>>> +        return v;
>>>
>>> This doesn't seem to guarantee to return the old value: When the
>>> passed in v has more than 8 significant bits (which will get ignored
>>> as input), nothing will zap those bits from the register. Same for
>>> the 16-bit case obviously.
>>>
>>>> +#define xadd(ptr, v) ({                                         \
>>>> +            __xadd((ptr), (unsigned long)(v), sizeof(*(ptr)));  \
>>>> +        })
>>>
>>> Assuming only xadd() is supposed to be used directly, perhaps
>>> the easiest would be to cast v to typeof(*(ptr)) (instead of
>>> unsigned long) here?
>>
>> I don't see how this helps.  Did you perhaps mean cast the result?
>>
>> #define xadd(ptr, v) ({                                    \
>>             (typeof *(ptr))__xadd(ptr, (unsigned long)(v), \
>>                                   sizeof(*(ptr)));         \
>>         })
> 
> Casting the result would work too; casting the input would have
> the same effect because (as said) the actual xadd doesn't alter
> bits 8...63 (or 16...63 in the 16-bit case), i.e. whether zero
> extension happens before or after doing the xadd doesn't matter.

Oh yes, of course.  Any preference to which method?

David

  reply	other threads:[~2015-04-21 13:16 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-21 10:11 [PATCHv3 0/4] Use ticket locks for spinlocks David Vrabel
2015-04-21 10:11 ` [PATCHv3 1/4] x86: provide xadd() David Vrabel
2015-04-21 10:36   ` Jan Beulich
2015-04-21 12:36     ` David Vrabel
2015-04-21 13:12       ` Jan Beulich
2015-04-21 13:15         ` David Vrabel [this message]
2015-04-21 13:20           ` Jan Beulich
2015-04-21 10:11 ` [PATCHv3 2/4] arm: " David Vrabel
2015-04-21 10:11 ` [PATCHv3 3/4] xen: use ticket locks for spin locks David Vrabel
2015-04-23 11:58   ` Jan Beulich
2015-04-28 15:56     ` David Vrabel
2015-04-28 23:15       ` Jan Beulich
2015-04-29 15:21         ` David Vrabel
2015-04-29 23:56           ` Jan Beulich
2015-04-30 10:09             ` Tim Deegan
2015-04-30 11:55               ` David Vrabel
2015-04-23 12:03   ` Tim Deegan
2015-04-23 13:43     ` David Vrabel
2015-04-23 13:45       ` Andrew Cooper
2015-04-23 14:58         ` Tim Deegan
2015-04-23 14:24       ` Tim Deegan
2015-04-23 14:51         ` Tim Deegan
2015-04-23 13:54     ` Jan Beulich
2015-04-23 14:43       ` Tim Deegan
2015-04-23 14:58         ` Jan Beulich
2015-04-29 15:36           ` David Vrabel
2015-04-29 16:56             ` Tim Deegan
2015-04-29 17:00               ` David Vrabel
2015-04-30  9:00                 ` Tim Deegan
2015-04-29 23:48             ` Jan Beulich
2015-04-21 10:11 ` [PATCHv3 4/4] x86, arm: remove asm/spinlock.h from all architectures David Vrabel
2015-04-21 10:22 ` [PATCHv3 0/4] Use ticket locks for spinlocks Jan Beulich
2015-04-21 11:24   ` Jennifer Herbert
2015-04-23 12:42   ` David Vrabel
2015-04-30 15:44     ` David Vrabel
2015-05-04  7:18       ` Jan Beulich

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=55364D8D.4080908@citrix.com \
    --to=david.vrabel@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=ian.campbell@citrix.com \
    --cc=jennifer.herbert@citrix.com \
    --cc=keir@xen.org \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=tim@xen.org \
    --cc=xen-devel@lists.xenproject.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.