Skip to contentSkip to conversation

question on memory barriers

DISCUSSION Oliver Neukum 2 participants 2 messages Jul 26, 2011 Arm Qualcomm mailing list

lore
Share & tools
lore
#0 lore raw

Hi,

this code made me think:

                                /* Give this link TRB to the hardware */
                                wmb();
                                next->link.control ^= cpu_to_le32(TRB_CYCLE);

Can you do this or may there be a CPU that speculatively writes before it reads next->link.control ?

Regards
Oliver

Signature · 6 lines
- - - 
SUSE LINUX Products GmbH, GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer, HRB 16746 (AG Nürnberg) 
Maxfeldstraße 5                         
90409 Nürnberg 
Germany 
- - - 
#1 lore raw
Quoted 10 lines · Oliver Neukum

Hi,

this code made me think:

                                /* Give this link TRB to the hardware */
                                wmb();
                                next->link.control ^= cpu_to_le32(TRB_CYCLE);

Can you do this or may there be a CPU that speculatively writes before it reads next->link.control ?

CPUs never do speculative writes. And even if they did, the wmb() would prevent the speculative write from preceding any statement that comes before the memory barrier.

Alan Stern