public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Robert Hancock <hancockr@shaw.ca>
To: Pavel Machek <pavel@suse.cz>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>,
	kernel list <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@osdl.org>,
	mtk.manpages@gmail.com, rdunlap@xenotime.net,
	linux-doc@vger.kernel.org
Subject: Re: atomics: document that linux expects certain atomic behaviour from unsigned long
Date: Sat, 03 Jan 2009 17:53:23 -0600	[thread overview]
Message-ID: <495FFA73.6030705@shaw.ca> (raw)
In-Reply-To: <20090103205628.GE1666@elf.ucw.cz>

Pavel Machek wrote:
> On Sat 2009-01-03 20:30:44, Alan Cox wrote:
>>> If it is okay and linux relies on it, it should be documented.
>>>
>>> If it is not okay, I guess we should document it, too -- it seems to
>>> be common mistake. 
>> A lot of old code did it knowing it was under the BKL, outside of the BKL
>> its a very bad idea. There were lots of them in the tty layer and I don't
>> doubt there are some left I missed too 8(
> 
> I have seen this in new code (some LED driver last time), definitely
> no BKL.
> 
> Is there concrete architecture where it breaks? I'd expect i386/x86-64
> to be safe, and pretty much everyone to be safe as long as that long
> is aligned.... or that was the result of arch-maintainers
> discussion...
> 
> I'd really like to document if it is right or not, so that I can point
> people to documentation...
> 								Pavel

If you look at the atomic implementation on x86 all it does is assign 
and read the internal int variable directly for atomic_set and 
atomic_read, so I suppose it would be OK to just use a normal variable 
in that case.. but then there's no performance hit so you might as well 
use atomic_t anyway. On some architectures like arm and sparc there is 
some magic involved in atomic_set and/or atomic_read (but those may just 
be to guard against other concurrent atomic ops, I'm not sure).

Certainly unless the code is really performance critical there is no 
point messing around, just use an atomic if it needs to be accessed 
without locking. Note that memory barriers may be an issue as well..

  parent reply	other threads:[~2009-01-03 23:53 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-03 12:44 atomics: document that linux expects certain atomic behaviour from unsigned long Pavel Machek
2009-01-03 20:19 ` Alan Cox
2009-01-03 20:27   ` Pavel Machek
2009-01-03 20:30     ` Alan Cox
2009-01-03 20:56       ` Pavel Machek
2009-01-03 23:01         ` david
2009-01-03 23:14         ` Alan Cox
2009-01-05 10:54           ` Nick Piggin
2009-01-05 11:23             ` Alan Cox
2009-01-05 12:00               ` Nick Piggin
2009-01-05 16:05                 ` Paul E. McKenney
2009-01-05 16:25                   ` Nick Piggin
2009-01-05 17:30                     ` Paul E. McKenney
2009-01-05 18:25                       ` Nick Piggin
2009-01-05 22:01                         ` Paul E. McKenney
2009-01-03 23:53         ` Robert Hancock [this message]
2009-01-04 18:05       ` Tilman Schmidt

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=495FFA73.6030705@shaw.ca \
    --to=hancockr@shaw.ca \
    --cc=akpm@osdl.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mtk.manpages@gmail.com \
    --cc=pavel@suse.cz \
    --cc=rdunlap@xenotime.net \
    /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