Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1402870

Re: [PATCH net-next] tuntap: introduce tx skb ring

From Jason Wang <jasowang@redhat.com>
Newsgroups linux.kernel
Subject Re: [PATCH net-next] tuntap: introduce tx skb ring
Date 2016-05-18 12:30 +0200
Message-ID <rA6TN-Pd-51@gated-at.bofh.it> (permalink)
References <rzg8Z-u7-309@gated-at.bofh.it> <rzhRf-1JW-3@gated-at.bofh.it> <rzlBv-4a7-19@gated-at.bofh.it> <rA4RX-7UR-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw



On 2016年05月18日 16:13, Jesper Dangaard Brouer wrote:
> On Mon, 16 May 2016 15:51:48 +0800
> Jason Wang <jasowang@redhat.com> wrote:
>
>> On 2016年05月16日 11:56, Eric Dumazet wrote:
>>> On Mon, 2016-05-16 at 09:17 +0800, Jason Wang wrote:
>>>> We used to queue tx packets in sk_receive_queue, this is less
>>>> efficient since it requires spinlocks to synchronize between producer
>>>> and consumer.
>>> ...
>>>   
>>>>    	struct tun_struct *detached;
>>>> +	/* reader lock */
>>>> +	spinlock_t rlock;
>>>> +	unsigned long tail;
>>>> +	struct tun_desc tx_descs[TUN_RING_SIZE];
>>>> +	/* writer lock */
>>>> +	spinlock_t wlock;
>>>> +	unsigned long head;
>>>>    };
>>>>      
>>> Ok, we had these kind of ideas floating around for many other cases,
>>> like qdisc, UDP or af_packet sockets...
>>>
>>> I believe we should have a common set of helpers, not hidden in
>>> drivers/net/tun.c but in net/core/skb_ring.c or something, with more
>>> flexibility (like the number of slots)
>>>   
>> Yes, this sounds good.
> I agree. It is sad to see everybody is implementing the same thing,
> open coding an array/circular based ring buffer.  This kind of code is
> hard to maintain and get right with barriers etc.  We can achieve the
> same performance with a generic implementation, by inlining the help
> function calls.
>
> I implemented an array based Lock-Free/cmpxchg based queue, that you
> could be inspired by, see:
>   https://github.com/netoptimizer/prototype-kernel/blob/master/kernel/include/linux/alf_queue.h

This looks really interesting, thanks.

>
> The main idea behind my implementation is bulking, to amortize the
> locked cmpxchg operation. You might not need it now, but I expect we
> need it in the future.

Right, we need change APIs which can read or write multiple buffers at 
one time for tun (and for others). I agree this will be a good 
optimization in the future.

>
> You cannot use my alf_queue directly as your "struct tun_desc" is
> larger than one-pointer (which the alf_queue works with).  But it
> should be possible to extend to handle larger "objects".

Yes, and for more generic usage, maybe one more void * is sufficient.

>
>
> Maybe Steven Rostedt have an even better ring queue implementation
> already avail in the kernel?
>

You mean ring buffer in tracing? Not sure, but it looks rather complex 
at first glance.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH net-next] tuntap: introduce tx skb ring Jason Wang <jasowang@redhat.com> - 2016-05-16 04:10 +0200
  Re: [PATCH net-next] tuntap: introduce tx skb ring Eric Dumazet <eric.dumazet@gmail.com> - 2016-05-16 06:00 +0200
    Re: [PATCH net-next] tuntap: introduce tx skb ring Jason Wang <jasowang@redhat.com> - 2016-05-16 10:00 +0200
      Re: [PATCH net-next] tuntap: introduce tx skb ring Jesper Dangaard Brouer <brouer@redhat.com> - 2016-05-18 10:20 +0200
        Re: [PATCH net-next] tuntap: introduce tx skb ring "Michael S. Tsirkin" <mst@redhat.com> - 2016-05-18 10:30 +0200
        Re: [PATCH net-next] tuntap: introduce tx skb ring Jason Wang <jasowang@redhat.com> - 2016-05-18 12:30 +0200
          Re: [PATCH net-next] tuntap: introduce tx skb ring Steven Rostedt <rostedt@goodmis.org> - 2016-05-18 14:00 +0200
        Re: [PATCH net-next] tuntap: introduce tx skb ring "Michael S. Tsirkin" <mst@redhat.com> - 2016-05-18 18:30 +0200
          Re: [PATCH net-next] tuntap: introduce tx skb ring Eric Dumazet <eric.dumazet@gmail.com> - 2016-05-18 18:50 +0200
            Re: [PATCH net-next] tuntap: introduce tx skb ring "Michael S. Tsirkin" <mst@redhat.com> - 2016-05-18 18:50 +0200
          Re: [PATCH net-next] tuntap: introduce tx skb ring Jesper Dangaard Brouer <brouer@redhat.com> - 2016-05-19 14:00 +0200
  Re: [PATCH net-next] tuntap: introduce tx skb ring "Michael S. Tsirkin" <mst@redhat.com> - 2016-05-16 06:30 +0200
    Re: [PATCH net-next] tuntap: introduce tx skb ring Jason Wang <jasowang@redhat.com> - 2016-05-16 10:00 +0200
      Re: [PATCH net-next] tuntap: introduce tx skb ring "Michael S. Tsirkin" <mst@redhat.com> - 2016-05-16 10:10 +0200
        Re: [PATCH net-next] tuntap: introduce tx skb ring Jason Wang <jasowang@redhat.com> - 2016-05-17 03:40 +0200
          Re: [PATCH net-next] tuntap: introduce tx skb ring Jesper Dangaard Brouer <brouer@redhat.com> - 2016-05-18 10:20 +0200
            Re: [PATCH net-next] tuntap: introduce tx skb ring "Michael S. Tsirkin" <mst@redhat.com> - 2016-05-18 10:30 +0200
              Re: [PATCH net-next] tuntap: introduce tx skb ring Jesper Dangaard Brouer <brouer@redhat.com> - 2016-05-18 11:30 +0200
                Re: [PATCH net-next] tuntap: introduce tx skb ring "Michael S. Tsirkin" <mst@redhat.com> - 2016-05-18 12:00 +0200
                Re: [PATCH net-next] tuntap: introduce tx skb ring Jason Wang <jasowang@redhat.com> - 2016-05-18 12:50 +0200
                Re: [PATCH net-next] tuntap: introduce tx skb ring "Michael S. Tsirkin" <mst@redhat.com> - 2016-05-18 13:00 +0200

csiph-web