[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <40cce150-0783-d382-b236-928fbe34e8d4@linaro.org>
Date: Thu, 9 Jan 2020 12:55:47 +0100
From: Daniel Lezcano <daniel.lezcano@...aro.org>
To: Paul Cercueil <paul@...pouillou.net>,
Thomas Gleixner <tglx@...utronix.de>
Cc: od@...c.me, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 1/2] time/sched_clock: Disable interrupts in
sched_clock_register
On 07/01/2020 02:06, Paul Cercueil wrote:
> 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@...pouillou.net>
Acked-by: Daniel Lezcano <daniel.lezcano@...aro.org>
> ---
>
> Notes:
> v2: New patch
>
> kernel/time/sched_clock.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/time/sched_clock.c b/kernel/time/sched_clock.c
> index dbd69052eaa6..e4332e3e2d56 100644
> --- a/kernel/time/sched_clock.c
> +++ b/kernel/time/sched_clock.c
> @@ -169,14 +169,15 @@ sched_clock_register(u64 (*read)(void), int bits, unsigned long rate)
> {
> u64 res, wrap, new_mask, new_epoch, cyc, ns;
> u32 new_mult, new_shift;
> - unsigned long r;
> + unsigned long r, flags;
> char r_unit;
> struct clock_read_data rd;
>
> if (cd.rate > rate)
> 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. */
> 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))
> enable_sched_clock_irqtime();
>
> + local_irq_restore(flags);
> +
> pr_debug("Registered %pS as sched_clock source\n", read);
> }
>
>
--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
Powered by blists - more mailing lists