public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Richard Palethorpe <rpalethorpe@suse.de>
To: Cyril Hrubis <chrubis@suse.cz>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v3 2/2] Refactor exit_group01 using new API
Date: Thu, 16 Nov 2023 13:24:36 +0000	[thread overview]
Message-ID: <87msvdaiug.fsf@suse.de> (raw)
In-Reply-To: <ZUJJmPJYqumtFZxh@yuki>

Hello,

Cyril Hrubis <chrubis@suse.cz> writes:

> Hi!
>> This could fail due to PID reuse or maybe because state == 'Z'.
>> 
>> Perhaps instead we could check the threads are put into the Z state?
>> 
>> I guess that the child threads are reparented to init and it reaps
>> them. So you will have to prevent that by setting PR_SET_CHILD_SUBREAPER
>> on the main test process with prctl.
>> 
>> The man pages are not clear on this though. I guess this is how it works
>> from reading the kernel code.
>
> What about we:
>
> 1) allocate a piece of shared memory
> 2) each thread would run a loop that would increment a counter in that
>    memory
> 3) the test process will wait() the main child
> 4) then monitor the shared memory to make sure that counters are not
>    incremented anymore

+1

>
> Also child threads shouldn't be reparented to init, as long as at least
> one of the threads runs the child process is technically alive and I
> guess that wait() will not return until last thread in the group is
> dead.

OK, I looked again and it appears that indeed the thread group leader is
not reaped if there are threads in the group that are still alive
(wait_consider_task). Also it is only the thread group leader that can
enter a zombie state (exit_notify).

So this just leaves PID recycling as a potential issue IIRC.

-- 
Thank you,
Richard.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

      reply	other threads:[~2023-11-16 14:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-08 10:23 [LTP] [PATCH v3 0/2] Rewrite exit_group01 test Andrea Cervesato
2023-09-08 10:23 ` [LTP] [PATCH v3 1/2] Add tst_gettid wrapper around gettid syscall Andrea Cervesato
2023-11-01 12:29   ` Cyril Hrubis
2023-09-08 10:23 ` [LTP] [PATCH v3 2/2] Refactor exit_group01 using new API Andrea Cervesato
2023-10-16 10:03   ` Richard Palethorpe
2023-11-01 12:50     ` Cyril Hrubis
2023-11-16 13:24       ` Richard Palethorpe [this message]

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=87msvdaiug.fsf@suse.de \
    --to=rpalethorpe@suse.de \
    --cc=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    /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