On Mon, Jun 23 2025 at 10:45, Tianyang Zhang wrote:
在 2025/6/13 下午11:20, Thomas Gleixner 写道:How so?
On Tue, Jun 10 2025 at 19:42, Tianyang Zhang wrote:The reason fo coding here is that during testing, it was found that a
+ tail = (tail + 1) % INVALID_QUEUE_SIZE;Why is this before the barrier? The barrier does not do anything about
this and you can simplify this. See below.
And as there is no rmb() counterpart you want to explain that this is
serializing against the hardware.
+ */write_queue_tail(rqueue->node, (tail + 1) & INVALID_QUEUE_MASK);
+ wmb();
+
+ write_queue_tail(rqueue->node, tail);
No?
barrier is needed between the update of temporary variable 'tail' and
the operation of register with 'write_queue_tail' , otherwise
write_queue_tail will probabilistically fail to obtain the correct
value.
tail is the software managed part of the ringbuffer which is shared with
the hardware, right?
So even if the compiler would be allowed to reevalutate tail after the
barrier (it is NOT), then tail would still contain the same value as
before, no?
The wmb() is required to ensure that the hardware can observe the full
write of the command _before_ it can observe the update to the tail
index.
Anything else is voodoo.
Thanks,
tglx