Skip to contentSkip to conversation

input-linux: Reset il->fd handler before closing it

PATCH In review Colin Xu 2 participants 2 messages Sep 25, 2020

lore
Share & tools
lore

Colin Xu

author
#0 lore raw

PATCH 1/1 input-linux: Reset il->fd handler before closing it

If object-del input-linux object on-the-fly, instance finalize will close evdev fd without resetting it. However the main thread is still trying to lock_acquire/lock_release during ppoll, which leads to a very high CPU utilization.

---
 ui/input-linux.c | 1 +
 1 file changed, 1 insertion(+)
ui/input-linux.c +1 -0
index ab351a418701..34cc531190f9 100644
@@ -418,6 +418,7 @@ static void input_linux_instance_finalize(Object *obj)
 
     if (il->initialized) {
         QTAILQ_REMOVE(&inputs, il, next);
+        qemu_set_fd_handler(il->fd, NULL, NULL, NULL);
         close(il->fd);
     }
     g_free(il->evdev);
Signature · 1 line
2.28.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Colin Xu <[email protected]> 于2020年9月25日周五 上午10:18写道:

If object-del input-linux object on-the-fly, instance finalize will close evdev fd without resetting it. However the main thread is still trying to lock_acquire/lock_release during ppoll, which leads to a very high CPU utilization.

Quoted 20 lines
---
 ui/input-linux.c | 1 +
 1 file changed, 1 insertion(+)
ui/input-linux.c +1 -1
index ab351a418701..34cc531190f9 100644
@@ -418,6 +418,7 @@ static void input_linux_instance_finalize(Object *obj)
 
     if (il->initialized) {
         QTAILQ_REMOVE(&inputs, il, next);
+        qemu_set_fd_handler(il->fd, NULL, NULL, NULL);
         close(il->fd);
     }
     g_free(il->evdev);
--

2.28.0