linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Frederic Weisbecker <frederic@kernel.org>
To: Thomas Gleixner <tglx@linutronix.de>,
	Anna-Maria Behnsen <anna-maria@linutronix.de>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Frederic Weisbecker <frederic@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Juri Lelli <juri.lelli@redhat.com>
Subject: [PATCH 02/12] timer: Preserve higher bits of expiration on index calculation
Date: Fri, 17 Jul 2020 16:05:41 +0200	[thread overview]
Message-ID: <20200717140551.29076-3-frederic@kernel.org> (raw)
In-Reply-To: <20200717140551.29076-1-frederic@kernel.org>

The higher bits of the timer expiration are cropped while calling
calc_index() due to the implicit cast from unsigned long to unsigned int.

This loss shouldn't have consequences on the current code since all the
computation to calculate the index is done on the lower 32 bits.

However we are preparing to return the actual bucket expiration from
calc_index() in order to properly fix base->next_expiry updates.
Preserving the higher bits is a requirement to achieve that.

Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
Cc: Frederic Weisbecker <frederic@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Juri Lelli <juri.lelli@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Anna-Maria Behnsen <anna-maria@linutronix.de>
---
 kernel/time/timer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/time/timer.c b/kernel/time/timer.c
index df1ff803acc4..bcdc3045138d 100644
--- a/kernel/time/timer.c
+++ b/kernel/time/timer.c
@@ -487,7 +487,7 @@ static inline void timer_set_idx(struct timer_list *timer, unsigned int idx)
  * Helper function to calculate the array index for a given expiry
  * time.
  */
-static inline unsigned calc_index(unsigned expires, unsigned lvl)
+static inline unsigned calc_index(unsigned long expires, unsigned lvl)
 {
 	expires = (expires + LVL_GRAN(lvl)) >> LVL_SHIFT(lvl);
 	return LVL_OFFS(lvl) + (expires & LVL_MASK);
-- 
2.26.2


  parent reply	other threads:[~2020-07-17 14:06 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-17 14:05 [PATCH 00/11] timer: Reduce timers softirq v3 Frederic Weisbecker
2020-07-17 14:05 ` [PATCH 01/12] timer: Fix wheel index calculation on last level Frederic Weisbecker
2020-07-17 19:49   ` [tip: timers/urgent] " tip-bot2 for Frederic Weisbecker
2020-07-17 14:05 ` Frederic Weisbecker [this message]
2020-07-17 20:00   ` [tip: timers/core] timers: Preserve higher bits of expiration on index calculation tip-bot2 for Frederic Weisbecker
2020-07-17 14:05 ` [PATCH 03/12] timers: Use only bucket expiry for base->next_expiry value Frederic Weisbecker
2020-07-17 20:00   ` [tip: timers/core] " tip-bot2 for Anna-Maria Behnsen
2020-07-17 14:05 ` [PATCH 04/12] timer: Move trigger_dyntick_cpu() to enqueue_timer() Frederic Weisbecker
2020-07-17 20:00   ` [tip: timers/core] timers: " tip-bot2 for Frederic Weisbecker
2020-07-17 14:05 ` [PATCH 05/12] timer: Add comments about calc_index() ceiling work Frederic Weisbecker
2020-07-17 20:00   ` [tip: timers/core] timers: " tip-bot2 for Frederic Weisbecker
2020-07-17 14:05 ` [PATCH 06/12] timer: Optimize _next_timer_interrupt() level iteration Frederic Weisbecker
2020-07-17 20:00   ` [tip: timers/core] timers: " tip-bot2 for Frederic Weisbecker
2020-07-17 14:05 ` [PATCH 07/12] timers: Always keep track of next expiry Frederic Weisbecker
2020-07-17 20:00   ` [tip: timers/core] " tip-bot2 for Frederic Weisbecker
2020-07-17 14:05 ` [PATCH 08/12] timer: Reuse next expiry cache after nohz exit Frederic Weisbecker
2020-07-17 20:00   ` [tip: timers/core] timers: " tip-bot2 for Frederic Weisbecker
2020-07-17 14:05 ` [PATCH 09/12] timer: Expand clk forward logic beyond nohz Frederic Weisbecker
2020-07-17 20:00   ` [tip: timers/core] timers: " tip-bot2 for Frederic Weisbecker
2020-07-17 14:05 ` [PATCH 10/12] timer: Spare timer softirq until next expiry Frederic Weisbecker
2020-07-17 20:00   ` [tip: timers/core] timers: " tip-bot2 for Frederic Weisbecker
2020-07-17 14:05 ` [PATCH 11/12] timer: Remove must_forward_clk Frederic Weisbecker
2020-07-17 20:00   ` [tip: timers/core] timers: " tip-bot2 for Frederic Weisbecker
2020-07-17 14:05 ` [PATCH 12/12] timer: Lower base clock forwarding threshold Frederic Weisbecker
2020-07-17 20:00   ` [tip: timers/core] timers: " tip-bot2 for Frederic Weisbecker

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=20200717140551.29076-3-frederic@kernel.org \
    --to=frederic@kernel.org \
    --cc=anna-maria@linutronix.de \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).