posix timers still use the legacy arg0-arg3 members of
restart_block. Use restart_block.nanosleep instead
Signed-off-by: Thomas Gleixner <[email protected]>
Cc: John Stultz <[email protected]>
Cc: Richard Cochran <[email protected]>
---
kernel/posix-cpu-timers.c | 38 +++++++++++++++-----------------------
kernel/posix-timers.c | 2 +-
2 files changed, 16 insertions(+), 24 deletions(-)
Index: linux-2.6-tip/kernel/posix-cpu-timers.c
===================================================================
--- linux-2.6-tip.orig/kernel/posix-cpu-timers.c
+++ linux-2.6-tip/kernel/posix-cpu-timers.c
@@ -1485,7 +1485,7 @@ int posix_cpu_nsleep(const clockid_t whi
struct timespec *rqtp, struct timespec __user *rmtp)
{
struct restart_block *restart_block =
- ¤t_thread_info()->restart_block;
+ ¤t_thread_info()->restart_block;
struct itimerspec it;
int error;
@@ -1501,50 +1501,42 @@ int posix_cpu_nsleep(const clockid_t whi
if (error == -ERESTART_RESTARTBLOCK) {
- if (flags & TIMER_ABSTIME)
+ if (flags & TIMER_ABSTIME)
return -ERESTARTNOHAND;
/*
- * Report back to the user the time still remaining.
- */
- if (rmtp != NULL && copy_to_user(rmtp, &it.it_value, sizeof *rmtp))
+ * Report back to the user the time still remaining.
+ */
+ if (rmtp && copy_to_user(rmtp, &it.it_value, sizeof *rmtp))
return -EFAULT;
restart_block->fn = posix_cpu_nsleep_restart;
- restart_block->arg0 = which_clock;
- restart_block->arg1 = (unsigned long) rmtp;
- restart_block->arg2 = rqtp->tv_sec;
- restart_block->arg3 = rqtp->tv_nsec;
+ restart_block->nanosleep.index = which_clock;
+ restart_block->nanosleep.rmtp = rmtp;
+ restart_block->nanosleep.expires = timespec_to_ns(rqtp);
}
return error;
}
long posix_cpu_nsleep_restart(struct restart_block *restart_block)
{
- clockid_t which_clock = restart_block->arg0;
- struct timespec __user *rmtp;
+ clockid_t which_clock = restart_block->nanosleep.index;
struct timespec t;
struct itimerspec it;
int error;
- rmtp = (struct timespec __user *) restart_block->arg1;
- t.tv_sec = restart_block->arg2;
- t.tv_nsec = restart_block->arg3;
+ t = ns_to_timespec(restart_block->nanosleep.expires);
- restart_block->fn = do_no_restart_syscall;
error = do_cpu_nanosleep(which_clock, TIMER_ABSTIME, &t, &it);
if (error == -ERESTART_RESTARTBLOCK) {
+ struct timespec __user *rmtp = restart_block->nanosleep.rmtp;
/*
- * Report back to the user the time still remaining.
- */
- if (rmtp != NULL && copy_to_user(rmtp, &it.it_value, sizeof *rmtp))
+ * Report back to the user the time still remaining.
+ */
+ if (rmtp && copy_to_user(rmtp, &it.it_value, sizeof *rmtp))
return -EFAULT;
- restart_block->fn = posix_cpu_nsleep_restart;
- restart_block->arg0 = which_clock;
- restart_block->arg1 = (unsigned long) rmtp;
- restart_block->arg2 = t.tv_sec;
- restart_block->arg3 = t.tv_nsec;
+ restart_block->nanosleep.expires = timespec_to_ns(&t);
}
return error;
Index: linux-2.6-tip/kernel/posix-timers.c
===================================================================
--- linux-2.6-tip.orig/kernel/posix-timers.c
+++ linux-2.6-tip/kernel/posix-timers.c
@@ -1034,7 +1034,7 @@ SYSCALL_DEFINE4(clock_nanosleep, const c
*/
long clock_nanosleep_restart(struct restart_block *restart_block)
{
- clockid_t which_clock = restart_block->arg0;
+ clockid_t which_clock = restart_block->nanosleep.index;
struct k_clock *kc = clockid_to_kclock(which_clock);
return kc->nsleep_restart(restart_block);
On Tue, 2011-02-01 at 13:51 +0000, Thomas Gleixner wrote:
> plain text document attachment
> (posix-timers-cleanup-restart-block.patch)
> posix timers still use the legacy arg0-arg3 members of
> restart_block. Use restart_block.nanosleep instead
>
> Signed-off-by: Thomas Gleixner <[email protected]>
> Cc: John Stultz <[email protected]>
> Cc: Richard Cochran <[email protected]>
[snip]
> long posix_cpu_nsleep_restart(struct restart_block *restart_block)
> {
> - clockid_t which_clock = restart_block->arg0;
> - struct timespec __user *rmtp;
> + clockid_t which_clock = restart_block->nanosleep.index;
> struct timespec t;
> struct itimerspec it;
> int error;
>
> - rmtp = (struct timespec __user *) restart_block->arg1;
> - t.tv_sec = restart_block->arg2;
> - t.tv_nsec = restart_block->arg3;
> + t = ns_to_timespec(restart_block->nanosleep.expires);
>
> - restart_block->fn = do_no_restart_syscall;
> error = do_cpu_nanosleep(which_clock, TIMER_ABSTIME, &t, &it);
>
> if (error == -ERESTART_RESTARTBLOCK) {
> + struct timespec __user *rmtp = restart_block->nanosleep.rmtp;
> /*
> - * Report back to the user the time still remaining.
> - */
> - if (rmtp != NULL && copy_to_user(rmtp, &it.it_value, sizeof *rmtp))
> + * Report back to the user the time still remaining.
> + */
> + if (rmtp && copy_to_user(rmtp, &it.it_value, sizeof *rmtp))
> return -EFAULT;
>
> - restart_block->fn = posix_cpu_nsleep_restart;
> - restart_block->arg0 = which_clock;
> - restart_block->arg1 = (unsigned long) rmtp;
> - restart_block->arg2 = t.tv_sec;
> - restart_block->arg3 = t.tv_nsec;
> + restart_block->nanosleep.expires = timespec_to_ns(&t);
The conversion back and forth from nanoseconds to timespec seems a
little extraneous, but short of reworking all of the do_nanosleep calls
to take a ktime I don't see a clean solution (since hrtimer also uses
the restart_block).
Acked-by: John Stultz <[email protected]>
thanks
-john
On Tue, 1 Feb 2011, john stultz wrote:
> On Tue, 2011-02-01 at 13:51 +0000, Thomas Gleixner wrote:
> > - restart_block->fn = posix_cpu_nsleep_restart;
> > - restart_block->arg0 = which_clock;
> > - restart_block->arg1 = (unsigned long) rmtp;
> > - restart_block->arg2 = t.tv_sec;
> > - restart_block->arg3 = t.tv_nsec;
> > + restart_block->nanosleep.expires = timespec_to_ns(&t);
>
> The conversion back and forth from nanoseconds to timespec seems a
> little extraneous, but short of reworking all of the do_nanosleep calls
> to take a ktime I don't see a clean solution (since hrtimer also uses
> the restart_block).
We could simply add a timespec to the nanosleep struct in the
restart_block. Could be a union with expires.
Thanks,
tglx
Commit-ID: 3751f9f29bcbc19bd10e92254a273486f150c245
Gitweb: http://git.kernel.org/tip/3751f9f29bcbc19bd10e92254a273486f150c245
Author: Thomas Gleixner <[email protected]>
AuthorDate: Tue, 1 Feb 2011 13:51:20 +0000
Committer: Thomas Gleixner <[email protected]>
CommitDate: Wed, 2 Feb 2011 15:28:13 +0100
posix-timers: Cleanup restart_block usage
posix timers still use the legacy arg0-arg3 members of
restart_block. Use restart_block.nanosleep instead
Signed-off-by: Thomas Gleixner <[email protected]>
Acked-by: John Stultz <[email protected]>
Tested-by: Richard Cochran <[email protected]>
LKML-Reference: <[email protected]>
---
kernel/posix-cpu-timers.c | 38 +++++++++++++++-----------------------
kernel/posix-timers.c | 2 +-
2 files changed, 16 insertions(+), 24 deletions(-)
diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
index 816cd49..9e617b0 100644
--- a/kernel/posix-cpu-timers.c
+++ b/kernel/posix-cpu-timers.c
@@ -1485,7 +1485,7 @@ int posix_cpu_nsleep(const clockid_t which_clock, int flags,
struct timespec *rqtp, struct timespec __user *rmtp)
{
struct restart_block *restart_block =
- ¤t_thread_info()->restart_block;
+ ¤t_thread_info()->restart_block;
struct itimerspec it;
int error;
@@ -1501,50 +1501,42 @@ int posix_cpu_nsleep(const clockid_t which_clock, int flags,
if (error == -ERESTART_RESTARTBLOCK) {
- if (flags & TIMER_ABSTIME)
+ if (flags & TIMER_ABSTIME)
return -ERESTARTNOHAND;
/*
- * Report back to the user the time still remaining.
- */
- if (rmtp != NULL && copy_to_user(rmtp, &it.it_value, sizeof *rmtp))
+ * Report back to the user the time still remaining.
+ */
+ if (rmtp && copy_to_user(rmtp, &it.it_value, sizeof *rmtp))
return -EFAULT;
restart_block->fn = posix_cpu_nsleep_restart;
- restart_block->arg0 = which_clock;
- restart_block->arg1 = (unsigned long) rmtp;
- restart_block->arg2 = rqtp->tv_sec;
- restart_block->arg3 = rqtp->tv_nsec;
+ restart_block->nanosleep.index = which_clock;
+ restart_block->nanosleep.rmtp = rmtp;
+ restart_block->nanosleep.expires = timespec_to_ns(rqtp);
}
return error;
}
long posix_cpu_nsleep_restart(struct restart_block *restart_block)
{
- clockid_t which_clock = restart_block->arg0;
- struct timespec __user *rmtp;
+ clockid_t which_clock = restart_block->nanosleep.index;
struct timespec t;
struct itimerspec it;
int error;
- rmtp = (struct timespec __user *) restart_block->arg1;
- t.tv_sec = restart_block->arg2;
- t.tv_nsec = restart_block->arg3;
+ t = ns_to_timespec(restart_block->nanosleep.expires);
- restart_block->fn = do_no_restart_syscall;
error = do_cpu_nanosleep(which_clock, TIMER_ABSTIME, &t, &it);
if (error == -ERESTART_RESTARTBLOCK) {
+ struct timespec __user *rmtp = restart_block->nanosleep.rmtp;
/*
- * Report back to the user the time still remaining.
- */
- if (rmtp != NULL && copy_to_user(rmtp, &it.it_value, sizeof *rmtp))
+ * Report back to the user the time still remaining.
+ */
+ if (rmtp && copy_to_user(rmtp, &it.it_value, sizeof *rmtp))
return -EFAULT;
- restart_block->fn = posix_cpu_nsleep_restart;
- restart_block->arg0 = which_clock;
- restart_block->arg1 = (unsigned long) rmtp;
- restart_block->arg2 = t.tv_sec;
- restart_block->arg3 = t.tv_nsec;
+ restart_block->nanosleep.expires = timespec_to_ns(&t);
}
return error;
diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
index 4dd86d1..4762986 100644
--- a/kernel/posix-timers.c
+++ b/kernel/posix-timers.c
@@ -1034,7 +1034,7 @@ SYSCALL_DEFINE4(clock_nanosleep, const clockid_t, which_clock, int, flags,
*/
long clock_nanosleep_restart(struct restart_block *restart_block)
{
- clockid_t which_clock = restart_block->arg0;
+ clockid_t which_clock = restart_block->nanosleep.index;
struct k_clock *kc = clockid_to_kclock(which_clock);
if (WARN_ON_ONCE(!kc || !kc->nsleep_restart))