public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Caspar Zhang <caspar@casparzhang.com>
To: ltp-list@lists.sourceforge.net
Subject: Re: [LTP] [PATCH] pipeio: prevent race between SIGCHLD and open()
Date: Thu, 15 Dec 2011 11:04:00 +0800	[thread overview]
Message-ID: <4EE963A0.8000902@casparzhang.com> (raw)
In-Reply-To: <4EE8830E.6050804@redhat.com>

On 12/14/2011 07:05 PM, Jan Stancek wrote:
> 
> This test occasionally hangs on some machines. The hang has been
> observed on some single CPU ones.
> 
> pipeio code is using signal(2), setting by default SA_RESTART
> flag, which is also the case for SIGCHLD.
> 
> If last child manages to exit while parent is still at open(),
> parent gets SIGCHLD and open() is restarted. At this point test
> hangs.
> 
> Here's strace output from parent point of view:
> 
> === snip ===
> brk(0)                                  = 0x11bb000
> brk(0x11dd000)                          = 0x11dd000
> getpid()                                = 18826
> stat("tpipe.18826", 0x7fff89e1d410)     = -1 ENOENT (No such file or
> directory)
> mknod("tpipe.18826", S_IFIFO|0777)      = 0
> rt_sigaction(SIGCHLD, {0x400a54, [CHLD], SA_RESTORER|SA_RESTART,
>    0x354aa32a20}, {SIG_DFL, [], 0}, 8) = 0
> clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|
>    CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f53b9ddd9d0) = 18827
> fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 3), ...}) = 0
> mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
>    = 0x7f53b9de5000
> open("tpipe.18826", O_RDONLY
> )           = ? ERESTARTSYS (To be restarted)
> --- SIGCHLD (Child exited) @ 0 (0) ---
> wait4(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 18827
> rt_sigreturn(0xffffffffffffffff)        = 2
> open("tpipe.18826", O_RDONLY
> === /snip ===
> 
> This patch is introducing semaphore, which prevents children from
> exiting until parent completes open(). It also adds timed wait,
> so parent waits for children to exit before it deletes pipe and
> semaphore.
> 
> Signed-off-by: Jan Stancek <jstancek@redhat.com>

looks good.

Reviewed-by: Caspar Zhang <caspar@casparzhang.com>

> ---
>   testcases/kernel/ipc/pipeio/pipeio.c |   37 
> ++++++++++++++++++++++++++++++++-
>   1 files changed, 35 insertions(+), 2 deletions(-)
> 

------------------------------------------------------------------------------
10 Tips for Better Server Consolidation
Server virtualization is being driven by many needs.  
But none more important than the need to reduce IT complexity 
while improving strategic productivity.  Learn More! 
http://www.accelacomm.com/jaw/sdnl/114/51507609/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

  reply	other threads:[~2011-12-15  3:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-14 11:05 [LTP] [PATCH] pipeio: prevent race between SIGCHLD and open() Jan Stancek
2011-12-15  3:04 ` Caspar Zhang [this message]
2011-12-15  5:46 ` Garrett Cooper

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=4EE963A0.8000902@casparzhang.com \
    --to=caspar@casparzhang.com \
    --cc=ltp-list@lists.sourceforge.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