History

Merge branch 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull timer updates from Thomas Gleixner: "The time/timekeeping/timer folks deliver with this update: - Fix a reintroduced signed/unsigned issue and cleanup the whole signed/unsigned mess in the timekeeping core so this wont happen accidentaly again. - Add a new trace clock based on boot time - Prevent injection of random sleep times when PM tracing abuses the RTC for storage - Make posix timers configurable for real tiny systems - Add tracepoints for the alarm timer subsystem so timer based suspend wakeups can be instrumented - The usual pile of fixes and updates to core and drivers" * 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (23 commits) timekeeping: Use mul_u64_u32_shr() instead of open coding it timekeeping: Get rid of pointless typecasts timekeeping: Make the conversion call chain consistently unsigned timekeeping_Force_unsigned_clocksource_to_nanoseconds_conversion alarmtimer: Add tracepoints for alarm timers trace: Update documentation for mono, mono_raw and boot clock trace: Add an option for boot clock as trace clock timekeeping: Add a fast and NMI safe boot clock timekeeping/clocksource_cyc2ns: Document intended range limitation timekeeping: Ignore the bogus sleep time if pm_trace is enabled selftests/timers: Fix spelling mistake "Asyncrhonous" -> "Asynchronous" clocksource/drivers/bcm2835_timer: Unmap region obtained by of_iomap clocksource/drivers/arm_arch_timer: Map frame with of_io_request_and_map() arm64: dts: rockchip: Arch counter doesn't tick in system suspend clocksource/drivers/arm_arch_timer: Don't assume clock runs in suspend posix-timers: Make them configurable posix_cpu_timers: Move the add_device_randomness() call to a proper place timer: Move sys_alarm from timer.c to itimer.c ptp_clock: Allow for it to be optional Kconfig: Regenerate *.c_shipped files after previous changes ...

Linus Torvalds committed 9 years ago

Commit 9465d9c2 parents e71c397 c029a2b61 files · +1479 −1041Browse files

Showing the changes to kernel/time/timer.c (1 of 61 files). Show all

Unified · Split

kernel/time/timer.c+18−30
@@ -1615,7 +1615,8 @@ void update_process_times(int user_tick) · 1614 unmodified lines
16151615 irq_work_tick();
16161616 #endif
16171617 scheduler_tick();
1618− run_posix_cpu_timers(p);
1618+ if (IS_ENABLED(CONFIG_POSIX_TIMERS))
1619+ run_posix_cpu_timers(p);
16191620 }
16201621
16211622 /**
@@ -1676,19 +1677,6 @@ void run_local_timers(void) · 54 unmodified lines
16761677 raise_softirq(TIMER_SOFTIRQ);
16771678 }
16781679
1679−#ifdef __ARCH_WANT_SYS_ALARM
1680−
1681−/*
1682− * For backwards compatibility? This can be done in libc so Alpha
1683− * and all newer ports shouldn't need it.
1684− */
1685−SYSCALL_DEFINE1(alarm, unsigned int, seconds)
1686−{
1687− return alarm_setitimer(seconds);
1688−}
1689−
1690−#endif
1691−
16921680 static void process_timeout(unsigned long __data)
16931681 {
16941682 wake_up_process((struct task_struct *)__data);
@@ -1705,11 +1693,12 @@ static void process_timeout(unsigned long __data) · 10 unmodified lines
17051693 * You can set the task state as follows -
17061694 *
17071695 * %TASK_UNINTERRUPTIBLE - at least @timeout jiffies are guaranteed to
1708− * pass before the routine returns. The routine will return 0
1696+ * pass before the routine returns unless the current task is explicitly
1697+ * woken up, (e.g. by wake_up_process())".
17091698 *
17101699 * %TASK_INTERRUPTIBLE - the routine may return early if a signal is
1711− * delivered to the current task. In this case the remaining time
1712− * in jiffies will be returned, or 0 if the timer expired in time
1700+ * delivered to the current task or the current task is explicitly woken
1701+ * up.
17131702 *
17141703 * The current task state is guaranteed to be TASK_RUNNING when this
17151704 * routine returns.
@@ -1718,7 +1707,9 @@ static void process_timeout(unsigned long __data) · 2 unmodified lines
17181707 * the CPU away without a bound on the timeout. In this case the return
17191708 * value will be %MAX_SCHEDULE_TIMEOUT.
17201709 *
1721− * In all cases the return value is guaranteed to be non-negative.
1710+ * Returns 0 when the timer has expired otherwise the remaining time in
1711+ * jiffies will be returned. In all cases the return value is guaranteed
1712+ * to be non-negative.
17221713 */
17231714 signed long __sched schedule_timeout(signed long timeout)
17241715 {
@@ -1910,16 +1901,6 @@ unsigned long msleep_interruptible(unsigned int msecs) · 185 unmodified lines
19101901
19111902 EXPORT_SYMBOL(msleep_interruptible);
19121903
1913−static void __sched do_usleep_range(unsigned long min, unsigned long max)
1914−{
1915− ktime_t kmin;
1916− u64 delta;
1917−
1918− kmin = ktime_set(0, min * NSEC_PER_USEC);
1919− delta = (u64)(max - min) * NSEC_PER_USEC;
1920− schedule_hrtimeout_range(&kmin, delta, HRTIMER_MODE_REL);
1921−}
1922−
19231904 /**
19241905 * usleep_range - Sleep for an approximate time
19251906 * @min: Minimum time in usecs to sleep
@@ -1933,7 +1914,14 @@ static void __sched do_usleep_range(unsigned long min, unsigned long max) · 7 unmodified lines
19331914 */
19341915 void __sched usleep_range(unsigned long min, unsigned long max)
19351916 {
1936− __set_current_state(TASK_UNINTERRUPTIBLE);
1937− do_usleep_range(min, max);
1917+ ktime_t exp = ktime_add_us(ktime_get(), min);
1918+ u64 delta = (u64)(max - min) * NSEC_PER_USEC;
1919+
1920+ for (;;) {
1921+ __set_current_state(TASK_UNINTERRUPTIBLE);
1922+ /* Do not return before the requested sleep time has elapsed */
1923+ if (!schedule_hrtimeout_range(&exp, delta, HRTIMER_MODE_ABS))
1924+ break;
1925+ }
19381926 }
19391927 EXPORT_SYMBOL(usleep_range);