From: stephane eranian <eranian@googlemail.com>
To: Jamie Lokier <jamie@shareable.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
oleg@redhat.com, mingo@elte.hu, linux-kernel@vger.kernel.org,
tglx@linutronix.de, robert.richter@amd.com, paulus@samba.org,
andi@firstfloor.org, mpjohn@us.ibm.com, cel@us.ibm.com,
cjashfor@us.ibm.com, mucci@eecs.utk.edu, terpstra@eecs.utk.edu,
perfmon2-devel@lists.sourceforge.net,
mtk.manpages@googlemail.com, roland@redhat.com
Subject: Re: F_SETOWN_TID: F_SETOWN was thread-specific for a while
Date: Mon, 10 Aug 2009 14:22:56 +0200 [thread overview]
Message-ID: <7c86c4470908100522q44dc1228i315b29d69fc98da3@mail.gmail.com> (raw)
In-Reply-To: <20090809054601.GA26152@shareable.org>
Jamie,
On Sun, Aug 9, 2009 at 7:46 AM, Jamie Lokier<jamie@shareable.org> wrote:
> stephane eranian wrote:
>> As Peter found out, the man page seems to indicate that if you specify a TID
>> instead a PID with F_SETOWN, then the kernel should interpret this as meaning
>> this particular thread, but this is not what is implemented right now.
>
> The behaviour was changed quietly in kernel 2.6.12.
>
> I wrote that part of the man page, and it was true at the time. SIGIO
> signals _were_ thread-specific.
>
I knew at some point this worked because with perfmon we managed
to get signals delivered to the right thread. But I guess it was just
until 2.6.12 ;-<
> Starting in kernel 2.5.60, SIGIO signals were thread-specific when
> F_SETSIG was used to enable queued siginfo.
>
Thank you for bringing up F_SETSIG. I use it in some of my test programs.
I thought it was related to the shared vs. private queue. But I looked at it
again, and in fact it is related to another yet important issue when
sampling.
You must use F_SETSIG on SIGIO if you want your signal handler to
receive the file descriptor in siginfo. This is useful if you want to perform
some actions on the descriptor. That is the case in perfmon and this is
the case in certain situations with perfcounters as well.
Setting SA_SIGINFO provides siginfo, but the si_fd field is NOT set
correctly without F_SETSIG. I have verified this with perfcounters, and
this is indeed the case.
This behavior seems kind of odd to me. I think it may be a "lucky" side
effect of the intended behavior of F_SETSIG. It would be good to clarify
this point more.
> Prompted by this F_SETOWN_TID patch, I checked through old kernel
> patches, and found that signals set by F_SIGSIG were changed to
> process-wide in 2.6.12:
>
> @@ -437,7 +438,7 @@ static void send_sigio_to_task(struct ta
> else
> si.si_band = band_table[reason - POLL_IN];
> si.si_fd = fd;
> - if (!send_sig_info(fown->signum, &si, p))
> + if (!send_group_sig_info(fown->signum, &si, p))
> break;
> /* fall-through: fall back on the old plain SIGIO signal */
> case 0:
>
> That's a bit annoying, because it breaks a library which uses queued
> I/O signals as an I/O event mechanism when used with multiple threads.
> (Fortunatelly epoll is available nowadays; it does I/O events much
> better, but sometimes you want SIGIO from epoll's descriptor...)
>
> So the man page is now incorrect, but if F_SETOWN_TID is added and has
> the behaviour which F_SETOWN used to have, then the text can be
> shuffled around.
>
> If anyone is interested, I have a fairly detailed test program which
> checks queued "SIGIO" (F_SETSIG) signals due to I/O on a socket,
> including SIGURG and SIGIO on overflow, and checks whether each one is
> delivered properly and is thread-specific. I found quite a few Glibc
> and kernel bugs with it in the past.
>
> -- Jamie
>
next prev parent reply other threads:[~2009-08-10 12:22 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-27 16:51 perf_counters issue with self-sampling threads stephane eranian
2009-07-27 16:56 ` Peter Zijlstra
2009-07-27 21:25 ` Andi Kleen
[not found] ` <7c86c4470907272213w2ee57080re50dd22a4d73a7e0@mail.gmail.com>
2009-07-28 8:51 ` stephane eranian
2009-07-28 8:56 ` Andi Kleen
2009-07-28 9:13 ` stephane eranian
2009-08-04 16:09 ` stephane eranian
2009-07-29 12:19 ` Peter Zijlstra
2009-07-29 12:37 ` stephane eranian
2009-07-29 12:46 ` Peter Zijlstra
2009-07-29 22:17 ` Oleg Nesterov
2009-07-30 11:31 ` Peter Zijlstra
2009-07-30 19:20 ` Oleg Nesterov
2009-07-30 20:00 ` Peter Zijlstra
2009-07-30 20:28 ` Oleg Nesterov
2009-07-30 21:09 ` stephane eranian
2009-07-31 8:35 ` [RFC][PATCH] fcntl: F_[SG]ETOWN_TID Peter Zijlstra
2009-07-31 14:01 ` stephane eranian
2009-07-31 20:52 ` Oleg Nesterov
2009-07-31 21:11 ` Andrew Morton
2009-08-01 1:27 ` [PATCH 0/2] send_sigio/do_send_sig_info (Was: [RFC][PATCH] fcntl: F_[SG]ETOWN_TID) Oleg Nesterov
2009-08-03 15:48 ` [PATCH 3/2] fcntl: F_[SG]ETOWN_TID Peter Zijlstra
2009-08-03 17:16 ` Oleg Nesterov
2009-08-03 17:47 ` Peter Zijlstra
2009-08-03 18:06 ` Oleg Nesterov
2009-08-03 18:36 ` Peter Zijlstra
2009-08-03 19:02 ` Oleg Nesterov
2009-08-04 11:39 ` [PATCH 3/2 -v3] fcntl: F_[SG]ETOWN_EX Peter Zijlstra
2009-08-04 16:20 ` Oleg Nesterov
2009-08-04 16:52 ` Peter Zijlstra
2009-08-04 17:19 ` Oleg Nesterov
2009-08-06 13:14 ` [PATCH 3/2 -v4] " Peter Zijlstra
2009-08-06 19:05 ` Oleg Nesterov
2009-08-07 12:10 ` stephane eranian
2009-08-01 1:28 ` [PATCH 1/2] signals: introduce do_send_sig_info() helper Oleg Nesterov
2009-08-01 1:28 ` [PATCH 2/2] signals: send_sigio: use do_send_sig_info() to avoid check_kill_permission() Oleg Nesterov
2009-08-03 12:53 ` [RFC][PATCH] fcntl: F_[SG]ETOWN_TID stephane eranian
2009-08-09 5:46 ` F_SETOWN_TID: F_SETOWN was thread-specific for a while Jamie Lokier
2009-08-10 12:22 ` stephane eranian [this message]
2009-08-10 17:03 ` Oleg Nesterov
2009-08-10 21:01 ` stephane eranian
2009-08-17 17:16 ` Oleg Nesterov
2009-08-17 17:40 ` Oleg Nesterov
2009-08-17 22:26 ` stephane eranian
2009-08-18 11:45 ` Oleg Nesterov
2009-08-20 10:00 ` stephane eranian
2009-08-11 13:10 ` Jamie Lokier
2009-08-17 17:05 ` Oleg Nesterov
2009-08-03 15:21 ` [RFC][PATCH] fcntl: F_[SG]ETOWN_TID Peter Zijlstra
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=7c86c4470908100522q44dc1228i315b29d69fc98da3@mail.gmail.com \
--to=eranian@googlemail.com \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=andi@firstfloor.org \
--cc=cel@us.ibm.com \
--cc=cjashfor@us.ibm.com \
--cc=eranian@gmail.com \
--cc=jamie@shareable.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mpjohn@us.ibm.com \
--cc=mtk.manpages@googlemail.com \
--cc=mucci@eecs.utk.edu \
--cc=oleg@redhat.com \
--cc=paulus@samba.org \
--cc=perfmon2-devel@lists.sourceforge.net \
--cc=robert.richter@amd.com \
--cc=roland@redhat.com \
--cc=terpstra@eecs.utk.edu \
--cc=tglx@linutronix.de \
/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®