On 06/21/2018 12:54 AM, Heiner Litz wrote:
READ_ONCE does not imply a read memory barrier in the presence of control
dependencies between two separate memory locations (flags and data). On x86
TSO, reading from the data page might be reordered before the flags read.
See chapter CONTROL DEPENDENCIES in
https://www.kernel.org/doc/Documentation/memory-barriers.txt
Signed-off-by: Heiner Litz <hlitz@xxxxxxxx>
---
drivers/lightnvm/pblk-rb.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/lightnvm/pblk-rb.c b/drivers/lightnvm/pblk-rb.c
index a81a97e..5f09983 100644
--- a/drivers/lightnvm/pblk-rb.c
+++ b/drivers/lightnvm/pblk-rb.c
@@ -545,6 +545,9 @@ unsigned int pblk_rb_read_to_bio(struct pblk_rb *rb, struct nvm_rq *rqd,
goto try;
}
+ /* Observe control dependency between flags and data read */
+ smp_rmb();
+
page = virt_to_page(entry->data);
if (!page) {
pr_err("pblk: could not allocate write bio page\n");
Hi Heiner,
Can you help explain how it is a control dependency? What case am I missing?
The way I read the code, there is the case where a read of entry->data
happens before entry->w_ctx.flags, but I see that as a memory
reordering, which the smp_rmb() fixes. Would that be more accurate?
Thank you,
Matias