Skip to content

Commit 99e6c0e

Browse files
Al ViroKAGA-KOKO
authored andcommitted
posix-timers: Store rmtp into restart_block in sys_clock_nanosleep()
... instead of doing that in every ->nsleep() instance Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: John Stultz <john.stultz@linaro.org> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/20170607084241.28657-5-viro@ZenIV.linux.org.uk
1 parent a760268 commit 99e6c0e

4 files changed

Lines changed: 10 additions & 22 deletions

File tree

‎kernel/time/alarmtimer.c‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -753,20 +753,14 @@ static long __sched alarm_timer_nsleep_restart(struct restart_block *restart)
753753
* Handles clock_nanosleep calls against _ALARM clockids
754754
*/
755755
static int alarm_timer_nsleep(const clockid_t which_clock, int flags,
756-
struct timespec64 *tsreq,
757-
struct timespec __user *rmtp)
756+
struct timespec64 *tsreq)
758757
{
759758
enum alarmtimer_type type = clock2alarm(which_clock);
760759
struct restart_block *restart = &current->restart_block;
761760
struct alarm alarm;
762761
ktime_t exp;
763762
int ret = 0;
764763

765-
if (flags & TIMER_ABSTIME)
766-
rmtp = NULL;
767-
768-
restart->nanosleep.rmtp = rmtp;
769-
770764
if (!alarmtimer_get_rtcdev())
771765
return -ENOTSUPP;
772766

‎kernel/time/posix-cpu-timers.c‎

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,16 +1328,11 @@ static int do_cpu_nanosleep(const clockid_t which_clock, int flags,
13281328
static long posix_cpu_nsleep_restart(struct restart_block *restart_block);
13291329

13301330
static int posix_cpu_nsleep(const clockid_t which_clock, int flags,
1331-
struct timespec64 *rqtp, struct timespec __user *rmtp)
1331+
struct timespec64 *rqtp)
13321332
{
13331333
struct restart_block *restart_block = &current->restart_block;
13341334
int error;
13351335

1336-
if (flags & TIMER_ABSTIME)
1337-
rmtp = NULL;
1338-
1339-
restart_block->nanosleep.rmtp = rmtp;
1340-
13411336
/*
13421337
* Diagnose required errors first.
13431338
*/
@@ -1388,10 +1383,9 @@ static int process_cpu_timer_create(struct k_itimer *timer)
13881383
return posix_cpu_timer_create(timer);
13891384
}
13901385
static int process_cpu_nsleep(const clockid_t which_clock, int flags,
1391-
struct timespec64 *rqtp,
1392-
struct timespec __user *rmtp)
1386+
struct timespec64 *rqtp)
13931387
{
1394-
return posix_cpu_nsleep(PROCESS_CLOCK, flags, rqtp, rmtp);
1388+
return posix_cpu_nsleep(PROCESS_CLOCK, flags, rqtp);
13951389
}
13961390
static long process_cpu_nsleep_restart(struct restart_block *restart_block)
13971391
{

‎kernel/time/posix-timers.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,11 +1041,8 @@ SYSCALL_DEFINE2(clock_getres, const clockid_t, which_clock,
10411041
* nanosleep for monotonic and realtime clocks
10421042
*/
10431043
static int common_nsleep(const clockid_t which_clock, int flags,
1044-
struct timespec64 *tsave, struct timespec __user *rmtp)
1044+
struct timespec64 *tsave)
10451045
{
1046-
if (flags & TIMER_ABSTIME)
1047-
rmtp = NULL;
1048-
current->restart_block.nanosleep.rmtp = rmtp;
10491046
return hrtimer_nanosleep(tsave, flags & TIMER_ABSTIME ?
10501047
HRTIMER_MODE_ABS : HRTIMER_MODE_REL,
10511048
which_clock);
@@ -1070,8 +1067,11 @@ SYSCALL_DEFINE4(clock_nanosleep, const clockid_t, which_clock, int, flags,
10701067
t64 = timespec_to_timespec64(t);
10711068
if (!timespec64_valid(&t64))
10721069
return -EINVAL;
1070+
if (flags & TIMER_ABSTIME)
1071+
rmtp = NULL;
1072+
current->restart_block.nanosleep.rmtp = rmtp;
10731073

1074-
return kc->nsleep(which_clock, flags, &t64, rmtp);
1074+
return kc->nsleep(which_clock, flags, &t64);
10751075
}
10761076

10771077
/*

‎kernel/time/posix-timers.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ struct k_clock {
1010
int (*clock_adj)(const clockid_t which_clock, struct timex *tx);
1111
int (*timer_create)(struct k_itimer *timer);
1212
int (*nsleep)(const clockid_t which_clock, int flags,
13-
struct timespec64 *, struct timespec __user *);
13+
struct timespec64 *);
1414
long (*nsleep_restart)(struct restart_block *restart_block);
1515
int (*timer_set)(struct k_itimer *timr, int flags,
1616
struct itimerspec64 *new_setting,

0 commit comments

Comments
 (0)