* [PATCH][net-2.6.25][NETNS] make netns cleanup to run in a separate workqueue
@ 2007-11-19 10:44 Daniel Lezcano
[not found] ` <47416909.4000602-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: Daniel Lezcano @ 2007-11-19 10:44 UTC (permalink / raw)
To: David Miller
Cc: Linux Netdev List, Eric W. Biederman, Denis V. Lunev,
Benjamin Thery, Linux Containers
[-- Attachment #1: Type: text/plain, Size: 0 bytes --]
[-- Attachment #2: create-workq-for-the-namespace.patch --]
[-- Type: text/x-patch, Size: 1849 bytes --]
Subject: make netns cleanup to run in a separate queue
From: Benjamin Thery <benjamin.thery@bull.net>
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.
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Signed-off-by: Benjamin Thery <benjamin.thery@bull.net>
Acked-by: Denis V. Lunev <den@openvz.org>
---
net/core/net_namespace.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
Index: net-2.6.25/net/core/net_namespace.c
===================================================================
--- net-2.6.25.orig/net/core/net_namespace.c
+++ net-2.6.25/net/core/net_namespace.c
@@ -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);
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][net-2.6.25][NETNS] make netns cleanup to run in a separate workqueue
[not found] ` <47416909.4000602-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org>
@ 2007-11-19 11:05 ` Kirill Korotaev
2007-11-19 11:08 ` Kirill Korotaev
0 siblings, 1 reply; 4+ messages in thread
From: Kirill Korotaev @ 2007-11-19 11:05 UTC (permalink / raw)
To: Daniel Lezcano
Cc: Linux Netdev List, Eric W. Biederman, Linux Containers,
Denis V. Lunev, David Miller, Benjamin Thery
imho panic() is too much.
create_singlethread_workqueue() can fail e.g. due to out of memory...
Thanks,
Kirill
Daniel Lezcano wrote:
> Subject: make netns cleanup to run in a separate queue
> From: Benjamin Thery <benjamin.thery-6ktuUTfB/bM@public.gmane.org>
>
> 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.
>
> Signed-off-by: Daniel Lezcano <dlezcano-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org>
> Signed-off-by: Benjamin Thery <benjamin.thery-6ktuUTfB/bM@public.gmane.org>
> Acked-by: Denis V. Lunev <den-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
> ---
> net/core/net_namespace.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> Index: net-2.6.25/net/core/net_namespace.c
> ===================================================================
> --- net-2.6.25.orig/net/core/net_namespace.c
> +++ net-2.6.25/net/core/net_namespace.c
> @@ -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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][net-2.6.25][NETNS] make netns cleanup to run in a separate workqueue
2007-11-19 11:05 ` Kirill Korotaev
@ 2007-11-19 11:08 ` Kirill Korotaev
2007-11-20 7:18 ` David Miller
0 siblings, 1 reply; 4+ messages in thread
From: Kirill Korotaev @ 2007-11-19 11:08 UTC (permalink / raw)
To: Kirill Korotaev
Cc: Daniel Lezcano, Linux Netdev List, Eric W. Biederman,
Linux Containers, Denis V. Lunev, David Miller, Benjamin Thery
Ah, sorry. Didn't notice it's called only on boot.
Acked-By: Kirill Korotaev <dev@sw.ru>
Kirill Korotaev wrote:
> imho panic() is too much.
> create_singlethread_workqueue() can fail e.g. due to out of memory...
>
> Thanks,
> Kirill
>
>
> Daniel Lezcano wrote:
>
>>Subject: make netns cleanup to run in a separate queue
>>From: Benjamin Thery <benjamin.thery@bull.net>
>>
>>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.
>>
>>Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
>>Signed-off-by: Benjamin Thery <benjamin.thery@bull.net>
>>Acked-by: Denis V. Lunev <den@openvz.org>
>>---
>> net/core/net_namespace.c | 9 ++++++++-
>> 1 file changed, 8 insertions(+), 1 deletion(-)
>>
>>Index: net-2.6.25/net/core/net_namespace.c
>>===================================================================
>>--- net-2.6.25.orig/net/core/net_namespace.c
>>+++ net-2.6.25/net/core/net_namespace.c
>>@@ -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@lists.linux-foundation.org
>>https://lists.linux-foundation.org/mailman/listinfo/containers
>
>
> _______________________________________________
> Containers mailing list
> Containers@lists.linux-foundation.org
> https://lists.linux-foundation.org/mailman/listinfo/containers
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][net-2.6.25][NETNS] make netns cleanup to run in a separate workqueue
2007-11-19 11:08 ` Kirill Korotaev
@ 2007-11-20 7:18 ` David Miller
0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2007-11-20 7:18 UTC (permalink / raw)
To: dev; +Cc: dlezcano, netdev, ebiederm, containers, den, benjamin.thery
From: Kirill Korotaev <dev@sw.ru>
Date: Mon, 19 Nov 2007 14:08:49 +0300
> Acked-By: Kirill Korotaev <dev@sw.ru>
I've applied this patch, thanks everyone.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-11-20 7:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-19 10:44 [PATCH][net-2.6.25][NETNS] make netns cleanup to run in a separate workqueue Daniel Lezcano
[not found] ` <47416909.4000602-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org>
2007-11-19 11:05 ` Kirill Korotaev
2007-11-19 11:08 ` Kirill Korotaev
2007-11-20 7:18 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).