On Fri, Jan 12, 2018 at 01:01:56PM -0800, Saeed Mahameed wrote: > Simply putting a memory barrier on the top or the bottom of a functions, > means nothing unless you are looking at the whole picture, of all the > callers of that function to understand why is it there. When I review code I want to see the memory barrier placed *directly* before the write which allows the DMA. So yes, this is my preference: > update_doorbell() { > dma_wmb(); > ring->db = prod; > } Conceptually what is happening here is very similar to what smp_store_release() does for SMP cases. In most cases wmb should always be strongly connected with a following write. smp_store_release() is called 'release' because the write it incorporates allows the other CPU to 'see' what is being protected. Similarly here, the write to the db allows the device to 'see' the new ring data. And this is bad idea: > fill buffers(); > dma_wmb(); > update_doorbell(); > I simply like the 2nd one since with one look you can understand > what this dma_wmb is protecting. What do you think the wmb is protecting in the above? It isn't the fill. Jason -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html