From patchwork Mon Jan 23 17:32:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Davidlohr Bueso X-Patchwork-Id: 645901 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 3B5CBC61DA0 for ; Mon, 23 Jan 2023 18:05:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233666AbjAWSFC (ORCPT ); Mon, 23 Jan 2023 13:05:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233833AbjAWSEw (ORCPT ); Mon, 23 Jan 2023 13:04:52 -0500 Received: from crane.ash.relay.mailchannels.net (crane.ash.relay.mailchannels.net [23.83.222.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3448421F; Mon, 23 Jan 2023 10:04:49 -0800 (PST) X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 4DB12641DF7; Mon, 23 Jan 2023 17:58:45 +0000 (UTC) Received: from pdx1-sub0-mail-a264.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 978BE641ECF; Mon, 23 Jan 2023 17:58:44 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1674496724; a=rsa-sha256; cv=none; b=1Ggyp8gC6IxDBGnQUMw+pGkiFOhzZZgq8big6vOge/eAAazp2pJPPj6ovA+o+7dfdp0zA2 ZXsQSO75O+b7bEylBZEC5yl+ODHzFMNCRCAe7AgW3F+UW0nnEDEqNbrebVx6efG6VjFRq5 AnJENdtfAiy22n5RBi8nuPOk+n8lASYN+GoGyWySW1dDDmhaHBZb4UX9alXntU5Zvq19RH QCgVhwGxtsSsNY6WxBSRQ5lALUw6PLi3K3bNO5xmUhe9tLnSI5wD6X3h/Xknw/lxuIAarY 5hqgBB3K+68c6uKjmR3rl9PgBVd66qr1UmmpE4VbryoCpH7p6bhif6gSraheQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1674496724; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=UklrNt/RN+54aaIDk4F5mKXRmBIU//hy7Ueqk16w5R0=; b=MInsk7TYoP+nFLC2XA3Ox35fQSxhw39ktL11cMVwsPeDNjOvLuu2dspT4gCqXn4pOQLaQH 0PGuw1O+8QasA1cOEuqTfZjQ8iboKCdtF3rFNlnOU7Wx3YXdBxy14RChRsky38N2nnzvsh JBUeSxdb9LJsXgID5Orun+6KrlXL5fy+fhts0Onuhr/XJO0Gt5sKpil4/l4Zbr2mXFcoDp 0JGJuxDoL6BnxUEpmNfkB6madxmdLJ572R5KWY4XPAKwFzAqH2+D5DPuYe+qpDH5iHYRnY xyTJGOb8AZU1uaBaxKdb5+P5yU7y/wEs03XrjhAUSeNEvSYOzXHv4bAmjc1xwA== ARC-Authentication-Results: i=1; rspamd-7cf955c847-fl9rx; auth=pass smtp.auth=dreamhost smtp.mailfrom=dave@stgolabs.net X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|dave@stgolabs.net X-MailChannels-Auth-Id: dreamhost X-Name-Occur: 563c0d213d670cc0_1674496725106_3431940781 X-MC-Loop-Signature: 1674496725105:3905830636 X-MC-Ingress-Time: 1674496725105 Received: from pdx1-sub0-mail-a264.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.126.30.40 (trex/6.7.1); Mon, 23 Jan 2023 17:58:45 +0000 Received: from localhost.localdomain (ip72-199-50-187.sd.sd.cox.net [72.199.50.187]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dave@stgolabs.net) by pdx1-sub0-mail-a264.dreamhost.com (Postfix) with ESMTPSA id 4P0yX358VpzM8; Mon, 23 Jan 2023 09:58:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stgolabs.net; s=dreamhost; t=1674496724; bh=UklrNt/RN+54aaIDk4F5mKXRmBIU//hy7Ueqk16w5R0=; h=From:To:Cc:Subject:Date:Content-Transfer-Encoding; b=FKfcOKT9J+XoFz4KtYifygqu/wJtK9QUnD8SdiIDcaJF0umKupUqfzG7ta6iEC9oU uLX4tChu16KVNKiZkv8SyP6lLJZHxNIAmghJB91T2U0Gy+CimTRsuQzPcCJIAeqlrT IM3YNbkFsus4RwtmCitLK0rSSZs8wPHijMe5AadaVyRxNXd4BjXTeEdi/fasSBfK32 LRumDPuZ5AvgRabKWJLXLgYzhjPpyNGT74ljn8K1yTGE4ej5tIQJwr/k1vJu+GA5bt TZqa4Vyqz+ly3bqx+LF6cmA9xYdxEUQGKa4uIXaYIob+Xv0FxZ5lxGkX+UEPN4flEo 9N1A3xUK2EhtQ== From: Davidlohr Bueso To: tglx@linutronix.de Cc: mingo@kernel.org, peterz@infradead.org, bigeasy@linutronix.de, dave@stgolabs.net, linux-rt-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] kernel/hrtimer: Rely on rt_task() for DL tasks too Date: Mon, 23 Jan 2023 09:32:05 -0800 Message-Id: <20230123173206.6764-2-dave@stgolabs.net> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230123173206.6764-1-dave@stgolabs.net> References: <20230123173206.6764-1-dave@stgolabs.net> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org Having dl_task() is redundant, trivially simplify. Signed-off-by: Davidlohr Bueso --- 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 3ae661ab6260..8336c2618ec1 100644 --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -2089,7 +2089,7 @@ long hrtimer_nanosleep(ktime_t rqtp, const enum hrtimer_mode mode, u64 slack; slack = current->timer_slack_ns; - if (dl_task(current) || rt_task(current)) + if (rt_task(current)) slack = 0; hrtimer_init_sleeper_on_stack(&t, clockid, mode); From patchwork Mon Jan 23 17:32:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Davidlohr Bueso X-Patchwork-Id: 645900 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 D88D2C25B50 for ; Mon, 23 Jan 2023 18:07:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233847AbjAWSHO (ORCPT ); Mon, 23 Jan 2023 13:07:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233840AbjAWSHJ (ORCPT ); Mon, 23 Jan 2023 13:07:09 -0500 Received: from bird.elm.relay.mailchannels.net (bird.elm.relay.mailchannels.net [23.83.212.17]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F03230E8B; Mon, 23 Jan 2023 10:06:52 -0800 (PST) X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 1124040F37; Mon, 23 Jan 2023 17:58:46 +0000 (UTC) Received: from pdx1-sub0-mail-a264.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 8F72F4136A; Mon, 23 Jan 2023 17:58:45 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1674496725; a=rsa-sha256; cv=none; b=Ydk1xQThOhi0rM3HRIH3CfgnoBNFwxmdJ0vqtMHjfhUUpOfX1I34HQfuNvQZtYOPB4qw/q gJGuC22y8ZR4hLS+7K7pcwLnaiJ1h/orbNtYcFHMNcDC9G/725vcm5R/F9Pneh/0g9FvIh m1AR/yVIb3sEDasmpGVDYD9b96QxqInGKHW+lRz19VACHffxuCFkEodhSwZfrD6gjKoW3s JtrnkcQ4lkAeE66fJl0+Zf243f2dOEkbTjzVIcUJJw1TF9e9sumC37Dy3XeSPaB7FCleCH Gj29xhK6Fo5HpId63dSgBjJp3BZBw+kVxP4TzZGFHLmtpSanILQiCIdw6w1Qig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1674496725; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=HgAdgrmSZwhL1H/zHHkhQTAR0+DUP7uLvndtCVdk2qo=; b=hm9TdxvZSgsJ9VcBfQGol9clbea7aLbqFyBch1N1Yak7uSrqFHSN70JagnWkDbhuLXP5aH hZVsavS+TFmdblKdUhvOyGpHJdLmhBv+fM5DnTj+HIeyQVGHd5/A0CxZv6Bv0JsPgYFbPK idwzAyIu44hyqufJUrgBZbDZgieYfJYxhwziratNKHV+2igQEVsZDxh90d04JprbEtQ/Eb uRjWZOhVUAvYYCQh3IRTpkGmCdSDDO1ZHHc5JM1BMC2MVsXb+Bw0rKDlpYCElDUQxCX0K5 b3d7/K80p6jZ2Pkr3+8LLD/vEYzNmE8ZGSDkJJdjGLhaZdtvb4ey8ZFhix71Rg== ARC-Authentication-Results: i=1; rspamd-6f569fcb69-rsl9k; auth=pass smtp.auth=dreamhost smtp.mailfrom=dave@stgolabs.net X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|dave@stgolabs.net X-MailChannels-Auth-Id: dreamhost X-Vacuous-Harmony: 7ff6a0843d702ea9_1674496725888_2713900432 X-MC-Loop-Signature: 1674496725888:410151927 X-MC-Ingress-Time: 1674496725888 Received: from pdx1-sub0-mail-a264.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.99.229.6 (trex/6.7.1); Mon, 23 Jan 2023 17:58:45 +0000 Received: from localhost.localdomain (ip72-199-50-187.sd.sd.cox.net [72.199.50.187]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dave@stgolabs.net) by pdx1-sub0-mail-a264.dreamhost.com (Postfix) with ESMTPSA id 4P0yX44BZ6zRs; Mon, 23 Jan 2023 09:58:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stgolabs.net; s=dreamhost; t=1674496725; bh=HgAdgrmSZwhL1H/zHHkhQTAR0+DUP7uLvndtCVdk2qo=; h=From:To:Cc:Subject:Date:Content-Transfer-Encoding; b=BvE7YjLYu07x6MeqispuTojP+NhTXef8mnV4Sofnl+MKUwzYVPzX6juCzh0mIZWup EbPGAJNtNn+iqAavu5q/sxAu6I0dcf+rxC8ClRYsLgkFJqFTCBYhld2tr4VMKM5vW9 0ly2O5QefatNHFSlAKwKex1KlLhkC8WYJtuyP/1QhbXxhztn4IcTGT1W7hJXl4UpBB I2RxIVpO8cUsE/+4tEGOSsvpFFeND8EtvZUH+/f9jIcDdR+aq48qy0+L34KzM3nP9Q fBYR4zEib4hgAw12w2If4DsBzVuOVG3PHCqseIeJnMXZq1USEqnBB6LUUM4ilFJJF5 JKZLyBamvA1GA== From: Davidlohr Bueso To: tglx@linutronix.de Cc: mingo@kernel.org, peterz@infradead.org, bigeasy@linutronix.de, dave@stgolabs.net, linux-rt-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] kernel/hrtimer: Ignore slack time for RT tasks Date: Mon, 23 Jan 2023 09:32:06 -0800 Message-Id: <20230123173206.6764-3-dave@stgolabs.net> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230123173206.6764-1-dave@stgolabs.net> References: <20230123173206.6764-1-dave@stgolabs.net> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org 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 --- 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 8336c2618ec1..78f2e07d3e7d 100644 --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -2270,7 +2270,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 */ @@ -2297,6 +2297,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); @@ -2316,7 +2323,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 @@ -2324,7 +2331,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. *