* Question about SMP
@ 2010-06-07 20:11 Dave Hylands
2010-06-25 16:16 ` Catalin Marinas
0 siblings, 1 reply; 2+ messages in thread
From: Dave Hylands @ 2010-06-07 20:11 UTC (permalink / raw)
To: linux-arm-kernel
Hi,
(filled in subject line this time - Doh).
I'm trying to understand what I need to be concerned about with SMP
processors and sharing global data (in particular a dual Cortex-A9)
I'm familiar with spinlocks, but in this case I'm trying to work with
some lockless data structures.
What I'm not sure is whether the following would work. Suppose I have
a couple of 8-bit get/put indicies which are in adjacent memory
locations (within the same 32-bit word).
If I have an ISR and a thread running on an SMP core, and the ISR is
running on one core and the thread is running on a second core, if the
ISR were to only write to the put pointer and the thread were only to
write to the get pointer, does the cache maintain consistency? Or do
the get and put pointers need to be in separate cache lines?
Another way of asking this: If both cores are writing to the same
32-bit word (but different bytes) do the writes collide?
--
Dave Hylands
Shuswap, BC, Canada
http://www.DaveHylands.com/
^ permalink raw reply [flat|nested] 2+ messages in thread
* Question about SMP
2010-06-07 20:11 Question about SMP Dave Hylands
@ 2010-06-25 16:16 ` Catalin Marinas
0 siblings, 0 replies; 2+ messages in thread
From: Catalin Marinas @ 2010-06-25 16:16 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, 2010-06-07 at 21:11 +0100, Dave Hylands wrote:
> I'm trying to understand what I need to be concerned about with SMP
> processors and sharing global data (in particular a dual Cortex-A9)
>
> I'm familiar with spinlocks, but in this case I'm trying to work with
> some lockless data structures.
You should be really concerned about memory ordering and barriers :).
See Documentation/memory-barriers.txt in the kernel source.
> What I'm not sure is whether the following would work. Suppose I have
> a couple of 8-bit get/put indicies which are in adjacent memory
> locations (within the same 32-bit word).
>
> If I have an ISR and a thread running on an SMP core, and the ISR is
> running on one core and the thread is running on a second core, if the
> ISR were to only write to the put pointer and the thread were only to
> write to the get pointer, does the cache maintain consistency? Or do
> the get and put pointers need to be in separate cache lines?
The consistency is maintained (though be careful about memory ordering
and when the put/get pointers become visible to the other CPUs).
> Another way of asking this: If both cores are writing to the same
> 32-bit word (but different bytes) do the writes collide?
No, though it's not very efficient because of cache line being moved
between CPUs. See http://en.wikipedia.org/wiki/MESI_protocol.
--
Catalin
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-06-25 16:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-07 20:11 Question about SMP Dave Hylands
2010-06-25 16:16 ` Catalin Marinas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).