From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752414AbcEPHvz (ORCPT ); Mon, 16 May 2016 03:51:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39687 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750721AbcEPHvx (ORCPT ); Mon, 16 May 2016 03:51:53 -0400 Subject: Re: [PATCH net-next] tuntap: introduce tx skb ring To: Eric Dumazet References: <1463361421-4397-1-git-send-email-jasowang@redhat.com> <1463370998.18194.74.camel@edumazet-glaptop3.roam.corp.google.com> Cc: davem@davemloft.net, mst@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org From: Jason Wang Message-ID: <57397C14.1080701@redhat.com> Date: Mon, 16 May 2016 15:51:48 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 MIME-Version: 1.0 In-Reply-To: <1463370998.18194.74.camel@edumazet-glaptop3.roam.corp.google.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 16 May 2016 07:51:53 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > BTW, why are you using spin_lock_irqsave() in tun_net_xmit() and > tun_peek() ? > > BH should be disabled already (in tun_next_xmit()), and we can not > transmit from hard irq. > > Thanks. Right, no need. But for tun_peek() we need spin_lock_bh() since it was called by vhost-net. Thanks