From: NeilBrown <neilb@suse.de>
To: Ingo Molnar <mingo@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Evgeniy Polyakov <zbr@ioremap.net>,
Stephen Smalley <sds@tycho.nsa.gov>,
Alex Williamson <alex.williamson@redhat.com>,
Oleg Nesterov <oleg@redhat.com>,
linux-kernel <linux-kernel@vger.kernel.org>,
kvm <kvm@vger.kernel.org>
Subject: Re: [PATCH] signals: Generate warning when flush_signals() is called from non-kthread context
Date: Sat, 2 May 2015 18:30:01 +1000 [thread overview]
Message-ID: <20150502183001.07eae212@notabene.brown> (raw)
In-Reply-To: <20150501193813.GA2812@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2044 bytes --]
On Fri, 1 May 2015 21:38:13 +0200 Ingo Molnar <mingo@kernel.org> wrote:
> drivers/md/md.c
> drivers/md/raid1.c
> drivers/md/raid5.c
>
> Hm, so I'm not super sure about the flush_signals() in
> raid1.c:make_request() AFAICS we can do direct RAID1 writes in
> raid1_unplug(). That looks unsafe ... I've Cc:-ed Neil.
>
> raid5.c seems safe: raid5_unplug() doesn't create requests directly,
> leaves it all for the mddev kthread.
Both raid1.c and raid5.c call flush_signals() in the make_request function
(in unusual circumstances).
I wanted a uninterruptible wait which didn't add to load-average. That
approach works in kernel threads...
All the calls in md.c are in a kernel thread so safe, but I'd rather have an
explicit "uninterruptible, but no load-average" wait....
I should probably change the make_request code to queue the request
somewhere rather than wait for it to be serviceable.
I'll look into that...
> In any case, it seems to me that the patch below would be justified?
> Totally untested and so. __flush_signals() not affected.
Fine by me - does seem justified.
Thanks,
NeilBrown
>
> Thanks,
>
> Ingo
>
> ---
> kernel/signal.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/kernel/signal.c b/kernel/signal.c
> index d51c5ddd855c..100e30afe5d2 100644
> --- a/kernel/signal.c
> +++ b/kernel/signal.c
> @@ -427,6 +427,10 @@ void flush_signals(struct task_struct *t)
> {
> unsigned long flags;
>
> + /* Only kthreads are allowed to destroy signals: */
> + if (WARN_ON_ONCE(!(current->flags & PF_KTHREAD)))
> + return;
> +
> spin_lock_irqsave(&t->sighand->siglock, flags);
> __flush_signals(t);
> spin_unlock_irqrestore(&t->sighand->siglock, flags);
> --
> 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/
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 811 bytes --]
next prev parent reply other threads:[~2015-05-02 8:30 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-01 17:40 [GIT PULL] VFIO fixes for v4.1-rc2 Alex Williamson
2015-05-01 18:37 ` Linus Torvalds
2015-05-01 18:48 ` Alex Williamson
2015-05-01 20:23 ` Linus Torvalds
2015-05-01 22:03 ` Alex Williamson
2015-05-01 19:38 ` [PATCH] signals: Generate warning when flush_signals() is called from non-kthread context Ingo Molnar
2015-05-02 8:30 ` NeilBrown [this message]
2015-05-02 16:27 ` Linus Torvalds
2015-05-07 12:54 ` Peter Zijlstra
2015-05-04 17:35 ` Oleg Nesterov
2015-05-07 13:33 ` Jiri Kosina
2015-05-07 22:37 ` NeilBrown
2015-05-02 11:56 ` Evgeniy Polyakov
2015-05-02 16:33 ` Richard Weinberger
2015-05-03 17:34 ` Oleg Nesterov
2015-05-04 16:45 ` [PATCH 0/1] signals: don't abuse __flush_signals() in selinux_bprm_committed_creds() Oleg Nesterov
2015-05-04 16:45 ` [PATCH 1/1] " Oleg Nesterov
2015-05-04 19:43 ` Paul Moore
2015-05-06 10:19 ` [PATCH] signals: Generate warning when flush_signals() is called from non-kthread context Ingo Molnar
2015-05-01 20:11 ` [GIT PULL] VFIO fixes for v4.1-rc2 Richard Weinberger
2015-05-01 21:09 ` Richard Weinberger
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=20150502183001.07eae212@notabene.brown \
--to=neilb@suse.de \
--cc=alex.williamson@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=oleg@redhat.com \
--cc=sds@tycho.nsa.gov \
--cc=torvalds@linux-foundation.org \
--cc=zbr@ioremap.net \
/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;
as well as URLs for NNTP newsgroup(s).