This potentially reduces lag and makes the input device initialization faster under CPU load.
Signed-off-by: Kai Krakow kai@kaishome.de --- dlls/winebus.sys/bus_iohid.c | 1 + dlls/winebus.sys/bus_sdl.c | 2 ++ dlls/winebus.sys/bus_udev.c | 9 +++++++-- 3 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/dlls/winebus.sys/bus_iohid.c b/dlls/winebus.sys/bus_iohid.c index 95077ac0be2..b4f7dabb153 100644 --- a/dlls/winebus.sys/bus_iohid.c +++ b/dlls/winebus.sys/bus_iohid.c @@ -410,6 +410,7 @@ NTSTATUS WINAPI iohid_driver_init(DRIVER_OBJECT *driver, UNICODE_STRING *registr return STATUS_UNSUCCESSFUL; }
+ SetThreadPriority(run_loop_handle, THREAD_PRIORITY_TIME_CRITICAL); return STATUS_SUCCESS; }
diff --git a/dlls/winebus.sys/bus_sdl.c b/dlls/winebus.sys/bus_sdl.c index 5cf5dddaf05..41f203f6e36 100644 --- a/dlls/winebus.sys/bus_sdl.c +++ b/dlls/winebus.sys/bus_sdl.c @@ -976,6 +976,8 @@ NTSTATUS WINAPI sdl_driver_init(DRIVER_OBJECT *driver, UNICODE_STRING *registry_ goto error; }
+ SetThreadPriority(events[1], THREAD_PRIORITY_TIME_CRITICAL); + result = WaitForMultipleObjects(2, events, FALSE, INFINITE); CloseHandle(events[0]); CloseHandle(events[1]); diff --git a/dlls/winebus.sys/bus_udev.c b/dlls/winebus.sys/bus_udev.c index 64b245e630d..10b79dcc6b1 100644 --- a/dlls/winebus.sys/bus_udev.c +++ b/dlls/winebus.sys/bus_udev.c @@ -795,8 +795,9 @@ static NTSTATUS begin_report_processing(DEVICE_OBJECT *device) close(private->control_pipe[1]); return STATUS_UNSUCCESSFUL; } - else - return STATUS_SUCCESS; + + SetThreadPriority(private->report_thread, THREAD_PRIORITY_TIME_CRITICAL); + return STATUS_SUCCESS; }
static NTSTATUS hidraw_set_output_report(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *written) @@ -1006,6 +1007,8 @@ static NTSTATUS lnxev_begin_report_processing(DEVICE_OBJECT *device) close(private->base.control_pipe[1]); return STATUS_UNSUCCESSFUL; } + + SetThreadPriority(private->base.report_thread, THREAD_PRIORITY_TIME_CRITICAL); return STATUS_SUCCESS; }
@@ -1462,6 +1465,8 @@ NTSTATUS WINAPI udev_driver_init(DRIVER_OBJECT *driver, UNICODE_STRING *registry goto error; }
+ SetThreadPriority(events[1], THREAD_PRIORITY_TIME_CRITICAL); + result = WaitForMultipleObjects(2, events, FALSE, INFINITE); CloseHandle(events[0]); CloseHandle(events[1]);
This potentially reduces lag and makes the input device initialization faster under CPU load.
Signed-off-by: Kai Krakow kai@kaishome.de --- dlls/dinput/dinput_main.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/dlls/dinput/dinput_main.c b/dlls/dinput/dinput_main.c index 6ed764e7485..d11ac249178 100644 --- a/dlls/dinput/dinput_main.c +++ b/dlls/dinput/dinput_main.c @@ -1817,6 +1817,8 @@ static BOOL check_hook_thread(void) { DWORD tid = hook_thread_id;
+ SetThreadPriority(hook_thread, THREAD_PRIORITY_TIME_CRITICAL); + hook_thread_id = 0; PostThreadMessageW(tid, WM_USER+0x10, 0, 0); LeaveCriticalSection(&dinput_hook_crit);
Hi,
While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=45610
Your paranoid android.
=== debian9 (32 bit Chinese:China report) ===
dinput: mouse.c:154: Test failed: GetDeviceData() failed: 00000000 cnt:0 mouse.c:162: Test failed: GetDeviceData() failed: 00000000 cnt:0 mouse.c:173: Test failed: GetDeviceData() failed: 00000000 cnt:0
Am Di., 11. Dez. 2018 um 02:02 Uhr schrieb Marvin testbot@winehq.org:
Hi,
While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=45610
Your paranoid android.
=== debian9 (32 bit Chinese:China report) ===
dinput: mouse.c:154: Test failed: GetDeviceData() failed: 00000000 cnt:0 mouse.c:162: Test failed: GetDeviceData() failed: 00000000 cnt:0 mouse.c:173: Test failed: GetDeviceData() failed: 00000000 cnt:0
I'm not sure why this should happen. But there's a small thinking error in this patch anyways. Please ignore this particular patch for now, I'm trying to come up with a fixed version.
Thanks, Kai
Kai Krakow kai@kaishome.de writes:
This potentially reduces lag and makes the input device initialization faster under CPU load.
Considering that SetThreadPriority() is basically a nop, I doubt that it improves anything.
Am Di., 11. Dez. 2018 um 14:54 Uhr schrieb Alexandre Julliard julliard@winehq.org:
Kai Krakow kai@kaishome.de writes:
This potentially reduces lag and makes the input device initialization faster under CPU load.
Considering that SetThreadPriority() is basically a nop, I doubt that it improves anything.
I agree for the non-staging case. But if you start using staging with the realtime priority patchset, it helps. As a side-effect it also solved another problem I was seeing: Games may miss gamepad trigger releases which are implemented as axis events. With this patch, I'm yet to reproduce that issue - or in other words: It didn't show again. But due to the nature of the patch, this is actually not a fix, it only tightens timing enough to work for me.
Also, other parts of wine source code already call this "basically" nop function, see "git grep SetThreadPriority".
In my local development branch I'm currently working on replacing the staging realtime patches with a more exact implementation of priorities, also touching parts of MMCSS so native xaudio2 could take advantage of realtime priorities (it reduces audio crackling in my tests). So far, I was able to reduce priority inversion effects that can be seen with the staging realtime patches.
But it is not ready for submission here, even not as a proposed staging patchset.
I'm not very familiar with wine source code in general yet but I dug through a lot of documents and papers. So my other question is: Would this list be a proper place to discuss development and improvement of such patches? And would patches touching this functionality even be worth considering inclusion into wine?
Thanks, Kai