Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp379976imn; Thu, 28 Jul 2022 03:45:04 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vF6TuwdLiCD1X71sxpxu9S3cdLplCborf1PYn23uR2IvaPoIfXnEYa09PivgBqmRieCurs X-Received: by 2002:a17:90b:3ece:b0:1f0:6b2e:6fbf with SMTP id rm14-20020a17090b3ece00b001f06b2e6fbfmr9276691pjb.203.1659005104219; Thu, 28 Jul 2022 03:45:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659005104; cv=none; d=google.com; s=arc-20160816; b=OVRJmgRQwlqJAI9OXA2em9wm9hkIUauNlp03orj7ky+oqnXkGMb107AaW2bwrGBnir T9S7+wQIRthtatdlYJPT39FMbZBi51WQGCPZ2TuIB5toEf7xmQQ23itOKkpjdhnf4SOc mkp95IvQ60O4a+Sp7sEouaIIbW308YdbN+zLEvErWfMOzgOhngsvW3mpZ9vX30nJWftK 6y+SIQw9IPUtVN7LfoBV4wlALHxPT7F8t5cw7Mf+b+4/3giptUVB0cw2nYBV3Cq0yrgn tPiphmXuZAG7cg7iG1h0L64BtmDl+26AtruqO9j++tB0vgun6SIXuCpuS31QxSe15VHo z/Ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=nkwwJxLCBT1sLAFNTWn91snmMJc4bUBLtrhm7BZoKFk=; b=NLXkq3OjE6epyu1Z/1oaFB5DMOVP9AmLWcRjYShBHFguneXVXonKKPjm03EWLJBoZu 7ZD/ybAMJGMzUb7ZsbEqsSQG2YdWWF/wZ2iyXKUb54T5Cdz7/Jlnj6uoxu1kbzUqs0UL S6iN+I6ZjJn4MkCgyNBK4J2Tih2rotJxRd6cud5feO/BsIcAe4O9xCpynM2WmexSnc23 2LJxK74Nu15leRVRteoKPDdubhMSpzQJxJ2qZyjdLdo1nuxNcxTK2y5rwDp22GXPMmoD GiiSEbQPWMLzG3Bzvw2c1uvqwrENmz2nVzctu5bRcVVfVJ0CkWzhIkSf7aMVj/UIaHfi kXpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=NqokuQYo; dkim=neutral (no key) header.i=@linutronix.de header.b=7Y8B5I94; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 22-20020a630e56000000b0041b230dbff6si710011pgo.378.2022.07.28.03.44.49; Thu, 28 Jul 2022 03:45:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=NqokuQYo; dkim=neutral (no key) header.i=@linutronix.de header.b=7Y8B5I94; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236064AbiG1KoD (ORCPT + 99 others); Thu, 28 Jul 2022 06:44:03 -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: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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/cceeeb6a6d02e7b9a74ddd27a3225013b34174aa 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 |= HRTIMER_MODE_HARD" 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) != KTIME_MAX) \ - hrtimer_start_range_ns(&__t.timer, timeout, \ - current->timer_slack_ns, \ - HRTIMER_MODE_REL); \ + if ((timeout) != KTIME_MAX) { \ + hrtimer_set_expires_range_ns(&__t.timer, timeout, \ + current->timer_slack_ns); \ + hrtimer_sleeper_start_expires(&__t, HRTIMER_MODE_REL); \ + } \ \ __ret = ___wait_event(wq_head, condition, state, 0, 0, \ if (!__t.task) { \