[LTP] [PATCH v2 1/2] epoll_pwait: Refactor timeout to struct timespec
Petr Vorel
pvorel@suse.cz
Wed Jun 4 08:35:21 CEST 2025
Hi Martin,
> Support higher precision timeout in do_epoll_pwait() by passing struct
> timespec instead of int value in milliseconds. Only one test actually
> uses the parameter.
Ah, you mean epoll_pwait03.c.
Reviewed-by: Petr Vorel <pvorel@suse.cz>
...
> +++ b/testcases/kernel/syscalls/epoll_pwait/epoll_pwait_var.h
> @@ -14,22 +14,22 @@
> #define NSEC_PER_MSEC (1000000L)
> static int do_epoll_pwait(int epfd, struct epoll_event *events, int
> - maxevents, int timeout, const sigset_t *sigmask)
> + maxevents, struct timespec *timeout, const sigset_t *sigmask)
> {
> - if (tst_variant == 0)
> - return epoll_pwait(epfd, events, maxevents, timeout, sigmask);
> + if (tst_variant == 0) {
> + int timeout_ms = -1;
very nit: I would reverse the condition to save indent for tst_variant == 0:
if (tst_variant != 0)
return epoll_pwait2(epfd, events, maxevents, timeout, sigmask);
...
Kind regards,
Petr
> - struct timespec ts;
> + if (timeout) {
> + timeout_ms = timeout->tv_sec * MSEC_PER_SEC;
> + timeout_ms += (timeout->tv_nsec + NSEC_PER_MSEC - 1) /
> + NSEC_PER_MSEC;
> + }
> - if (timeout < 0) {
> - return epoll_pwait2(epfd, events, maxevents, NULL, sigmask);
> - } else {
> - ts.tv_sec = timeout / MSEC_PER_SEC;
> - ts.tv_nsec = NSEC_PER_MSEC * (timeout % MSEC_PER_SEC);
> + return epoll_pwait(epfd, events, maxevents, timeout_ms,
> + sigmask);
> }
> - return epoll_pwait2(epfd, events, maxevents, &ts, sigmask);
> -
> + return epoll_pwait2(epfd, events, maxevents, timeout, sigmask);
> }
> static void epoll_pwait_init(void)
More information about the ltp
mailing list