hrtimer: Make hrtimer_reprogramm() unconditional
hrtimer_reprogram() needs to be available unconditionally for softirq based hrtimers. Move the function and all required struct members out of the CONFIG_HIGH_RES_TIMERS #ifdef. There is no functional change because hrtimer_reprogram() is only invoked when hrtimer_cpu_base.hres_active is true. Making it unconditional increases the text size for the CONFIG_HIGH_RES_TIMERS=n case, but avoids replication of that code for the upcoming softirq based hrtimers support. Signed-off-by: Anna-Maria Gleixner <anna-maria@linutronix.de> Cc: Christoph Hellwig <hch@lst.de> Cc: John Stultz <john.stultz@linaro.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: keescook@chromium.org Link: http://lkml.kernel.org/r/20171221104205.7269-18-anna-maria@linutronix.de Signed-off-by: Ingo Molnar <mingo@kernel.org>
This commit is contained in:
Родитель
eb27926ba0
Коммит
11a9fe069e
|
@ -182,10 +182,10 @@ struct hrtimer_cpu_base {
|
|||
unsigned int cpu;
|
||||
unsigned int active_bases;
|
||||
unsigned int clock_was_set_seq;
|
||||
unsigned int hres_active : 1;
|
||||
#ifdef CONFIG_HIGH_RES_TIMERS
|
||||
unsigned int in_hrtirq : 1,
|
||||
unsigned int hres_active : 1,
|
||||
in_hrtirq : 1,
|
||||
hang_detected : 1;
|
||||
#ifdef CONFIG_HIGH_RES_TIMERS
|
||||
unsigned int nr_events;
|
||||
unsigned short nr_retries;
|
||||
unsigned short nr_hangs;
|
||||
|
|
|
@ -581,6 +581,70 @@ hrtimer_force_reprogram(struct hrtimer_cpu_base *cpu_base, int skip_equal)
|
|||
tick_program_event(cpu_base->expires_next, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Retrigger next event is called after clock was set
|
||||
*
|
||||
* Called with interrupts disabled via on_each_cpu()
|
||||
*/
|
||||
static void retrigger_next_event(void *arg)
|
||||
{
|
||||
struct hrtimer_cpu_base *base = this_cpu_ptr(&hrtimer_bases);
|
||||
|
||||
if (!__hrtimer_hres_active(base))
|
||||
return;
|
||||
|
||||
raw_spin_lock(&base->lock);
|
||||
hrtimer_update_base(base);
|
||||
hrtimer_force_reprogram(base, 0);
|
||||
raw_spin_unlock(&base->lock);
|
||||
}
|
||||
|
||||
/*
|
||||
* Switch to high resolution mode
|
||||
*/
|
||||
static void hrtimer_switch_to_hres(void)
|
||||
{
|
||||
struct hrtimer_cpu_base *base = this_cpu_ptr(&hrtimer_bases);
|
||||
|
||||
if (tick_init_highres()) {
|
||||
printk(KERN_WARNING "Could not switch to high resolution "
|
||||
"mode on CPU %d\n", base->cpu);
|
||||
return;
|
||||
}
|
||||
base->hres_active = 1;
|
||||
hrtimer_resolution = HIGH_RES_NSEC;
|
||||
|
||||
tick_setup_sched_timer();
|
||||
/* "Retrigger" the interrupt to get things going */
|
||||
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; }
|
||||
static inline void hrtimer_switch_to_hres(void) { }
|
||||
static inline void
|
||||
hrtimer_force_reprogram(struct hrtimer_cpu_base *base, int skip_equal) { }
|
||||
static inline void retrigger_next_event(void *arg) { }
|
||||
|
||||
#endif /* CONFIG_HIGH_RES_TIMERS */
|
||||
|
||||
/*
|
||||
* When a timer is enqueued and expires earlier than the already enqueued
|
||||
* timers, we have to check, whether it expires earlier than the timer for
|
||||
|
@ -643,75 +707,6 @@ static void hrtimer_reprogram(struct hrtimer *timer,
|
|||
tick_program_event(expires, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Retrigger next event is called after clock was set
|
||||
*
|
||||
* Called with interrupts disabled via on_each_cpu()
|
||||
*/
|
||||
static void retrigger_next_event(void *arg)
|
||||
{
|
||||
struct hrtimer_cpu_base *base = this_cpu_ptr(&hrtimer_bases);
|
||||
|
||||
if (!__hrtimer_hres_active(base))
|
||||
return;
|
||||
|
||||
raw_spin_lock(&base->lock);
|
||||
hrtimer_update_base(base);
|
||||
hrtimer_force_reprogram(base, 0);
|
||||
raw_spin_unlock(&base->lock);
|
||||
}
|
||||
|
||||
/*
|
||||
* Switch to high resolution mode
|
||||
*/
|
||||
static void hrtimer_switch_to_hres(void)
|
||||
{
|
||||
struct hrtimer_cpu_base *base = this_cpu_ptr(&hrtimer_bases);
|
||||
|
||||
if (tick_init_highres()) {
|
||||
printk(KERN_WARNING "Could not switch to high resolution "
|
||||
"mode on CPU %d\n", base->cpu);
|
||||
return;
|
||||
}
|
||||
base->hres_active = 1;
|
||||
hrtimer_resolution = HIGH_RES_NSEC;
|
||||
|
||||
tick_setup_sched_timer();
|
||||
/* "Retrigger" the interrupt to get things going */
|
||||
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; }
|
||||
static inline void hrtimer_switch_to_hres(void) { }
|
||||
static inline void
|
||||
hrtimer_force_reprogram(struct hrtimer_cpu_base *base, int skip_equal) { }
|
||||
static inline int hrtimer_reprogram(struct hrtimer *timer,
|
||||
struct hrtimer_clock_base *base)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
static inline void retrigger_next_event(void *arg) { }
|
||||
|
||||
#endif /* CONFIG_HIGH_RES_TIMERS */
|
||||
|
||||
/*
|
||||
* Clock realtime was set
|
||||
*
|
||||
|
|
Загрузка…
Ссылка в новой задаче