Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1900219pxb; Thu, 16 Sep 2021 19:35:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwEVdRN9lbgYACZMWTU+uokXtTgKl8r63xvfb3VWxjeJM4tz69+trG7MPoh+vrqhkdKMcLS X-Received: by 2002:a05:6e02:1546:: with SMTP id j6mr6112434ilu.154.1631846100396; Thu, 16 Sep 2021 19:35:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631846100; cv=none; d=google.com; s=arc-20160816; b=fk8ni5+1eIDbPmhegVLQkbcjerEMRrIRhFpkRoOmuuJNKHqzTL9r1UmEYB/2zGsMQW SXnCSmSroCXAt6nrWXYQPpjKW3Gh/IhgU+3IveEba6oVHC4PId/A6zCSrr2vrhhG8D1b Q4386WdF/8jBJHoBOT9AM4dZmvql79kCpJhtTErubohtVHkqVayGaiA2EkkMi44TscWu 6nlIsUMZqbxSFA3iUc9UeP6Ry+9o6oCuTqF2ftfBEokWCQNmraQmjnHYQucYkVXCEAMR sbvql5g4bw4JXuxYp8/Dn3VGAqzTYeH0KovcGtSPz0mSo2PAewe+NZ9tzvZd71w92aro 4usA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9MOOFudp2CsyeHQEgLGowI+5pYjDxYPyn3iEGzS5eks=; b=rKLptKUnchCR5xkAdq4bwYfV/DnvVxnInfyqW1JNj8aKz0RkU6omZVhhUaN+VCd8w8 I+v7qYF39vOdvTckdAyLIhFykucjYEGkHffXWWZvbwIemTgikJ3dJuxaCNPxWdtS4wov pAsDZpLVjNxCAQv1jIt8AVl+lWyD+Xy2Gh2qVmMH08S8KcVjGqDj1aCVhHDNWN1NO/iS PbU/8BuSZMjJ2YvUzz7xVhxaZb8dldgIpM/kdpXQ8u6HhSeLKKYTWuuWq93EsR+WV0Cv 9QRbXJxqufLU4v4lkpThbcIKn9isOPUqPjZM5yjAp30Aq3qerENFzdJ6SkpdwHgUUDYV p+Mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qypHYInt; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g14si4575147jat.122.2021.09.16.19.34.49; Thu, 16 Sep 2021 19:35:00 -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=@linuxfoundation.org header.s=korg header.b=qypHYInt; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351869AbhIPRTz (ORCPT + 99 others); Thu, 16 Sep 2021 13:19:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:39922 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350710AbhIPRMD (ORCPT ); Thu, 16 Sep 2021 13:12:03 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9BBF46140A; Thu, 16 Sep 2021 16:38:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631810309; bh=ok+fuA4dato3FKC1J7L3luDz2EmLvG0cvX85bnbgvMw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qypHYInt0Oj0TkuYu9x+I+x4M0DPp/beAmOb9ss80UDEGtdiVo7NNqWCLed6uQ8eY 4KFOkZjBHjwCbpaXUz1/1LMALvTMqgQK8JywNxVngZCpN0dJqxx5ol64x0E6Atd8B2 GkaWSJ2ydv5aM5lskgKfGEP6QcJFgfAJTpTssoao= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sebastian Siewior , Thomas Gleixner , "Peter Zijlstra (Intel)" Subject: [PATCH 5.14 061/432] sched: Prevent balance_push() on remote runqueues Date: Thu, 16 Sep 2021 17:56:50 +0200 Message-Id: <20210916155812.853791406@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155810.813340753@linuxfoundation.org> References: <20210916155810.813340753@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thomas Gleixner commit 868ad33bfa3bf39960982682ad3a0f8ebda1656e upstream. 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 Signed-off-by: Greg Kroah-Hartman --- kernel/sched/core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -8536,7 +8536,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); @@ -8544,9 +8543,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; /*