[Devel] [PATCH RHEL7 COMMIT] net: Kill net_mutex
Konstantin Khorenko
khorenko at virtuozzo.com
Wed May 27 21:35:02 MSK 2020
The commit is pushed to "branch-rh7-3.10.0-1127.8.2.vz7.161.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1127.8.2.vz7.161.3
------>
commit 39fb6f9def2c24896bbec28b039c4c8476c3332a
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date: Wed May 27 21:35:02 2020 +0300
net: Kill net_mutex
ms commit 19efbd93e6fb
We take net_mutex, when there are !async pernet_operations
registered, and read locking of net_sem is not enough. But
we may get rid of taking the mutex, and just change the logic
to write lock net_sem in such cases. This obviously reduces
the number of lock operations, we do.
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
Signed-off-by: David S. Miller <davem at davemloft.net>
[vz7: many intermediate and following patches skipped]
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
=====================
Patchset description:
Parallel per-net init/exit
https://jira.sw.ru/browse/PSBM-104158
---
net/core/net_namespace.c | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index 9827efc52a2e6..c766e74c0fc55 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -31,7 +31,6 @@
static LIST_HEAD(pernet_list);
static struct list_head *first_device = &pernet_list;
-DEFINE_MUTEX(net_mutex);
/*
* net_sem: protects: pernet_list, net_generic_ids,
* init_net_initialized and first_device pointer.
@@ -72,11 +71,10 @@ int net_assign_generic(struct net *net, int id, void *data)
{
struct net_generic *ng, *old_ng;
- BUG_ON(!mutex_is_locked(&net_mutex));
BUG_ON(id == 0);
old_ng = rcu_dereference_protected(net->gen,
- lockdep_is_held(&net_mutex));
+ lockdep_is_held(&net_sem));
ng = old_ng;
if (old_ng->len >= id)
goto assign;
@@ -430,13 +428,7 @@ struct net *copy_net_ns(unsigned long flags,
if (rv < 0)
goto put_userns;
- rv = mutex_lock_killable(&net_mutex);
- if (rv < 0)
- goto up_read;
-
rv = setup_net(net, user_ns);
- mutex_unlock(&net_mutex);
-up_read:
up_read(&net_sem);
if (rv < 0) {
put_userns:
@@ -494,7 +486,6 @@ static void cleanup_net(struct work_struct *work)
spin_unlock_irq(&cleanup_list_lock);
down_read(&net_sem);
- mutex_lock(&net_mutex);
/* Don't let anyone else find us. */
rtnl_lock();
More information about the Devel
mailing list