From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758895AbdKOQbx (ORCPT ); Wed, 15 Nov 2017 11:31:53 -0500 Received: from out03.mta.xmission.com ([166.70.13.233]:38872 "EHLO out03.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758872AbdKOQbl (ORCPT ); Wed, 15 Nov 2017 11:31:41 -0500 From: ebiederm@xmission.com (Eric W. Biederman) To: Kirill Tkhai Cc: Cong Wang , David Miller , vyasevic@redhat.com, kstewart@linuxfoundation.org, pombredanne@nexb.com, Vladislav Yasevich , mark.rutland@arm.com, Greg KH , Alexey Dobriyan , Florian Westphal , Nicolas Dichtel , roman.kapl@sysgo.com, Paul Moore , David Ahern , Daniel Borkmann , lucien xin , Matthias Schiffer , rshearma@brocade.com, LKML , Linux Kernel Network Developers , avagin@virtuozzo.com, gorcunov@virtuozzo.com References: <151066759055.14465.9783879083192000862.stgit@localhost.localdomain> <88152c11-a5b5-90f8-be46-99ed6c722064@virtuozzo.com> <87shdg8bzd.fsf@xmission.com> <8c808278-1925-37c0-619c-87bd1802790a@virtuozzo.com> <06b1d740-d443-ac23-a7b0-675e7b6ff6f9@virtuozzo.com> Date: Wed, 15 Nov 2017 10:31:11 -0600 In-Reply-To: <06b1d740-d443-ac23-a7b0-675e7b6ff6f9@virtuozzo.com> (Kirill Tkhai's message of "Wed, 15 Nov 2017 15:36:34 +0300") Message-ID: <87r2sz33n4.fsf@xmission.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1eF0b7-0002x3-2z;;;mid=<87r2sz33n4.fsf@xmission.com>;;;hst=in01.mta.xmission.com;;;ip=75.170.119.32;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX1/n9A+zp2mdW5ilHT0wgxtF+5Rs5W+Rfss= X-SA-Exim-Connect-IP: 75.170.119.32 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.7 XMSubLong Long Subject * 0.0 TVD_RCVD_IP Message was received from an IP address * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.4976] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa08 1397; Body=1 Fuz1=1 Fuz2=1] * 0.0 T_TooManySym_02 5+ unique symbols in subject * 0.0 T_TooManySym_01 4+ unique symbols in subject * 0.0 T_TooManySym_03 6+ unique symbols in subject X-Spam-DCC: XMission; sa08 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ;Kirill Tkhai X-Spam-Relay-Country: X-Spam-Timing: total 5297 ms - load_scoreonly_sql: 0.03 (0.0%), signal_user_changed: 3.3 (0.1%), b_tie_ro: 2.6 (0.0%), parse: 0.62 (0.0%), extract_message_metadata: 9 (0.2%), get_uri_detail_list: 1.17 (0.0%), tests_pri_-1000: 5 (0.1%), tests_pri_-950: 0.92 (0.0%), tests_pri_-900: 0.76 (0.0%), tests_pri_-400: 27 (0.5%), check_bayes: 26 (0.5%), b_tokenize: 6 (0.1%), b_tok_get_all: 12 (0.2%), b_comp_prob: 1.78 (0.0%), b_tok_touch_all: 3.2 (0.1%), b_finish: 0.57 (0.0%), tests_pri_0: 210 (4.0%), check_dkim_signature: 0.38 (0.0%), check_dkim_adsp: 2.1 (0.0%), tests_pri_500: 5038 (95.1%), poll_dns_idle: 5033 (95.0%), rewrite_mail: 0.00 (0.0%) Subject: Re: [PATCH] net: Convert net_mutex into rw_semaphore and down read it on net->init/->exit X-Spam-Flag: No X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in01.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Kirill Tkhai writes: > On 15.11.2017 12:51, Kirill Tkhai wrote: >> On 15.11.2017 06:19, Eric W. Biederman wrote: >>> Kirill Tkhai writes: >>> >>>> On 14.11.2017 21:39, Cong Wang wrote: >>>>> On Tue, Nov 14, 2017 at 5:53 AM, Kirill Tkhai wrote: >>>>>> @@ -406,7 +406,7 @@ struct net *copy_net_ns(unsigned long flags, >>>>>> >>>>>> get_user_ns(user_ns); >>>>>> >>>>>> - rv = mutex_lock_killable(&net_mutex); >>>>>> + rv = down_read_killable(&net_sem); >>>>>> if (rv < 0) { >>>>>> net_free(net); >>>>>> dec_net_namespaces(ucounts); >>>>>> @@ -421,7 +421,7 @@ struct net *copy_net_ns(unsigned long flags, >>>>>> list_add_tail_rcu(&net->list, &net_namespace_list); >>>>>> rtnl_unlock(); >>>>>> } >>>>>> - mutex_unlock(&net_mutex); >>>>>> + up_read(&net_sem); >>>>>> if (rv < 0) { >>>>>> dec_net_namespaces(ucounts); >>>>>> put_user_ns(user_ns); >>>>>> @@ -446,7 +446,7 @@ static void cleanup_net(struct work_struct *work) >>>>>> list_replace_init(&cleanup_list, &net_kill_list); >>>>>> spin_unlock_irq(&cleanup_list_lock); >>>>>> >>>>>> - mutex_lock(&net_mutex); >>>>>> + down_read(&net_sem); >>>>>> >>>>>> /* Don't let anyone else find us. */ >>>>>> rtnl_lock(); >>>>>> @@ -486,7 +486,7 @@ static void cleanup_net(struct work_struct *work) >>>>>> list_for_each_entry_reverse(ops, &pernet_list, list) >>>>>> ops_free_list(ops, &net_exit_list); >>>>>> >>>>>> - mutex_unlock(&net_mutex); >>>>>> + up_read(&net_sem); >>>>> >>>>> After your patch setup_net() could run concurrently with cleanup_net(), >>>>> given that ops_exit_list() is called on error path of setup_net() too, >>>>> it means ops->exit() now could run concurrently if it doesn't have its >>>>> own lock. Not sure if this breaks any existing user. >>>> >>>> Yes, there will be possible concurrent ops->init() for a net namespace, >>>> and ops->exit() for another one. I hadn't found pernet operations, which >>>> have a problem with that. If they exist, they are hidden and not clear seen. >>>> The pernet operations in general do not touch someone else's memory. >>>> If suddenly there is one, KASAN should show it after a while. >>> >>> Certainly the use of hash tables shared between multiple network >>> namespaces would count. I don't rembmer how many of these we have but >>> there used to be quite a few. >> >> Could you please provide an example of hash tables, you mean? > > Ah, I see, it's dccp_hashinfo etc. The big one used to be the route cache. With resizable hash tables things may be getting better in that regard. Eric