[bpf-next,05/12] xsk: eliminate the RX batch size
diff mbox series

Message ID 1575878189-31860-6-git-send-email-magnus.karlsson@intel.com
State Changes Requested
Delegated to: BPF Maintainers
Headers show
Series
  • xsk: clean up ring access functions
Related show

Commit Message

Magnus Karlsson Dec. 9, 2019, 7:56 a.m. UTC
In the xsk consumer ring code there is a variable call RX_BATCH_SIZE
that dictates the minimum number of entries that we try to grab from
the fill and Tx rings. In fact, the code always try to grab the
maximum amount of entries from these rings. The only thing this
variable does is to throw an error if there is less than 16 (as it is
defined) entries on the ring. There is no reason to do this and it
will just lead to weird behavior from user space's point of view. So
eliminate this variable.

With this change, we will be able to simplify the xskq_nb_free and
xskq_nb_avail code in the next commit.

Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
---
 net/xdp/xsk_queue.h | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Sergei Shtylyov Dec. 9, 2019, 10:16 a.m. UTC | #1
Hello!

On 09.12.2019 10:56, Magnus Karlsson wrote:

> In the xsk consumer ring code there is a variable call RX_BATCH_SIZE

    Called?

> that dictates the minimum number of entries that we try to grab from
> the fill and Tx rings. In fact, the code always try to grab the
   ^^^^^^^^^^^^^^^^^^^^^ hm, are you sure there's no typo here?

> maximum amount of entries from these rings. The only thing this
> variable does is to throw an error if there is less than 16 (as it is
> defined) entries on the ring. There is no reason to do this and it
> will just lead to weird behavior from user space's point of view. So
> eliminate this variable.
> 
> With this change, we will be able to simplify the xskq_nb_free and
> xskq_nb_avail code in the next commit.
> 
> Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
[...]

MBR, Sergei
Magnus Karlsson Dec. 9, 2019, 1:07 p.m. UTC | #2
On Mon, Dec 9, 2019 at 11:17 AM Sergei Shtylyov
<sergei.shtylyov@cogentembedded.com> wrote:
>
> Hello!
>
> On 09.12.2019 10:56, Magnus Karlsson wrote:
>
> > In the xsk consumer ring code there is a variable call RX_BATCH_SIZE
>
>     Called?

Yes, definitely. Will fix.

Thanks: Magnus

> > that dictates the minimum number of entries that we try to grab from
> > the fill and Tx rings. In fact, the code always try to grab the
>    ^^^^^^^^^^^^^^^^^^^^^ hm, are you sure there's no typo here?
>
> > maximum amount of entries from these rings. The only thing this
> > variable does is to throw an error if there is less than 16 (as it is
> > defined) entries on the ring. There is no reason to do this and it
> > will just lead to weird behavior from user space's point of view. So
> > eliminate this variable.
> >
> > With this change, we will be able to simplify the xskq_nb_free and
> > xskq_nb_avail code in the next commit.
> >
> > Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
> [...]
>
> MBR, Sergei
>

Patch
diff mbox series

diff --git a/net/xdp/xsk_queue.h b/net/xdp/xsk_queue.h
index 85358af..e3ae62d 100644
--- a/net/xdp/xsk_queue.h
+++ b/net/xdp/xsk_queue.h
@@ -10,8 +10,6 @@ 
 #include <linux/if_xdp.h>
 #include <net/xdp_sock.h>
 
-#define RX_BATCH_SIZE 16
-
 struct xdp_ring {
 	u32 producer ____cacheline_aligned_in_smp;
 	u32 consumer ____cacheline_aligned_in_smp;
@@ -202,7 +200,7 @@  static inline u64 *xskq_peek_addr(struct xsk_queue *q, u64 *addr,
 	if (q->cons_tail == q->cons_head) {
 		smp_mb(); /* D, matches A */
 		WRITE_ONCE(q->ring->consumer, q->cons_tail);
-		q->cons_head = q->cons_tail + xskq_nb_avail(q, RX_BATCH_SIZE);
+		q->cons_head = q->cons_tail + xskq_nb_avail(q, 1);
 
 		/* Order consumer and data */
 		smp_rmb();
@@ -320,7 +318,7 @@  static inline struct xdp_desc *xskq_peek_desc(struct xsk_queue *q,
 	if (q->cons_tail == q->cons_head) {
 		smp_mb(); /* D, matches A */
 		WRITE_ONCE(q->ring->consumer, q->cons_tail);
-		q->cons_head = q->cons_tail + xskq_nb_avail(q, RX_BATCH_SIZE);
+		q->cons_head = q->cons_tail + xskq_nb_avail(q, 1);
 
 		/* Order consumer and data */
 		smp_rmb(); /* C, matches B */