pepoll_wait ...
PATCH 1/1 pepoll_wait ...
The attached patch implements the pepoll_wait system call, that extend the event wait mechanism with the same logic ppoll and pselect do. The definition of pepoll_wait is:
int pepoll_wait(int epfd, struct epoll_event *events, int maxevents,
int timeout, const sigset_t *sigmask, size_t sigsetsize);
The difference between the vanilla epoll_wait and pepoll_wait is that the latter allows the caller to specify a signal mask to be set while waiting for events. Hence pepoll_wait will wait until either one monitored event, or an unmasked signal happen. If sigmask is NULL, the pepoll_wait system call will act exactly like epoll_wait. For the POSIX definition of pselect, information is available here:
http://www.opengroup.org/onlinepubs/009695399/functions/select.html
This patch goes over 2.6.15-mm4 and depends on the TIF_RESTORE_SIGMASK bits.
- Davide
arch/i386/kernel/syscall_table.S | 1 fs/eventpoll.c | 58 ++++++++++++++++++++++++++++++++++----- include/asm-i386/unistd.h | 3 +- include/linux/syscalls.h | 3 ++ 4 files changed, 57 insertions(+), 8 deletions(-)
arch/i386/kernel/syscall_table.S +1 -0
@@ -310,3 +310,4 @@ .long sys_pselect6 .long sys_ppoll .long sys_unshare /* 310 */ + .long sys_pepoll_wait
fs/eventpoll.c +51 -7
100 lines not on this page · raw message
include/asm-i386/unistd.h +2 -1
@@ -316,8 +316,9 @@#define __NR_pselect6 308#define __NR_ppoll 309#define __NR_unshare 310 +#define __NR_pepoll_wait 311 -#define NR_syscalls 311 +#define NR_syscalls 312/* * user-visible error numbers are in the range -1 - -128: see
include/linux/syscalls.h +3 -0
@@ -428,6 +428,9 @@ struct epoll_event __user *event);asmlinkage long sys_epoll_wait (int epfd,struct epoll_event __user *events,int maxevents,int timeout); +asmlinkage long sys_pepoll_wait (int epfd,struct epoll_event __user *events, +int maxevents,int timeout,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);
Quoted 3 lines · Davide Libenzi
The attached patch implements the
pepoll_waitsystem call, that extend the event wait mechanism with the same logic ppoll and pselect do. The definition ofpepoll_waitis: [...]
I definitely ACK this patch, it's needed for the same reasons we need pselect and ppoll.
fs/eventpoll.c line 730
Quoted 7 lines
fs/eventpoll.c +7
-0+if (error == -EINTR ) { +if (sigmask) { +memcpy (¤t->saved_sigmask, &sigsaved,sizeof (sigsaved)); +set_thread_flag (TIF_RESTORE_SIGMASK ); + } + }else if (sigmask) +sigprocmask (SIG_SETMASK , &sigsaved,NULL );
This part I'd clean up a bit, though. Move the if (sigmask) test to the top and have the EINTR test decide what to do. As is the code would be a bit irritating if it wouldn't be so trivial. The important thing is that you only do something special if sigmask != NULL.
Signature · 1 line
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖
Quoted 9 lines · Ulrich Drepper
Quoted 3 lines · Davide Libenzi
The attached patch implements the
pepoll_waitsystem call, that extend the event wait mechanism with the same logic ppoll and pselect do. The definition ofpepoll_waitis: [...]I definitely ACK this patch, it's needed for the same reasons we need pselect and ppoll.
It busts most architectures.
fs/eventpoll.c: In function `sys_pepoll_wait':fs/eventpoll.c:727: error: `TIF_RESTORE_SIGMASK' undeclared (first use in this function)
It seems that the preferred way to fix this is to sprinkle #ifdef TIF_RESTORE_SIGMASK all over the code.
Quoted 2 lines · Andrew Morton
It seems that the preferred way to fix this is to sprinkle #ifdef
TIF_RESTORE_SIGMASKall over the code.
That's intended to be a temporary 'fix' until all the other architectures catch up. I don't want it there long-term.
Signature · 1 line
dwmw2
Quoted 11 lines · Andrew Morton
Quoted 9 lines · Ulrich Drepper
Quoted 3 lines · Davide Libenzi
The attached patch implements the
pepoll_waitsystem call, that extend the event wait mechanism with the same logic ppoll and pselect do. The definition ofpepoll_waitis: [...]I definitely ACK this patch, it's needed for the same reasons we need pselect and ppoll.
Quoted 7 lines
It busts most architectures.
fs/eventpoll.c: In function `sys_pepoll_wait':fs/eventpoll.c:727: error: `TIF_RESTORE_SIGMASK' undeclared (first use in this function)It seems that the preferred way to fix this is to sprinkle #ifdef
TIF_RESTORE_SIGMASKall over the code.
Hey, I've written in the comments that it depends on the TIF_RESTORE_SIGMASK bits ;) The latest one that dwmw posted used such feature, so I though to align epoll bits to that too.
- Davide
Quoted 3 lines · Davide Libenzi
Hey, I've written in the comments that it depends on the
TIF_RESTORE_SIGMASKbits ;) The latest one that dwmw posted used such feature, so I though to align epoll bits to that too.
The point is that TIF_RESTORE_SIGMASK needs to be implemented for each architecture, and we only have it for powerpc, i386 and FR-V at the moment. So in _generic_ files you have to use #ifdef TIF_RESTORE_SIGMASK for now, until the other architectures catch up.
Signature · 1 line
dwmw2
Quoted 9 lines · David Woodhouse
Quoted 3 lines · Davide Libenzi
Hey, I've written in the comments that it depends on the
TIF_RESTORE_SIGMASKbits ;) The latest one that dwmw posted used such feature, so I though to align epoll bits to that too.The point is that
TIF_RESTORE_SIGMASKneeds to be implemented for each architecture, and we only have it for powerpc, i386 and FR-V at the moment. So in _generic_ files you have to use #ifdefTIF_RESTORE_SIGMASKfor now, until the other architectures catch up.
Ok, will do. You then let me know when all archs are aligned so that I can nuke the #ifdef and use TIF_RESTORE_SIGMASK.
- Davide
Quoted 9 lines · Ulrich Drepper
Quoted 3 lines · Davide Libenzi
The attached patch implements the
pepoll_waitsystem call, that extend the event wait mechanism with the same logic ppoll and pselect do. The definition ofpepoll_waitis: [...]I definitely ACK this patch, it's needed for the same reasons we need pselect and ppoll.
Quoted 12 lines
fs/eventpoll.c line 730
Quoted 7 lines
fs/eventpoll.c +7
-0+if (error == -EINTR ) { +if (sigmask) { +memcpy (¤t->saved_sigmask, &sigsaved,sizeof (sigsaved)); +set_thread_flag (TIF_RESTORE_SIGMASK ); + } + }else if (sigmask) +sigprocmask (SIG_SETMASK , &sigsaved,NULL );This part I'd clean up a bit, though. Move the if (sigmask) test to the top and have the EINTR test decide what to do. As is the code would be a bit irritating if it wouldn't be so trivial. The important thing is that you only do something special if sigmask != NULL.
Agreed.
- Davide
Quoted 5 lines · Davide Libenzi
The attached patch implements the
pepoll_waitsystem call, that extend the event wait mechanism with the same logic ppoll and pselect do. The definition ofpepoll_waitis:int pepoll_wait(int epfd, struct
epoll_event*events, int maxevents,int timeout, const sigset_t *sigmask, size_t sigsetsize);
How about epoll_pwait() instead? It looks more appropriate, for my eyes anyway. (Just a name, nothing more)
/mjt
Quoted 9 lines · Michael Tokarev
Quoted 5 lines · Davide Libenzi
The attached patch implements the
pepoll_waitsystem call, that extend the event wait mechanism with the same logic ppoll and pselect do. The definition ofpepoll_waitis:int pepoll_wait(int epfd, struct
epoll_event*events, int maxevents,int timeout, const sigset_t *sigmask, size_t sigsetsize);How about
epoll_pwait()instead? It looks more appropriate, for my eyes anyway. (Just a name, nothing more)
Thinking about it, it looks netter for me too. I'll change it if there are no other objections ...
- Davide
Quoted 2 lines · Michael Tokarev
How about
epoll_pwait()instead? It looks more appropriate, for my eyes anyway. (Just a name, nothing more)
It's just a name but I have thought along the same lines. It's just more pleasing.
Signature · 1 line
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖