From nobody Wed Apr 15 01:29:59 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1964BC04A68 for ; Thu, 28 Jul 2022 10:44:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236074AbiG1KoE (ORCPT ); Thu, 28 Jul 2022 06:44:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234966AbiG1KoA (ORCPT ); Thu, 28 Jul 2022 06:44:00 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 432CC13E8D; Thu, 28 Jul 2022 03:44:00 -0700 (PDT) Date: Thu, 28 Jul 2022 10:43:57 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1659005038; 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=nkwwJxLCBT1sLAFNTWn91snmMJc4bUBLtrhm7BZoKFk=; b=NqokuQYooji40wAuHTwnHeA5zTK82B81CgTd89bDy0n0+Q6vqVQ2vFbNfISmfGN441MQwq kWJVYCszmRUuyt04xGtoJW5dS3dl+rh3ifg5JSy3Vic6jYvZo6Z27EgklCPiENzKZ7tJSc 7ZAk2payrVFJckTgzgfd0i/+Ja4DWm6YL420t2ecdR2fuYAjgaKVEDHus8t3i3PV+Ou2st OeNSJCmSn4VyJla6i6RetOznPGaSXoVaZlB1jgBu8Klb832IkIn8Sgin+PgpW0MQCFZqvH 8dkKoyot+ZJo59VvZAzuLrtvIFOMZYvSWcd6BqlcKOkOmUH1zRW9gBHGw3jdLQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1659005038; 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=nkwwJxLCBT1sLAFNTWn91snmMJc4bUBLtrhm7BZoKFk=; b=7Y8B5I94clDnFs9yWsNG54ShupQLAMR7qSKQUhlWcqdJMheCSyjcFocwLx+x9P9rRtydiK OM+aIeEhcwSfpKAg== From: "tip-bot2 for Juri Lelli" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: timers/core] wait: Fix __wait_event_hrtimeout for RT/DL tasks Cc: Bruno Goncalves , Juri Lelli , Thomas Gleixner , Daniel Bristot de Oliveira , Valentin Schneider , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20220627095051.42470-1-juri.lelli@redhat.com> References: <20220627095051.42470-1-juri.lelli@redhat.com> MIME-Version: 1.0 Message-ID: <165900503767.15455.17162045260398535319.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the timers/core branch of tip: Commit-ID: cceeeb6a6d02e7b9a74ddd27a3225013b34174aa Gitweb: https://git.kernel.org/tip/cceeeb6a6d02e7b9a74ddd27a3225013b= 34174aa Author: Juri Lelli AuthorDate: Mon, 27 Jun 2022 11:50:51 +02:00 Committer: Thomas Gleixner CommitterDate: Thu, 28 Jul 2022 12:35:12 +02:00 wait: Fix __wait_event_hrtimeout for RT/DL tasks Changes to hrtimer mode (potentially made by __hrtimer_init_sleeper on PREEMPT_RT) are not visible to hrtimer_start_range_ns, thus not accounted for by hrtimer_start_expires call paths. In particular, __wait_event_hrtimeout suffers from this problem as we have, for example: fs/aio.c::read_events wait_event_interruptible_hrtimeout __wait_event_hrtimeout hrtimer_init_sleeper_on_stack <- this might "mode |=3D HRTIMER_MODE_H= ARD" on RT if task runs at RT/DL priority hrtimer_start_range_ns WARN_ON_ONCE(!(mode & HRTIMER_MODE_HARD) ^ !timer->is_hard) fires since the latter doesn't see the change of mode done by init_sleeper Fix it by making __wait_event_hrtimeout call hrtimer_sleeper_start_expires, which is aware of the special RT/DL case, instead of hrtimer_start_range_ns. Reported-by: Bruno Goncalves Signed-off-by: Juri Lelli Signed-off-by: Thomas Gleixner Reviewed-by: Daniel Bristot de Oliveira Reviewed-by: Valentin Schneider Link: https://lore.kernel.org/r/20220627095051.42470-1-juri.lelli@redhat.com --- include/linux/wait.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/include/linux/wait.h b/include/linux/wait.h index 851e07d..58cfbf8 100644 --- a/include/linux/wait.h +++ b/include/linux/wait.h @@ -544,10 +544,11 @@ do { \ \ hrtimer_init_sleeper_on_stack(&__t, CLOCK_MONOTONIC, \ HRTIMER_MODE_REL); \ - if ((timeout) !=3D KTIME_MAX) \ - hrtimer_start_range_ns(&__t.timer, timeout, \ - current->timer_slack_ns, \ - HRTIMER_MODE_REL); \ + if ((timeout) !=3D KTIME_MAX) { \ + hrtimer_set_expires_range_ns(&__t.timer, timeout, \ + current->timer_slack_ns); \ + hrtimer_sleeper_start_expires(&__t, HRTIMER_MODE_REL); \ + } \ \ __ret =3D ___wait_event(wq_head, condition, state, 0, 0, \ if (!__t.task) { \