All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] crypto/af_alg02: use pthread_tryjoin_np() instead of pthread_kill()
Date: Fri, 16 Jul 2021 11:51:27 +0200	[thread overview]
Message-ID: <YPFWn+/sbK1vlJKt@pevik> (raw)
In-Reply-To: <CAEemH2cXAY8KSFNNv8_23uSs-wRaResAkTPmPyZQNN6UwcMcgA@mail.gmail.com>

> Hi Alexey,

> On Thu, Jul 15, 2021 at 6:29 PM Alexey Kodanev <aleksei.kodanev@bell-sw.com>
> wrote:

> > musl doesn't return ESRCH for pthread_kill() if thread id is not found.
Maybe ask on MUSL mailing list?

> > POSIX only recommends to return ESRCH, and also says that pthread_kill()
> > produces undefined behavior if tid lifetime has ended [1].

> > [1]: https://man7.org/linux/man-pages/man3/pthread_kill.3.html

> > Signed-off-by: Alexey Kodanev <aleksei.kodanev@bell-sw.com>
> > ---
> >  testcases/kernel/crypto/af_alg02.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)

> > diff --git a/testcases/kernel/crypto/af_alg02.c
> > b/testcases/kernel/crypto/af_alg02.c
> > index 31d30777c..0f5793c16 100644
> > --- a/testcases/kernel/crypto/af_alg02.c
> > +++ b/testcases/kernel/crypto/af_alg02.c
> > @@ -60,7 +60,7 @@ static void run(void)

> >         TST_CHECKPOINT_WAIT(0);

> > -       while (pthread_kill(thr, 0) != ESRCH) {
> > +       while (pthread_tryjoin_np(thr, NULL) == EBUSY) {


> I'm not sure if safe enough to use because it is nonstandard GNU extensions
> and the "_np" means nonportable.
Others please double check, but pthread_tryjoin_np() seems to be in uclibc-ng
and musl (+ of course in glibc). It's only missing in bionic (it looks like
people would like to have it [1]).

> Maybe another workaround is to define a volatile flag 'thread_complete',
> initialize it to '0' when thread_B starts and reset to '1' while exit, and
> just
> do a value check in the while loop of thread_A should acquire thread_B
> status.
> Is this way a bit better?
Sounds as reasonable workaround for me.

Kind regards,
Petr

[1] https://github.com/kito-cheng/android-checkpoint/blob/master/bionic/0003-bionic-Implement-pthread_tryjoin_np.patch

  reply	other threads:[~2021-07-16  9:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-15 10:28 [LTP] [PATCH] crypto/af_alg02: use pthread_tryjoin_np() instead of pthread_kill() Alexey Kodanev
2021-07-16  7:06 ` Li Wang
2021-07-16  9:51   ` Petr Vorel [this message]
2021-07-16 12:12     ` Alexey Kodanev
2021-07-16 12:03   ` Alexey Kodanev
2021-07-16 13:12     ` Li Wang
2021-07-16 13:21       ` Li Wang
2021-07-16 13:35         ` Alexey Kodanev

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=YPFWn+/sbK1vlJKt@pevik \
    --to=pvorel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.