From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kirill Tkhai Subject: Re: [PATCH] net: Convert net_mutex into rw_semaphore and down read it on net->init/->exit Date: Tue, 14 Nov 2017 20:25:41 +0300 Message-ID: References: <151066759055.14465.9783879083192000862.stgit@localhost.localdomain> <1510679257.2849.170.camel@edumazet-glaptop3.roam.corp.google.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit 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, avagin@virtuozzo.com, gorcunov@virtuozzo.com To: Eric Dumazet Return-path: In-Reply-To: <1510679257.2849.170.camel@edumazet-glaptop3.roam.corp.google.com> Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org List-Id: netdev.vger.kernel.org On 14.11.2017 20:07, Eric Dumazet wrote: > On Tue, 2017-11-14 at 16:53 +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. >> > ... > >> 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 patch requires commit 76f8507f7a64 "locking/rwsem: Add down_read_killable()" >> from Linus tree (not in net-next yet). > > > Looks great, thanks for doing this. > > I wonder if the down_read_killable() is really needed, maybe a > down_read() would not be blocking the thread too long after this change. I'm afraid there are spin_unlock() or similar actions leading to preempt_enable(), which are made under the mutex/new rw_sem. They may be preempted and leave a cpu for some time. So the possibility to break the wait may be useful in some way...