From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: torvalds <torvalds@osdl.org>
Cc: Jeff Dike <jdike@addtoit.com>,
linux-kernel <linux-kernel@vger.kernel.org>,
David Howells <dhowells@redhat.com>
Subject: Re: [PATCH] uml: fix net_kern workqueue abuse
Date: Fri, 08 Dec 2006 11:45:08 +0100 [thread overview]
Message-ID: <1165574708.32332.16.camel@twins> (raw)
In-Reply-To: <1165573234.32332.15.camel@twins>
Garh, it seems I forgot to finish the subject.
On Fri, 2006-12-08 at 11:20 +0100, Peter Zijlstra wrote:
> fixup the work on stack and exit scope trouble by placing the work_struct in
> the uml_net_private data.
>
> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
> ---
> arch/um/drivers/net_kern.c | 15 +++++++++------
> arch/um/include/net_kern.h | 2 ++
> 2 files changed, 11 insertions(+), 6 deletions(-)
>
> Index: linux-2.6-git/arch/um/drivers/net_kern.c
> ===================================================================
> --- linux-2.6-git.orig/arch/um/drivers/net_kern.c 2006-12-08 10:32:56.000000000 +0100
> +++ linux-2.6-git/arch/um/drivers/net_kern.c 2006-12-08 11:14:28.000000000 +0100
> @@ -72,9 +72,11 @@ static int uml_net_rx(struct net_device
> return pkt_len;
> }
>
> -static void uml_dev_close(void* dev)
> +static void uml_dev_close(struct work_struct *work)
> {
> - dev_close( (struct net_device *) dev);
> + struct uml_net_private *lp =
> + container_of(work, struct uml_net_private, work);
> + dev_close(lp->dev);
> }
>
> irqreturn_t uml_net_interrupt(int irq, void *dev_id)
> @@ -89,7 +91,6 @@ irqreturn_t uml_net_interrupt(int irq, v
> spin_lock(&lp->lock);
> while((err = uml_net_rx(dev)) > 0) ;
> if(err < 0) {
> - DECLARE_WORK(close_work, uml_dev_close, dev);
> printk(KERN_ERR
> "Device '%s' read returned %d, shutting it down\n",
> dev->name, err);
> @@ -97,9 +98,10 @@ irqreturn_t uml_net_interrupt(int irq, v
> * again lp->lock.
> * And dev_close() can be safely called multiple times on the
> * same device, since it tests for (dev->flags & IFF_UP). So
> - * there's no harm in delaying the device shutdown. */
> - schedule_work(&close_work);
> -#error this is not permitted - close_work will go out of scope
> + * there's no harm in delaying the device shutdown.
> + * Furthermore, the workqueue will not re-enqueue an already
> + * enqueued work item. */
> + schedule_work(&lp->work);
> goto out;
> }
> reactivate_fd(lp->fd, UM_ETH_IRQ);
> @@ -366,6 +368,7 @@ static int eth_configure(int n, void *in
> /* This points to the transport private data. It's still clear, but we
> * must memset it to 0 *now*. Let's help the drivers. */
> memset(lp, 0, size);
> + INIT_WORK(&lp->work, uml_dev_close);
>
> /* sysfs register */
> if (!driver_registered) {
> Index: linux-2.6-git/arch/um/include/net_kern.h
> ===================================================================
> --- linux-2.6-git.orig/arch/um/include/net_kern.h 2006-12-08 10:55:25.000000000 +0100
> +++ linux-2.6-git/arch/um/include/net_kern.h 2006-12-08 11:00:26.000000000 +0100
> @@ -11,6 +11,7 @@
> #include <linux/skbuff.h>
> #include <linux/socket.h>
> #include <linux/list.h>
> +#include <linux/workqueue.h>
>
> struct uml_net {
> struct list_head list;
> @@ -26,6 +27,7 @@ struct uml_net_private {
> struct net_device *dev;
> struct timer_list tl;
> struct net_device_stats stats;
> + struct work_struct work;
> int fd;
> unsigned char mac[ETH_ALEN];
> unsigned short (*protocol)(struct sk_buff *);
>
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
next prev parent reply other threads:[~2006-12-08 10:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-12-08 10:20 [PATCH] uml: Peter Zijlstra
2006-12-08 10:45 ` Peter Zijlstra [this message]
2006-12-08 16:36 ` Jeff Dike
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1165574708.32332.16.camel@twins \
--to=a.p.zijlstra@chello.nl \
--cc=dhowells@redhat.com \
--cc=jdike@addtoit.com \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@osdl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox