Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp361276pxb; Thu, 9 Sep 2021 02:40:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0u0r7pe8qyJbrFUpmwzGGxYXoKfABbt6N4yAkZH3APXMzcxPSCz6FMmsyw4fdWX0r4bYS X-Received: by 2002:a92:ddcc:: with SMTP id d12mr1713895ilr.187.1631180442981; Thu, 09 Sep 2021 02:40:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631180442; cv=none; d=google.com; s=arc-20160816; b=hNe2y8+UFpZwTn+o4gqc5VkhKgV4KnQmzD9vNiCLXFJxIgj24qu99TCX26YcI276Xi nKcFJIsS/D2gF52Z3MenptQ0zeveJuLYMl4zyk8U0C16TJ7edha7ucYl4DY70kbShs8c 2rTR/lxg52tMwi9kAjAMZU0hvfec2LUHuPGqso67QEjR0geh+Oah5Ha6pfbkhRTqkR+h R8JB0zg2yzWvTDswiVE6nRlLBdQlTFN+tKnWIh67a/Ke+cyBdnDdXSghYB1ghoHmkS6S V9E2zFkUomUANjxmpFDT9S3UahaolzNBJNlI4BgFQKvjGSrkjg6j2dZYQK6GmxCus0G8 3acw== 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=lcNaP07PKMAmOJRYwyE4hu2hgVbleeLOp79xPo503QA=; b=xzjgFspbgRPsl+Vr7mqSBCetvI3VBRgfOH+fc+U80AVeB1b84SeI7ghekv1ZZI3Yk+ 3cJt7l4VgiPrwVhRwtNBbDOMTcVYPWDmLId41CW7zQ3Cv31rfaY+ejAnJhTvpG1gTBCe SXkC9qljoQoW70N0UurD1UInEjFsJPJAKwfk9ISdYMb4IQdiN1JIdw1ZrYHNIIlGZsjO ImLzqFkGaev/TI/nV5kETjOE3pK9C24uPSpLhUZaq+HUaeyDyess2cldvZ/kcoWCvVnv bRMdBKfMY5yvpmTCIoVYrIK1F/m0aBRCs/b5JOZ52Er2izurScQyzJuj5EgEeC02XG5/ D2mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=FnhyKhFH; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=emY8EWEW; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m24si1278652jac.82.2021.09.09.02.40.31; Thu, 09 Sep 2021 02:40:42 -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; dkim=pass header.i=@linutronix.de header.s=2020 header.b=FnhyKhFH; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=emY8EWEW; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233087AbhIIJjs (ORCPT + 99 others); Thu, 9 Sep 2021 05:39:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229927AbhIIJjr (ORCPT ); Thu, 9 Sep 2021 05:39:47 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02033C061575; Thu, 9 Sep 2021 02:38:37 -0700 (PDT) Date: Thu, 09 Sep 2021 09:38:34 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1631180315; 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=lcNaP07PKMAmOJRYwyE4hu2hgVbleeLOp79xPo503QA=; b=FnhyKhFH5VbglJwVrG886b43A+BIuM4Gs4i43SgnnD8RxLQIJtStnZPlyvz5MuudKysy6z pIfg2ggyOZ0+A9A0+WIxltii5vYtXOokYqU+Vv3cyO7uLjJ5Jl/UGv97t04l02FudCgyfc j7XuqG2ZT4KyFufuRGaB2QFs/DQ1GzSbiUx0lZPoPwVvYn0MAjJnWpPize25dw2yOM+UCm FnTb1IDJ8FUBqhiHMzvNarY8BXd+hlN6qSFdvYPGpm6ll6mvgrsiPBejdGq0nfEYtBaAiF xwAXp+nwJOlAUNCA2FpWKioZtAx2418qX4ayfyCNQ9dxnOVvAiq22Q9WOye6jQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1631180315; 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=lcNaP07PKMAmOJRYwyE4hu2hgVbleeLOp79xPo503QA=; b=emY8EWEWXfYbLaCfIQBpbkzvY4MF+U8nS/0zEkj9DaVZoWvkyHc4GUJOEOe7CPleBM5y3S CimKJo6QSL7wDPCQ== From: "tip-bot2 for Thomas Gleixner" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/urgent] sched: Prevent balance_push() on remote runqueues Cc: Sebastian Siewior , Thomas Gleixner , "Peter Zijlstra (Intel)" , stable@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <87zgt1hdw7.ffs@tglx> References: <87zgt1hdw7.ffs@tglx> MIME-Version: 1.0 Message-ID: <163118031401.25758.11404036783844944649.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/urgent branch of tip: Commit-ID: 868ad33bfa3bf39960982682ad3a0f8ebda1656e Gitweb: https://git.kernel.org/tip/868ad33bfa3bf39960982682ad3a0f8ebda1656e Author: Thomas Gleixner AuthorDate: Sat, 28 Aug 2021 15:55:52 +02:00 Committer: Peter Zijlstra CommitterDate: Thu, 09 Sep 2021 11:27:23 +02:00 sched: Prevent balance_push() on remote runqueues sched_setscheduler() and rt_mutex_setprio() invoke the run-queue balance callback after changing priorities or the scheduling class of a task. The run-queue for which the callback is invoked can be local or remote. That's not a problem for the regular rq::push_work which is serialized with a busy flag in the run-queue struct, but for the balance_push() work which is only valid to be invoked on the outgoing CPU that's wrong. It not only triggers the debug warning, but also leaves the per CPU variable push_work unprotected, which can result in double enqueues on the stop machine list. Remove the warning and validate that the function is invoked on the outgoing CPU. Fixes: ae7927023243 ("sched: Optimize finish_lock_switch()") Reported-by: Sebastian Siewior Signed-off-by: Thomas Gleixner Signed-off-by: Peter Zijlstra (Intel) Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/87zgt1hdw7.ffs@tglx --- kernel/sched/core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index f3b27c6..b21a185 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -8523,7 +8523,6 @@ static void balance_push(struct rq *rq) struct task_struct *push_task = rq->curr; lockdep_assert_rq_held(rq); - SCHED_WARN_ON(rq->cpu != smp_processor_id()); /* * Ensure the thing is persistent until balance_push_set(.on = false); @@ -8531,9 +8530,10 @@ static void balance_push(struct rq *rq) rq->balance_callback = &balance_push_callback; /* - * Only active while going offline. + * Only active while going offline and when invoked on the outgoing + * CPU. */ - if (!cpu_dying(rq->cpu)) + if (!cpu_dying(rq->cpu) || rq != this_rq()) return; /*