From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C64723A7840 for ; Tue, 24 Feb 2026 16:38:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771951081; cv=none; b=cGaVSjeYYAMWEeQPoxrSpwl4cJyryTb21p4R/MU6fGtf+wSgpAvcGLwblseSGU5p++8i8w9MG2IIPevLRhJt61WLlkf0fI5dthM3g+UqdvobMjdtBllfr3tKW8ajuHkHPiiEip9Iq+ReiWW2mxrAeSqqtyX+ffXTBv5MBXG8NjM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771951081; c=relaxed/simple; bh=RZl68DY8fdYAWHtGAsOCw4dlq5rNslnt+7CvrsCiDHs=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=tL6VmZ7l/b87RSK7peUNVN6+yt00hOBzl74VR5/sYezNPy5eudxm3VnWzM2yueuYyLxsp+e/9H4VRvCEj7Yj7YCtRcbL4qHYCpN2jc28tDA63RgiIUASNOR6qgL1lKqc419Cy4aniTot2OkYgrJPbbJuAurKm2rXEMWwPVwbFko= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=I7IpcWUK; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="I7IpcWUK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C0966C116D0; Tue, 24 Feb 2026 16:38:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1771951081; bh=RZl68DY8fdYAWHtGAsOCw4dlq5rNslnt+7CvrsCiDHs=; h=Date:From:To:Cc:Subject:References:From; b=I7IpcWUKcl9nFJWAY24o2ZBPvwb1bA3SLRpJg1HRnPP5oT6uwds7vHW/+hwcEZnvO ILKN52jATxHrT5NrKMEEJv0HRYoWcdAbGen3d6HU6Ht8eUDgoqejsautXmfIFN7VcB NK0nYTKKRloCpIxgmFDjkDkZ5lXxHOWmHzLY1MDYhUJ59Wod35uYrLuH2ZBZfMK6Zb mQVv+TgWU+6w0yIyXBlzXdyU+BeRuQ2MIc8SxoNtW/eYv4azWXLRnvXNv4BUV73Vdi zJy/7WRPwvsjV9WJ/44LM0t2dEBIukwvXAYAoElKkT9l7mC0olnfHIR23OF6YWFBOS HeXg6mCOuXLCA== Date: Tue, 24 Feb 2026 17:37:58 +0100 Message-ID: <20260224163431.000891171@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: Anna-Maria Behnsen , John Stultz , Stephen Boyd , Daniel Lezcano , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , x86@kernel.org, Peter Zijlstra , Frederic Weisbecker , Eric Dumazet Subject: [patch 34/48] hrtimer: Prepare stubs for deferred rearming References: <20260224163022.795809588@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 From: Peter Zijlstra The hrtimer interrupt expires timers and at the end of the interrupt it rearms the clockevent device for the next expiring timer. That's obviously correct, but in the case that a expired timer set NEED_RESCHED the return from interrupt ends up in schedule(). If HRTICK is enabled then schedule() will modify the hrtick timer, which causes another reprogramming of the hardware. That can be avoided by deferring the rearming to the return from interrupt path and if the return results in a immediate schedule() invocation then it can be deferred until the end of schedule(). To make this correct the affected code parts need to be made aware of this. Provide empty stubs for the deferred rearming mechanism, so that the relevant code changes for entry, softirq and scheduler can be split up into separate changes independent of the actual enablement in the hrtimer code. Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Thomas Gleixner --- tglx: Split out to make it simpler to review and to make cross subsystem merge logistics trivial. --- include/linux/hrtimer.h | 1 + include/linux/hrtimer_rearm.h | 21 +++++++++++++++++++++ kernel/time/Kconfig | 4 ++++ 3 files changed, 26 insertions(+) --- a/include/linux/hrtimer.h +++ b/include/linux/hrtimer.h @@ -13,6 +13,7 @@ #define _LINUX_HRTIMER_H #include +#include #include #include #include --- /dev/null +++ b/include/linux/hrtimer_rearm.h @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0 +#ifndef _LINUX_HRTIMER_REARM_H +#define _LINUX_HRTIMER_REARM_H + +#ifdef CONFIG_HRTIMER_REARM_DEFERRED +static __always_inline void __hrtimer_rearm_deferred(void) { } +static __always_inline void hrtimer_rearm_deferred(void) { } +static __always_inline void hrtimer_rearm_deferred_tif(unsigned long tif_work) { } +static __always_inline bool +hrtimer_rearm_deferred_user_irq(unsigned long *tif_work, const unsigned long tif_mask) { return false; } +static __always_inline bool hrtimer_test_and_clear_rearm_deferred(void) { return false; } +#else /* CONFIG_HRTIMER_REARM_DEFERRED */ +static __always_inline void __hrtimer_rearm_deferred(void) { } +static __always_inline void hrtimer_rearm_deferred(void) { } +static __always_inline void hrtimer_rearm_deferred_tif(unsigned long tif_work) { } +static __always_inline bool +hrtimer_rearm_deferred_user_irq(unsigned long *tif_work, const unsigned long tif_mask) { return false; } +static __always_inline bool hrtimer_test_and_clear_rearm_deferred(void) { return false; } +#endif /* !CONFIG_HRTIMER_REARM_DEFERRED */ + +#endif --- a/kernel/time/Kconfig +++ b/kernel/time/Kconfig @@ -58,6 +58,10 @@ config GENERIC_CLOCKEVENTS_COUPLED_INLIN config GENERIC_CMOS_UPDATE bool +# Deferred rearming of the hrtimer interrupt +config HRTIMER_REARM_DEFERRED + def_bool n + # Select to handle posix CPU timers from task_work # and not from the timer interrupt context config HAVE_POSIX_CPU_TIMERS_TASK_WORK