Skip to content

Commit

Permalink
hrtimer: Ensure timerfd notification for HIGHRES=n
Browse files Browse the repository at this point in the history
[ Upstream commit 8c3b5e6 ]

If high resolution timers are disabled the timerfd notification about a
clock was set event is not happening for all cases which use
clock_was_set_delayed() because that's a NOP for HIGHRES=n, which is wrong.

Make clock_was_set_delayed() unconditially available to fix that.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20210713135158.196661266@linutronix.de
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Thomas Gleixner authored and gregkh committed Sep 15, 2021
1 parent 77f3efd commit 961159c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 21 deletions.
5 changes: 0 additions & 5 deletions include/linux/hrtimer.h
Expand Up @@ -318,16 +318,12 @@ struct clock_event_device;

extern void hrtimer_interrupt(struct clock_event_device *dev);

extern void clock_was_set_delayed(void);

extern unsigned int hrtimer_resolution;

#else

#define hrtimer_resolution (unsigned int)LOW_RES_NSEC

static inline void clock_was_set_delayed(void) { }

#endif

static inline ktime_t
Expand All @@ -351,7 +347,6 @@ hrtimer_expires_remaining_adjusted(const struct hrtimer *timer)
timer->base->get_time());
}

extern void clock_was_set(void);
#ifdef CONFIG_TIMERFD
extern void timerfd_clock_was_set(void);
#else
Expand Down
32 changes: 16 additions & 16 deletions kernel/time/hrtimer.c
Expand Up @@ -758,22 +758,6 @@ static void hrtimer_switch_to_hres(void)
retrigger_next_event(NULL);
}

static void clock_was_set_work(struct work_struct *work)
{
clock_was_set();
}

static DECLARE_WORK(hrtimer_work, clock_was_set_work);

/*
* Called from timekeeping and resume code to reprogram the hrtimer
* interrupt device on all cpus.
*/
void clock_was_set_delayed(void)
{
schedule_work(&hrtimer_work);
}

#else

static inline int hrtimer_is_hres_enabled(void) { return 0; }
Expand Down Expand Up @@ -891,6 +875,22 @@ void clock_was_set(void)
timerfd_clock_was_set();
}

static void clock_was_set_work(struct work_struct *work)
{
clock_was_set();
}

static DECLARE_WORK(hrtimer_work, clock_was_set_work);

/*
* Called from timekeeping and resume code to reprogram the hrtimer
* interrupt device on all cpus and to notify timerfd.
*/
void clock_was_set_delayed(void)
{
schedule_work(&hrtimer_work);
}

/*
* During resume we might have to reprogram the high resolution timer
* interrupt on all online CPUs. However, all other CPUs will be
Expand Down
3 changes: 3 additions & 0 deletions kernel/time/tick-internal.h
Expand Up @@ -164,3 +164,6 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);

extern u64 get_next_timer_interrupt(unsigned long basej, u64 basem);
void timer_clear_idle(void);

void clock_was_set(void);
void clock_was_set_delayed(void);

0 comments on commit 961159c

Please sign in to comment.