From: Matt Fleming <matt@console-pimps.org>
To: Oleg Nesterov <oleg@redhat.com>
Cc: Tejun Heo <tj@kernel.org>,
linux-kernel@vger.kernel.org,
Thomas Gleixner <tglx@linutronix.de>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
"H. Peter Anvin" <hpa@zytor.com>,
Matt Fleming <matt.fleming@linux.intel.com>
Subject: Re: [RFC][PATCH 5/5] signals: Don't hold shared siglock across signal delivery
Date: Thu, 14 Apr 2011 11:57:50 +0100 [thread overview]
Message-ID: <20110414115750.1a6703b6@mfleming-mobl1.ger.corp.intel.com> (raw)
In-Reply-To: <20110413201219.GB15330@redhat.com>
On Wed, 13 Apr 2011 22:12:19 +0200
Oleg Nesterov <oleg@redhat.com> wrote:
> On 04/05, Matt Fleming wrote:
> >
> > To reduce the contention on the shared siglock this patch pushes the
> > responsibility of acquiring and releasing the shared siglock down into
> > the functions that need it. That way, if we don't call a function that
> > needs to be run under the shared siglock, we can run without acquiring
> > it at all.
>
> This adds new races. And this time I do not even understand the intent.
> I mean, it is not clear to me why this change can really help to speed
> up get_signal_to_deliver().
Again, it's not necessarily speeding up get_signal_to_deliver(), but
rather it's reducing the contention on the shared siglock.
For example, without this patch, if you've got someone sending a signal
to a task group, you can't run get_signal_to_deliver() in parallel
because you'll be waiting for the sending thread to release the shared
siglock. Which, if you were going to dequeue a private signal anyway
and didn't need to access signal->shared_pending, is unnecessary
overhead :-(
As it turns out, the shared siglock protects more than just
signal->shared_pending, so in certain cases you need to acquire it
anyway (like the fatal signal code paths) so this isn't as optimised
as it could be, which is a shame.
> > Note that this does not make signal delivery lockless. A signal must
> > still be dequeued from either the shared or private signal
> > queues. However, in the private signal case we can now get by with
> > just acquiring the per-thread siglock
>
> OK, we can dequeue the signal. But dequeue_signal()->recalc_sigpending()
> becomes even more wrong. We do not hold any lock, we can race with both
> shared/private signal sending.
Yep, this was covered in the previous patch review.
> > Also update tracehook.h to indicate it's not called with siglock held
> > anymore.
>
> Heh. This breaks this tracehook completely ;) OK, nobody cares about
> the out-of-tree users, forget.
I was hoping you'd say that ;-)
> Also. get_signal_to_deliver() does
>
> signr = dequeue_signal(current, ¤t->blocked,
> info);
> ...
>
> ka = &sighand->action[signr-1];
>
> ...
>
> if (ka->sa.sa_handler != SIG_DFL) {
> /* Run the handler. */
> *return_ka = *ka;
>
> This memcpy() can race with sys_rt_sigaction(), we can't read *ka
> atomically.
Eek! I hadn't noticed that. Thanks.
> Actually, even SIG_DFL/SIG_IGN checks can race, although this is minor...
> But still not correct.
>
> if (ka->sa.sa_flags & SA_ONESHOT) {
> write_lock(&sighand->action_lock);
> ka->sa.sa_handler = SIG_DFL;
> write_unlock(&sighand->action_lock);
>
> We should check SA_ONESHOT under ->action_lock. But even then this
> will bw racy, although we can probably ignore this... Suppose that
> SA_ONESHOT was set after we dequeued the signal.
Right, most of this side is wrong wrt to the action_lock.
Thanks Oleg.
--
Matt Fleming, Intel Open Source Technology Center
next prev parent reply other threads:[~2011-04-14 10:57 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-05 19:21 [RFC][PATCH 0/5] Improve signal delivery scalability Matt Fleming
2011-04-05 19:21 ` [RFC][PATCH 1/5] signals: Always place SIGCONT and SIGSTOP on 'shared_pending' Matt Fleming
2011-04-05 20:19 ` Oleg Nesterov
2011-04-05 20:50 ` Matt Fleming
2011-04-06 12:57 ` Oleg Nesterov
2011-04-06 13:09 ` Tejun Heo
2011-04-06 13:30 ` Matt Fleming
2011-04-06 13:15 ` Matt Fleming
2011-04-11 18:50 ` Oleg Nesterov
2011-04-11 19:24 ` Matt Fleming
2011-04-05 19:21 ` [RFC][PATCH 2/5] signals: Introduce per-thread siglock and action rwlock Matt Fleming
2011-04-13 19:42 ` Oleg Nesterov
2011-04-14 10:34 ` Matt Fleming
2011-04-14 19:00 ` Oleg Nesterov
2011-04-16 13:08 ` Matt Fleming
2011-04-18 16:45 ` Oleg Nesterov
2011-04-21 19:03 ` arch/tile/kernel/hardwall.c:do_hardwall_trap unsafe/wrong usage of ->sighand Oleg Nesterov
2011-04-22 13:04 ` Chris Metcalf
2011-04-26 20:36 ` [PATCH 0/1] tile: do_hardwall_trap: do not play with task->sighand Oleg Nesterov
2011-04-26 20:37 ` [PATCH 1/1] " Oleg Nesterov
2011-05-02 22:42 ` Chris Metcalf
2011-04-26 9:46 ` [RFC][PATCH 2/5] signals: Introduce per-thread siglock and action rwlock Matt Fleming
2011-04-05 19:21 ` [RFC][PATCH 3/5] ia64: Catch up with new sighand action spinlock Matt Fleming
2011-04-05 19:21 ` [RFC][PATCH 4/5] signals: Introduce __dequeue_private_signal helper function Matt Fleming
2011-04-05 19:21 ` [RFC][PATCH 5/5] signals: Don't hold shared siglock across signal delivery Matt Fleming
2011-04-13 20:12 ` Oleg Nesterov
2011-04-14 10:57 ` Matt Fleming [this message]
2011-04-14 19:20 ` Oleg Nesterov
2011-04-16 13:27 ` Matt Fleming
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=20110414115750.1a6703b6@mfleming-mobl1.ger.corp.intel.com \
--to=matt@console-pimps.org \
--cc=a.p.zijlstra@chello.nl \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=matt.fleming@linux.intel.com \
--cc=oleg@redhat.com \
--cc=tglx@linutronix.de \
--cc=tj@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
all inboxes | Powered by JetHome®