From: "Satyam Sharma" <satyam.sharma@gmail.com>
To: "Jeff Layton" <jlayton@redhat.com>
Cc: "Herbert Xu" <herbert@gondor.apana.org.au>,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
"Eric W. Biederman" <ebiederm@xmission.com>,
"Oleg Nesterov" <oleg@tv-sign.ru>
Subject: Re: [PATCH] RFC: have tcp_recvmsg() check kthread_should_stop() and treat it as if it were signalled
Date: Tue, 26 Jun 2007 01:11:20 +0530 [thread overview]
Message-ID: <a781481a0706251241n36126456x7f4b445a86d1a68f@mail.gmail.com> (raw)
In-Reply-To: <20070609070826.7bd3480c.jlayton@redhat.com>
Hi,
On 6/9/07, Jeff Layton <jlayton@redhat.com> wrote:
> On Sat, 09 Jun 2007 11:30:04 +1000
> Herbert Xu <herbert@gondor.apana.org.au> wrote:
>
> > Please cc networking patches to netdev@vger.kernel.org.
> >
> > Jeff Layton <jlayton@redhat.com> wrote:
> > >
> > > The following patch is a first stab at removing this need. It makes it
> > > so that in tcp_recvmsg() we also check kthread_should_stop() at any
> > > point where we currently check to see if the task was signalled. If
> > > that returns true, then it acts as if it were signalled and returns to
> > > the calling function.
I got bit by the same thing when I was implementing a kthread that sleeps
on skb_recv_datagram() (=> wait_for_packet) with noblock = 0 over a netlink
socket. I need to use the same SIGKILL hack before kthread_stop() to ensure
the kthread does wake up *and* unblock from skb_recv_datagram() when the
module is being unloaded. Searched hard, but just couldn't find a prettier
solution (if someone knows, please let me know).
> > This just doesn't seem to fit. Why should networking care about kthreads?
I agree.
> > Perhaps you can get kthread_stop to send a signal instead?
Yes, why not embed a send_sig(SIGKILL) just before the wake_up_process()
in kthread_stop() itself?
Looking at some happily out-of-date comments in the kthread code, I can
guess that at some point of time (perhaps very early drafts) Rusty actually
*did* implement the whole kthread_stop() functionality using signals, but
I suspect it might've been discarded and the kthread_stop_info approach
used instead to protect from spurious signals from userspace. (?)
So could we have signals in _addition_ to kthread_stop_info and change
kthread_should_stop() to check for both:
kthread_stop_info.k == current && signal_pending(current)
If !kthread_should_stop() && signal_pending(current) => spurious signal,
so just flush and discard (in the kthread).
> The problem there is that we still have to make the kthread let signals
> through. The nice thing about this approach is that we can make the
> kthread ignore signals, but still allow it to break out of kernel_recvmsg
> when a kthread_stop is done.
Why is it wrong for kthreads to let signals through? We can ignore out
all signals we're not interested in, and flush the spurious ones ...
otherwise there really isn't much those kthreads can do that get blocked
in such functions, is there?
Satyam
next prev parent reply other threads:[~2007-06-25 19:41 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20070605152340.f09fa6f2.jlayton@redhat.com>
[not found] ` <20070606085550.GA7351@infradead.org>
2007-06-08 16:35 ` Jeff Layton
2007-06-09 1:30 ` Herbert Xu
2007-06-09 11:08 ` Jeff Layton
2007-06-25 19:41 ` Satyam Sharma [this message]
2007-06-25 19:52 ` Jeff Layton
2007-06-25 22:09 ` Satyam Sharma
2007-06-26 0:46 ` Jeff Layton
2007-06-26 11:54 ` Oleg Nesterov
2007-06-26 22:53 ` Satyam Sharma
2007-06-27 1:29 ` Satyam Sharma
2007-06-27 12:24 ` Oleg Nesterov
2007-06-28 0:44 ` Satyam Sharma
2007-06-28 14:12 ` Oleg Nesterov
2007-06-28 15:44 ` Satyam Sharma
2007-06-28 16:19 ` Satyam Sharma
2007-06-28 16:24 ` Satyam Sharma
2007-06-28 17:08 ` Oleg Nesterov
2007-06-28 18:41 ` Jeff Layton
2007-06-28 19:22 ` Satyam Sharma
2007-06-21 14:35 ` [linux-cifs-client] Re: [PATCH] CIFS: make cifsd (more) signal-safe Jeff Layton
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=a781481a0706251241n36126456x7f4b445a86d1a68f@mail.gmail.com \
--to=satyam.sharma@gmail.com \
--cc=ebiederm@xmission.com \
--cc=herbert@gondor.apana.org.au \
--cc=jlayton@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=oleg@tv-sign.ru \
/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
all inboxes | Powered by JetHome®