From: george anzinger <george@mvista.com>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: Jim Houston <jim.houston@ccur.com>,
Stephen Rothwell <sfr@canb.auug.org.au>,
LKML <linux-kernel@vger.kernel.org>,
anton@samba.org, "David S. Miller" <davem@redhat.com>,
ak@muc.de, davidm@hpl.hp.com, schwidefsky@de.ibm.com,
ralf@gnu.org, willy@debian.org
Subject: Re: [PATCH] compatibility syscall layer (lets try again)
Date: Thu, 05 Dec 2002 01:48:18 -0800 [thread overview]
Message-ID: <3DEF20E2.5AEE3E78@mvista.com> (raw)
In-Reply-To: Pine.LNX.4.44.0212042009340.11869-100000@home.transmeta.com
[-- Attachment #1: Type: text/plain, Size: 1282 bytes --]
Linus Torvalds wrote:
>
> On Wed, 4 Dec 2002, george anzinger wrote:
> >
> > Once it changes the system call (eax, right), could the new
> > call code then just get the parms from the restart_block.
>
> Agreed.
>
> > I think it would be best to keep this as generic as
> > possible, i.e. let the new call code fetch its own
> > paramerers from the restart_block.
>
> We could even have one _single_ a generic "restart" system call, and have
> the function pointer for that be in the restart block.
>
> > My question is who sets up these values? I think you are
> > saying it should be the system call. Is this right?
>
> Whatever system call that return -ERESTART_RESTARTBLOCK, yes.
>
> So it would never get set up at all in the fast path. Only in the error
> case path of a system call that wants to have restarting capabilities.
>
> Linus
Ok, here is a patch to do all this. This is against
2.5.50-bk4. (Bk5 did not get posted this evening.)
I think this covers all the bases. It builds boots and
runs. I haven't tested nano_sleep to see if it does the
right thing yet...
--
George Anzinger george@mvista.com
High-res-timers:
http://sourceforge.net/projects/high-res-timers/
Preemption patch:
http://www.kernel.org/pub/linux/kernel/people/rml
[-- Attachment #2: regs-fix-2.5.50-bk4.1.0.patch --]
[-- Type: text/plain, Size: 6109 bytes --]
diff -urP -I \$Id:.*Exp \$ -X /usr/src/patch.exclude linux-2.5.50-bk4-kb/arch/i386/kernel/entry.S linux/arch/i386/kernel/entry.S
--- linux-2.5.50-bk4-kb/arch/i386/kernel/entry.S Wed Dec 4 23:28:20 2002
+++ linux/arch/i386/kernel/entry.S Wed Dec 4 23:48:49 2002
@@ -769,6 +769,7 @@
.long sys_epoll_wait
.long sys_remap_file_pages
.long sys_set_tid_address
+ .long sys_restart_syscall
.rept NR_syscalls-(.-sys_call_table)/4
diff -urP -I \$Id:.*Exp \$ -X /usr/src/patch.exclude linux-2.5.50-bk4-kb/arch/i386/kernel/signal.c linux/arch/i386/kernel/signal.c
--- linux-2.5.50-bk4-kb/arch/i386/kernel/signal.c Thu Oct 3 10:41:57 2002
+++ linux/arch/i386/kernel/signal.c Thu Dec 5 00:27:21 2002
@@ -507,6 +507,7 @@
/* If so, check system call restarting.. */
switch (regs->eax) {
case -ERESTARTNOHAND:
+ case -ERESTART_RESTARTBLOCK:
regs->eax = -EINTR;
break;
@@ -589,6 +590,10 @@
regs->eax == -ERESTARTSYS ||
regs->eax == -ERESTARTNOINTR) {
regs->eax = regs->orig_eax;
+ regs->eip -= 2;
+ }
+ if (regs->eax == -ERESTART_RESTARTBLOCK){
+ regs->eax = __NR_restart_syscall;
regs->eip -= 2;
}
}
diff -urP -I \$Id:.*Exp \$ -X /usr/src/patch.exclude linux-2.5.50-bk4-kb/include/asm-i386/thread_info.h linux/include/asm-i386/thread_info.h
--- linux-2.5.50-bk4-kb/include/asm-i386/thread_info.h Mon Sep 9 10:35:03 2002
+++ linux/include/asm-i386/thread_info.h Thu Dec 5 01:07:23 2002
@@ -20,6 +20,12 @@
* - if the contents of this structure are changed, the assembly constants must also be changed
*/
#ifndef __ASSEMBLY__
+struct restart_block {
+ int (*fun)(void *);
+ long arg0;
+ long arg1;
+};
+
struct thread_info {
struct task_struct *task; /* main task structure */
struct exec_domain *exec_domain; /* execution domain */
@@ -31,6 +37,7 @@
0-0xBFFFFFFF for user-thead
0-0xFFFFFFFF for kernel-thread
*/
+ struct restart_block restart_block;
__u8 supervisor_stack[0];
};
@@ -44,6 +51,7 @@
#define TI_CPU 0x0000000C
#define TI_PRE_COUNT 0x00000010
#define TI_ADDR_LIMIT 0x00000014
+#define TI_RESTART_BLOCK 0x0000018
#endif
@@ -63,6 +71,9 @@
.cpu = 0, \
.preempt_count = 1, \
.addr_limit = KERNEL_DS, \
+ .restart_block = { \
+ .fun = 0, \
+ }, \
}
#define init_thread_info (init_thread_union.thread_info)
diff -urP -I \$Id:.*Exp \$ -X /usr/src/patch.exclude linux-2.5.50-bk4-kb/include/asm-i386/unistd.h linux/include/asm-i386/unistd.h
--- linux-2.5.50-bk4-kb/include/asm-i386/unistd.h Wed Nov 27 15:49:22 2002
+++ linux/include/asm-i386/unistd.h Wed Dec 4 23:48:46 2002
@@ -263,7 +263,7 @@
#define __NR_sys_epoll_wait 256
#define __NR_remap_file_pages 257
#define __NR_set_tid_address 258
-
+#define __NR_restart_syscall 259
/* user-visible error numbers are in the range -1 - -124: see <asm-i386/errno.h> */
diff -urP -I \$Id:.*Exp \$ -X /usr/src/patch.exclude linux-2.5.50-bk4-kb/include/linux/errno.h linux/include/linux/errno.h
--- linux-2.5.50-bk4-kb/include/linux/errno.h Mon Sep 9 10:35:15 2002
+++ linux/include/linux/errno.h Wed Dec 4 23:53:21 2002
@@ -10,6 +10,7 @@
#define ERESTARTNOINTR 513
#define ERESTARTNOHAND 514 /* restart if no handler.. */
#define ENOIOCTLCMD 515 /* No ioctl command */
+#define ERESTART_RESTARTBLOCK 516 /* restart by calling sys_restart_syscall */
/* Defined for the NFSv3 protocol */
#define EBADHANDLE 521 /* Illegal NFS file handle */
diff -urP -I \$Id:.*Exp \$ -X /usr/src/patch.exclude linux-2.5.50-bk4-kb/kernel/signal.c linux/kernel/signal.c
--- linux-2.5.50-bk4-kb/kernel/signal.c Wed Dec 4 23:27:02 2002
+++ linux/kernel/signal.c Thu Dec 5 01:18:20 2002
@@ -1351,6 +1351,15 @@
* System call entry points.
*/
+asmlinkage long
+sys_restart_syscall( void *parm)
+{
+ if ( ! current_thread_info()->restart_block.fun){
+ return current_thread_info()->restart_block.fun(&parm);
+ }
+ return -ENOSYS;
+}
+
/*
* We don't need to get the kernel lock - this is all local to this
* particular thread.. (and that's good, because this is _heavily_
diff -urP -I \$Id:.*Exp \$ -X /usr/src/patch.exclude linux-2.5.50-bk4-kb/kernel/timer.c linux/kernel/timer.c
--- linux-2.5.50-bk4-kb/kernel/timer.c Wed Dec 4 23:27:02 2002
+++ linux/kernel/timer.c Thu Dec 5 01:16:03 2002
@@ -1020,19 +1020,39 @@
return current->pid;
}
+struct nano_sleep_call {
+ struct timespec *rqtp;
+ struct timespec *rmtp;
+};
+
+asmlinkage long sys_nanosleep_restart( struct nano_sleep_call * parms);
+
asmlinkage long sys_nanosleep(struct timespec *rqtp, struct timespec *rmtp)
{
struct timespec t;
unsigned long expire;
+ struct restart_block *restart_block;
- if(copy_from_user(&t, rqtp, sizeof(struct timespec)))
- return -EFAULT;
-
- if (t.tv_nsec >= 1000000000L || t.tv_nsec < 0 || t.tv_sec < 0)
- return -EINVAL;
+ if (rqtp) {
+ if(copy_from_user(&t, rqtp, sizeof(struct timespec)))
+ return -EFAULT;
- expire = timespec_to_jiffies(&t) + (t.tv_sec || t.tv_nsec);
+ if (t.tv_nsec >= 1000000000L || t.tv_nsec < 0 || t.tv_sec < 0)
+ return -EINVAL;
+ expire = timespec_to_jiffies(&t) + (t.tv_sec || t.tv_nsec);
+ }else{
+ restart_block = ¤t_thread_info()->restart_block;
+ if( restart_block->fun !=
+ (int (*)(void *))sys_nanosleep_restart ||
+ ! restart_block->arg0){
+ return -EFAULT;
+ }
+ restart_block->fun = NULL;
+ expire = restart_block->arg0 - jiffies;
+ if (expire < 0)
+ return 0;
+ }
current->state = TASK_INTERRUPTIBLE;
expire = schedule_timeout(expire);
@@ -1042,10 +1062,19 @@
if (copy_to_user(rmtp, &t, sizeof(struct timespec)))
return -EFAULT;
}
- return -EINTR;
+ restart_block = ¤t_thread_info()->restart_block;
+ restart_block->fun = (int (*)(void *))sys_nanosleep_restart;
+ restart_block->arg0 = jiffies + expire;
+ return -ERESTART_RESTARTBLOCK;
}
return 0;
}
+
+asmlinkage long sys_nanosleep_restart( struct nano_sleep_call * parms)
+{
+ return sys_nanosleep(NULL, parms->rmtp);
+}
+
/*
* sys_sysinfo - fill in sysinfo struct
next prev parent reply other threads:[~2002-12-05 9:47 UTC|newest]
Thread overview: 78+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-12-04 7:02 [PATCH] compatibility syscall layer (lets try again) Stephen Rothwell
2002-12-04 7:07 ` [PATCH] compatibility syscall layer - PPC64 Stephen Rothwell
2002-12-06 23:03 ` Anton Blanchard
2002-12-04 7:16 ` [PATCH] compatibility syscall layer - SPARC64 Stephen Rothwell
2002-12-04 7:18 ` [PATCH] compatibility syscall layer - X86_64 Stephen Rothwell
2002-12-04 11:29 ` Andi Kleen
2002-12-04 7:26 ` [PATCH] compatibility syscall layer - IA64 Stephen Rothwell
2002-12-04 7:37 ` David Mosberger
2002-12-04 7:28 ` [PATCH] compatibility syscall layer (lets try again) Stephen Rothwell
2002-12-04 7:29 ` [PATCH] compatibility syscall layer - PARISC Stephen Rothwell
2002-12-04 7:30 ` [PATCH] compatibility syscall layer (lets try again) Stephen Rothwell
2002-12-04 7:33 ` Stephen Rothwell
2002-12-04 11:57 ` Pavel Machek
2002-12-04 16:54 ` Linus Torvalds
2002-12-04 16:54 ` David S. Miller
2002-12-04 17:05 ` Linus Torvalds
2002-12-04 19:56 ` george anzinger
2002-12-04 20:07 ` Linus Torvalds
2002-12-04 20:56 ` Daniel Jacobowitz
2002-12-04 22:09 ` David S. Miller
2002-12-04 22:31 ` george anzinger
2002-12-04 22:39 ` David S. Miller
2002-12-04 22:42 ` Linus Torvalds
2002-12-04 23:42 ` Jim Houston
2002-12-05 0:18 ` Linus Torvalds
2002-12-05 2:01 ` george anzinger
2002-12-05 2:51 ` Linus Torvalds
2002-12-05 3:10 ` Andi Kleen
2002-12-05 3:46 ` george anzinger
2002-12-05 4:11 ` Linus Torvalds
2002-12-05 7:10 ` george anzinger
2002-12-05 9:48 ` george anzinger [this message]
2002-12-05 15:24 ` Jim Houston
2002-12-05 16:35 ` george anzinger
2002-12-06 0:03 ` Richard Henderson
2002-12-05 17:03 ` Linus Torvalds
2002-12-06 9:17 ` george anzinger
2002-12-06 17:57 ` Linus Torvalds
2002-12-06 19:20 ` Linus Torvalds
2002-12-06 20:09 ` [PATCH] compatibility syscall layer (let's " Jim Houston
2002-12-06 20:33 ` george anzinger
2002-12-06 20:18 ` [PATCH] compatibility syscall layer (lets " george anzinger
2002-12-06 21:12 ` Linus Torvalds
2002-12-06 21:56 ` Jim Houston
2002-12-06 22:58 ` Linus Torvalds
2002-12-07 2:25 ` george anzinger
2002-12-06 23:08 ` george anzinger
2002-12-08 20:41 ` David S. Miller
2002-12-09 6:18 ` Stephen Rothwell
2002-12-09 15:41 ` Daniel Jacobowitz
2002-12-09 16:48 ` Linus Torvalds
2002-12-09 17:27 ` David Mosberger
2002-12-09 20:22 ` David S. Miller
2002-12-09 17:49 ` Jim Houston
2002-12-09 17:57 ` Linus Torvalds
2002-12-09 23:30 ` Paul Mackerras
2002-12-10 23:07 ` george anzinger
2002-12-11 7:10 ` Daniel Jacobowitz
2002-12-11 8:11 ` george anzinger
2002-12-11 8:26 ` Daniel Jacobowitz
2002-12-10 11:08 ` Jamie Lokier
2002-12-05 2:27 ` Jim Houston
-- strict thread matches above, loose matches on Subject: below --
2002-12-09 16:58 Mikael Starvik
2002-12-09 17:35 ` Linus Torvalds
2002-12-09 18:46 ` David Mosberger
2002-12-10 0:13 ` Paul Mackerras
2002-12-10 23:11 ` george anzinger
2002-12-09 17:16 Martin Schwidefsky
2002-12-09 17:33 ` Linus Torvalds
2002-12-09 20:18 ` David S. Miller
2002-12-09 17:56 Martin Schwidefsky
2002-12-09 18:20 ` Linus Torvalds
2002-12-10 14:40 ` Keith Owens
2002-12-09 18:41 Martin Schwidefsky
2002-12-09 18:52 ` Linus Torvalds
2002-12-10 8:20 ` george anzinger
2002-12-10 8:42 Martin Schwidefsky
2002-12-10 17:17 Martin Schwidefsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3DEF20E2.5AEE3E78@mvista.com \
--to=george@mvista.com \
--cc=ak@muc.de \
--cc=anton@samba.org \
--cc=davem@redhat.com \
--cc=davidm@hpl.hp.com \
--cc=jim.houston@ccur.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ralf@gnu.org \
--cc=schwidefsky@de.ibm.com \
--cc=sfr@canb.auug.org.au \
--cc=torvalds@transmeta.com \
--cc=willy@debian.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).