OSDN Git Service

ptr_ring: keep consumer_head valid at all times
authorMichael S. Tsirkin <mst@redhat.com>
Thu, 25 Jan 2018 23:36:27 +0000 (01:36 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 29 Jan 2018 17:02:53 +0000 (12:02 -0500)
commit406de7555424d93849166684d0bd172743d2a30c
tree8f440597d97aade025b56f2127d0a39bb60fd124
parent7ece54a60ee2ba7a386308cae73c790bd580589c
ptr_ring: keep consumer_head valid at all times

The comment near __ptr_ring_peek says:

 * If ring is never resized, and if the pointer is merely
 * tested, there's no need to take the lock - see e.g.  __ptr_ring_empty.

but this was in fact never possible since consumer_head would sometimes
point outside the ring. Refactor the code so that it's always
pointing within a ring.

Fixes: c5ad119fb6c09 ("net: sched: pfifo_fast use skb_array")
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/ptr_ring.h