From: Jeevaka Prabu Badrappan <jeevaka.badrappan@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: jeevaka.badrappan@intel.com, sapna1.singh@intel.com,
markyacoub@google.com, seanpaul@google.com,
carlos.santa@intel.com
Subject: [PATCH 3/5] Avoid use of pthread_cancel by introducing an exit flag
Date: Tue, 29 Apr 2025 20:39:58 +0000 [thread overview]
Message-ID: <20250429204000.41537-4-jeevaka.badrappan@intel.com> (raw)
In-Reply-To: <20250429204000.41537-1-jeevaka.badrappan@intel.com>
Android build fails due to pthread_cancel unavailability.
Replace pthread_cancel with thread exit based on an exit flag.
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:41 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-29 20:39 [PATCH v2 0/5] Extend IGT to support Android Jeevaka Prabu Badrappan
2025-04-29 20:39 ` [PATCH 1/5] Add stub for libunwind, procps and glib Jeevaka Prabu Badrappan
2025-04-30 17:04 ` Kamil Konieczny
2025-04-29 20:39 ` [PATCH 2/5] Replace program_invocation_short_name with prog_name from command line Jeevaka Prabu Badrappan
2025-04-30 17:07 ` Kamil Konieczny
2025-04-29 20:39 ` Jeevaka Prabu Badrappan [this message]
2025-04-29 20:39 ` [PATCH 4/5] Replace glib hash table with c specific implementation Jeevaka Prabu Badrappan
2025-04-30 17:11 ` Kamil Konieczny
2025-04-29 20:40 ` [PATCH 5/5] igt-gpu-tools: Changes to compile for Android Jeevaka Prabu Badrappan
2025-04-30 17:26 ` Kamil Konieczny
2025-04-29 21:14 ` [PATCH v2 0/5] Extend IGT to support Android Dixit, Ashutosh
2025-04-30 20:13 ` Mark Yacoub
2025-04-30 5:17 ` ✓ i915.CI.BAT: success for Extend IGT to support Android (rev3) Patchwork
2025-04-30 5:49 ` ✗ Xe.CI.BAT: failure " Patchwork
2025-04-30 8:47 ` ✗ Xe.CI.Full: " Patchwork
2025-04-30 9:08 ` ✗ i915.CI.Full: " Patchwork
2025-04-30 13:48 ` [PATCH v2 0/5] Extend IGT to support Android Ryszard Knop
2025-04-30 16:48 ` Badrappan, Jeevaka
2025-04-30 20:16 ` Mark Yacoub
-- strict thread matches above, loose matches on Subject: below --
2025-04-29 20:39 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 19:57 [RFC] [PATCH 0/5] Extend IGT to support Android 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
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=20250429204000.41537-4-jeevaka.badrappan@intel.com \
--to=jeevaka.badrappan@intel.com \
--cc=carlos.santa@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--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