lkml.org 
[lkml]   [2023]   [Aug]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC Optimizing veth xsk performance 06/10] veth: add ndo_xsk_wakeup callback for veth
On Thu, Aug 03, 2023 at 10:04:32PM +0800, huangjie.albert wrote:
> Signed-off-by: huangjie.albert <huangjie.albert@bytedance.com>
> ---
> drivers/net/veth.c | 40 ++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 40 insertions(+)
>
> diff --git a/drivers/net/veth.c b/drivers/net/veth.c
> index 944761807ca4..600225e27e9e 100644
> --- a/drivers/net/veth.c
> +++ b/drivers/net/veth.c
> @@ -1840,6 +1840,45 @@ static void veth_set_rx_headroom(struct net_device *dev, int new_hr)
> rcu_read_unlock();
> }
>
> +static void veth_xsk_remote_trigger_napi(void *info)
> +{
> + struct veth_sq *sq = info;
> +
> + napi_schedule(&sq->xdp_napi);
> +}
> +
> +static int veth_xsk_wakeup(struct net_device *dev, u32 qid, u32 flag)
> +{
> + struct veth_priv *priv;
> + struct veth_sq *sq;
> + u32 last_cpu, cur_cpu;
> +
> + if (!netif_running(dev))
> + return -ENETDOWN;
> +
> + if (qid >= dev->real_num_rx_queues)
> + return -EINVAL;
> +
> + priv = netdev_priv(dev);
> + sq = &priv->sq[qid];
> +
> + if (napi_if_scheduled_mark_missed(&sq->xdp_napi))
> + return 0;
> +
> + last_cpu = sq->xsk.last_cpu;
> + cur_cpu = get_cpu();
> +
> + /* raise a napi */
> + if (last_cpu == cur_cpu) {
> + napi_schedule(&sq->xdp_napi);
> + } else {
> + smp_call_function_single(last_cpu, veth_xsk_remote_trigger_napi, sq, true);
> + }

nit: no need for braces in the above.

if (last_cpu == cur_cpu)
napi_schedule(&sq->xdp_napi);
else
smp_call_function_single(last_cpu, veth_xsk_remote_trigger_napi, sq, true);

...

\
 
 \ /
  Last update: 2023-08-04 23:01    [W:0.116 / U:0.056 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site