Received: by 10.223.164.202 with SMTP id h10csp154565wrb; Tue, 14 Nov 2017 12:45:51 -0800 (PST) X-Google-Smtp-Source: AGs4zMaBEtv0jlJ0oIk2kCKv46ccB3og/wQES+Uk5f5pQjwb0d8IRD65vsC30I9ZKC+oupUWzYJ+ X-Received: by 10.98.9.209 with SMTP id 78mr6164315pfj.59.1510692351369; Tue, 14 Nov 2017 12:45:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510692351; cv=none; d=google.com; s=arc-20160816; b=pZshHGVkmkOeYHUQiv4ubY8UDjlWrocnF1Mp3dCQVP7+yZrWFUNLQm4aAJUQv072th 6SQG+pCDj8VYU5SiyR23G0Gckho+Wy3EopSiPcAyjfv4cKianHndF3qJUertMo5wXrHU adG2quuYxUnjBmKs3VKg6+GnVLUeoeeGbZ4qFR55Jf4BoQIWmACDs+gwTWWeQyii50/T vOJxV5XLul9sFhLGiUrAq6uq2beU3ZoeTUUUs29TNq6Cus4TqmFK+D8hCcJWsCwmXX1x EMEOxPRihFbFXfyjgduLD5E0EMtO0tSxa/xmHGf1z6QLLzktAA1ZC/LQWgvmrtmGg7TR AuQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature:arc-authentication-results; bh=LBW7afYNMkxKtbrimk2qcuxPVidmG6njsb0NHs8pj04=; b=S5fb1587IyMLMeO6wXlpYQdPRN93oT17zbDzza8J37AUZx2uz+zwQnTYHOxUNW1olg vBZhbfpDr9qu7GJlBOGSOvlGrJCADnCxH2tU9+nqmU0sfiPoaxothfk0MtWxDxRPyYe1 8kkaHmHaXk4JyfXJzjZu7aLN0B0uRfD+ZnwtcqGp3PX+jnl81+BS4eJuZXF2pOKMD//u I1Lfun4YHLAP4Ey42s6F//g+TMXlr6SZPoPO8+S4IT0uU+ZqM+sKUGV709lgFUJ2GoDE ZYpZ/MoINKTvmEgDhisRUAkyQaCqa1CDvKHR8lwrr0m912heaUyL9QXplPn3GlGO48kO qZQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=selector1 header.b=EodNQRqU; 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=pass (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a92si16879949pla.28.2017.11.14.12.45.39; Tue, 14 Nov 2017 12:45:51 -0800 (PST) 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; dkim=pass header.i=@virtuozzo.com header.s=selector1 header.b=EodNQRqU; 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=pass (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756632AbdKNUoj (ORCPT + 88 others); Tue, 14 Nov 2017 15:44:39 -0500 Received: from mail-ve1eur01on0101.outbound.protection.outlook.com ([104.47.1.101]:56512 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755236AbdKNUo3 (ORCPT ); Tue, 14 Nov 2017 15:44:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=LBW7afYNMkxKtbrimk2qcuxPVidmG6njsb0NHs8pj04=; b=EodNQRqUJIKmapbQFmWmbqC4htFPNR/zEazaxRYqHd/dvsReM6vcbbOAOvjHrmUgcJvKyKUVHFsh0eXo8P75DsGqkgptApUr2SItKfzRd643jBRZf/f6tqO/G0USpdIaGNx6yUuvP7vcq7n+dzHvZH5JtoZnFufqQvz1OqWUCAQ= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=ktkhai@virtuozzo.com; Received: from localhost.localdomain (89.178.236.212) by VI1PR0801MB1343.eurprd08.prod.outlook.com (2603:10a6:800:3b::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.218.12; Tue, 14 Nov 2017 20:43:53 +0000 Subject: Re: [PATCH] net: Convert net_mutex into rw_semaphore and down read it on net->init/->exit To: Andrei Vagin Cc: davem@davemloft.net, vyasevic@redhat.com, kstewart@linuxfoundation.org, pombredanne@nexb.com, vyasevich@gmail.com, mark.rutland@arm.com, gregkh@linuxfoundation.org, adobriyan@gmail.com, fw@strlen.de, nicolas.dichtel@6wind.com, xiyou.wangcong@gmail.com, roman.kapl@sysgo.com, paul@paul-moore.com, dsahern@gmail.com, daniel@iogearbox.net, lucien.xin@gmail.com, mschiffer@universe-factory.net, rshearma@brocade.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, ebiederm@xmission.com, gorcunov@virtuozzo.com References: <151066759055.14465.9783879083192000862.stgit@localhost.localdomain> <20171114174454.GA11452@outlook.office365.com> <20171114183826.GB11452@outlook.office365.com> From: Kirill Tkhai Message-ID: Date: Tue, 14 Nov 2017 23:43:28 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20171114183826.GB11452@outlook.office365.com> Content-Type: text/plain; charset=koi8-r Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [89.178.236.212] X-ClientProxiedBy: HE1PR0202CA0001.eurprd02.prod.outlook.com (2603:10a6:3:8c::11) To VI1PR0801MB1343.eurprd08.prod.outlook.com (2603:10a6:800:3b::7) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 550cff2c-3de5-4fc7-7aad-08d52ba07d4c X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(2017052603199);SRVR:VI1PR0801MB1343; X-Microsoft-Exchange-Diagnostics: 1;VI1PR0801MB1343;3:VVSb9fiJuhcxgj1rWPYkZ3a8yC9e7MxB5/ucBmFJuonKBdJVKlYqlQrJ/8xSir3uG3iZg3EsIAOtCohFxyYl/7iXFo7R0Ibcbuv6dDok1mMhmDX1F6zYBsozaJWDkqAX/QvmqFZVUCBq+0yJACTfilutWcSarZMhWM10hbiYSi0/w4eNXGuUKR7di0yhM9XhUZL5V/HaH2Dv2q8QvjCCz5OaqSFtv9AarQIIBWNqKtvHUSki5hEvlCtFEJ7kraQf;25:P71J6R0f2RkSg3E3963oUc1v46f6EvEYrbqIc/D1p/PP49Dsxi92Alw1QXe7E57iOFzIuAteoIL9e+m4jTScuzXYmb7Qn/hypKvXB/1MUmnE1HOSRKA5p0AdCj/RmzHWXBkWybKhM1IQN6Qc8JdczsBMdT8st25K4jR2l22yFQI1HxMCjszrIkZzvw/fzs8RLA3guhwoLhrAGK1l4ZHpMzHExWrmX3LfSEEWflTo9KtgjnASDI4hQJvItlycn4zrdqw78TXm9ntOowQAh/smsb9AoJiuf5BOZ+gDJOc0cgGxxXTzX96S/YILWFbF99vtfi+85BpokJVrXvZEOY3VPw==;31:fAexoT8l57GITS//RAHyrFene90IjfGElgqZrR/Smg12C4GOX1KsYZ2xnq6FIsS0fC9yK518lbzddeKXFZnv0fbvS5Ttd3hVoTJQDh/S632Dm8kTiWXZquEjuWBXFsXc6ms7P1Vzd4lxN+NfymJ+NMRro8kk80bs8kBU3Tjft3iz2j6vhHr54YSYorfby18grzD8C5CR7WOSFRwrlIqWzUq27LSfS2C0G8tODGiAkFQ= X-MS-TrafficTypeDiagnostic: VI1PR0801MB1343: X-Microsoft-Exchange-Diagnostics: 1;VI1PR0801MB1343;20:qIyEGESY7xWNOxPd/bkEk6qWbKw/7lm6sOzI7LArjkmGvjt/qxUWbA9HhdXtmlXjj8GQ2bV+zT8TpOMFwT3Guprryw2A4ce51Jbl98mMGxUjhroEfT63vn+F2EnLLFhZkgAThK0Blw5/5jFVY0nDLT+sKQ/sbWOThbPMCCWPuU9qMvNv2GIm47KZ3whzeJcRCJa75oh9ie36puA0+zprfnPEyO6jqNrN2N+AlAn8tVpPND+I1KTqsYV7RR3sIP/Un9XvuCpHpGPYr8PkhR4TJvx9ooEolUNYKLP2NKS44t1OOFNJi3kSQR9uMyeJZ8ANTApiqNWT/A/aQtgTD5NC6eTsgP9CT9dYsu511IBpQ6lwrxJGDkQRjOYSno5rbuTxoHSddNoKAFMKX/TswsTbzVUBGAb18LU8CIIA0fJI07s=;4:WHme+2c0DzTGs3xDLmxW1YBjEbz2myf1Llh6pDQvfy+/sLV00vwpdCPanwTpNRLIHX09QEycLGepeOw5m1J6/ddfBu+n0j0buZwjOKI1GfZc0fN1P+GGUkJsewEGwdDPW7oDT19cSedPSF6+dR+eWouWGFilweqj2ElAuUn9Y/+aum+CKtr2ugeaz9xVjKxGbw2NJ0WvQbIuvPMuNbsvzif0u+dG1gilJJHXmgFD19NReJeq64BajSPzTllxp0kZHnD3vpDipy+WjRDgjHHXlQ== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(5005006)(8121501046)(100000703101)(100105400095)(93006095)(93001095)(10201501046)(3231022)(3002001)(6041248)(20161123558100)(20161123562025)(20161123560025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:VI1PR0801MB1343;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:VI1PR0801MB1343; X-Forefront-PRVS: 04916EA04C X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6009001)(6069001)(346002)(376002)(24454002)(189002)(199003)(52314003)(65826007)(83506002)(53546010)(64126003)(230700001)(478600001)(6116002)(16526018)(93886005)(47776003)(106356001)(66066001)(65956001)(65806001)(105586002)(316002)(25786009)(966005)(86362001)(2906002)(58126008)(7416002)(97736004)(3846002)(31696002)(39060400002)(101416001)(107886003)(6512007)(6862004)(37006003)(81156014)(81166006)(53936002)(229853002)(6506006)(50986999)(54356999)(76176999)(2950100002)(6306002)(6486002)(68736007)(23686003)(6246003)(33646002)(31686004)(7736002)(4326008)(50466002)(305945005)(6666003)(8676002)(189998001)(36756003)(6636002)(8936002)(5660300001);DIR:OUT;SFP:1102;SCL:1;SRVR:VI1PR0801MB1343;H:localhost.localdomain;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; Received-SPF: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?koi8-r?Q?1;VI1PR0801MB1343;23:qAOEQc5MikbS5kHpWYwQJzAYCkIOrtJWFAaZGoN9n?= =?koi8-r?Q?kLb5YRAe3LKwC8TJcUgBBDFmdx2ZiEg7QLbpeQlhwUzCeUGtPEvCIObBgkpKZo?= =?koi8-r?Q?p9PhNsEFI95Er7KV+l+uIqXvvT1tWo/Uj1HCZi6g1dUgMh+O7AUgcNr7eucLQ3?= =?koi8-r?Q?oQol3O3+vxXlavLBaXn0okYN/Om9GwnP7eF5Sg7g/TStww/jbPJFq9OGacDcCO?= =?koi8-r?Q?DZi+a33ogacI5YyG8njUGgATzD2F0B/2uKd2CoxuJfGt6aY3LM7BWeZcEnvl1L?= =?koi8-r?Q?Gzrqgp9TXQ6kJpPFV9YJFqUu14fkc8SYL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rvZZoY7PiFbgGdrP6RjQYgeSN3VZyydsEBtKDglitGAmtno92gcA6lp+fwVTGFHhmdP56nn1pw9VKiLlvHoBVh/B420eeIUTt0tRuHkevFrqO7ODRfbJWhLO5/h9+5ZNd6sIZR0BSascv2hasMPJ/HOX+c109fYdpU6xHJVYfbWAFj/8wIQkmdlZUszI/dgFaJNqooykjiCKio5d8vh4LeYgOudaG/NG4aOFrsFAnb8n SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;VI1PR0801MB1343;20:4EZZdOm6G+2sMyO6yfTKrG2FxgtmwUtWhIf5TCXvi95YKpQ10vc24Co/v3bn7d0NZIftkZacxB33zv9wFA03G52/R65z6EvwtnuIPKupKNtnQqT01sszTf31A5KL4XLeYw6mYT71hGa78sr+LWRjWNzJjlot0xuxvung/RUBayw= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2017 20:43:53.4084 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 550cff2c-3de5-4fc7-7aad-08d52ba07d4c X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0801MB1343 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 14.11.2017 21:38, Andrei Vagin wrote: > On Tue, Nov 14, 2017 at 09:04:06PM +0300, Kirill Tkhai wrote: >> On 14.11.2017 20:44, Andrei Vagin wrote: >>> On Tue, Nov 14, 2017 at 04:53:33PM +0300, Kirill Tkhai wrote: >>>> Curently mutex is used to protect pernet operations list. It makes >>>> cleanup_net() to execute ->exit methods of the same operations set, >>>> which was used on the time of ->init, even after net namespace is >>>> unlinked from net_namespace_list. >>>> >>>> But the problem is it's need to synchronize_rcu() after net is removed >>>> from net_namespace_list(): >>>> >>>> Destroy net_ns: >>>> cleanup_net() >>>> mutex_lock(&net_mutex) >>>> list_del_rcu(&net->list) >>>> synchronize_rcu() <--- Sleep there for ages >>>> list_for_each_entry_reverse(ops, &pernet_list, list) >>>> ops_exit_list(ops, &net_exit_list) >>>> list_for_each_entry_reverse(ops, &pernet_list, list) >>>> ops_free_list(ops, &net_exit_list) >>>> mutex_unlock(&net_mutex) >>>> >>>> This primitive is not fast, especially on the systems with many processors >>>> and/or when preemptible RCU is enabled in config. So, all the time, while >>>> cleanup_net() is waiting for RCU grace period, creation of new net namespaces >>>> is not possible, the tasks, who makes it, are sleeping on the same mutex: >>>> >>>> Create net_ns: >>>> copy_net_ns() >>>> mutex_lock_killable(&net_mutex) <--- Sleep there for ages >>>> >>>> The solution is to convert net_mutex to the rw_semaphore. Then, >>>> pernet_operations::init/::exit methods, modifying the net-related data, >>>> will require down_read() locking only, while down_write() will be used >>>> for changing pernet_list. >>>> >>>> This gives signify performance increase, like you may see below. There >>>> is measured sequential net namespace creation in a cycle, in single >>>> thread, without other tasks (single user mode): >>>> >>>> 1)int main(int argc, char *argv[]) >>>> { >>>> unsigned nr; >>>> if (argc < 2) { >>>> fprintf(stderr, "Provide nr iterations arg\n"); >>>> return 1; >>>> } >>>> nr = atoi(argv[1]); >>>> while (nr-- > 0) { >>>> if (unshare(CLONE_NEWNET)) { >>>> perror("Can't unshare"); >>>> return 1; >>>> } >>>> } >>>> return 0; >>>> } >>>> >>>> Origin, 100000 unshare(): >>>> 0.03user 23.14system 1:39.85elapsed 23%CPU >>>> >>>> Patched, 100000 unshare(): >>>> 0.03user 67.49system 1:08.34elapsed 98%CPU >>>> >>>> 2)for i in {1..10000}; do unshare -n bash -c exit; done >>> >>> Hi Kirill, >>> >>> This mutex has another role. You know that net namespaces are destroyed >>> asynchronously, and the net mutex gurantees that a backlog will be not >>> big. If we have something in backlog, we know that it will be handled >>> before creating a new net ns. >>> >>> As far as I remember net namespaces are created much faster than >>> they are destroyed, so with this changes we can create a really big >>> backlog, can't we? >> >> I don't think limitation is a good goal or a gool for the mutex, >> because it's very easy to create many net namespaces in case of >> the mutex exists. You may open /proc/[pid]/ns/net like a file, >> and net_ns counter will increment. Then, do unshare(), and >> the mutex has no a way to protect against that. > > You are right, but with the mutex a user can not support a big backlog > for a long time, it is shrunk to zero periodically. With these changes > he can support a big backlog for a long time. > > A big backlog affects other users. If someone creates namespaces, he > probably expects that they will be destroyed for a reasonable time. Here 2 different topics: 1)Limitation. This problem exists in current code, and the patch does not make it worse. If someone wants to limit number of net namespaces per user_ns/cgroup, he should solve it in another way. Mutex does not help there. 2)Speed-up struct net destruction. Many structures in kernel are released via rcu. The only difference of struct net is it has more delayed actions, then task_struct for example. User is not interested in the time, when task_struct is completely destroyed. But I may imagine it's more important for struct net, if (for example) some delayed connections are destroyed from ops->exit(). Are they?! But like in the first paragraph, I think this is not related to the patch, because in the current code you may generate dozen thousands of net namespaces and then destroy them at once. And they will be destroyed for the same long time, and there is additional worse thing, that it won't be possible to create a new one for a long period. So, it's completely unrelated to the patch. > But currently someone else can increase a destroy time to a really big > values. This problem was before your patches, but they may do this > problem worse. The question here is: Should we think about this problem > in the context of these patches? I think we shouldn't, because the main thing in this patch is parallel execution of ops->init() and ->exit() and their safety. I hope people will look at this and nothing will remain hidden. The problem of long time destruction of net namespaces may be solved as next step. As we will be able to destroy them in parallel, we'll implement percpu destroy works and will destroy them much time faster then now. >> Anyway, mutex >> can't limit a number of something in general, I've never seen >> a (good) example in kernel. > > I'm agree with you here. > > >> >> As I see, the real limitation happen in inc_net_namespaces(), >> which is decremented after RCU grace period in cleanup_net(), >> and it has not changed. > > ucount limits are to big to handle this problem. > > >> >>> There was a discussion a few month ago: >>> https://lists.onap.org/pipermail/containers/2016-October/037509.html >>> >>> >>>> >>>> Origin: >>>> real 1m24,190s >>>> user 0m6,225s >>>> sys 0m15,132s >>> >>> Here you measure time of creating and destroying net namespaces. >>> >>>> >>>> Patched: >>>> real 0m18,235s (4.6 times faster) >>>> user 0m4,544s >>>> sys 0m13,796s >>> >>> But here you measure time of crearing namespaces and you know nothing >>> when they will be destroyed. >> >> You're right, and I predict, the sum time, spent on cpu, will remain the same, >> but the think is that now creation and destroying may be executed in parallel. From 1584073418847440915@xxx Tue Nov 14 20:08:54 +0000 2017 X-GM-THRID: 1584049999819820517 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread