From nobody Fri Dec 19 21:46:36 2025 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 ED5F814C58C for ; Mon, 10 Jun 2024 16:42:20 +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=1718037742; cv=none; b=qOkXzIpDdUw7/t5eUcR4+LECwTvs7/F7PnPM+EXuqdPBnJVCC+LD1eU1yvnSQPgJ880gysqWp+eYXUMxjo1f7pBiqfR63RL5WKCEfRWI0iUXMEeIUZkoUTb7P8jPp4Lg/mxGESai3qTOy+YYBC17/OTdYXxmFQ89YmdAxp4trsk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718037742; c=relaxed/simple; bh=uF1VDsOZ4FIX9FT58rai3eHyWyTmEsXGceZwBt+UMwI=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=tqzhBeIqOhGxweDGGYMXojpF6kyKczkl8xXILmtxyp373s580Pwq37Kzr1w1EYdePt77i4Hw1EJdaKi3ZM7XnzUTMVyWTNKxKglDB279CI1BN1kq9VvOZfDbVJGcnLfz13RbEpTo3wQ4mw7X94Ehqiio+JqFPSUh4paZYcocqFE= 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=1aKYBAAJ; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=D0KqAgwz; 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="1aKYBAAJ"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="D0KqAgwz" Message-ID: <20240610164026.099214180@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1718037737; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=vXPCMrPwGrJjX858eQh8BXnWzZ6Yig+J2QuB2rurbL0=; b=1aKYBAAJStW4RUQXCW07jzw6bT01OVH2YUAcLzxkU160tuv7FeJBvPAz41pc15tp+0DNI9 K0Y3P6GR07tfZ0qeYM3lNrq1ub0wl94Y22S9GXkY5/NUQhpzMa5uaUOB6bXfec2cMccwj+ bz/4I/DFwWXkVl8zooyLDIPyWHfBpBEcHCrON1fpiJDl0IWzVrwLvmqEYk9G1SS/4WbPtN E07XWf9m83rpCPv2kQT3fxYkTaL/o7hzHepz4Gef3hdHhIdLOx1Qka/8gPQwtpJDaR9O2s szhPGZYOpii+K27pyGgNhV63dpcUraoW4fYrgrGbK634akOyuTUf7Enmh/KZqQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1718037737; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=vXPCMrPwGrJjX858eQh8BXnWzZ6Yig+J2QuB2rurbL0=; b=D0KqAgwzQY3WSiLkwf4WRZKatXYq52JWwqsTLFGW5pCIScot9p6pfsXPT15T3HRBitpkB4 2nGYVamt3b19N4Dw== From: Thomas Gleixner To: LKML Cc: Anna-Maria Behnsen , Frederic Weisbecker , John Stultz , Peter Zijlstra , Ingo Molnar , Stephen Boyd , Eric Biederman , Oleg Nesterov Subject: [patch V3 10/51] posix-cpu-timers: Handle SIGEV_NONE timers correctly in timer_get() References: <20240610163452.591699700@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Mon, 10 Jun 2024 18:42:17 +0200 (CEST) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Expired SIGEV_NONE oneshot timers must return 0 nsec for the expiry time in timer_get(), but the posix CPU timer implementation returns 1 nsec. Add the missing conditional. Signed-off-by: Thomas Gleixner Reviewed-by: Frederic Weisbecker --- V2: Split out into new patch to make review simpler - Frederic --- kernel/time/posix-cpu-timers.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) --- a/kernel/time/posix-cpu-timers.c +++ b/kernel/time/posix-cpu-timers.c @@ -787,15 +787,17 @@ static int posix_cpu_timer_set(struct k_ =20 static void __posix_cpu_timer_get(struct k_itimer *timer, struct itimerspe= c64 *itp, u64 now) { + bool sigev_none =3D timer->it_sigev_notify =3D=3D SIGEV_NONE; u64 expires, iv =3D timer->it_interval; =20 /* * Make sure that interval timers are moved forward for the * following cases: + * - SIGEV_NONE timers which are never armed * - Timers which expired, but the signal has not yet been * delivered */ - if (iv && (timer->it_requeue_pending & REQUEUE_PENDING)) + if (iv && ((timer->it_requeue_pending & REQUEUE_PENDING) || sigev_none)) expires =3D bump_cpu_timer(timer, now); else expires =3D cpu_timer_getexpires(&timer->it.cpu); @@ -809,11 +811,13 @@ static void __posix_cpu_timer_get(struct itp->it_value =3D ns_to_timespec64(expires - now); } else { /* - * The timer should have expired already, but the firing - * hasn't taken place yet. Say it's just about to expire. + * A single shot SIGEV_NONE timer must return 0, when it is + * expired! Timers which have a real signal delivery mode + * must return a remaining time greater than 0 because the + * signal has not yet been delivered. */ - itp->it_value.tv_nsec =3D 1; - itp->it_value.tv_sec =3D 0; + if (!sigev_none) + itp->it_value.tv_nsec =3D 1; } }