public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@zip.com.au>
To: Robert Kuebel <kuebelr@email.uc.edu>
Cc: linux-kernel@vger.kernel.org
Subject: Re: 8139too termination
Date: Mon, 29 Oct 2001 15:27:27 -0800	[thread overview]
Message-ID: <3BDDE5DF.71917D8F@zip.com.au> (raw)
In-Reply-To: <20011029181029.A320@cartman>

Robert Kuebel wrote:
> 
> hi,
> 
> i have been getting this message at shutdown ...
> 
> "eth1: unable to signal thread"
> 
> it turns out that 8139too's kernel thread gets killed at shutdown (or
> reboot) when SIGTERM is sent to all processes.  then the network
> shutdown script comes along and takes down the interface.  the driver
> complains ...
> 
> "eth1: unable to signal thread"
> 
> because the thread has already terminated.  the driver currently does
> not block any signals.
> 
> my question is, should 8139too really not block any signals (and allow
> itself to be killed by them)?  isn't it a bad thing to allow a kernel
> thread to be killed accidentally like this?
> 

Yes, I'd agree that the driver should ignore random signals.
The kernel thread should only allow itself to be terminated
via the driver's close() method.

An obvious approach is to change rtl8139_close() to do:

	tp->diediedie = 1;
	wmb();
	ret = kill_proc(...);

and test the flag in rtl8139_thread().

The tricky part is teaching the thread to ignore the
spurious signals - the signal_pending() state needs to be
cleared.  I think flush_signals() is the way to do this.
See context_thread() for an example.

           spin_lock_irq(&curtask->sigmask_lock);
           flush_signals(curtask);
           recalc_sigpending(curtask);
           spin_unlock_irq(&curtask->sigmask_lock);

The recalc_sigpending() here appears to be unnecessary...

The kernel thread in 8139too has certainly been an interesting
learning exercise :)  Using signals and task management in-kernel
is full of pitfalls.  In retrospect, probably it should have used
waitqueues directly.

-

  reply	other threads:[~2001-10-29 23:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-10-29 23:10 8139too termination Robert Kuebel
2001-10-29 23:27 ` Andrew Morton [this message]
2001-10-30  0:08   ` Robert Kuebel
     [not found]     ` <3BDDF4B0.194E132F@zip.com.au>
2001-10-30  0:58       ` Robert Kuebel

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=3BDDE5DF.71917D8F@zip.com.au \
    --to=akpm@zip.com.au \
    --cc=kuebelr@email.uc.edu \
    --cc=linux-kernel@vger.kernel.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