public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] 8139too thread termination
@ 2001-10-30  4:25 Robert Kuebel
  2001-10-31  0:11 ` Robert Kuebel
  0 siblings, 1 reply; 5+ messages in thread
From: Robert Kuebel @ 2001-10-30  4:25 UTC (permalink / raw)
  To: torvalds, alan; +Cc: akpm, linux-kernel

this patch stops the 8139too kernel thread from dying on any signal.
now, it will only terminate when the driver is closed.

the patch is agains 2.4.13.

thanks.
rob.

--- drivers/net/8139too.orig.c	Mon Oct 29 22:59:15 2001
+++ drivers/net/8139too.c	Mon Oct 29 23:07:32 2001
@@ -80,6 +80,8 @@
 
 		Kalle Olavi Niemitalo - Wake-on-LAN ioctls
 
+		Robert Kuebel - Save kernel thread from dying on any signal.
+
 	Submitting bug reports:
 
 		"rtl8139-diag -mmmaaavvveefN" output
@@ -616,6 +618,7 @@
 	struct completion thr_exited;
 	u32 rx_config;
 	struct rtl_extra_stats xstats;
+	int time_to_die;
 };
 
 MODULE_AUTHOR ("Jeff Garzik <jgarzik@mandrakesoft.com>");
@@ -1669,7 +1672,13 @@
 			timeout = interruptible_sleep_on_timeout (&tp->thr_wait, timeout);
 		} while (!signal_pending (current) && (timeout > 0));
 
-		if (signal_pending (current))
+		if (signal_pending (current)) {
+			spin_lock_irq(&current->sigmask_lock);
+			flush_signals(current);
+			spin_unlock_irq(&current->sigmask_lock);
+		}
+
+		if (tp->time_to_die)
 			break;
 
 		rtnl_lock ();
@@ -2200,6 +2209,8 @@
 	netif_stop_queue (dev);
 
 	if (tp->thr_pid >= 0) {
+		tp->time_to_die = 1;
+		wmb();
 		ret = kill_proc (tp->thr_pid, SIGTERM, 1);
 		if (ret) {
 			printk (KERN_ERR "%s: unable to signal thread\n", dev->name);

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] 8139too thread termination
  2001-10-30  4:25 [PATCH] 8139too thread termination Robert Kuebel
@ 2001-10-31  0:11 ` Robert Kuebel
  2001-10-31  0:17   ` Andrew Morton
  2001-10-31  0:18   ` Jeff Garzik
  0 siblings, 2 replies; 5+ messages in thread
From: Robert Kuebel @ 2001-10-31  0:11 UTC (permalink / raw)
  To: Robert Kuebel, linux-kernel

ok, i am wondering if i have made a mistake.  this patch will make the
kernel thread die when tp->time_to_die is true.  tp is kmalloc()'ed
inside of alloc_etherdev.  i didn't initialize time_to_die to 0, but
this patch has been working perfectly for me.  am i just lucky or are
kmalloc()'ed regions zero'ed out?  i know there is stuff like
get_zeroed_page(), but i don't think that applies here.  i guess it
doesn't hurt to set the flag to zero myself.

can someone clue me in?

thanks.
rob.

On Mon, Oct 29, 2001 at 11:25:08PM -0500, Robert Kuebel wrote:
> this patch stops the 8139too kernel thread from dying on any signal.
> now, it will only terminate when the driver is closed.
> 
> the patch is agains 2.4.13.
> 
> thanks.
> rob.
> 
> --- drivers/net/8139too.orig.c	Mon Oct 29 22:59:15 2001
> +++ drivers/net/8139too.c	Mon Oct 29 23:07:32 2001
> @@ -80,6 +80,8 @@
>  
>  		Kalle Olavi Niemitalo - Wake-on-LAN ioctls
>  
> +		Robert Kuebel - Save kernel thread from dying on any signal.
> +
>  	Submitting bug reports:
>  
>  		"rtl8139-diag -mmmaaavvveefN" output
> @@ -616,6 +618,7 @@
>  	struct completion thr_exited;
>  	u32 rx_config;
>  	struct rtl_extra_stats xstats;
> +	int time_to_die;
>  };
>  
>  MODULE_AUTHOR ("Jeff Garzik <jgarzik@mandrakesoft.com>");
> @@ -1669,7 +1672,13 @@
>  			timeout = interruptible_sleep_on_timeout (&tp->thr_wait, timeout);
>  		} while (!signal_pending (current) && (timeout > 0));
>  
> -		if (signal_pending (current))
> +		if (signal_pending (current)) {
> +			spin_lock_irq(&current->sigmask_lock);
> +			flush_signals(current);
> +			spin_unlock_irq(&current->sigmask_lock);
> +		}
> +
> +		if (tp->time_to_die)
>  			break;
>  
>  		rtnl_lock ();
> @@ -2200,6 +2209,8 @@
>  	netif_stop_queue (dev);
>  
>  	if (tp->thr_pid >= 0) {
> +		tp->time_to_die = 1;
> +		wmb();
>  		ret = kill_proc (tp->thr_pid, SIGTERM, 1);
>  		if (ret) {
>  			printk (KERN_ERR "%s: unable to signal thread\n", dev->name);

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] 8139too thread termination
  2001-10-31  0:11 ` Robert Kuebel
@ 2001-10-31  0:17   ` Andrew Morton
  2001-10-31  0:18   ` Jeff Garzik
  1 sibling, 0 replies; 5+ messages in thread
From: Andrew Morton @ 2001-10-31  0:17 UTC (permalink / raw)
  To: Robert Kuebel; +Cc: linux-kernel

Robert Kuebel wrote:
> 
> ok, i am wondering if i have made a mistake.  this patch will make the
> kernel thread die when tp->time_to_die is true.  tp is kmalloc()'ed
> inside of alloc_etherdev.  i didn't initialize time_to_die to 0, but
> this patch has been working perfectly for me.  am i just lucky or are
> kmalloc()'ed regions zero'ed out?  i know there is stuff like
> get_zeroed_page(), but i don't think that applies here.  i guess it
> doesn't hurt to set the flag to zero myself.
> 

alloc_etherdev->alloc_netdev->memset(dev, 0, alloc_size);

It was zeroed for you.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] 8139too thread termination
  2001-10-31  0:11 ` Robert Kuebel
  2001-10-31  0:17   ` Andrew Morton
@ 2001-10-31  0:18   ` Jeff Garzik
  2001-10-31  0:30     ` Robert Kuebel
  1 sibling, 1 reply; 5+ messages in thread
From: Jeff Garzik @ 2001-10-31  0:18 UTC (permalink / raw)
  To: Robert Kuebel; +Cc: linux-kernel

Robert Kuebel wrote:
> 
> ok, i am wondering if i have made a mistake.  this patch will make the
> kernel thread die when tp->time_to_die is true.  tp is kmalloc()'ed
> inside of alloc_etherdev.  i didn't initialize time_to_die to 0, but
> this patch has been working perfectly for me.  am i just lucky or are
> kmalloc()'ed regions zero'ed out?

And here I thought you did it on purpose :)

alloc_etherdev zeroes memory it allocates, so in net drivers all private
structures can be considered initialized to zero when you get them.

	Jeff


-- 
Jeff Garzik      | Only so many songs can be sung
Building 1024    | with two lips, two lungs, and one tongue.
MandrakeSoft     |         - nomeansno


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] 8139too thread termination
  2001-10-31  0:18   ` Jeff Garzik
@ 2001-10-31  0:30     ` Robert Kuebel
  0 siblings, 0 replies; 5+ messages in thread
From: Robert Kuebel @ 2001-10-31  0:30 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: linux-kernel

i was so wrapped up in digging through kmalloc(), that i missed the
memset() in alloc_netdev().  duh!

On Tue, Oct 30, 2001 at 07:18:50PM -0500, Jeff Garzik wrote:
> Robert Kuebel wrote:
> > 
> > ok, i am wondering if i have made a mistake.  this patch will make the
> > kernel thread die when tp->time_to_die is true.  tp is kmalloc()'ed
> > inside of alloc_etherdev.  i didn't initialize time_to_die to 0, but
> > this patch has been working perfectly for me.  am i just lucky or are
> > kmalloc()'ed regions zero'ed out?
> 
> And here I thought you did it on purpose :)
> 
> alloc_etherdev zeroes memory it allocates, so in net drivers all private
> structures can be considered initialized to zero when you get them.
> 
> 	Jeff
> 
> 
> -- 
> Jeff Garzik      | Only so many songs can be sung
> Building 1024    | with two lips, two lungs, and one tongue.
> MandrakeSoft     |         - nomeansno

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2001-10-31  0:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-10-30  4:25 [PATCH] 8139too thread termination Robert Kuebel
2001-10-31  0:11 ` Robert Kuebel
2001-10-31  0:17   ` Andrew Morton
2001-10-31  0:18   ` Jeff Garzik
2001-10-31  0:30     ` Robert Kuebel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox