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

2016-05-19 Thread Jesper Dangaard Brouer
On Wed, 18 May 2016 19:26:38 +0300 "Michael S. Tsirkin" wrote: > On Wed, May 18, 2016 at 10:13:59AM +0200, Jesper Dangaard Brouer wrote: > > 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 m

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

2016-05-18 Thread Michael S. Tsirkin
On Wed, May 18, 2016 at 09:41:03AM -0700, Eric Dumazet wrote: > On Wed, 2016-05-18 at 19:26 +0300, Michael S. Tsirkin wrote: > > On Wed, May 18, 2016 at 10:13:59AM +0200, Jesper Dangaard Brouer wrote: > > > I agree. It is sad to see everybody is implementing the same thing, > > > open coding an arr

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

2016-05-18 Thread Eric Dumazet
On Wed, 2016-05-18 at 19:26 +0300, Michael S. Tsirkin wrote: > On Wed, May 18, 2016 at 10:13:59AM +0200, Jesper Dangaard Brouer wrote: > > 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 maint

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

2016-05-18 Thread Michael S. Tsirkin
On Wed, May 18, 2016 at 10:13:59AM +0200, Jesper Dangaard Brouer wrote: > 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 perfo

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

2016-05-18 Thread Steven Rostedt
On Wed, 18 May 2016 18:23:48 +0800 Jason Wang wrote: > > > > > > > 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. Yes it is, and I'm not sure

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

2016-05-18 Thread Michael S. Tsirkin
On Wed, May 18, 2016 at 06:42:10PM +0800, Jason Wang wrote: > > > On 2016年05月18日 17:55, Michael S. Tsirkin wrote: > >On Wed, May 18, 2016 at 11:21:29AM +0200, Jesper Dangaard Brouer wrote: > >>On Wed, 18 May 2016 11:21:59 +0300 > >>"Michael S. Tsirkin" wrote: > >> > >>>On Wed, May 18, 2016 at 10

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

2016-05-18 Thread Jason Wang
On 2016年05月18日 17:55, Michael S. Tsirkin wrote: On Wed, May 18, 2016 at 11:21:29AM +0200, Jesper Dangaard Brouer wrote: On Wed, 18 May 2016 11:21:59 +0300 "Michael S. Tsirkin" wrote: On Wed, May 18, 2016 at 10:16:31AM +0200, Jesper Dangaard Brouer wrote: On Tue, 17 May 2016 09:38:37 +0800

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

2016-05-18 Thread Jason Wang
On 2016年05月18日 16:13, Jesper Dangaard Brouer wrote: On Mon, 16 May 2016 15:51:48 +0800 Jason Wang 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

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

2016-05-18 Thread Michael S. Tsirkin
On Wed, May 18, 2016 at 11:21:29AM +0200, Jesper Dangaard Brouer wrote: > On Wed, 18 May 2016 11:21:59 +0300 > "Michael S. Tsirkin" wrote: > > > On Wed, May 18, 2016 at 10:16:31AM +0200, Jesper Dangaard Brouer wrote: > > > > > > On Tue, 17 May 2016 09:38:37 +0800 Jason Wang wrote: > > > > >

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

2016-05-18 Thread Jesper Dangaard Brouer
On Wed, 18 May 2016 11:21:59 +0300 "Michael S. Tsirkin" wrote: > On Wed, May 18, 2016 at 10:16:31AM +0200, Jesper Dangaard Brouer wrote: > > > > On Tue, 17 May 2016 09:38:37 +0800 Jason Wang wrote: > > > > > >> And if tx_queue_length is not power of 2, > > > >> we probably need modulus to ca

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

2016-05-18 Thread Michael S. Tsirkin
On Wed, May 18, 2016 at 10:13:59AM +0200, Jesper Dangaard Brouer wrote: > On Mon, 16 May 2016 15:51:48 +0800 > Jason Wang 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, thi

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

2016-05-18 Thread Michael S. Tsirkin
On Wed, May 18, 2016 at 10:16:31AM +0200, Jesper Dangaard Brouer wrote: > > On Tue, 17 May 2016 09:38:37 +0800 Jason Wang wrote: > > > >> And if tx_queue_length is not power of 2, > > >> we probably need modulus to calculate the capacity. > > > Is that really that important for speed? > > >

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

2016-05-18 Thread Jesper Dangaard Brouer
On Tue, 17 May 2016 09:38:37 +0800 Jason Wang wrote: > >> And if tx_queue_length is not power of 2, > >> we probably need modulus to calculate the capacity. > > Is that really that important for speed? > > Not sure, I can test. In my experience, yes, adding a modulus does affect performanc

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

2016-05-18 Thread Jesper Dangaard Brouer
On Mon, 16 May 2016 15:51:48 +0800 Jason Wang 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

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

2016-05-16 Thread Jason Wang
On 2016年05月16日 16:08, Michael S. Tsirkin wrote: On Mon, May 16, 2016 at 03:52:11PM +0800, Jason Wang wrote: On 2016年05月16日 12:23, Michael S. Tsirkin wrote: On Mon, May 16, 2016 at 09:17:01AM +0800, Jason Wang wrote: We used to queue tx packets in sk_receive_queue, this is less efficient sin

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

2016-05-16 Thread Michael S. Tsirkin
On Mon, May 16, 2016 at 03:52:11PM +0800, Jason Wang wrote: > > > On 2016年05月16日 12:23, Michael S. Tsirkin wrote: > >On Mon, May 16, 2016 at 09:17:01AM +0800, Jason Wang wrote: > >>We used to queue tx packets in sk_receive_queue, this is less > >>efficient since it requires spinlocks to synchroni

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

2016-05-16 Thread Jason Wang
On 2016年05月16日 12:23, Michael S. Tsirkin wrote: On Mon, May 16, 2016 at 09:17:01AM +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. This patch tries to address this by usi

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

2016-05-16 Thread Jason Wang
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; + /

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

2016-05-15 Thread Michael S. Tsirkin
On Mon, May 16, 2016 at 09:17:01AM +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. > > This patch tries to address this by using circular buffer which allows > lockless

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

2016-05-15 Thread Eric Dumazet
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;

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

2016-05-15 Thread Jason Wang
We used to queue tx packets in sk_receive_queue, this is less efficient since it requires spinlocks to synchronize between producer and consumer. This patch tries to address this by using circular buffer which allows lockless synchronization. This is done by switching from sk_receive_queue to a tx