All of lore.kernel.org
 help / color / mirror / Atom feed
From: "tip-bot2 for Paul Cercueil" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Paul Cercueil <paul@crapouillou.net>,
	Thomas Gleixner <tglx@linutronix.de>,
	Daniel Lezcano <daniel.lezcano@linaro.org>, x86 <x86@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: [tip: timers/core] time/sched_clock: Disable interrupts in sched_clock_register()
Date: Thu, 09 Jan 2020 17:33:56 -0000	[thread overview]
Message-ID: <157859123687.30329.9990387106834700222.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20200107010630.954648-1-paul@crapouillou.net>

The following commit has been merged into the timers/core branch of tip:

Commit-ID:     479c296303e8d29711a5153f0fc4b67faa6d9866
Gitweb:        https://git.kernel.org/tip/479c296303e8d29711a5153f0fc4b67faa6d9866
Author:        Paul Cercueil <paul@crapouillou.net>
AuthorDate:    Tue, 07 Jan 2020 02:06:29 +01:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Thu, 09 Jan 2020 18:28:34 +01: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

---
 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 dbd6905..e4332e3 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);
 }
 

  parent reply	other threads:[~2020-01-09 17:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-07  1:06 [PATCH v2 1/2] time/sched_clock: Disable interrupts in sched_clock_register Paul Cercueil
2020-01-07  1:06 ` [PATCH v2 2/2] clocksource: Add driver for the Ingenic JZ47xx OST Paul Cercueil
2020-01-09 14:28   ` Thomas Gleixner
2020-01-09 18:26     ` Paul Cercueil
2020-01-09 11:55 ` [PATCH v2 1/2] time/sched_clock: Disable interrupts in sched_clock_register Daniel Lezcano
2020-01-09 17:33 ` tip-bot2 for Paul Cercueil [this message]
2020-01-09 17:56 ` [tip: timers/core] time/sched_clock: Disable interrupts in sched_clock_register() tip-bot2 for Paul Cercueil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=157859123687.30329.9990387106834700222.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=daniel.lezcano@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=paul@crapouillou.net \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.