From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4DF0C4742C for ; Wed, 11 Nov 2020 08:25:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 852A7206D9 for ; Wed, 11 Nov 2020 08:25:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="thSYj4Js"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="ToY68pLK" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725924AbgKKIYt (ORCPT ); Wed, 11 Nov 2020 03:24:49 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:36286 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726285AbgKKIXV (ORCPT ); Wed, 11 Nov 2020 03:23:21 -0500 Date: Wed, 11 Nov 2020 08:23:17 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1605082997; 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=Y9IifaIw0QwRvl6U2deNGkGSCFvonz6UPTCXLv5v2SM=; b=thSYj4JsGkYkaWaRomOWGgSYQiPEPbES6H2A2tIc+s+1cvOfhOmKjWlWA+vOTlY0qXa/rh nMwyfFJGY363M37cpYv0rlm7Sr4uOxWOi8GnBaxCKLN4ZlQMCpNpOl4mVMgo2o/8DpFEb5 aozB/FaroUPuLx7i3BhjfXR3OhEPYYyjLHJxPi8X4dvJCl/Zumtsei/6WKSXMdiVPSw3KW GyihJ5cF1GIzvyzA0nL1TncgyfPOKfqYcKaZCdvFlNtpZPgYmQCNVkB+fWnggTxtRQc7C1 AJdJvw9avMhi1hYX++vk7ScFiwJ1OwmKfZZPO7PtM01KTAODJMyKKt6AVExAeQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1605082997; 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=Y9IifaIw0QwRvl6U2deNGkGSCFvonz6UPTCXLv5v2SM=; b=ToY68pLK9vUChdTZuXrxkVPx0U/GemtFWSIACav7gDu7E0aByLRxb8WOSCY/qO7xrLeq7M PhItbnLsPoblARCw== From: "tip-bot2 for Peter Zijlstra" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] sched, lockdep: Annotate ->pi_lock recursion Cc: "Peter Zijlstra (Intel)" , Valentin Schneider , Daniel Bristot de Oliveira , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20201023102347.406912197@infradead.org> References: <20201023102347.406912197@infradead.org> MIME-Version: 1.0 Message-ID: <160508299702.11244.2062481705202743132.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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the sched/core branch of tip: Commit-ID: ded467dc83ac7173f1532bb0faa25022ff8769e5 Gitweb: https://git.kernel.org/tip/ded467dc83ac7173f1532bb0faa25022ff8769e5 Author: Peter Zijlstra AuthorDate: Thu, 01 Oct 2020 16:13:01 +02:00 Committer: Peter Zijlstra CommitterDate: Tue, 10 Nov 2020 18:39:01 +01:00 sched, lockdep: Annotate ->pi_lock recursion There's a valid ->pi_lock recursion issue where the actual PI code tries to wake up the stop task. Make lockdep aware so it doesn't complain about this. Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Valentin Schneider Reviewed-by: Daniel Bristot de Oliveira Link: https://lkml.kernel.org/r/20201023102347.406912197@infradead.org --- kernel/sched/core.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 6ea593c..9ce2fc7 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -2658,6 +2658,7 @@ int select_task_rq(struct task_struct *p, int cpu, int sd_flags, int wake_flags) void sched_set_stop_task(int cpu, struct task_struct *stop) { + static struct lock_class_key stop_pi_lock; struct sched_param param = { .sched_priority = MAX_RT_PRIO - 1 }; struct task_struct *old_stop = cpu_rq(cpu)->stop; @@ -2673,6 +2674,20 @@ void sched_set_stop_task(int cpu, struct task_struct *stop) sched_setscheduler_nocheck(stop, SCHED_FIFO, ¶m); stop->sched_class = &stop_sched_class; + + /* + * The PI code calls rt_mutex_setprio() with ->pi_lock held to + * adjust the effective priority of a task. As a result, + * rt_mutex_setprio() can trigger (RT) balancing operations, + * which can then trigger wakeups of the stop thread to push + * around the current task. + * + * The stop task itself will never be part of the PI-chain, it + * never blocks, therefore that ->pi_lock recursion is safe. + * Tell lockdep about this by placing the stop->pi_lock in its + * own class. + */ + lockdep_set_class(&stop->pi_lock, &stop_pi_lock); } cpu_rq(cpu)->stop = stop;