usnic: create blocking libevent for progress thread emulation
In the v1.10 opal_progress_thread emulation, ensure to create a blocking libevent timer far in the future. Without that, opal_event_loop() will return immediately (and therefore the progress thread spins hard, stealing CPU cycles).
Этот коммит содержится в:
родитель
7cb6c2fcc2
Коммит
7bf364ff04
@ -152,8 +152,23 @@ int usnic_compat_free_list_init(opal_free_list_t *free_list,
|
|||||||
|
|
||||||
static volatile bool agent_thread_time_to_exit = false;
|
static volatile bool agent_thread_time_to_exit = false;
|
||||||
static opal_thread_t agent_thread;
|
static opal_thread_t agent_thread;
|
||||||
|
static opal_event_t blocker; // event to block on
|
||||||
static opal_event_base_t *agent_evbase = NULL;
|
static opal_event_base_t *agent_evbase = NULL;
|
||||||
|
|
||||||
|
static struct timeval long_timeout = {
|
||||||
|
.tv_sec = 3600,
|
||||||
|
.tv_usec = 0
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If this event is fired, just restart it so that this event base
|
||||||
|
* continues to have something to block on.
|
||||||
|
*/
|
||||||
|
static void blocker_timeout_cb(int fd, short args, void *cbdata)
|
||||||
|
{
|
||||||
|
opal_event_add(&blocker, &long_timeout);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Agent progress thread main entry point
|
* Agent progress thread main entry point
|
||||||
*/
|
*/
|
||||||
@ -176,6 +191,12 @@ opal_event_base_t *opal_progress_thread_init(const char *name)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* add an event to the new event base (if there are no events,
|
||||||
|
opal_event_loop() will return immediately) */
|
||||||
|
opal_event_set(agent_evbase, &blocker, -1, OPAL_EV_PERSIST,
|
||||||
|
blocker_timeout_cb, NULL);
|
||||||
|
opal_event_add(&blocker, &long_timeout);
|
||||||
|
|
||||||
/* Spawn the agent thread event loop */
|
/* Spawn the agent thread event loop */
|
||||||
OBJ_CONSTRUCT(&agent_thread, opal_thread_t);
|
OBJ_CONSTRUCT(&agent_thread, opal_thread_t);
|
||||||
agent_thread.t_run = agent_thread_main;
|
agent_thread.t_run = agent_thread_main;
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user