Re: [PATCH net V2] tuntap: synchronize through tfiles array instead of tun->numqueues

2019-05-09 Thread Jason Wang
On 2019/5/9 下午1:34, Cong Wang wrote: On Tue, May 7, 2019 at 7:54 PM Jason Wang wrote: This is only true if you can make sure tfile[tun->numqueues] is not freed. Either my patch or SOCK_RCU_FREE can solve this, but for SOCK_RCU_FREE we need do extra careful audit to make sure it doesn't break

Re: [PATCH net V2] tuntap: synchronize through tfiles array instead of tun->numqueues

2019-05-08 Thread Cong Wang
On Tue, May 7, 2019 at 7:54 PM Jason Wang wrote: > This is only true if you can make sure tfile[tun->numqueues] is not > freed. Either my patch or SOCK_RCU_FREE can solve this, but for > SOCK_RCU_FREE we need do extra careful audit to make sure it doesn't > break someting. So synchronize through p

Re: [PATCH net V2] tuntap: synchronize through tfiles array instead of tun->numqueues

2019-05-08 Thread Jason Wang
On 2019/5/9 上午1:36, David Miller wrote: From: Jason Wang Date: Tue, 7 May 2019 00:03:36 -0400 @@ -1313,6 +1315,10 @@ static int tun_xdp_xmit(struct net_device *dev, int n, tfile = rcu_dereference(tun->tfiles[smp_processor_id() % numqueues])

Re: [PATCH net V2] tuntap: synchronize through tfiles array instead of tun->numqueues

2019-05-08 Thread David Miller
From: Jason Wang Date: Tue, 7 May 2019 00:03:36 -0400 > @@ -1313,6 +1315,10 @@ static int tun_xdp_xmit(struct net_device *dev, int n, > > tfile = rcu_dereference(tun->tfiles[smp_processor_id() % > numqueues]); > + if (!tfile) { > +

Re: [PATCH net V2] tuntap: synchronize through tfiles array instead of tun->numqueues

2019-05-07 Thread Jason Wang
On 2019/5/8 下午12:16, Michael S. Tsirkin wrote: On Tue, May 07, 2019 at 12:03:36AM -0400, Jason Wang wrote: When a queue(tfile) is detached through __tun_detach(), we move the last enabled tfile to the position where detached one sit but don't NULL out last position. We expect to synchronize th

Re: [PATCH net V2] tuntap: synchronize through tfiles array instead of tun->numqueues

2019-05-07 Thread Michael S. Tsirkin
On Tue, May 07, 2019 at 12:03:36AM -0400, Jason Wang wrote: > When a queue(tfile) is detached through __tun_detach(), we move the > last enabled tfile to the position where detached one sit but don't > NULL out last position. We expect to synchronize the datapath through > tun->numqueues. Unfortuna

Re: [PATCH net V2] tuntap: synchronize through tfiles array instead of tun->numqueues

2019-05-07 Thread Jason Wang
On 2019/5/7 下午10:41, Cong Wang wrote: On Mon, May 6, 2019 at 11:19 PM Jason Wang wrote: On 2019/5/7 下午12:54, Cong Wang wrote: On Mon, May 6, 2019 at 9:03 PM Jason Wang wrote: diff --git a/drivers/net/tun.c b/drivers/net/tun.c index e9ca1c0..32a0b23 100644 --- a/drivers/net/tun.c +++ b/dri

Re: [PATCH net V2] tuntap: synchronize through tfiles array instead of tun->numqueues

2019-05-07 Thread Cong Wang
On Mon, May 6, 2019 at 11:19 PM Jason Wang wrote: > > > On 2019/5/7 下午12:54, Cong Wang wrote: > > On Mon, May 6, 2019 at 9:03 PM Jason Wang wrote: > >> diff --git a/drivers/net/tun.c b/drivers/net/tun.c > >> index e9ca1c0..32a0b23 100644 > >> --- a/drivers/net/tun.c > >> +++ b/drivers/net/tun.c >

Re: [PATCH net V2] tuntap: synchronize through tfiles array instead of tun->numqueues

2019-05-06 Thread Jason Wang
On 2019/5/7 下午12:54, Cong Wang wrote: On Mon, May 6, 2019 at 9:03 PM Jason Wang wrote: diff --git a/drivers/net/tun.c b/drivers/net/tun.c index e9ca1c0..32a0b23 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -700,6 +700,8 @@ static void __tun_detach(struct tun_file *tfile, bool cle

Re: [PATCH net V2] tuntap: synchronize through tfiles array instead of tun->numqueues

2019-05-06 Thread Cong Wang
On Mon, May 6, 2019 at 9:03 PM Jason Wang wrote: > diff --git a/drivers/net/tun.c b/drivers/net/tun.c > index e9ca1c0..32a0b23 100644 > --- a/drivers/net/tun.c > +++ b/drivers/net/tun.c > @@ -700,6 +700,8 @@ static void __tun_detach(struct tun_file *tfile, bool > clean) >

[PATCH net V2] tuntap: synchronize through tfiles array instead of tun->numqueues

2019-05-06 Thread Jason Wang
When a queue(tfile) is detached through __tun_detach(), we move the last enabled tfile to the position where detached one sit but don't NULL out last position. We expect to synchronize the datapath through tun->numqueues. Unfortunately, this won't work since we're lacking sufficient mechanism to or