From nobody Mon Feb 9 01:11:53 2026 Received: from mta-64-226.siemens.flowmailer.net (mta-64-226.siemens.flowmailer.net [185.136.64.226]) (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 C9B0915531A for ; Mon, 5 Aug 2024 12:41:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.136.64.226 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722861718; cv=none; b=enXqKBxzgklsGBZ1YlvMICCG7PSBymPML8/1FUZ/S6I9Ay9YT6b12WInBi+9GDR18KrMHtg734G/xqYPkMUpyCyJ3BasXUbj301AQR9rb2B1oDIWSSx/LTvetxae6thPzLijhywl17UoGuw4iTG/jfO9wTX2R16WeyALS1NiVaI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722861718; c=relaxed/simple; bh=3A6rVcuW0m0078khO1mNI86Z9b7w2oQ3ht6yUDw5gfc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XqX/he/dXxgmiube7dgaiC8eEWHS4yDS7mtHgyAoS5PwTX0grRiLUkF/6dOv1YeAYGMAt+yC/owhxl1S04CcIdLVHSkKBOWHTz6JHjbbr64khmKUrL32DtQWfouNfWUjgokE7Misv38Jma0NPManbpdnlffc9TA520/Lwm0WCJI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=siemens.com; spf=pass smtp.mailfrom=rts-flowmailer.siemens.com; dkim=pass (2048-bit key) header.d=siemens.com header.i=felix.moessbauer@siemens.com header.b=S9YqwyOF; arc=none smtp.client-ip=185.136.64.226 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=siemens.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rts-flowmailer.siemens.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=siemens.com header.i=felix.moessbauer@siemens.com header.b="S9YqwyOF" Received: by mta-64-226.siemens.flowmailer.net with ESMTPSA id 20240805124147f472750eb3c525785e for ; Mon, 05 Aug 2024 14:41:48 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=fm1; d=siemens.com; i=felix.moessbauer@siemens.com; h=Date:From:Subject:To:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc:References:In-Reply-To; bh=z1LmfkSa79b3Ou+9g4Zco79UrjCLf4Sb2US5vjHH17Q=; b=S9YqwyOF76pn6ZoLSTpfiZGZNgK+ngZt8pMMBzuPpC2BMtP/Pjn383PAfbfVV017vsXUio P21Gzy+W9eku0WGncrJRauTDz58cgwSCTYP/OLYGQXCCwlpMHAEcRora4i/zy92TDn3C4H9K 1TWVsm4trgmaa8xfPQJD82VaSCsKITrqyOhjx27K6Tt9osQjRXZRuawSVtjuYx7/GRkqLi2Z /2k9SlhoTw2pOMZbedbqVTn5KQZbyT4+EG3NvAqSutCvavKv0KZjkmixg1hD5u2v13gL6iy9 WLWCOAFGTHhIWXc9LOZAUE48y8kH3f5YviICG/Qzh5UGsm8qoswa1ILQ==; From: Felix Moessbauer To: linux-kernel@vger.kernel.org Cc: Thomas Gleixner , Frederic Weisbecker , Anna-Maria Behnsen , jan.kiszka@siemens.com, Felix Moessbauer Subject: [PATCH 1/2] hrtimer: Document, that PI boosted tasks have no timer slack Date: Mon, 5 Aug 2024 14:41:15 +0200 Message-Id: <20240805124116.21394-2-felix.moessbauer@siemens.com> In-Reply-To: <20240805124116.21394-1-felix.moessbauer@siemens.com> References: <20240805124116.21394-1-felix.moessbauer@siemens.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-1321639:519-21489:flowmailer Content-Type: text/plain; charset="utf-8" The documentation of schedule_hrtimeout_range already states, that RT and DL tasks do not have a timer slack. However, no information about PI boosted tasks is given. The current implementation consistently ignores the timer slack also for PI boosted tasks (all tasks with a rt priority at time of programming the timer). This patch improves the documentation by stating that the timer slack is also ignored for PI boosted tasks. It does not include any functional change. Signed-off-by: Felix Moessbauer --- kernel/time/hrtimer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c index b8ee320208d4..2b1469f61d9c 100644 --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -2311,7 +2311,7 @@ EXPORT_SYMBOL_GPL(schedule_hrtimeout_range_clock); * * The @delta argument gives the kernel the freedom to schedule the * actual wakeup to a time that is both power and performance friendly - * for regular (non RT/DL) tasks. + * for regular (non RT/DL or PI boosted) tasks. * The kernel give the normal best effort behavior for "@expires+@delta", * but may decide to fire the timer earlier, but no earlier than @expires. * --=20 2.39.2 From nobody Mon Feb 9 01:11:53 2026 Received: from mta-64-226.siemens.flowmailer.net (mta-64-226.siemens.flowmailer.net [185.136.64.226]) (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 6B2451598F4 for ; Mon, 5 Aug 2024 12:42:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.136.64.226 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722861722; cv=none; b=Iyb914g2p5Tuq9oIMDRaUvW4BOlGJ1kO6bLRxWHEaYcQKD7X4ozB7gmzY2v6Lg8aEOKXir4K4gmSZAfQLZMvP4m2Gq6brevzm8rUHNrsinbHgsnmldbY72SwTvBD1aGNc4NOqLeWP9TtkDykTxHj33x8klAp0D/nNVdScMRf9II= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722861722; c=relaxed/simple; bh=2oeDCd43gj3tEVG9acz79y7We8C38uo5aN+ARIR8P5k=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=l9860e5mfrpKwq1HdPtX5sanOc6M0mHo3ENec1ppAfBZWcU0yDBFPqbZnG8ABekhzgXZe9b8K4H+Yq9xKRGRJlvDrToR/8iE1D7YAJSvDW4EL+529gEsrcgL/aM3BBPO010EMYv3v8irjfBseCIUSk9TtroNCDp+95tAenDfWSc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=siemens.com; spf=pass smtp.mailfrom=rts-flowmailer.siemens.com; dkim=pass (2048-bit key) header.d=siemens.com header.i=felix.moessbauer@siemens.com header.b=SvVeTsqg; arc=none smtp.client-ip=185.136.64.226 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=siemens.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rts-flowmailer.siemens.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=siemens.com header.i=felix.moessbauer@siemens.com header.b="SvVeTsqg" Received: by mta-64-226.siemens.flowmailer.net with ESMTPSA id 202408051241522dfffbfceef6f47042 for ; Mon, 05 Aug 2024 14:41:52 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=fm1; d=siemens.com; i=felix.moessbauer@siemens.com; h=Date:From:Subject:To:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc:References:In-Reply-To; bh=sS9nfVqlSth+qJIirvho6CZ3s4rCPhOH4Nl/w1oH1ms=; b=SvVeTsqgVS6d8YDOBWAVZD2yAZdKEZeXb78g4MnbhGBBl2pDGFbGZlt0iZ1TFQsczUxLQN qe1R4T9Q3ax6gJ0U2O3JyRjeudPavxH7B84CnQtWEtbFbJbRtly5yZoDrcVU4bQ5S1xcA8VU Rd0bybvZhs5KpyLL03CR11Jp+/vFk0Yz1aa0UFdfDWmNHKjdt6V0mfcnRL2veQZ+9+dJkNMA lCYYX2m4e95OScjG21PflqgrhJl6u25AdmNddoSrlBsbHEhBDdUMSEda8Q0JTIeDTz5lPPiv y42VhNgkbwPT4HsLV6kvjlyMOqjA3a8h4ftl2TXC86bg5ZViQ4ga0qow==; From: Felix Moessbauer To: linux-kernel@vger.kernel.org Cc: Thomas Gleixner , Frederic Weisbecker , Anna-Maria Behnsen , jan.kiszka@siemens.com, Felix Moessbauer , stable@vger.kernel.org Subject: [PATCH 2/2] hrtimer: Ignore slack time for RT tasks in hrtimer_start_range_ns() Date: Mon, 5 Aug 2024 14:41:16 +0200 Message-Id: <20240805124116.21394-3-felix.moessbauer@siemens.com> In-Reply-To: <20240805124116.21394-1-felix.moessbauer@siemens.com> References: <20240805124116.21394-1-felix.moessbauer@siemens.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-1321639:519-21489:flowmailer Content-Type: text/plain; charset="utf-8" RT tasks do not have any timerslack, as this induces jitter. By that, the timer slack is already ignored in the nanosleep family and schedule_hrtimeout_range() (fixed in 0c52310f2600). The hrtimer_start_range_ns function is indirectly used by glibc-2.33+ for timed waits on condition variables. These are sometimes used in RT applications for realtime queue processing. At least on the combination of kernel 5.10 and glibc-2.31, the timed wait on condition variables in rt tasks was precise (no slack), however glibc-2.33 changed the internal wait implementation, exposing the kernel bug. This patch makes the timer slack consistent across all hrtimer programming code, by ignoring the timerslack for rt tasks also in the last remaining location in hrtimer_start_range_ns(). Similar to 0c52310f2600, this fix should be backported as well. Cc: stable@vger.kernel.org Signed-off-by: Felix Moessbauer --- kernel/time/hrtimer.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c index 2b1469f61d9c..1b26e095114d 100644 --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -1274,7 +1274,7 @@ static int __hrtimer_start_range_ns(struct hrtimer *t= imer, ktime_t tim, * hrtimer_start_range_ns - (re)start an hrtimer * @timer: the timer to be added * @tim: expiry time - * @delta_ns: "slack" range for the timer + * @delta_ns: "slack" range for the timer for SCHED_OTHER tasks * @mode: timer mode: absolute (HRTIMER_MODE_ABS) or * relative (HRTIMER_MODE_REL), and pinned (HRTIMER_MODE_PINNED); * softirq based mode is considered for debug purpose only! @@ -1299,6 +1299,10 @@ void hrtimer_start_range_ns(struct hrtimer *timer, k= time_t tim, =20 base =3D lock_hrtimer_base(timer, &flags); =20 + /* rt-tasks do not have a timer slack for obvious reasons */ + if (rt_task(current)) + delta_ns =3D 0; + if (__hrtimer_start_range_ns(timer, tim, delta_ns, mode, base)) hrtimer_reprogram(timer, true); =20 --=20 2.39.2