mirror of
https://github.com/torvalds/linux.git
synced 2024-12-12 22:23:55 +00:00
time/sched_clock: Disable interrupts in sched_clock_register()
Instead of issueing a warning if sched_clock_register() is called from a context where IRQs are enabled, the code now ensures that IRQs are indeed disabled. Signed-off-by: Paul Cercueil <paul@crapouillou.net> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20200107010630.954648-1-paul@crapouillou.net
This commit is contained in:
parent
c79f46a282
commit
2707745533
@ -169,14 +169,15 @@ sched_clock_register(u64 (*read)(void), int bits, unsigned long rate)
|
|||||||
{
|
{
|
||||||
u64 res, wrap, new_mask, new_epoch, cyc, ns;
|
u64 res, wrap, new_mask, new_epoch, cyc, ns;
|
||||||
u32 new_mult, new_shift;
|
u32 new_mult, new_shift;
|
||||||
unsigned long r;
|
unsigned long r, flags;
|
||||||
char r_unit;
|
char r_unit;
|
||||||
struct clock_read_data rd;
|
struct clock_read_data rd;
|
||||||
|
|
||||||
if (cd.rate > rate)
|
if (cd.rate > rate)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
WARN_ON(!irqs_disabled());
|
/* Cannot register a sched_clock with interrupts on */
|
||||||
|
local_irq_save(flags);
|
||||||
|
|
||||||
/* Calculate the mult/shift to convert counter ticks to ns. */
|
/* Calculate the mult/shift to convert counter ticks to ns. */
|
||||||
clocks_calc_mult_shift(&new_mult, &new_shift, rate, NSEC_PER_SEC, 3600);
|
clocks_calc_mult_shift(&new_mult, &new_shift, rate, NSEC_PER_SEC, 3600);
|
||||||
@ -233,6 +234,8 @@ sched_clock_register(u64 (*read)(void), int bits, unsigned long rate)
|
|||||||
if (irqtime > 0 || (irqtime == -1 && rate >= 1000000))
|
if (irqtime > 0 || (irqtime == -1 && rate >= 1000000))
|
||||||
enable_sched_clock_irqtime();
|
enable_sched_clock_irqtime();
|
||||||
|
|
||||||
|
local_irq_restore(flags);
|
||||||
|
|
||||||
pr_debug("Registered %pS as sched_clock source\n", read);
|
pr_debug("Registered %pS as sched_clock source\n", read);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user