public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: John Hubbard <john.hubbard@gmail.com>
To: Pravin Nanaware <p.nanaware@nihilent.com>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: Re: Bitops source problem
Date: Wed, 16 Jan 2008 21:47:16 -0800	[thread overview]
Message-ID: <478EEBE4.40400@gmail.com> (raw)
In-Reply-To: <1145971D427D7F43B0DBDAE22221C4B5035FDDAC@nipns00a210.FPS.NIHILENT.COM>

Pravin Nanaware wrote:
> Hi,
> 
> I was just going through the include file in the /usr/include/asm/bitops.h
> 
> The function description describes it as non-atomic but it seems it is not. 
> 
> static __inline__ void __change_bit(int nr, volatile void * addr)
> {
>         __asm__ __volatile__(
>                 "btcl %1,%0"
>                 :"=m" (ADDR)
>                 :"Ir" (nr));
> }
> 
> The kernel version I am using is 2.6.9-42. Is it right or am I missing something ?  
> 
> Thanks,
> Pravin
> 

The bitops.h comments are correct: the btc IA-32 instruction is only 
atomic if used with the lock prefix. The function above does not use the 
lock prefix, so it is not atomic.

thanks,
John Hubbard


  reply	other threads:[~2008-01-17  5:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-17  5:09 Bitops source problem Pravin Nanaware
2008-01-17  5:47 ` John Hubbard [this message]
  -- strict thread matches above, loose matches on Subject: below --
2008-01-17  6:38 Pravin Nanaware
2008-01-17  6:44 ` Roland Dreier
2008-01-17  6:59   ` KOSAKI Motohiro
2008-01-17  8:11 Pravin Nanaware
2008-01-17 19:32 ` Roland Dreier
2008-01-18  4:40 Pravin Nanaware

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=478EEBE4.40400@gmail.com \
    --to=john.hubbard@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=p.nanaware@nihilent.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