From nobody Sun Jun 14 07:41:59 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 DF01C42DFE6; Fri, 1 May 2026 19:40:35 +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=1777664439; cv=none; b=dEMIzPjJq4uVF2PwivXGFR3lbu8TUkv7UwTvKPvcuVsDmdYEMd3SgMaR3K2Ii5EJInmsRtO10yzYrLi9PplyFezGfbApKKScbungeyoi0odNqynqoxi82pJp70h31dsXzVoNp9IGnfY2r/YS+qjyXqXoM9K7OPmHid4XHiqdCxw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777664439; c=relaxed/simple; bh=wp6sh1AuitrL5SJgooG29iQXtY7k3nsNbLwFC4oB944=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=NMcPSqovd2+bjNxcQlCanzAPExLoAsRyeJOFye9XFlGEJ+0q+2UDDFQYa1odu+KRY9tD+lNa+L8tuJwzXU8PcCXyT0RM4aOUgRJmRBbbe12IAqnIugAu4ajHer8kwjFxWIfL2vSJg3y90oxTVlrqvERHXBM7PYyNU7ni29dnXRA= 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=QBVBLEmk; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=cp+2cL8C; 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="QBVBLEmk"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="cp+2cL8C" Date: Fri, 01 May 2026 19:40:31 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1777664432; 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=9Q/uNEgETLhcdTuNiQtmLct+blLnEYyDo1DNU0Oy3f0=; b=QBVBLEmkl0g/KEbR6htNDVhSA2tc2sroy4ycMx5UQm5NcubR1qekKkytznI3NmBp7b33DX HRZWt9LqNN3BPFxSAzNLCeSLwIBtLJqo64g/HmTYbEfuyniwNkfAYX2USogtli4JphLIaN xIE1mVFhFXxYOdMyAkE7z7efOn7n0bZw4/7n1PBpJVD86bSyIzl2OnIdCdHd41yd1qUCFF eRgYNH4rR/vZsvkVGIHOWiFXPBWMDZ8N8BFuJF8qek5527q0yDb29zB91pF5HHeCwILX9l ZKmoSaKVrsYBbRTb2el0xC7ygWE2SZsjmAzHG+GMTBZSgnCIzvcbCnMERVYCFg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1777664432; 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=9Q/uNEgETLhcdTuNiQtmLct+blLnEYyDo1DNU0Oy3f0=; b=cp+2cL8CzNWRAf+utJVpoiU31EJ3oczROSVcrPzBK80/z1Wox9istES/Kc2wrVyK+5HjW6 CV8YxlsccpvTidAg== 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] posix-timers: Handle the timer_[re]arm() return value Cc: Thomas Gleixner , Frederic Weisbecker , "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260408114952.198028466@kernel.org> References: <20260408114952.198028466@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <177766443145.3521451.3596472751043354687.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: cfb7fe3fdd4ca1d37da1ed15a1897d4a27c47a8a Gitweb: https://git.kernel.org/tip/cfb7fe3fdd4ca1d37da1ed15a1897d4a2= 7c47a8a Author: Thomas Gleixner AuthorDate: Wed, 08 Apr 2026 13:54:01 +02:00 Committer: Thomas Gleixner CommitterDate: Fri, 01 May 2026 21:36:12 +02:00 posix-timers: Handle the timer_[re]arm() return value The [re]arm callbacks will return true when the timer was queued and false if it was already expired at enqueue time. In both cases the call sites can trivially queue the signal right there, when the timer was already expired. That avoids a full round trip through the hrtimer interrupt. Signed-off-by: Thomas Gleixner Reviewed-by: Frederic Weisbecker Acked-by: Peter Zijlstra (Intel) Link: https://patch.msgid.link/20260408114952.198028466@kernel.org --- kernel/time/posix-timers.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c index da04ed4..db62cfa 100644 --- a/kernel/time/posix-timers.c +++ b/kernel/time/posix-timers.c @@ -299,6 +299,8 @@ static bool common_hrtimer_rearm(struct k_itimer *timr) =20 static bool __posixtimer_deliver_signal(struct kernel_siginfo *info, struc= t k_itimer *timr) { + bool queued; + guard(spinlock)(&timr->it_lock); =20 /* @@ -312,12 +314,18 @@ static bool __posixtimer_deliver_signal(struct kernel= _siginfo *info, struct k_it if (!timr->it_interval || WARN_ON_ONCE(timr->it_status !=3D POSIX_TIMER_R= EQUEUE_PENDING)) return true; =20 - timr->kclock->timer_rearm(timr); - timr->it_status =3D POSIX_TIMER_ARMED; + /* timer_rearm() updates timr::it_overrun */ + queued =3D timr->kclock->timer_rearm(timr); + timr->it_overrun_last =3D timr->it_overrun; timr->it_overrun =3D -1LL; ++timr->it_signal_seq; info->si_overrun =3D timer_overrun_to_int(timr); + + if (queued) + timr->it_status =3D POSIX_TIMER_ARMED; + else + posix_timer_queue_signal(timr); return true; } =20 @@ -905,9 +913,13 @@ int common_timer_set(struct k_itimer *timr, int flags, expires =3D timens_ktime_to_host(timr->it_clock, expires); sigev_none =3D timr->it_sigev_notify =3D=3D SIGEV_NONE; =20 - kc->timer_arm(timr, expires, flags & TIMER_ABSTIME, sigev_none); - if (!sigev_none) - timr->it_status =3D POSIX_TIMER_ARMED; + if (kc->timer_arm(timr, expires, flags & TIMER_ABSTIME, sigev_none)) { + if (!sigev_none) + timr->it_status =3D POSIX_TIMER_ARMED; + } else { + /* Timer was already expired, queue the signal */ + posix_timer_queue_signal(timr); + } return 0; } =20