From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934159AbdKBDpr (ORCPT ); Wed, 1 Nov 2017 23:45:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59264 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934073AbdKBDpq (ORCPT ); Wed, 1 Nov 2017 23:45:46 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D19A5883A2 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=jasowang@redhat.com Subject: Re: [PATCH net-next V2 3/3] tun: add eBPF based queue selection method To: "Michael S. Tsirkin" Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, willemdebruijn.kernel@gmail.com, tom@herbertland.com References: <1509445938-4345-1-git-send-email-jasowang@redhat.com> <1509445938-4345-4-git-send-email-jasowang@redhat.com> <20171031184002-mutt-send-email-mst@kernel.org> <43c86606-2911-768d-704f-8b25e04cb47b@redhat.com> <20171101150458-mutt-send-email-mst@kernel.org> From: Jason Wang Message-ID: <30aa1418-9253-5721-a489-84cd6e1722c5@redhat.com> Date: Thu, 2 Nov 2017 11:45:39 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <20171101150458-mutt-send-email-mst@kernel.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 02 Nov 2017 03:45:46 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2017年11月01日 21:59, Michael S. Tsirkin wrote: > On Wed, Nov 01, 2017 at 09:02:03PM +0800, Jason Wang wrote: >> >> On 2017年11月01日 00:45, Michael S. Tsirkin wrote: >>>> +static void __tun_set_steering_ebpf(struct tun_struct *tun, >>>> + struct bpf_prog *new) >>>> +{ >>>> + struct bpf_prog *old; >>>> + >>>> + old = rtnl_dereference(tun->steering_prog); >>>> + rcu_assign_pointer(tun->steering_prog, new); >>>> + >>>> + if (old) { >>>> + synchronize_net(); >>>> + bpf_prog_destroy(old); >>>> + } >>>> +} >>>> + >>> Is this really called under rtnl? >> Yes it is __tun_chr_ioctl() will call rtnl_lock(). > Is the call from tun_free_netdev under rtnl too? Looks not, need hold rtnl_lock() in tun_free_netdev in next version. > >>> If no then rtnl_dereference >>> is wrong. If yes I'm not sure you can call synchronize_net >>> under rtnl. >>> >> Are you worrying about the long wait? Looking at synchronize_net(), it does: >> >> void synchronize_net(void) >> { >>     might_sleep(); >>     if (rtnl_is_locked()) >>         synchronize_rcu_expedited(); >>     else >>         synchronize_rcu(); >> } >> EXPORT_SYMBOL(synchronize_net); >> >> Thanks > Not the wait - expedited is not a good thing to allow unpriveledged > userspace to do, it interrupts all VMs running on the same box. Good point. > > We could use a callback though the docs warn userspace can use that > to cause a DOS and needs to be limited. > > Will do this in next version. Thanks