Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3424855ybt; Tue, 23 Jun 2020 01:50:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwjXW8WpXGbAljysEdlbX9DCP7z0bo+iC453YjB6txacSBEoC/lan45jOZf0ieYBkhr2VdI X-Received: by 2002:a17:906:5590:: with SMTP id y16mr20428358ejp.228.1592902256114; Tue, 23 Jun 2020 01:50:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592902256; cv=none; d=google.com; s=arc-20160816; b=MdbINe9DxSmpOTXIS08xBhAYDVVUbPM1SUt3hRRnEjvV0gocsKIU1nQROmSLrdoHSL mV1glp1quTZJM69YOgpd3a0cKK2B8oIW2V1c2Lv2Me++b6C7KO7mplvroBaB1ORHPPQz bJJZuWQ4ggarACPwQo/4rtKMR888nCYY60zoD+7YltXFick2mQLKMEfbjW49qjve4tTc 4oK9l0cVgB5vOGHyTMoCuXuTLPAvAYv6BXumnPBScAhPODEJpY2VYEayjOAIPs4Rzagd gon2TXuQIS7YBUNK/HyIEpTI6M1/WgXOsuE/qEl5OIyN9KulgHtvVx8r+ISCydhfT9vx EB6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=ZIHdLWfBxxXbN0ZmSAUL3Irl+CMEWJa9ccDh9vwvjsg=; b=PFvMM3K239HIUkn7MAJ7PKjrAwM/lNmZ6vsBpFKjpCuwxZ6hQ2g5cYj1f6vJ61OlqT Pc5z6KQAyrobenPd1wAV0fO1ooJmdsk2LtsHjFl4dE0chBoHVC65pv99m5uMldyPdyCU XrvUnhk8E6cVE6bNLzNftyZtDcYJyf9/h3x463SYWXwm3VR8T+R0nzwvhrHPvKgHohXO QjZuv1Q6DxkXWcgC/uo6win1tZXWv44jqNcU+TDh1ox/5/B3UHCRfcMDl88f4uZTlKBV 4/gyLNEcIrO6ISv7BXHU8OB1uOSESMhdOinfmtcBams/uiPsFxfTgHN0MKiSXm1nqXou JIeQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u26si4526265edy.187.2020.06.23.01.50.33; Tue, 23 Jun 2020 01:50:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731960AbgFWIsi (ORCPT + 99 others); Tue, 23 Jun 2020 04:48:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731910AbgFWIsc (ORCPT ); Tue, 23 Jun 2020 04:48:32 -0400 Received: from Galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 471DBC061755; Tue, 23 Jun 2020 01:48:32 -0700 (PDT) Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1jnebR-0005Rb-Ou; Tue, 23 Jun 2020 10:48:25 +0200 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id 6F9301C0244; Tue, 23 Jun 2020 10:48:25 +0200 (CEST) Date: Tue, 23 Jun 2020 08:48:25 -0000 From: "tip-bot2 for Juri Lelli" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/urgent] sched/core: Fix PI boosting between RT and DEADLINE tasks Cc: syzbot+119ba87189432ead09b4@syzkaller.appspotmail.com, Juri Lelli , "Peter Zijlstra (Intel)" , Ingo Molnar , Daniel Bristot de Oliveira , Daniel Wagner , x86 , LKML In-Reply-To: <20181119153201.GB2119@localhost.localdomain> References: <20181119153201.GB2119@localhost.localdomain> MIME-Version: 1.0 Message-ID: <159290210525.16989.11595870440958834087.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the sched/urgent branch of tip: Commit-ID: 93a952a81bf31bffaf21eca1b530245acce12597 Gitweb: https://git.kernel.org/tip/93a952a81bf31bffaf21eca1b530245acce12597 Author: Juri Lelli AuthorDate: Mon, 19 Nov 2018 16:32:01 +01:00 Committer: Ingo Molnar CommitterDate: Tue, 23 Jun 2020 10:42:39 +02:00 sched/core: Fix PI boosting between RT and DEADLINE tasks syzbot reported the following warning: WARNING: CPU: 1 PID: 6351 at kernel/sched/deadline.c:628 enqueue_task_dl+0x22da/0x38a0 kernel/sched/deadline.c:1504 At deadline.c:628 we have: 623 static inline void setup_new_dl_entity(struct sched_dl_entity *dl_se) 624 { 625 struct dl_rq *dl_rq = dl_rq_of_se(dl_se); 626 struct rq *rq = rq_of_dl_rq(dl_rq); 627 628 WARN_ON(dl_se->dl_boosted); 629 WARN_ON(dl_time_before(rq_clock(rq), dl_se->deadline)); [...] } Which means that setup_new_dl_entity() has been called on a task currently boosted. This shouldn't happen though, as setup_new_dl_entity() is only called when the 'dynamic' deadline of the new entity is in the past w.r.t. rq_clock and boosted tasks shouldn't verify this condition. Digging through the PI code I noticed that what above might in fact happen if an RT tasks blocks on an rt_mutex hold by a DEADLINE task. In the first branch of boosting conditions we check only if a pi_task 'dynamic' deadline is earlier than mutex holder's and in this case we set mutex holder to be dl_boosted. However, since RT 'dynamic' deadlines are only initialized if such tasks get boosted at some point (or if they become DEADLINE of course), in general RT 'dynamic' deadlines are usually equal to 0 and this verifies the aforementioned condition. Fix it by checking that the potential donor task is actually (even if temporary because in turn boosted) running at DEADLINE priority before using its 'dynamic' deadline value. Fixes: 2d3d891d3344 ("sched/deadline: Add SCHED_DEADLINE inheritance logic") Reported-by: syzbot+119ba87189432ead09b4@syzkaller.appspotmail.com Signed-off-by: Juri Lelli Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Ingo Molnar Reviewed-by: Daniel Bristot de Oliveira Tested-by: Daniel Wagner Link: https://lkml.kernel.org/r/20181119153201.GB2119@localhost.localdomain --- kernel/sched/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 9eeac94..c1ba2e5 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -4533,7 +4533,8 @@ void rt_mutex_setprio(struct task_struct *p, struct task_struct *pi_task) */ if (dl_prio(prio)) { if (!dl_prio(p->normal_prio) || - (pi_task && dl_entity_preempt(&pi_task->dl, &p->dl))) { + (pi_task && dl_prio(pi_task->prio) && + dl_entity_preempt(&pi_task->dl, &p->dl))) { p->dl.dl_boosted = 1; queue_flag |= ENQUEUE_REPLENISH; } else