Re: [PATCH net-next v3] net: xsk: introduce XDP_MAX_TX_BUDGET set/getsockopt

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

 



On Thu, Jun 19, 2025 at 9:53 PM Willem de Bruijn
<willemdebruijn.kernel@xxxxxxxxx> wrote:
>
> Jason Xing wrote:
> > From: Jason Xing <kernelxing@xxxxxxxxxxx>
> >
> > The patch does the following things:
> > - Add XDP_MAX_TX_BUDGET socket option.
> > - Unify TX_BATCH_SIZE and MAX_PER_SOCKET_BUDGET into single one
> >   tx_budget_spent.
> > - tx_budget_spent is set to 32 by default in the initialization phase.
> >   It's a per-socket granular control.
> >
> > The idea behind this comes out of real workloads in production. We use a
> > user-level stack with xsk support to accelerate sending packets and
> > minimize triggering syscall. When the packets are aggregated, it's not
> > hard to hit the upper bound (namely, 32). The moment user-space stack
> > fetches the -EAGAIN error number passed from sendto(), it will loop to try
> > again until all the expected descs from tx ring are sent out to the driver.
> > Enlarging the XDP_MAX_TX_BUDGET value contributes to less frequencies of
> > sendto(). Besides, applications leveraging this setsockopt can adjust
> > its proper value in time after noticing the upper bound issue happening.
> >
> > Signed-off-by: Jason Xing <kernelxing@xxxxxxxxxxx>
> > ---
> > V3
> > Link: https://lore.kernel.org/all/20250618065553.96822-1-kerneljasonxing@xxxxxxxxx/
> > 1. use a per-socket control (suggested by Stanislav)
> > 2. unify both definitions into one
> > 3. support setsockopt and getsockopt
> > 4. add more description in commit message
>
> +1 on an XSK setsockopt only

May I ask why only setsockopt? In tradition, dev_tx_weight can be read
and written through running sysctl. I think they are the same?

>
> >
> > V2
> > Link: https://lore.kernel.org/all/20250617002236.30557-1-kerneljasonxing@xxxxxxxxx/
> > 1. use a per-netns sysctl knob
> > 2. use sysctl_xsk_max_tx_budget to unify both definitions.
> > ---
> >  include/net/xdp_sock.h            |  3 ++-
> >  include/uapi/linux/if_xdp.h       |  1 +
> >  net/xdp/xsk.c                     | 36 +++++++++++++++++++++++++------
> >  tools/include/uapi/linux/if_xdp.h |  1 +
> >  4 files changed, 34 insertions(+), 7 deletions(-)
> >
> > diff --git a/include/net/xdp_sock.h b/include/net/xdp_sock.h
> > index e8bd6ddb7b12..8eecafad92c0 100644
> > --- a/include/net/xdp_sock.h
> > +++ b/include/net/xdp_sock.h
> > @@ -65,11 +65,12 @@ struct xdp_sock {
> >       struct xsk_queue *tx ____cacheline_aligned_in_smp;
> >       struct list_head tx_list;
> >       /* record the number of tx descriptors sent by this xsk and
> > -      * when it exceeds MAX_PER_SOCKET_BUDGET, an opportunity needs
> > +      * when it exceeds max_tx_budget, an opportunity needs
> >        * to be given to other xsks for sending tx descriptors, thereby
> >        * preventing other XSKs from being starved.
> >        */
> >       u32 tx_budget_spent;
> > +     u32 max_tx_budget;
>
> This probably does not need to be a u32?


[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux