From patchwork Tue Jan 31 10:29:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 50771 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2677315wrn; Tue, 31 Jan 2023 02:44:01 -0800 (PST) X-Google-Smtp-Source: AMrXdXudAkNdTe9Mj5F35i3ackh2cHBSjF/mwkDDDgDec8aEC977IZy0v2fMFVwjAlFRB+QUM81l X-Received: by 2002:a05:6402:28c6:b0:49b:98be:c38 with SMTP id ef6-20020a05640228c600b0049b98be0c38mr57824087edb.11.1675161840971; Tue, 31 Jan 2023 02:44:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675161840; cv=none; d=google.com; s=arc-20160816; b=S9MEXer/GkyjkK74gWbcX3RUDcnxf5QSyqEgZL9ugPQ3snbyImaWcQgGG44HnZErZQ uNQ83eSJEIkKlrX9zHU9s/bTbCB1VDM7aESn4yLfheQBQEgum1dVJ2D8HeOJZUhuyeto qudee10tq3HFq9D4UuX/fSwhTvFpLaMbMALGrfE/IftgU7stpFHh84Is4wcqvMgonCXc i8m5anEeaWTDsItbFsmSJGMmrU4y8pnKtXgQyoNj297av0tubAuRjisARxsN9hWnZr09 3xorAjygVUXp8ac9rQywhiWaAj1Ry2+DMWEiFqx8bP+gLPkgaTpgfXMJbCwxiD8TJMTX x5vA== 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=Mi0xskgCf7FEoeugCADqGqRpxrjV8N9iSMOx8TKwgyY=; b=Qr6yxK0U1IpbzEh0aIDnYOzfG0NO0wGNpS7FZdGsz4Z4lz2ZnD/GHLefLrbsEpxkGt PskyyJ4UDgdE+FVp/O44Z97pkcimuJ9lr/QUXMG+F68PXlp2L9FNFNARvehDADt7ZzPg EK+sAZU8Eaj1A45Fw8rBj5fGgpEKiBUBGPPnj2V3h7UBrOlCkSHdiowj3r6S2bUjHRUB geIgwJA14woKga0Pqna/4gvqTOaiRz0nH4Ky40nK/13PtUe41DA14t/Q9nt5XIH/1H2G /hCZD0MSzXCdcz4sUsdpkmd172qFPkd9EMaREYcP/TFAElbR0ipmP3c217FPaV7eL5Mp zI8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=o7pkl7Bm; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=rK0ix6KN; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e3-20020a50fb83000000b0049febe6cd32si16639871edq.604.2023.01.31.02.43.37; Tue, 31 Jan 2023 02:44:00 -0800 (PST) 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=o7pkl7Bm; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=rK0ix6KN; 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 S230321AbjAaK3y (ORCPT + 99 others); Tue, 31 Jan 2023 05:29:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231359AbjAaK3u (ORCPT ); Tue, 31 Jan 2023 05:29:50 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8E1E2DE4A; Tue, 31 Jan 2023 02:29:49 -0800 (PST) Date: Tue, 31 Jan 2023 10:29:47 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1675160988; 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=Mi0xskgCf7FEoeugCADqGqRpxrjV8N9iSMOx8TKwgyY=; b=o7pkl7BmSceGIKBIFG31b7hTLaYQumkypW5o134JypcNjctxCAr0wR1ByOi91tU76crIJV SyGy8x1MsBCqjc2UGUNm5HavPduD/O4w7rL02bKZpk8Dzj34kdK/EMJhmN3yIzvCglgav2 DhHPn5xrSUKnGLEBCMR6JgPeexa1tDmFy9VU3v+wUlAPHbzzLzYbRCs91Wif0vOz5E+Sst iYXR9INJHX8WJqJ8/Vsd4eBAi7PG/Oj0/1/gyw4rdv5prjHrz+u1bOg9YUvaoqJiHN//oY UcvD2GL/sin87SPiauMRj3YH4q7RYV4TEK4RfX1zRCRannJ8n1A78osCsXulwA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1675160988; 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=Mi0xskgCf7FEoeugCADqGqRpxrjV8N9iSMOx8TKwgyY=; b=rK0ix6KNPot4u+gCmovCg7/jzTNOV/pFJQfItjTIeJ25do+1bVazxUF8waEjCXO/lDBOOY J6cmpQOKFcCRPFBQ== From: "tip-bot2 for Davidlohr Bueso" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: timers/core] hrtimer: Ignore slack time for RT tasks in schedule_hrtimeout_range() Cc: Davidlohr Bueso , Thomas Gleixner , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230123173206.6764-3-dave@stgolabs.net> References: <20230123173206.6764-3-dave@stgolabs.net> MIME-Version: 1.0 Message-ID: <167516098750.4906.3310557441657379579.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756534502447028623?= X-GMAIL-MSGID: =?utf-8?q?1756534502447028623?= The following commit has been merged into the timers/core branch of tip: Commit-ID: 0c52310f260014d95c1310364379772cb74cf82d Gitweb: https://git.kernel.org/tip/0c52310f260014d95c1310364379772cb74cf82d Author: Davidlohr Bueso AuthorDate: Mon, 23 Jan 2023 09:32:06 -08:00 Committer: Thomas Gleixner CommitterDate: Tue, 31 Jan 2023 11:23:07 +01:00 hrtimer: Ignore slack time for RT tasks in schedule_hrtimeout_range() While in theory the timer can be triggered before expires + delta, for the cases of RT tasks they really have no business giving any lenience for extra slack time, so override any passed value by the user and always use zero for schedule_hrtimeout_range() calls. Furthermore, this is similar to what the nanosleep(2) family already does with current->timer_slack_ns. Signed-off-by: Davidlohr Bueso Signed-off-by: Thomas Gleixner Link: https://lore.kernel.org/r/20230123173206.6764-3-dave@stgolabs.net --- kernel/time/hrtimer.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c index 667b713..e8c0829 100644 --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -2272,7 +2272,7 @@ void __init hrtimers_init(void) /** * schedule_hrtimeout_range_clock - sleep until timeout * @expires: timeout value (ktime_t) - * @delta: slack in expires timeout (ktime_t) + * @delta: slack in expires timeout (ktime_t) for SCHED_OTHER tasks * @mode: timer mode * @clock_id: timer clock to be used */ @@ -2299,6 +2299,13 @@ schedule_hrtimeout_range_clock(ktime_t *expires, u64 delta, return -EINTR; } + /* + * Override any slack passed by the user if under + * rt contraints. + */ + if (rt_task(current)) + delta = 0; + hrtimer_init_sleeper_on_stack(&t, clock_id, mode); hrtimer_set_expires_range_ns(&t.timer, *expires, delta); hrtimer_sleeper_start_expires(&t, mode); @@ -2318,7 +2325,7 @@ EXPORT_SYMBOL_GPL(schedule_hrtimeout_range_clock); /** * schedule_hrtimeout_range - sleep until timeout * @expires: timeout value (ktime_t) - * @delta: slack in expires timeout (ktime_t) + * @delta: slack in expires timeout (ktime_t) for SCHED_OTHER tasks * @mode: timer mode * * Make the current task sleep until the given expiry time has @@ -2326,7 +2333,8 @@ EXPORT_SYMBOL_GPL(schedule_hrtimeout_range_clock); * the current task state has been set (see set_current_state()). * * The @delta argument gives the kernel the freedom to schedule the - * actual wakeup to a time that is both power and performance friendly. + * actual wakeup to a time that is both power and performance friendly + * for regular (non RT/DL) 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. *