Merge branch 'fortglx/4.8/time' of https://git.linaro.org/people/john.stultz/linux...
authorThomas Gleixner <tglx@linutronix.de>
Tue, 21 Jun 2016 06:22:51 +0000 (08:22 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Tue, 21 Jun 2016 06:22:51 +0000 (08:22 +0200)
Pull time(keeping) updates from John Stultz:

 - Handle the 1ns issue with the old refusing to die vsyscall machinery
 - More y2038 updates
 - Documentation fixes
 - Simplify clocksource handling

fs/timerfd.c
kernel/time/hrtimer.c
kernel/time/timer.c

index 053818d..9ae4abb 100644 (file)
@@ -390,6 +390,11 @@ SYSCALL_DEFINE2(timerfd_create, int, clockid, int, flags)
             clockid != CLOCK_BOOTTIME_ALARM))
                return -EINVAL;
 
+       if (!capable(CAP_WAKE_ALARM) &&
+           (clockid == CLOCK_REALTIME_ALARM ||
+            clockid == CLOCK_BOOTTIME_ALARM))
+               return -EPERM;
+
        ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
        if (!ctx)
                return -ENOMEM;
@@ -433,6 +438,11 @@ static int do_timerfd_settime(int ufd, int flags,
                return ret;
        ctx = f.file->private_data;
 
+       if (!capable(CAP_WAKE_ALARM) && isalarm(ctx)) {
+               fdput(f);
+               return -EPERM;
+       }
+
        timerfd_setup_cancel(ctx, flags);
 
        /*
index e99df0f..d13c9ae 100644 (file)
@@ -177,7 +177,7 @@ hrtimer_check_target(struct hrtimer *timer, struct hrtimer_clock_base *new_base)
 #endif
 }
 
-#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
+#ifdef CONFIG_NO_HZ_COMMON
 static inline
 struct hrtimer_cpu_base *get_target_base(struct hrtimer_cpu_base *base,
                                         int pinned)
index 3a95f97..67dd610 100644 (file)
@@ -1702,9 +1702,15 @@ static void __sched do_usleep_range(unsigned long min, unsigned long max)
 }
 
 /**
- * usleep_range - Drop in replacement for udelay where wakeup is flexible
+ * usleep_range - Sleep for an approximate time
  * @min: Minimum time in usecs to sleep
  * @max: Maximum time in usecs to sleep
+ *
+ * In non-atomic context where the exact wakeup time is flexible, use
+ * usleep_range() instead of udelay().  The sleep improves responsiveness
+ * by avoiding the CPU-hogging busy-wait of udelay(), and the range reduces
+ * power usage by allowing hrtimers to take advantage of an already-
+ * scheduled interrupt instead of scheduling a new one just for this sleep.
  */
 void __sched usleep_range(unsigned long min, unsigned long max)
 {