make netns cleanup to run in a separate workqueue
Subsystems (2)
PATCH 1/1 make netns cleanup to run in a separate workqueue
Subject: make netns cleanup to run in a separate queue
From: Benjamin Thery <[email protected]>
This patch adds a separate workqueue for cleaning up a network namespace. If we use the keventd workqueue to execute cleanup_net(), there is a problem to unregister devices in IPv6. Indeed the code that cleans up also schedule work in keventd: as long as cleanup_net() hasn't return, dst_gc_task() cannot run and as long as dst_gc_task() has not run, there are still some references pending on the net devices and cleanup_net() can not unregister and exit the keventd workqueue.
--- net/core/net_namespace.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
net/core/net_namespace.c +8 -1
@@ -58,6 +58,7 @@ out_undo:#ifdef CONFIG_NET_NS static struct kmem_cache *net_cachep; +static struct workqueue_struct *netns_wq;static struct net *net_alloc (void ) {
@@ -149,7 +150,7 @@ void __put_net(struct net *net) {/* Cleanup the network namespace in process context */ INIT_WORK (&net->work, cleanup_net); -schedule_work (&net->work); +queue_work (netns_wq, &net->work); }EXPORT_SYMBOL_GPL (__put_net);
@@ -171,7 +172,13 @@ static int __init net_ns_init(void) net_cachep =kmem_cache_create ("net_namespace" ,sizeof (struct net ),SMP_CACHE_BYTES ,SLAB_PANIC ,NULL ); + +/* Create workqueue for cleanup */ + netns_wq =create_singlethread_workqueue ("netns" ); +if (!netns_wq) +panic ("Could not create netns workq" );#endif +mutex_lock (&net_mutex); err =setup_net (&init_net);
A message that is not in the archive (sent off-list or not yet received): 47416909.4000602-NmTC/[email protected]
imho panic() is too much.create_singlethread_workqueue() can fail e.g. due to out of memory...
Thanks,
Kirill
Quoted 62 lines · Daniel Lezcano
Subject: make netns cleanup to run in a separate queue
From: Benjamin Thery <benjamin.thery-6ktuUTfB/[email protected]>This patch adds a separate workqueue for cleaning up a network namespace. If we use the keventd workqueue to execute
cleanup_net(), there is a problem to unregister devices in IPv6. Indeed the code that cleans up also schedule work in keventd: as long ascleanup_net()hasn't return,dst_gc_task()cannot run and as long asdst_gc_task()has not run, there are still some references pending on the net devices andcleanup_net()can not unregister and exit the keventd workqueue.Signed-off-by Daniel Lezcano <dlezcano-NmTC/[email protected]>Acked-by Denis V. Lunev <[email protected]>--- net/core/net_namespace.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)Index:
net-2.6.25/net/core/net_namespace.c
===================================================================net/core/net_namespace.c +8
-2@@ -58,6 +58,7 @@ out_undo:#ifdef CONFIG_NET_NS static struct kmem_cache *net_cachep; +static struct workqueue_struct *netns_wq;static struct net *net_alloc (void ) {@@ -149,7 +150,7 @@ void __put_net(struct net *net) {/* Cleanup the network namespace in process context */ INIT_WORK (&net->work, cleanup_net); -schedule_work (&net->work); +queue_work (netns_wq, &net->work); }EXPORT_SYMBOL_GPL (__put_net);@@ -171,7 +172,13 @@ static int __init net_ns_init(void) net_cachep =kmem_cache_create ("net_namespace" ,sizeof (struct net ),SMP_CACHE_BYTES ,SLAB_PANIC ,NULL ); + +/* Create workqueue for cleanup */ + netns_wq =create_singlethread_workqueue ("netns" ); +if (!netns_wq) +panic ("Could not create netns workq" );#endif +mutex_lock (&net_mutex); err =setup_net (&init_net); ------------------------------------------------------------------------_______________________________________________
Containers mailing list Containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
https://lists.linux-foundation.org/mailman/listinfo/containers
Kirill Korotaev
Acked-byAh, sorry. Didn't notice it's called only on boot.
Quoted 79 lines · Kirill Korotaev
imho
panic()is too much.create_singlethread_workqueue()can fail e.g. due to out of memory...Thanks,
KirillQuoted 57 lines · Daniel Lezcano
Subject: make netns cleanup to run in a separate queue
From: Benjamin Thery <[email protected]>This patch adds a separate workqueue for cleaning up a network namespace. If we use the keventd workqueue to execute
cleanup_net(), there is a problem to unregister devices in IPv6. Indeed the code that cleans up also schedule work in keventd: as long ascleanup_net()hasn't return,dst_gc_task()cannot run and as long asdst_gc_task()has not run, there are still some references pending on the net devices andcleanup_net()can not unregister and exit the keventd workqueue.Signed-off-by Daniel Lezcano <[email protected]>Signed-off-by Benjamin Thery <[email protected]>Acked-by Denis V. Lunev <[email protected]>---
net/core/net_namespace.c| 9 ++++++++-1 file changed, 8 insertions(+), 1 deletion(-)Index:
net-2.6.25/net/core/net_namespace.c
===================================================================net/core/net_namespace.c +8
-1@@ -58,6 +58,7 @@ out_undo:#ifdef CONFIG_NET_NS static struct kmem_cache *net_cachep; +static struct workqueue_struct *netns_wq;static struct net *net_alloc (void ) {@@ -149,7 +150,7 @@ void __put_net(struct net *net) {/* Cleanup the network namespace in process context */ INIT_WORK (&net->work, cleanup_net); -schedule_work (&net->work); +queue_work (netns_wq, &net->work); }EXPORT_SYMBOL_GPL (__put_net);@@ -171,7 +172,13 @@ static int __init net_ns_init(void) net_cachep =kmem_cache_create ("net_namespace" ,sizeof (struct net ),SMP_CACHE_BYTES ,SLAB_PANIC ,NULL ); + +/* Create workqueue for cleanup */ + netns_wq =create_singlethread_workqueue ("netns" ); +if (!netns_wq) +panic ("Could not create netns workq" );#endif +mutex_lock (&net_mutex);err = setup_net(&init_net);Quoted 6 lines
------------------------------------------------------------------------
_______________________________________________
Containers mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/containers_______________________________________________
Containers mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/containers
From: Kirill Korotaev <[email protected]>
Date: Mon, 19 Nov 2007 14:08:49 +0300
Quoted 1 line
Acked-by Kirill Korotaev <[email protected]>
I've applied this patch, thanks everyone.