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.
Signed-off-by: Davide Libenzi <[email protected]>
- 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(-)
Davide Libenzi wrote:
> 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: [...]
I definitely ACK this patch, it's needed for the same reasons we need
pselect and ppoll.
> + 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.
--
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖
Ulrich Drepper <[email protected]> wrote:
>
> Davide Libenzi wrote:
> > 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: [...]
>
> 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.
On Tue, 2006-01-17 at 21:03 -0800, Andrew Morton wrote:
> It seems that the preferred way to fix this is to sprinkle #ifdef
> TIF_RESTORE_SIGMASK all 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.
--
dwmw2
On Tue, 17 Jan 2006, Ulrich Drepper wrote:
> Davide Libenzi wrote:
>> 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: [...]
>
> I definitely ACK this patch, it's needed for the same reasons we need
> pselect and ppoll.
>
>
>> + 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
On Tue, 17 Jan 2006, Andrew Morton wrote:
> Ulrich Drepper <[email protected]> wrote:
>>
>> Davide Libenzi wrote:
>>> 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: [...]
>>
>> 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.
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
On Tue, 2006-01-17 at 23:40 -0800, Davide Libenzi wrote:
> 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.
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.
--
dwmw2
On Wed, 18 Jan 2006, David Woodhouse wrote:
> On Tue, 2006-01-17 at 23:40 -0800, Davide Libenzi wrote:
>> 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.
>
> 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.
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
Davide Libenzi wrote:
>
> 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);
How about epoll_pwait() instead? It looks more appropriate, for
my eyes anyway. (Just a name, nothing more)
/mjt
On Wed, 18 Jan 2006, Michael Tokarev wrote:
> Davide Libenzi wrote:
>>
>> 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);
>
> 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
Michael Tokarev wrote:
> 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.
--
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖