2006-01-18 03:36:35

by Davide Libenzi

[permalink] [raw]
Subject: [PATCH] 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.




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(-)


Attachments:
pepoll-2.6.15-0.3.diff (5.23 kB)

2006-01-18 04:19:52

by Ulrich Drepper

[permalink] [raw]
Subject: Re: [PATCH] pepoll_wait ...

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(&current->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 ❖


Attachments:
signature.asc (251.00 B)
OpenPGP digital signature

2006-01-18 05:04:23

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH] pepoll_wait ...

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.

2006-01-18 07:13:15

by David Woodhouse

[permalink] [raw]
Subject: Re: [PATCH] pepoll_wait ...

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

2006-01-18 07:38:45

by Davide Libenzi

[permalink] [raw]
Subject: Re: [PATCH] pepoll_wait ...

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(&current->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


2006-01-18 07:40:37

by Davide Libenzi

[permalink] [raw]
Subject: Re: [PATCH] pepoll_wait ...

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


2006-01-18 07:48:49

by David Woodhouse

[permalink] [raw]
Subject: Re: [PATCH] pepoll_wait ...

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

2006-01-18 08:14:27

by Davide Libenzi

[permalink] [raw]
Subject: Re: [PATCH] pepoll_wait ...

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


2006-01-18 18:37:54

by Michael Tokarev

[permalink] [raw]
Subject: Re: [PATCH] pepoll_wait ...

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

2006-01-18 18:51:11

by Davide Libenzi

[permalink] [raw]
Subject: Re: [PATCH] pepoll_wait ...

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


2006-01-18 19:07:21

by Ulrich Drepper

[permalink] [raw]
Subject: Re: [PATCH] pepoll_wait ...

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 ❖


Attachments:
signature.asc (251.00 B)
OpenPGP digital signature