* [LTP] [PATCH] Fix rt_sigtimedwait ordering test
@ 2011-02-07 14:28 Will Deacon
2011-02-16 16:43 ` Will Deacon
[not found] ` <9151393516569896904@unknownmsgid>
0 siblings, 2 replies; 4+ messages in thread
From: Will Deacon @ 2011-02-07 14:28 UTC (permalink / raw)
To: ltp-list
The rt_sigtimedwait test invokes test_masked_matching_rt, which
spawns two children who send consecutive RT signals to the parent.
The test then checks (via sigwaitinfo) that the RT signals are
delivered in the correct order: namely that the lower signal is taken
first.
This test can fail due to a race condition where the parent issues
the sigwaitinfo syscall before the first child has signalled the
parent but after the second child has (due to context switching).
This results in the signals being received in the reverse order.
This patch inserts waitpid syscalls to the parent thread so that the
sigwaitinfo call is only issued after the children have exited.
Signed-off-by: Will Deacon <will.deacon@arm.com>
---
.../kernel/syscalls/sigwaitinfo/sigwaitinfo01.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c b/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c
index c0e0241..439dfb3 100644
--- a/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c
+++ b/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c
@@ -232,6 +232,7 @@ void test_masked_matching_rt(swi_func sigwaitinfo, int signo)
sigset_t sigs, oldmask;
siginfo_t si;
pid_t child[2];
+ int status;
signo = SIGRTMIN+1;
@@ -250,6 +251,10 @@ void test_masked_matching_rt(swi_func sigwaitinfo, int signo)
child[0]=create_sig_proc(0, signo, 1);
child[1]=create_sig_proc(0, signo+1, 1);
+ /* Ensure that the signals have been sent */
+ waitpid(child[0], &status, 0);
+ waitpid(child[1], &status, 0);
+
TEST(sigwaitinfo(&sigs, &si, NULL));
REPORT_SUCCESS_COND(signo, 0, si.si_pid==child[0] && si.si_code==SI_USER && si.si_signo==signo, "Struct siginfo mismatch");
@@ -434,4 +439,4 @@ int main(int argc, char** argv)
cleanup();
tst_exit();
-}
\ No newline at end of file
+}
--
1.7.0.4
------------------------------------------------------------------------------
The modern datacenter depends on network connectivity to access resources
and provide services. The best practices for maximizing a physical server's
connectivity to a physical network are well understood - see how these
rules translate into the virtual world?
http://p.sf.net/sfu/oracle-sfdevnlfb
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [LTP] [PATCH] Fix rt_sigtimedwait ordering test
2011-02-07 14:28 [LTP] [PATCH] Fix rt_sigtimedwait ordering test Will Deacon
@ 2011-02-16 16:43 ` Will Deacon
[not found] ` <9151393516569896904@unknownmsgid>
1 sibling, 0 replies; 4+ messages in thread
From: Will Deacon @ 2011-02-16 16:43 UTC (permalink / raw)
To: Will Deacon, ltp-list
Hello,
> The rt_sigtimedwait test invokes test_masked_matching_rt, which
> spawns two children who send consecutive RT signals to the parent.
> The test then checks (via sigwaitinfo) that the RT signals are
> delivered in the correct order: namely that the lower signal is taken
> first.
>
> This test can fail due to a race condition where the parent issues
> the sigwaitinfo syscall before the first child has signalled the
> parent but after the second child has (due to context switching).
> This results in the signals being received in the reverse order.
>
> This patch inserts waitpid syscalls to the parent thread so that the
> sigwaitinfo call is only issued after the children have exited.
>
> Signed-off-by: Will Deacon <will.deacon@arm.com>
> ---
> .../kernel/syscalls/sigwaitinfo/sigwaitinfo01.c | 7 ++++++-
> 1 files changed, 6 insertions(+), 1 deletions(-)
I've not heard anything further on this, but it does fix a real issue
on the platform I'm using. Do you need anything more from me for this
to be considered for committing?
Cheers,
Will
------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 4+ messages in thread[parent not found: <9151393516569896904@unknownmsgid>]
* Re: [LTP] [PATCH] Fix rt_sigtimedwait ordering test
[not found] ` <9151393516569896904@unknownmsgid>
@ 2011-02-23 8:02 ` Garrett Cooper
2011-02-25 10:53 ` Will Deacon
0 siblings, 1 reply; 4+ messages in thread
From: Garrett Cooper @ 2011-02-23 8:02 UTC (permalink / raw)
To: Will Deacon; +Cc: ltp-list
qOn Wed, Feb 16, 2011 at 8:43 AM, Will Deacon <will.deacon@arm.com> wrote:
...
> I've not heard anything further on this, but it does fix a real issue
> on the platform I'm using. Do you need anything more from me for this
> to be considered for committing?
Kind of odd that only doing it there would fix the entire testcase
as that's not the only pattern of
create_sig_proc(...)
that isn't handled with a wait/waitpid.
It just seems like there are tons of bugs lurking under the scenes
with this create_sig_proc deal because it doesn't wait, and if the
parent doesn't wait, then you're just creating a ton of races
potentially if not handled properly.
FWIW some more synchronization may need to be added in
create_sig_proc (like blocking I/O with a pipe for instance, mq_*,
sem_*? mq_* and sem_* are kind of undesirable though because those
APIs are buggy on different architectures / versions of Linux, and
pipes are generally simple enough to express synchronization), in
order to ensure that things are deterministically ordered and the
results of the test are sane.
Thanks,
-Garrett
------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in
Real-Time with Splunk. Collect, index and harness all the fast moving IT data
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business
insights. http://p.sf.net/sfu/splunk-dev2dev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [LTP] [PATCH] Fix rt_sigtimedwait ordering test
2011-02-23 8:02 ` Garrett Cooper
@ 2011-02-25 10:53 ` Will Deacon
0 siblings, 0 replies; 4+ messages in thread
From: Will Deacon @ 2011-02-25 10:53 UTC (permalink / raw)
To: 'Garrett Cooper'; +Cc: ltp-list
Hi Garrett,
> > I've not heard anything further on this, but it does fix a real issue
> > on the platform I'm using. Do you need anything more from me for this
> > to be considered for committing?
>
> Kind of odd that only doing it there would fix the entire testcase
> as that's not the only pattern of
>
> create_sig_proc(...)
>
> that isn't handled with a wait/waitpid.
It's not that strange because, in this testcase at least, we call
sigwaitinfo either with a timeout or a sigset_t in the parent. In
the latter case this will block until the signal is delivered so
the race between child and parent isn't a problem.
> It just seems like there are tons of bugs lurking under the scenes
> with this create_sig_proc deal because it doesn't wait, and if the
> parent doesn't wait, then you're just creating a ton of races
> potentially if not handled properly.
The issue is when you have multiple children and the test relies
on a specific ordering of signal delivery (as is the case for RT
signals).
> FWIW some more synchronization may need to be added in
> create_sig_proc (like blocking I/O with a pipe for instance, mq_*,
> sem_*? mq_* and sem_* are kind of undesirable though because those
> APIs are buggy on different architectures / versions of Linux, and
> pipes are generally simple enough to express synchronization), in
> order to ensure that things are deterministically ordered and the
> results of the test are sane.
I'm not sure this is necessary because it restricts the concurrency
for testcases where the race shouldn't matter.
Will
------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in
Real-Time with Splunk. Collect, index and harness all the fast moving IT data
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business
insights. http://p.sf.net/sfu/splunk-dev2dev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-02-25 10:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-07 14:28 [LTP] [PATCH] Fix rt_sigtimedwait ordering test Will Deacon
2011-02-16 16:43 ` Will Deacon
[not found] ` <9151393516569896904@unknownmsgid>
2011-02-23 8:02 ` Garrett Cooper
2011-02-25 10:53 ` Will Deacon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox