Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 810fb07a authored by Linus Torvalds's avatar Linus Torvalds
Browse files

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

Pull timer fixes from Thomas Gleixner:
 "Two fixes from the timer departement:

   - Fix a long standing issue in the NOHZ tick code which causes RB
     tree corruption, delayed timers and other malfunctions. The cause
     for this is code which modifies the expiry time of an enqueued
     hrtimer.

   - Revert the CLOCK_MONOTONIC/CLOCK_BOOTTIME unification due to
     regression reports. Seems userspace _is_ relying on the documented
     behaviour despite our hope that it wont"

* 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  Revert: Unify CLOCK_MONOTONIC and CLOCK_BOOTTIME
  tick/sched: Do not mess with an enqueued hrtimer
parents 7d9e55fe a3ed0e43
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -461,9 +461,17 @@ of ftrace. Here is a list of some of the key files:
		and ticks at the same rate as the hardware clocksource.

	boot:
		Same as mono. Used to be a separate clock which accounted
		for the time spent in suspend while CLOCK_MONOTONIC did
		not.
		This is the boot clock (CLOCK_BOOTTIME) and is based on the
		fast monotonic clock, but also accounts for time spent in
		suspend. Since the clock access is designed for use in
		tracing in the suspend path, some side effects are possible
		if clock is accessed after the suspend time is accounted before
		the fast mono clock is updated. In this case, the clock update
		appears to happen slightly sooner than it normally would have.
		Also on 32-bit systems, it's possible that the 64-bit boot offset
		sees a partial update. These effects are rare and post
		processing should be able to handle them. See comments in the
		ktime_get_boot_fast_ns() function for more information.

	To set a clock, simply echo the clock name into this file::

+6 −1
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@
enum evdev_clock_type {
	EV_CLK_REAL = 0,
	EV_CLK_MONO,
	EV_CLK_BOOT,
	EV_CLK_MAX
};

@@ -197,10 +198,12 @@ static int evdev_set_clk_type(struct evdev_client *client, unsigned int clkid)
	case CLOCK_REALTIME:
		clk_type = EV_CLK_REAL;
		break;
	case CLOCK_BOOTTIME:
	case CLOCK_MONOTONIC:
		clk_type = EV_CLK_MONO;
		break;
	case CLOCK_BOOTTIME:
		clk_type = EV_CLK_BOOT;
		break;
	default:
		return -EINVAL;
	}
@@ -311,6 +314,8 @@ static void evdev_events(struct input_handle *handle,

	ev_time[EV_CLK_MONO] = ktime_get();
	ev_time[EV_CLK_REAL] = ktime_mono_to_real(ev_time[EV_CLK_MONO]);
	ev_time[EV_CLK_BOOT] = ktime_mono_to_any(ev_time[EV_CLK_MONO],
						 TK_OFFS_BOOT);

	rcu_read_lock();

+2 −0
Original line number Diff line number Diff line
@@ -161,9 +161,11 @@ struct hrtimer_clock_base {
enum  hrtimer_base_type {
	HRTIMER_BASE_MONOTONIC,
	HRTIMER_BASE_REALTIME,
	HRTIMER_BASE_BOOTTIME,
	HRTIMER_BASE_TAI,
	HRTIMER_BASE_MONOTONIC_SOFT,
	HRTIMER_BASE_REALTIME_SOFT,
	HRTIMER_BASE_BOOTTIME_SOFT,
	HRTIMER_BASE_TAI_SOFT,
	HRTIMER_MAX_CLOCK_BASES,
};
+0 −2
Original line number Diff line number Diff line
@@ -52,7 +52,6 @@ struct tk_read_base {
 * @offs_real:		Offset clock monotonic -> clock realtime
 * @offs_boot:		Offset clock monotonic -> clock boottime
 * @offs_tai:		Offset clock monotonic -> clock tai
 * @time_suspended:	Accumulated suspend time
 * @tai_offset:		The current UTC to TAI offset in seconds
 * @clock_was_set_seq:	The sequence number of clock was set events
 * @cs_was_changed_seq:	The sequence number of clocksource change events
@@ -95,7 +94,6 @@ struct timekeeper {
	ktime_t			offs_real;
	ktime_t			offs_boot;
	ktime_t			offs_tai;
	ktime_t			time_suspended;
	s32			tai_offset;
	unsigned int		clock_was_set_seq;
	u8			cs_was_changed_seq;
+25 −12
Original line number Diff line number Diff line
@@ -33,7 +33,6 @@ extern void ktime_get_ts64(struct timespec64 *ts);
extern time64_t ktime_get_seconds(void);
extern time64_t __ktime_get_real_seconds(void);
extern time64_t ktime_get_real_seconds(void);
extern void ktime_get_active_ts64(struct timespec64 *ts);

extern int __getnstimeofday64(struct timespec64 *tv);
extern void getnstimeofday64(struct timespec64 *tv);
@@ -41,17 +40,13 @@ extern void getboottime64(struct timespec64 *ts);

#define ktime_get_real_ts64(ts)	getnstimeofday64(ts)

/* Clock BOOTTIME compatibility wrappers */
static inline void get_monotonic_boottime64(struct timespec64 *ts)
{
	ktime_get_ts64(ts);
}

/*
 * ktime_t based interfaces
 */

enum tk_offsets {
	TK_OFFS_REAL,
	TK_OFFS_BOOT,
	TK_OFFS_TAI,
	TK_OFFS_MAX,
};
@@ -62,10 +57,6 @@ extern ktime_t ktime_mono_to_any(ktime_t tmono, enum tk_offsets offs);
extern ktime_t ktime_get_raw(void);
extern u32 ktime_get_resolution_ns(void);

/* Clock BOOTTIME compatibility wrappers */
static inline ktime_t ktime_get_boottime(void) { return ktime_get(); }
static inline u64 ktime_get_boot_ns(void) { return ktime_get(); }

/**
 * ktime_get_real - get the real (wall-) time in ktime_t format
 */
@@ -74,6 +65,17 @@ static inline ktime_t ktime_get_real(void)
	return ktime_get_with_offset(TK_OFFS_REAL);
}

/**
 * ktime_get_boottime - Returns monotonic time since boot in ktime_t format
 *
 * This is similar to CLOCK_MONTONIC/ktime_get, but also includes the
 * time spent in suspend.
 */
static inline ktime_t ktime_get_boottime(void)
{
	return ktime_get_with_offset(TK_OFFS_BOOT);
}

/**
 * ktime_get_clocktai - Returns the TAI time of day in ktime_t format
 */
@@ -100,6 +102,11 @@ static inline u64 ktime_get_real_ns(void)
	return ktime_to_ns(ktime_get_real());
}

static inline u64 ktime_get_boot_ns(void)
{
	return ktime_to_ns(ktime_get_boottime());
}

static inline u64 ktime_get_tai_ns(void)
{
	return ktime_to_ns(ktime_get_clocktai());
@@ -112,11 +119,17 @@ static inline u64 ktime_get_raw_ns(void)

extern u64 ktime_get_mono_fast_ns(void);
extern u64 ktime_get_raw_fast_ns(void);
extern u64 ktime_get_boot_fast_ns(void);
extern u64 ktime_get_real_fast_ns(void);

/*
 * timespec64 interfaces utilizing the ktime based ones
 */
static inline void get_monotonic_boottime64(struct timespec64 *ts)
{
	*ts = ktime_to_timespec64(ktime_get_boottime());
}

static inline void timekeeping_clocktai64(struct timespec64 *ts)
{
	*ts = ktime_to_timespec64(ktime_get_clocktai());
Loading