aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorKirill Tkhai <ktkhai@virtuozzo.com>2018-02-19 04:58:38 -0500
committerDavid S. Miller <davem@davemloft.net>2018-02-20 13:23:13 -0500
commit19efbd93e6fb05eab81856b4fc8d64211dd37088 (patch)
tree92b753425011641fc730a1eda732169350ad6ffd /include
parentffc385b95adb0e601f6858b06401adabedf59f81 (diff)
net: Kill net_mutex
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@virtuozzo.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r--include/linux/rtnetlink.h1
-rw-r--r--include/net/net_namespace.h11
2 files changed, 7 insertions, 5 deletions
diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h
index e9ee9ad0a681..3573b4bf2fdf 100644
--- a/include/linux/rtnetlink.h
+++ b/include/linux/rtnetlink.h
@@ -35,7 +35,6 @@ extern int rtnl_trylock(void);
35extern int rtnl_is_locked(void); 35extern int rtnl_is_locked(void);
36 36
37extern wait_queue_head_t netdev_unregistering_wq; 37extern wait_queue_head_t netdev_unregistering_wq;
38extern struct mutex net_mutex;
39extern struct rw_semaphore net_sem; 38extern struct rw_semaphore net_sem;
40 39
41#ifdef CONFIG_PROVE_LOCKING 40#ifdef CONFIG_PROVE_LOCKING
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
index 9158ec1ad06f..115b01b92f4d 100644
--- a/include/net/net_namespace.h
+++ b/include/net/net_namespace.h
@@ -60,8 +60,11 @@ struct net {
60 60
61 struct list_head list; /* list of network namespaces */ 61 struct list_head list; /* list of network namespaces */
62 struct list_head cleanup_list; /* namespaces on death row */ 62 struct list_head cleanup_list; /* namespaces on death row */
63 struct list_head exit_list; /* Use only net_mutex */ 63 struct list_head exit_list; /* To linked to call pernet exit
64 64 * methods on dead net (net_sem
65 * read locked), or to unregister
66 * pernet ops (net_sem wr locked).
67 */
65 struct user_namespace *user_ns; /* Owning user namespace */ 68 struct user_namespace *user_ns; /* Owning user namespace */
66 struct ucounts *ucounts; 69 struct ucounts *ucounts;
67 spinlock_t nsid_lock; 70 spinlock_t nsid_lock;
@@ -89,7 +92,7 @@ struct net {
89 /* core fib_rules */ 92 /* core fib_rules */
90 struct list_head rules_ops; 93 struct list_head rules_ops;
91 94
92 struct list_head fib_notifier_ops; /* protected by net_mutex */ 95 struct list_head fib_notifier_ops; /* protected by net_sem */
93 96
94 struct net_device *loopback_dev; /* The loopback */ 97 struct net_device *loopback_dev; /* The loopback */
95 struct netns_core core; 98 struct netns_core core;
@@ -316,7 +319,7 @@ struct pernet_operations {
316 /* 319 /*
317 * Indicates above methods are allowed to be executed in parallel 320 * Indicates above methods are allowed to be executed in parallel
318 * with methods of any other pernet_operations, i.e. they are not 321 * with methods of any other pernet_operations, i.e. they are not
319 * need synchronization via net_mutex. 322 * need write locked net_sem.
320 */ 323 */
321 bool async; 324 bool async;
322}; 325};