Fix one second delay when exiting

Signed-off-by: Torge Matthies <openglfreak@googlemail.com>
This commit is contained in:
Torge Matthies 2023-09-01 17:51:31 +02:00
parent 63c8f14756
commit e0e3032926
No known key found for this signature in database
GPG Key ID: 7C95CD70C9E8438D

View File

@ -131,7 +131,21 @@ void run_shrinkers(gfp_t gfp_mask, bool allocation_failed)
static int shrinker_thread(void *arg)
{
while (!kthread_should_stop()) {
sleep(1);
struct timespec to;
int v;
clock_gettime(CLOCK_MONOTONIC, &to);
to.tv_sec += 1;
__set_current_state(TASK_INTERRUPTIBLE);
errno = 0;
while ((v = READ_ONCE(current->state)) != TASK_RUNNING &&
errno != ETIMEDOUT)
futex(&current->state, FUTEX_WAIT_BITSET|FUTEX_PRIVATE_FLAG,
v, &to, NULL, (uint32_t)~0);
if (kthread_should_stop())
break;
if (v != TASK_RUNNING)
__set_current_state(TASK_RUNNING);
run_shrinkers(GFP_KERNEL, false);
}