[Question] A question about t/io_uring.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I found two implementation details in t/io_uring.c quite interesting.
Both are in the prep_more_ios() function.

1.
reading the sq ring head is not protected using something like
READ_ONCE() or smp_read_acquire().
According to https://www.kernel.org/doc/Documentation/memory-barriers.txt
```
It _must_not_ be assumed that the compiler will do what you want
with memory references that are not protected by READ_ONCE() and
WRITE_ONCE().  Without them, the compiler is within its rights to
do all sorts of "creative" transformations, which are covered in
the COMPILER BARRIER section.
```

Is it possible that the modifications to the sqe using init_io() get
reordered prior to reading the sq ring head?

2.
Writing to the sq ring tail is not protected using something like
smp_store_release.
Even according to the article "Efficient IO with io_uring", adding an
sqe should be like:
```
write_barrier();
sqring->tail = tail;
write_barrier();
```
However, the first write barrier is missing in the t/io_uring.c
Is it possible that the memory stores get reordered?

Can anyone provide some insights on this? Thank you!

Best,
Hongwei



[Index of Archives]     [Linux Kernel]     [Linux SCSI]     [Linux IDE]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux