From nobody Sun Jun 14 07:41:20 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 AD99F425CFF; Fri, 1 May 2026 19:40:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777664438; cv=none; b=Nvbi5iJzHPH5lRyN+8AWX+Ed6hsyHJ9DjNQIhODGN1ter5a3XznGr2c6Hd5cogrXiY2L7uMAV0tc+Qj4F5VKzAZDTGzU3TVpi4lrUPR96vMZQFxf4cj+32S2FCjlT3TzeTm3WMgj7AEpeB4Cv0EgZ3FWAythpTm6dhe2KdqjcXY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777664438; c=relaxed/simple; bh=mRxyqFYuolnrUdt9YTJRdAFdOyBBQ2kO4Kvmx3Wqm6E=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=qWZVVHJ5NaYYNK0pWcgoT5uVKXxvbU+43sROjpiR61jS+OlfT3FIF5c3PhaZrtOxQFDr+fEjbBILpnEB4JgJOrDcCApUSYaOsz6TpnQTWeGRcSIR0nZTSInXLk5r+S+EDXBqAXzk6TKOk48enaoX3FRnEcQxhDuvEDgvlEsphBo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=h86iLPYw; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=5Qhnwfyt; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="h86iLPYw"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="5Qhnwfyt" Date: Fri, 01 May 2026 19:40:28 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1777664430; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uvbHFs5zVSLVilZ59+AIyzQUO28HYopsgXZPr9kTwNY=; b=h86iLPYwBVPRH94zZGsph8QEspSasB+N/aEnrl+716G8COjjvyUp8GNLckW/Lzc5/fzINA 2jAvPubNW7n6QgmaZYLfqK90/eEelnxMW1Dj3t0Y172s4Eb/tfBXUshYpqSf5+p5yAX8RO 5wcQvuIVhY7yRzvK3kD6FNUNP5s0i61lu3BcpMPYG7dHVvWjyhV3cKwhlJ3KQmzIgVkkVV WhSubApZ0gvWnA6rDpfDFyXREeP4qMMms5RBYSXYlYM27pRHa8x9BEIFdgu+4umT4zfnbS RqFbxrHEeGSC9uJeDwJTvFH04M/vY83xIcfs9ICYU0dNtBp6y+eUOLBitlcL5w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1777664430; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uvbHFs5zVSLVilZ59+AIyzQUO28HYopsgXZPr9kTwNY=; b=5QhnwfytrpxKV5P4kSEwE8KAnLUg/h/xktApl4LWKY25f25u9C4iaSTXQLAk+jv1bi4kPt IYrd/QodJClMPeDg== From: "tip-bot2 for Thomas Gleixner" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: timers/core] alarmtimer: Provide alarm_start_timer() Cc: Thomas Gleixner , Frederic Weisbecker , John Stultz , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260408114952.332822525@kernel.org> References: <20260408114952.332822525@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <177766442877.3521451.14094343376390259750.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the timers/core branch of tip: Commit-ID: 183d00b727139cf3b4be78d66a5602ce71a3acec Gitweb: https://git.kernel.org/tip/183d00b727139cf3b4be78d66a5602ce7= 1a3acec Author: Thomas Gleixner AuthorDate: Wed, 08 Apr 2026 13:54:11 +02:00 Committer: Thomas Gleixner CommitterDate: Fri, 01 May 2026 21:36:12 +02:00 alarmtimer: Provide alarm_start_timer() Alarm timers utilize hrtimers for normal operation and only switch to the RTC on suspend. In order to catch already expired timers early and without going through a timer interrupt cycle, provide a new start function which internally uses hrtimer_start_range_ns_user(). If hrtimer_start_range_ns_user() detects an already expired timer, it does not queue it. In that case remove the timer from the alarm base as well. Return the status queued or not back to the caller to handle the early expiry. Signed-off-by: Thomas Gleixner Reviewed-by: Frederic Weisbecker Acked-by: John Stultz Link: https://patch.msgid.link/20260408114952.332822525@kernel.org --- include/linux/alarmtimer.h | 6 ++++++ kernel/time/alarmtimer.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/include/linux/alarmtimer.h b/include/linux/alarmtimer.h index 3ffa534..14d729f 100644 --- a/include/linux/alarmtimer.h +++ b/include/linux/alarmtimer.h @@ -42,8 +42,14 @@ struct alarm { void *data; }; =20 +static __always_inline ktime_t alarm_get_expires(struct alarm *alarm) +{ + return alarm->node.expires; +} + void alarm_init(struct alarm *alarm, enum alarmtimer_type type, void (*function)(struct alarm *, ktime_t)); +bool alarm_start_timer(struct alarm *alarm, ktime_t expires, bool relative= ); void alarm_start(struct alarm *alarm, ktime_t start); void alarm_start_relative(struct alarm *alarm, ktime_t start); void alarm_restart(struct alarm *alarm); diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c index e10021b..2348b08 100644 --- a/kernel/time/alarmtimer.c +++ b/kernel/time/alarmtimer.c @@ -369,6 +369,34 @@ void alarm_start_relative(struct alarm *alarm, ktime_t= start) } EXPORT_SYMBOL_GPL(alarm_start_relative); =20 +/** + * alarm_start_timer - Sets an alarm to fire + * @alarm: Pointer to alarm to set + * @expires: Expiry time + * @relative: True if @expires is relative + * + * Returns: True if the alarm was queued. False if it already expired + */ +bool alarm_start_timer(struct alarm *alarm, ktime_t expires, bool relative) +{ + struct alarm_base *base =3D &alarm_bases[alarm->type]; + + if (relative) + expires =3D ktime_add_safe(expires, base->get_ktime()); + + trace_alarmtimer_start(alarm, base->get_ktime()); + + guard(spinlock_irqsave)(&base->lock); + alarm->node.expires =3D expires; + alarmtimer_enqueue(base, alarm); + if (!hrtimer_start_range_ns_user(&alarm->timer, expires, 0, HRTIMER_MODE_= ABS)) { + alarmtimer_dequeue(base, alarm); + return false; + } + return true; +} +EXPORT_SYMBOL_GPL(alarm_start_timer); + void alarm_restart(struct alarm *alarm) { struct alarm_base *base =3D &alarm_bases[alarm->type];