[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAL+tcoCDpyyVd1kiutPsH8abNRkAcoo=SkXKVJG+U90pAd+3tw@mail.gmail.com>
Date: Fri, 29 Aug 2025 08:31:17 +0800
From: Jason Xing <kerneljasonxing@...il.com>
To: Alexander Lobakin <aleksander.lobakin@...el.com>
Cc: davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org,
pabeni@...hat.com, bjorn@...nel.org, magnus.karlsson@...el.com,
maciej.fijalkowski@...el.com, jonathan.lemon@...il.com, sdf@...ichev.me,
ast@...nel.org, daniel@...earbox.net, hawk@...nel.org,
john.fastabend@...il.com, horms@...nel.org, andrew+netdev@...n.ch,
bpf@...r.kernel.org, netdev@...r.kernel.org,
Jason Xing <kernelxing@...cent.com>
Subject: Re: [PATCH net-next v2 5/9] xsk: add xsk_alloc_batch_skb() to build
skbs in batch
On Thu, Aug 28, 2025 at 11:29 PM Alexander Lobakin
<aleksander.lobakin@...el.com> wrote:
>
> From: Jason Xing <kerneljasonxing@...il.com>
> Date: Thu, 28 Aug 2025 08:38:42 +0800
>
> > On Wed, Aug 27, 2025 at 10:33 PM Alexander Lobakin
> > <aleksander.lobakin@...el.com> wrote:
> >>
> >> From: Jason Xing <kerneljasonxing@...il.com>
> >> Date: Mon, 25 Aug 2025 21:53:38 +0800
> >>
> >>> From: Jason Xing <kernelxing@...cent.com>
> >>>
> >>> Support allocating and building skbs in batch.
> >>
> >> [...]
> >>
> >>> + base_len = max(NET_SKB_PAD, L1_CACHE_ALIGN(dev->needed_headroom));
> >>> + if (!(dev->priv_flags & IFF_TX_SKB_NO_LINEAR))
> >>> + base_len += dev->needed_tailroom;
> >>> +
> >>> + if (xs->skb_count >= nb_pkts)
> >>> + goto build;
> >>> +
> >>> + if (xs->skb) {
> >>> + i = 1;
> >>> + xs->skb_count++;
> >>> + }
> >>> +
> >>> + xs->skb_count += kmem_cache_alloc_bulk(net_hotdata.skbuff_cache,
> >>> + gfp_mask, nb_pkts - xs->skb_count,
> >>> + (void **)&skbs[xs->skb_count]);
> >>
> >> Have you tried napi_skb_cache_get_bulk()? Depending on the workload, it
> >> may give better perf numbers.
> >
> > Sure, my initial try is using this interface. But later I want to see
> > a standalone cache belonging to xsk. The whole xsk_alloc_batch_skb
> > function I added is quite similar to napi_skb_cache_get_bulk(), to
> > some extent.
> >
> > And if using napi_xxx(), we need a lock to avoid the race between this
> > context and softirq context on the same core.
>
> Are you saying this particular function is not run in the softirq
No, it runs in process context. Please see this chain:
sendto->__xsk_generic_xmit-> (allocating skbs function handling).
Thanks,
Jason
> context? I thought all Tx is done in BH.
> If it's not BH, then ignore my suggestion -- napi_skb_cache_get_bulk()
> requires BH, that's true.
>
> >
> > Thanks,
> > Jason
>
> Thanks,
> Olek
Powered by blists - more mailing lists