Unlike ppoll(2), which accepts a timespec argument "timeout_ts" to specify the timeout, epoll_wait(2) and epoll_pwait(2) expect a microsecond timeout in int type. This is an obstacle for applications in switching from ppoll to epoll, if they want nanosecond resolution in their event loops. Therefore, adding this variation of epoll wait interface, giving user an option with *both* advantages, is a reasonable move: there could be constantly scalable performance polling many fds, while having a nanosecond timeout precision (assuming it has properly set up timer slack with prctl(2)). Signed-off-by: Fam Zheng <famz@xxxxxxxxxx> --- fs/eventpoll.c | 24 ++++++++++++++++++++++++ include/linux/syscalls.h | 4 ++++ kernel/sys_ni.c | 3 +++ 3 files changed, 31 insertions(+) diff --git a/fs/eventpoll.c b/fs/eventpoll.c index 117ba72..ee69fd4 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c @@ -2066,6 +2066,30 @@ SYSCALL_DEFINE6(epoll_pwait, int, epfd, struct epoll_event __user *, events, sigmask ? &ksigmask : NULL, sigsetsize); } +SYSCALL_DEFINE6(epoll_pwait1, int, epfd, struct epoll_event __user *, events, + int, maxevents, + struct timespec __user *, timeout, + const sigset_t __user *, sigmask, + size_t, sigsetsize) +{ + struct timespec ts; + sigset_t ksigmask; + + if (timeout && copy_from_user(&ts, timeout, sizeof(ts))) + return -EFAULT; + + if (sigmask) { + if (sigsetsize != sizeof(sigset_t)) + return -EINVAL; + if (copy_from_user(&ksigmask, sigmask, sizeof(ksigmask))) + return -EFAULT; + } + return epoll_pwait_do(epfd, events, maxevents, + timeout ? &ts : NULL, + sigmask ? &ksigmask : NULL, + sigsetsize); +} + #ifdef CONFIG_COMPAT COMPAT_SYSCALL_DEFINE6(epoll_pwait, int, epfd, struct epoll_event __user *, events, diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index 85893d7..3e0ed0b 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h @@ -630,6 +630,10 @@ asmlinkage long sys_epoll_pwait(int epfd, struct epoll_event __user *events, int maxevents, int timeout, const sigset_t __user *sigmask, size_t sigsetsize); +asmlinkage long sys_epoll_pwait1(int epfd, struct epoll_event __user *events, + int maxevents, struct timespec __user *ts, + const sigset_t __user *sigmask, + size_t sigsetsize); asmlinkage long sys_gethostname(char __user *name, int len); asmlinkage long sys_sethostname(char __user *name, int len); asmlinkage long sys_setdomainname(char __user *name, int len); diff --git a/kernel/sys_ni.c b/kernel/sys_ni.c index 5adcb0a..1044158 100644 --- a/kernel/sys_ni.c +++ b/kernel/sys_ni.c @@ -229,3 +229,6 @@ cond_syscall(sys_bpf); /* execveat */ cond_syscall(sys_execveat); + +/* epoll_pwait1 */ +cond_syscall(sys_epoll_pwait1); -- 1.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-api" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html