[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.LFD.1.00.0803060807120.12253@woody.linux-foundation.org>
Date: Thu, 6 Mar 2008 08:11:59 -0800 (PST)
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Mark Lord <lkml@....ca>
cc: Alan Stern <stern@...land.harvard.edu>,
Alan Cox <alan@...rguk.ukuu.org.uk>,
Pavel Machek <pavel@....cz>,
"Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Zdenek Kabelac <zdenek.kabelac@...il.com>, davem@...emloft.net,
"Rafael J. Wysocki" <rjw@...k.pl>,
Pierre Ossman <drzeus-mmc@...eus.cx>,
Kernel development list <linux-kernel@...r.kernel.org>,
pm list <linux-pm@...ts.linux-foundation.org>
Subject: Re: [patch] Re: using long instead of atomic_t when only set/read
is required
On Thu, 6 Mar 2008, Mark Lord wrote:
>
> But also consider something like this:
>
> void store_task(void)
> {
> *the_task = current;
> }
>
> In this case, there is no guarantee that the assignment
> can be done atomically on all CPU types. Some RISC archs
> (eg. MIPS R2xxx) require an (interruptible) instruction pair
> to store values to a potentially unaligned address.
You'd better not be using unaligned accesses for memory-ordering-sensitive
things (I think x86 happens get even that right for most cases, but I
don't think the architecture specification guarantees it, and I'm pretty
sure that you might find problems on cache crossing writes, for example)
But quite frankly, if you have an architecture that can't do the above as
a single write when it's a pointer, then you have a totally broken
architecture. It's not worth supporting.
(There are data structures that are harder than native words: bytes and
shorts can require load-modify-write cycles, and "u64" and friends can
obviously be multiple words, so you shouldn't depend on things for those
"complex" cases. But we *definitely* depend on atomicity for regular word
accesses).
Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists