From patchwork Sat Feb 11 10:30:53 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: 55775 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1432537wrn; Sat, 11 Feb 2023 02:38:54 -0800 (PST) X-Google-Smtp-Source: AK7set/3LAeOohpJ8HwYFmwDgzAQKf4l9IIaoQqt9LERC6YlKtLK8wPW8eNpBAN7bIx2RlJ8TbhR X-Received: by 2002:a50:9b13:0:b0:4ab:44bd:80a1 with SMTP id o19-20020a509b13000000b004ab44bd80a1mr5812612edi.22.1676111934515; Sat, 11 Feb 2023 02:38:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676111934; cv=none; d=google.com; s=arc-20160816; b=rblkI9QgFksOFYZTsp4XhlQx64Cu0qNwA9dtzvjyzTg3vRaG45aF9FVk9zufi5bpY4 sT4/P7wPe1V71APE84/upVoEDmfG8m5vPx31q8k08VxcGbwksZ6ULO7uddXXhRqYWdTe hbX58L9TDspTbP4z0jIL11ypSl1b+Ky0uqOesgIwE5SofsxqwjPX2ULU3pHe8+1AhiyY hmparI67XanUQS9dANu6KW2dQNzWgmAGEU5OMqbNHO9giMz+xByDw6jasy5aHFTQ/HOa W/5MYJI4xDkkORcJvpzUJGzTFcR42hgbF55wSu/bCkeZlmRJZkKslxaFW/VGlt1Iv2Zu vMzw== 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=ungYDX7qzyRMeHGhhRpZSXmVK1Nj64kF59rGW+NJBKg=; b=UahsLQyr35oNeQl9QCjZHjwFv6OkvBZxdxhesgdlHsldH9LNir432Wpx828M4COXCS FCKJzS2MIwJu1rPz0YK4vgoyzgJl9bvCr8GS12v3vdu3d2Gr9L0CV3jNGOLQ8T/e4iLF hYjL/NkdmNV90W854QJtN7UVVT9Auk4/2VNrHjoMWOZeRuN5j/yaWUbiWqLPDS2pckC6 2htn+KRWG7bkowVSPej3emzsffikexozeQ+okA8Jt3ZDEMVWrmd4nxCZ83WUEsbs0Ffk EqvE5qVG1l5F+RmKkRXnQK0wSfYGp+wO2Cu9lkTeE6h5eFynuz3giUW2JnYJY0F+QbHw MSPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=46hDFntx; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=NepQjkAS; 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 a12-20020aa7d74c000000b004a25fc8f8e8si6262217eds.383.2023.02.11.02.38.31; Sat, 11 Feb 2023 02:38:54 -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=46hDFntx; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=NepQjkAS; 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 S229956AbjBKKa7 (ORCPT + 99 others); Sat, 11 Feb 2023 05:30:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229666AbjBKKa4 (ORCPT ); Sat, 11 Feb 2023 05:30:56 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77A022196B; Sat, 11 Feb 2023 02:30:55 -0800 (PST) Date: Sat, 11 Feb 2023 10:30:53 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1676111454; 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=ungYDX7qzyRMeHGhhRpZSXmVK1Nj64kF59rGW+NJBKg=; b=46hDFntxGBqknSmVIMYVDAoo8H2Ohd7rmP7Sv3aoeTgTINHnlpYWldTpklVW3Kj27fgehK ncJqUc/0HItXG0muxrd5rHqy6zSeXWG4e17JXq6OUVmrHV8UKVaJ29oivq23hN/hMfdy7t 0mtNZhWLfso/3kUtmFgUeHIr/9/A/GOXHbAuKO+Z8XDHnmS6idRozbvHscfckQI3a2wHMK B1mF+ryvvHZ8KTy9eTh/VRbcTl/wUluxJE7fiRxKSawTAT+zRnlxl5sX3z75/C7RrHt3Se +yU3eaALFahvg4dJcPHTeULyLKRedcTmZ0HknBnGD8Vb2UiM+VwtR/U0rQxKtQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1676111454; 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=ungYDX7qzyRMeHGhhRpZSXmVK1Nj64kF59rGW+NJBKg=; b=NepQjkASgEDH9BLtmMskoC1VpKVt5P0CA1udotDSVRT9mV5uLgyuWR5hvZVUOaNvrwi5w9 vEwNXFgjrRDpR+DA== From: "tip-bot2 for Valentin Schneider" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] sched/deadline: Add more reschedule cases to prio_changed_dl() Cc: Valentin Schneider , "Peter Zijlstra (Intel)" , Juri Lelli , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230206140612.701871-1-vschneid@redhat.com> References: <20230206140612.701871-1-vschneid@redhat.com> MIME-Version: 1.0 Message-ID: <167611145381.4906.16019956049524655182.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?1756747149576044661?= X-GMAIL-MSGID: =?utf-8?q?1757530748088839983?= The following commit has been merged into the sched/core branch of tip: Commit-ID: 7ea98dfa44917a201e76d4fe96bf61d76e60f524 Gitweb: https://git.kernel.org/tip/7ea98dfa44917a201e76d4fe96bf61d76e60f524 Author: Valentin Schneider AuthorDate: Mon, 06 Feb 2023 14:06:12 Committer: Peter Zijlstra CommitterDate: Sat, 11 Feb 2023 11:18:10 +01:00 sched/deadline: Add more reschedule cases to prio_changed_dl() I've been tracking down an issue on a ~5.17ish kernel where: CPUx CPUy
[idle task keeps running here until *something* accidentally sets TIF_NEED_RESCHED] On that kernel, it is quite easy to trigger using rt-tests's deadline_test [1] with the test running on isolated CPUs (this reduces the chance of something unrelated setting TIF_NEED_RESCHED on the idle tasks, making the issue even more obvious as the hung task detector chimes in). I haven't been able to reproduce this using a mainline kernel, even if I revert 2972e3050e35 ("tracing: Make trace_marker{,_raw} stream-like") which gets rid of the lock involved in the above test, *but* I cannot convince myself the issue isn't there from looking at the code. Make prio_changed_dl() issue a reschedule if the current task isn't a deadline one. While at it, ensure a reschedule is emitted when a queued-but-not-current task gets boosted with an earlier deadline that current's. [1]: https://git.kernel.org/pub/scm/utils/rt-tests/rt-tests.git Signed-off-by: Valentin Schneider Signed-off-by: Peter Zijlstra (Intel) Acked-by: Juri Lelli Link: https://lore.kernel.org/r/20230206140612.701871-1-vschneid@redhat.com --- kernel/sched/deadline.c | 42 +++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 0d97d54..71b2437 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -2663,17 +2663,20 @@ static void switched_to_dl(struct rq *rq, struct task_struct *p) static void prio_changed_dl(struct rq *rq, struct task_struct *p, int oldprio) { - if (task_on_rq_queued(p) || task_current(rq, p)) { + if (!task_on_rq_queued(p)) + return; + #ifdef CONFIG_SMP - /* - * This might be too much, but unfortunately - * we don't have the old deadline value, and - * we can't argue if the task is increasing - * or lowering its prio, so... - */ - if (!rq->dl.overloaded) - deadline_queue_pull_task(rq); + /* + * This might be too much, but unfortunately + * we don't have the old deadline value, and + * we can't argue if the task is increasing + * or lowering its prio, so... + */ + if (!rq->dl.overloaded) + deadline_queue_pull_task(rq); + if (task_current(rq, p)) { /* * If we now have a earlier deadline task than p, * then reschedule, provided p is still on this @@ -2681,15 +2684,24 @@ static void prio_changed_dl(struct rq *rq, struct task_struct *p, */ if (dl_time_before(rq->dl.earliest_dl.curr, p->dl.deadline)) resched_curr(rq); -#else + } else { /* - * Again, we don't know if p has a earlier - * or later deadline, so let's blindly set a - * (maybe not needed) rescheduling point. + * Current may not be deadline in case p was throttled but we + * have just replenished it (e.g. rt_mutex_setprio()). + * + * Otherwise, if p was given an earlier deadline, reschedule. */ - resched_curr(rq); -#endif /* CONFIG_SMP */ + if (!dl_task(rq->curr) || + dl_time_before(p->dl.deadline, rq->curr->dl.deadline)) + resched_curr(rq); } +#else + /* + * We don't know if p has a earlier or later deadline, so let's blindly + * set a (maybe not needed) rescheduling point. + */ + resched_curr(rq); +#endif } DEFINE_SCHED_CLASS(dl) = {