Skip to content

Commit

Permalink
xsk: Remove unnecessary READ_ONCE of data
Browse files Browse the repository at this point in the history
There are two unnecessary READ_ONCE of descriptor data. These are not
needed since the data is written by the producer before it signals
that the data is available by incrementing the producer pointer. As the
access to this producer pointer is serialized and the consumer always
reads the descriptor after it has read and synchronized with the
producer counter, the write of the descriptor will have fully
completed and it does not matter if the consumer has any read tearing.

Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/1576759171-28550-11-git-send-email-magnus.karlsson@intel.com
  • Loading branch information
Magnus Karlsson authored and Alexei Starovoitov committed Dec 21, 2019
1 parent f8509aa commit c34787f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions net/xdp/xsk_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ static inline bool xskq_cons_read_addr(struct xsk_queue *q, u64 *addr,
while (q->cached_cons != q->cached_prod) {
u32 idx = q->cached_cons & q->ring_mask;

*addr = READ_ONCE(ring->desc[idx]) & q->chunk_mask;
*addr = ring->desc[idx] & q->chunk_mask;

if (umem->flags & XDP_UMEM_UNALIGNED_CHUNK_FLAG) {
if (xskq_cons_is_valid_unaligned(q, *addr,
Expand Down Expand Up @@ -308,7 +308,7 @@ static inline bool xskq_cons_read_desc(struct xsk_queue *q,
struct xdp_rxtx_ring *ring = (struct xdp_rxtx_ring *)q->ring;
u32 idx = q->cached_cons & q->ring_mask;

*desc = READ_ONCE(ring->desc[idx]);
*desc = ring->desc[idx];
if (xskq_cons_is_valid_desc(q, desc, umem))
return true;

Expand Down

0 comments on commit c34787f

Please sign in to comment.