Files
geramyloveless 33e6465ef2 dext: KFD signal events and asynchronous event waits (selectors 86, 87)
EVENT creates, destroys and sets a KFD signal event of the client's KFD
process and reports its id, trigger and mailbox address for an
amd_signal_t. EVENT_WAIT is asynchronous: the dext registers the wait
and hands it to a wait-pool thread (rt/wait_pool.h: threads made on
demand, idle ones blocked with no timeout), which sleeps in WAIT_EVENTS
until KFD's interrupt handler signals an event or the timeout passes,
then completes the client's call. A wait the pool cannot take is
refused (-EAGAIN), never run on the caller's queue.

The HSA runtime does not use these yet.
2026-10-03 17:28:26 -07:00

36 lines
1.2 KiB
C

/* Threads that sleep for clients: the shared half of interrupt-driven
* waits.
*
* A client's wait (a KFD signal event, a fence) must not block the queue
* its call arrived on, so the call registers the wait and hands it here;
* a pool thread runs it (it sleeps until the interrupt that ends it, or
* its timeout) and then completes the client's asynchronous call. Pool
* threads are created on demand, up to RT_WAIT_POOL_THREADS, and an idle
* one blocks on a condition with no timeout: no request means no thread
* runs. Runtime: linuxu/src/amdgpu-rt/wait_pool.c. */
#ifndef LINUXU_RT_WAIT_POOL_H
#define LINUXU_RT_WAIT_POOL_H
#ifdef __cplusplus
extern "C" {
#endif
#define RT_WAIT_POOL_THREADS 32u
/* Run @fn(@arg) on a pool thread. -EAGAIN when every thread is busy (the
* caller's wait did not start), -ENOMEM when no thread could be made. */
int rt_wait_pool_run(void (*fn)(void *arg), void *arg);
struct rt_wait_pool_stats {
unsigned int threads; /* created */
unsigned int busy; /* running a wait now */
unsigned long long runs; /* waits run */
unsigned long long refused; /* -EAGAIN */
};
void rt_wait_pool_stats(struct rt_wait_pool_stats *out);
#ifdef __cplusplus
}
#endif
#endif