Received: by 10.192.165.148 with SMTP id m20csp449857imm; Fri, 20 Apr 2018 09:18:33 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/83GwTlAmfx762TdV9rfdwArVEnKUG0Uc4tBiCE6KtHVNUByO+Gqx0cTehUv5aql0fXQOp X-Received: by 10.98.59.203 with SMTP id w72mr2672513pfj.129.1524241113609; Fri, 20 Apr 2018 09:18:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524241113; cv=none; d=google.com; s=arc-20160816; b=K1hyLVqGBvKuXmw2jKlBgEpdH9Pey/8KSSES8x5nGzS/jBtdoAi0n42szQGf/CGmSr /CYzJSsIms08YpTDYYPN9FQp7EmIVE3uJbZyhTDWoN1I01k5HH1JFx3XJS6ePlovRwk8 K3zdph1tFFLZWVoCWHrLVjoxCn6iAdAq2sC5EfmcD08RcPXVP0g1LO6On0qJL1OLI8C1 GKF9JYZk4cOVvY8dSsmWa8yVvLkGyVv8+DUhwJjMLUSum/1RIMG0kbChywn+fmy8+fyN idedjPW/ktKK3vB2nB8X6+qOhCvTQw/Gl41UzQdgj9ALAG8HKpO4ccuvl8KCQvMzM3A9 8g4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:date:from :arc-authentication-results; bh=OlZh0QmuXePFahTwnZriE4pjZTguQxsjKOScuSMwCL0=; b=fx9aZAp2/sSPRKCknmiJetjSrqtS4R2p5YoUCUWb4eWIoPBW7UUsRBNPSsulCqX2Kr oo5M1Kq+0ucpBnFomdWd03gE3s/sMLCAATgSDm+oQr99j1Rit7uHIF0i4pUYsjhTQpqT s2UpbBgB/9f10Rz+qoqd1EqyFGwZHOKN8jGzMduSnQLctlC5gNZMgKRu1BuAsd4vkY7L IZ8+tixOqs4EJMW+0EM9PCS5SlLUCeuPIKcD4i7ZCFGqoAM29HQGWln6SnnVavjF3xbw zU81b5A4IcfaujN+HXYahctLEyng8ooXVLAcDWO8bGR/JSNznFTtwIP/u6ZgkDIfO/Ug xF8w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d18si5338667pgo.310.2018.04.20.09.18.19; Fri, 20 Apr 2018 09:18:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752785AbeDTQQu (ORCPT + 99 others); Fri, 20 Apr 2018 12:16:50 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:49720 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750985AbeDTQQr (ORCPT ); Fri, 20 Apr 2018 12:16:47 -0400 Received: from mail-wr0-f199.google.com ([209.85.128.199]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1f9YiM-0006wa-73 for linux-kernel@vger.kernel.org; Fri, 20 Apr 2018 16:16:46 +0000 Received: by mail-wr0-f199.google.com with SMTP id b9-v6so9377549wrj.15 for ; Fri, 20 Apr 2018 09:16:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=OlZh0QmuXePFahTwnZriE4pjZTguQxsjKOScuSMwCL0=; b=DcT7tWZ+3gufTdlnb+yJLY3K6/qANDW+qQ4b339Zfy1csO7Y6xPZnyIRx+LGK4qoJG 2eHRezKo17er9uy8/cmxIzz9fx8MZZB7a/DsqDq9rtO7k/wLzyX5yCqfUzUcukypQPE7 sYpy+LtQeJwOrGRMG3ju992XftiuJJnrX+Vk7oEkskz9ILf4bDoAx1EfL1YZciMcAI9z O6nSyQFZkxTpAy3WtdKE6awdaqBUFP5HZjq9mbh7srXNRXzwQbDL0ni1AyvH2DQJCVg9 2z5HfDnR0H/1sqLm4NxaA5HMeczm73+yLG4D/nrb+YAhqCRI0RB40fRdMkH9u6LfCaeg ODpg== X-Gm-Message-State: ALQs6tCUkcgV9tZPDUbSy1T7n2IMPOlbieDTfb4/bZumn0MBvnkDu/Y4 kXxMYsSmYnJWwf0eAvZQ8znluUeGexvbide8ktvjUozN9XkIQgMIBhfuIgBkCBbqMYT8LaumWvG z5UwtRfwB1LChGiOhJrDBotEIiobwAtgXKVm/MNNI4A== X-Received: by 2002:adf:8248:: with SMTP id 66-v6mr8681552wrb.127.1524241005849; Fri, 20 Apr 2018 09:16:45 -0700 (PDT) X-Received: by 2002:adf:8248:: with SMTP id 66-v6mr8681527wrb.127.1524241005448; Fri, 20 Apr 2018 09:16:45 -0700 (PDT) Received: from gmail.com (u-087-c122.eap.uni-tuebingen.de. [134.2.87.122]) by smtp.gmail.com with ESMTPSA id i30-v6sm5497205wra.38.2018.04.20.09.16.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 20 Apr 2018 09:16:45 -0700 (PDT) From: Christian Brauner X-Google-Original-From: Christian Brauner Date: Fri, 20 Apr 2018 18:16:44 +0200 To: "Eric W. Biederman" Cc: davem@davemloft.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, avagin@virtuozzo.com, ktkhai@virtuozzo.com, serge@hallyn.com, gregkh@linuxfoundation.org Subject: Re: [PATCH net-next 2/2] netns: isolate seqnums to use per-netns locks Message-ID: <20180420161643.GA15182@gmail.com> References: <20180418152106.18519-1-christian.brauner@ubuntu.com> <20180418152106.18519-3-christian.brauner@ubuntu.com> <874lk8wj1j.fsf@xmission.com> <20180418215246.GA24000@gmail.com> <20180420135627.GA8350@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180420135627.GA8350@gmail.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 20, 2018 at 03:56:28PM +0200, Christian Brauner wrote: > On Wed, Apr 18, 2018 at 11:52:47PM +0200, Christian Brauner wrote: > > On Wed, Apr 18, 2018 at 11:55:52AM -0500, Eric W. Biederman wrote: > > > Christian Brauner writes: > > > > > > > Now that it's possible to have a different set of uevents in different > > > > network namespaces, per-network namespace uevent sequence numbers are > > > > introduced. This increases performance as locking is now restricted to the > > > > network namespace affected by the uevent rather than locking > > > > everything. > > > > > > Numbers please. I personally expect that the netlink mc_list issues > > > will swamp any benefit you get from this. > > > > I wouldn't see how this would be the case. The gist of this is: > > Everytime you send a uevent into a network namespace *not* owned by > > init_user_ns you currently *have* to take mutex_lock(uevent_sock_list) > > effectively blocking the host from processing uevents even though > > - the uevent you're receiving might be totally different from the > > uevent that you're sending > > - the uevent socket of the non-init_user_ns owned network namespace > > isn't even recorded in the list. > > > > The other argument is that we now have properly isolated network > > namespaces wrt to uevents such that each netns can have its own set of > > uevents. This can either happen by a sufficiently privileged userspace > > process sending it uevents that are only dedicated to that specific > > netns. Or - and this *has been true for a long time* - because network > > devices are *properly namespaced*. Meaning a uevent for that network > > device is *tied to a network namespace*. For both cases the uevent > > sequence numbering will be absolutely misleading. For example, whenever > > you create e.g. a new veth device in a new network namespace it > > shouldn't be accounted against the initial network namespace but *only* > > against the network namespace that has that device added to it. > > Eric, I did the testing. Here's what I did: > > I compiled two 4.17-rc1 Kernels: > - one with per netns uevent seqnums with decoupled locking > - one without per netns uevent seqnums with decoupled locking > > # Testcase 1: > Only Injecting Uevents into network namespaces not owned by the initial user > namespace. > - created 1000 new user namespace + network namespace pairs > - opened a uevent listener in each of those namespace pairs > - injected uevents into each of those network namespaces 10,000 times meaning > 10,000,000 (10 million) uevents were injected. (The high number of > uevent injections should get rid of a lot of jitter.) > - Calculated the mean transaction time. > - *without* uevent sequence number namespacing: > 67 μs > - *with* uevent sequence number namespacing: > 55 μs > - makes a difference of 12 μs > > # Testcase 2: > Injecting Uevents into network namespaces not owned by the initial user > namespace and network namespaces owned by the initial user namespace. > - created 500 new user namespace + network namespace pairs > - created 500 new network namespace pairs > - opened a uevent listener in each of those namespace pairs > - injected uevents into each of those network namespaces 10,000 times meaning > 10,000,000 (10 million) uevents were injected. (The high number of > uevent injections should get rid of a lot of jitter.) > - Calculated the mean transaction time. > - *without* uevent sequence number namespacing: > 572 μs > - *with* uevent sequence number namespacing: > 514 μs > - makes a difference of 58 μs > > So there's performance gain. The third case would be to create a bunch > of hanging processes that send SIGSTOP to themselves but do not actually > open a uevent socket in their respective namespaces and then inject > uevents into them. I expect there to be an even more performance > benefits since the rtnl_table_lock() isn't hit in this case because > there are no listeners. I did the third test-case as well so: - created 500 new user namespace + network namespace pairs *without uevent listeners* - created 500 new network namespace pairs *without uevent listeners* - injected uevents into each of those network namespaces 10,000 times meaning 10,000,000 (10 million) uevents were injected. (The high number of uevent injections should get rid of a lot of jitter.) - Calculated the mean transaction time. - *without* uevent sequence number namespacing: 206 μs - *with* uevent sequence number namespacing: 163 μs - makes a difference of 43 μs So this test-case shows performance improvement as well. Thanks! Christian