[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAOJe8K0bi3oMwTp8VN4OPdaDtp6PvU1w6fZ4EkXFdbcc-zciZA@mail.gmail.com>
Date: Mon, 29 Jun 2020 13:13:51 +0300
From: Denis Kirjanov <kda@...ux-powerpc.org>
To: Jesper Dangaard Brouer <brouer@...hat.com>
Cc: netdev@...r.kernel.org, jgross@...e.com, wei.liu@...nel.org,
paul@....org, ilias.apalodimas@...aro.org
Subject: Re: [PATCH net-next v13 2/3] xen networking: add basic XDP support
for xen-netfront
On 6/26/20, Jesper Dangaard Brouer <brouer@...hat.com> wrote:
> On Fri, 26 Jun 2020 14:40:38 +0300
> Denis Kirjanov <kda@...ux-powerpc.org> wrote:
>
>> diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
>> index 482c6c8..91a3b53 100644
>> --- a/drivers/net/xen-netfront.c
>> +++ b/drivers/net/xen-netfront.c
> [...]
>> @@ -560,6 +572,67 @@ static u16 xennet_select_queue(struct net_device
>> *dev, struct sk_buff *skb,
>> return queue_idx;
>> }
>>
>> +static int xennet_xdp_xmit_one(struct net_device *dev,
>> + struct netfront_queue *queue,
>> + struct xdp_frame *xdpf)
>> +{
>> + struct netfront_info *np = netdev_priv(dev);
>> + struct netfront_stats *tx_stats = this_cpu_ptr(np->tx_stats);
>> + struct xen_netif_tx_request *tx;
>> + int notify;
>> +
>> + tx = xennet_make_first_txreq(queue, NULL,
>> + virt_to_page(xdpf->data),
>> + offset_in_page(xdpf->data),
>> + xdpf->len);
>> +
>> + RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&queue->tx, notify);
>> + if (notify)
>> + notify_remote_via_irq(queue->tx_irq);
>
> Is this an expensive operation?
Hi Jesper,
actually not.
>
> Do you think this can be moved outside the loop?
> So that it is called once per bulk.
I've tested both variants and it turned out that there is no
difference between both:
with xdp_redirect I see the similar picture:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1074 root 20 0 0 0 0 R 100.0 0.0 1:17.60 cpumap/3/m+
9 root 20 0 0 0 0 R 93.7 0.0 1:37.03 ksoftirqd/0
with the similar pps rate reported by xdp_redirect.
So I'll keep the code as is in the next submission.
Thanks!
>
>
>> + u64_stats_update_begin(&tx_stats->syncp);
>> + tx_stats->bytes += xdpf->len;
>> + tx_stats->packets++;
>> + u64_stats_update_end(&tx_stats->syncp);
>> +
>> + xennet_tx_buf_gc(queue);
>> +
>> + return 0;
>> +}
>> +
>> +static int xennet_xdp_xmit(struct net_device *dev, int n,
>> + struct xdp_frame **frames, u32 flags)
>> +{
>> + unsigned int num_queues = dev->real_num_tx_queues;
>> + struct netfront_info *np = netdev_priv(dev);
>> + struct netfront_queue *queue = NULL;
>> + unsigned long irq_flags;
>> + int drops = 0;
>> + int i, err;
>> +
>> + if (unlikely(flags & ~XDP_XMIT_FLAGS_MASK))
>> + return -EINVAL;
>> +
>> + queue = &np->queues[smp_processor_id() % num_queues];
>> +
>> + spin_lock_irqsave(&queue->tx_lock, irq_flags);
>> + for (i = 0; i < n; i++) {
>> + struct xdp_frame *xdpf = frames[i];
>> +
>> + if (!xdpf)
>> + continue;
>> + err = xennet_xdp_xmit_one(dev, queue, xdpf);
>> + if (err) {
>> + xdp_return_frame_rx_napi(xdpf);
>> + drops++;
>> + }
>> + }
>> + spin_unlock_irqrestore(&queue->tx_lock, irq_flags);
>> +
>> + return n - drops;
>> +}
>
>
> --
> Best regards,
> Jesper Dangaard Brouer
> MSc.CS, Principal Kernel Engineer at Red Hat
> LinkedIn: http://www.linkedin.com/in/brouer
>
>
Powered by blists - more mailing lists