From: "Dixit, Ashutosh" <ashutosh.dixit@intel.com>
To: Jeevaka Prabu Badrappan <jeevaka.badrappan@intel.com>
Cc: igt-dev@lists.freedesktop.org, sapna1.singh@intel.com,
markyacoub@google.com, seanpaul@google.com,
carlos.santa@intel.com
Subject: Re: [PATCH 3/5] Avoid use of pthread_cancel by introducing an exit flag
Date: Tue, 29 Apr 2025 13:29:19 -0700 [thread overview]
Message-ID: <85wmb2r9sw.wl-ashutosh.dixit@intel.com> (raw)
In-Reply-To: <20250429195745.40982-4-jeevaka.badrappan@intel.com>
On Tue, 29 Apr 2025 12:57:43 -0700, Jeevaka Prabu Badrappan wrote:
>
> Android build fails due to pthread_cancel unavailability.
> Replace pthread_cancel with thread exit based on an exit flag.
How about adding the definition of pthread_cancel() in an android specific
library and using that, rather than making changes here?
I would think that approach might be better in general, calling into the
android specific library, rather than using '#ifdef ANDROID' as seems to be
done in other patches here?
Thoughts?
>
> Signed-off-by: Jeevaka Prabu Badrappan <jeevaka.badrappan@intel.com>
> ---
> lib/igt_dummyload.c | 6 +++---
> lib/igt_dummyload.h | 2 ++
> lib/xe/xe_spin.c | 2 +-
> 3 files changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/lib/igt_dummyload.c b/lib/igt_dummyload.c
> index 3cf80b762..38249afb7 100644
> --- a/lib/igt_dummyload.c
> +++ b/lib/igt_dummyload.c
> @@ -530,7 +530,7 @@ static void *timer_thread(void *data)
> /* Wait until we see the timer fire, or we get cancelled */
> do {
> read(spin->timerfd, &overruns, sizeof(overruns));
> - } while (!overruns);
> + } while (!overruns && !spin->exit_thread);
>
> igt_spin_end(spin);
> return NULL;
> @@ -565,7 +565,7 @@ void igt_spin_set_timeout(igt_spin_t *spin, int64_t ns)
> timerfd = timerfd_create(CLOCK_MONOTONIC, 0);
> igt_assert(timerfd >= 0);
> spin->timerfd = timerfd;
> -
> + spin->exit_thread = false;
> pthread_attr_init(&attr);
> pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
> pthread_attr_setschedpolicy(&attr, SCHED_FIFO);
> @@ -631,7 +631,7 @@ void igt_spin_end(igt_spin_t *spin)
> static void __igt_spin_free(int fd, igt_spin_t *spin)
> {
> if (spin->timerfd >= 0) {
> - pthread_cancel(spin->timer_thread);
> + spin->exit_thread = true;
> igt_assert(pthread_join(spin->timer_thread, NULL) == 0);
> close(spin->timerfd);
> }
> diff --git a/lib/igt_dummyload.h b/lib/igt_dummyload.h
> index b771011af..07b21227d 100644
> --- a/lib/igt_dummyload.h
> +++ b/lib/igt_dummyload.h
> @@ -26,6 +26,7 @@
> #define __IGT_DUMMYLOAD_H__
>
> #include <stdint.h>
> +#include <stdatomic.h>
> #include <time.h>
>
> #include "drmtest.h"
> @@ -75,6 +76,7 @@ typedef struct igt_spin {
>
> struct timespec last_signal;
> pthread_t timer_thread;
> + atomic_bool exit_thread;
> int timerfd;
>
> int out_fence;
> diff --git a/lib/xe/xe_spin.c b/lib/xe/xe_spin.c
> index a92903b6b..2fb688179 100644
> --- a/lib/xe/xe_spin.c
> +++ b/lib/xe/xe_spin.c
> @@ -264,7 +264,7 @@ void xe_spin_free(int fd, struct igt_spin *spin)
> igt_assert(spin->driver == INTEL_DRIVER_XE);
>
> if (spin->timerfd >= 0) {
> - pthread_cancel(spin->timer_thread);
> + spin->exit_thread = true;
> igt_assert(pthread_join(spin->timer_thread, NULL) == 0);
> close(spin->timerfd);
> }
> --
> 2.49.0
>
next prev parent reply other threads:[~2025-04-29 20:29 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-29 19:57 [RFC] [PATCH 0/5] Extend IGT to support Android Jeevaka Prabu Badrappan
2025-04-29 19:57 ` [PATCH 1/5] Add stub for libunwind, procps and glib Jeevaka Prabu Badrappan
2025-04-29 19:57 ` [PATCH 2/5] Replace program_invocation_short_name with prog_name from command line Jeevaka Prabu Badrappan
2025-04-29 19:57 ` [PATCH 3/5] Avoid use of pthread_cancel by introducing an exit flag Jeevaka Prabu Badrappan
2025-04-29 20:29 ` Dixit, Ashutosh [this message]
2025-04-29 19:57 ` [PATCH 4/5] Replace glib hash table with c specific implementation Jeevaka Prabu Badrappan
2025-04-29 20:33 ` Dixit, Ashutosh
2025-04-29 19:57 ` [PATCH 5/5] igt-gpu-tools: Changes to compile for Android Jeevaka Prabu Badrappan
2025-04-29 20:12 ` [RFC] [PATCH 0/5] Extend IGT to support Android Dixit, Ashutosh
-- strict thread matches above, loose matches on Subject: below --
2025-04-29 20:39 [PATCH v2 " Jeevaka Prabu Badrappan
2025-04-29 20:39 ` [PATCH 3/5] Avoid use of pthread_cancel by introducing an exit flag Jeevaka Prabu Badrappan
2025-04-29 20:39 [PATCH v2 0/5] Extend IGT to support Android Jeevaka Prabu Badrappan
2025-04-29 20:39 ` [PATCH 3/5] Avoid use of pthread_cancel by introducing an exit flag Jeevaka Prabu Badrappan
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=85wmb2r9sw.wl-ashutosh.dixit@intel.com \
--to=ashutosh.dixit@intel.com \
--cc=carlos.santa@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=jeevaka.badrappan@intel.com \
--cc=markyacoub@google.com \
--cc=sapna1.singh@intel.com \
--cc=seanpaul@google.com \
/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