Skip to contentSkip to conversation

pepoll_wait ...

PATCH In review Davide Libenzi 5 participants 11 messages Jan 18, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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
diff -Nru linux-2.6.15/arch/i386/kernel/syscall_table.S linux-2.6.15.mod/arch/i386/kernel/syscall_table.S
@@ -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
diff -Nru linux-2.6.15/include/asm-i386/unistd.h linux-2.6.15.mod/include/asm-i386/unistd.h
@@ -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
diff -Nru linux-2.6.15/include/linux/syscalls.h linux-2.6.15.mod/include/linux/syscalls.h
@@ -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);
#1 lore raw
Quoted 3 lines · Davide Libenzi

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.

fs/eventpoll.c line 730

Quoted 7 lines
fs/eventpoll.c +7 -0
+	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.

Signature · 1 line
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖
#2 lore raw
Quoted 9 lines · Ulrich Drepper
Quoted 3 lines · Davide Libenzi

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.

#3 lore raw
Quoted 2 lines · Andrew Morton

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.

Signature · 1 line
dwmw2
#4 lore raw
In reply to Andrew Morton
Quoted 11 lines · Andrew Morton
Quoted 9 lines · Ulrich Drepper
Quoted 3 lines · Davide Libenzi

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.

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_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

#5 lore raw
Quoted 3 lines · Davide Libenzi

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.

Signature · 1 line
dwmw2
#6 lore raw
Quoted 9 lines · David Woodhouse
Quoted 3 lines · Davide Libenzi

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

#7 lore raw
In reply to Ulrich Drepper
Quoted 9 lines · Ulrich Drepper
Quoted 3 lines · Davide Libenzi

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.

Quoted 12 lines

fs/eventpoll.c line 730

Quoted 7 lines
fs/eventpoll.c +7 -0
+	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

#8 lore raw
In reply to Davide Libenzi
Quoted 5 lines · Davide Libenzi

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

#9 lore raw
Quoted 9 lines · Michael Tokarev
Quoted 5 lines · Davide Libenzi

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

#10 lore raw
In reply to Michael Tokarev
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 ❖