Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2180168pxb; Sat, 28 Aug 2021 06:57:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw8xtderwbd9Y8KheLM0Ctqocu+kkiBrlbwmj+ws8v3LPt6zJrIFYPbD2ePtJ04aRTLbf2V X-Received: by 2002:a92:440c:: with SMTP id r12mr9867605ila.174.1630159025326; Sat, 28 Aug 2021 06:57:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630159025; cv=none; d=google.com; s=arc-20160816; b=yi8RZjNWcynmXliu5tzJc+Mkl4IrvJyG8wfFexeVsmF2bL5jvurrUGHHDofLDQeQTD Z8qxneIfqYsdjrsuqswlzn3Hh2Tx0VKopUuik3GE1PMWr9kmIVjKoqGu0yQ6kbqPQySA +LmSM/aLitgvhVfU/TDn6b6cSbtDmp9alG0habhcYvrrGr1VrQ39vDwnG7EJTFEgTbIz coPsk3LhvyMcmJTvUKW2Gk+4zBx2WArhx26HzaIx0g0geXDZuW4oqFfGv7AoHPt1lYGu IkbxG0wXVBBZYck/Pn29vkkeIO0FpU3/rWG2gCit9g7g4OK+7P8dWZEEgsk8ChMB2S6R VY+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=szT5lkD+YWto/0wcn5LngBYE8usayOdbrKOZ9uNLgNI=; b=MrN0H5KASGB4htwEwS+siGx8xN1v/7ouApaJ5aRMETlRxjtPWbk5dk5ksDNZa5diqn VvetaySBcPHPlkJDCUyPxAMyj2eFcZpLo+VT4qH4rc9YaNFbpkKqZj4tQnI5aSm/Z3xM UXs406MWQVPjmAfKIIHK3hF6nlQShEpQSm0DKNBmDHEyZ12vjoCeQX9lqibWO29V9oar ykvUUTZgFljo15nCBUPXwRZTAUYhUyM6Q1YGf0qIwcWYOTUQ42I0bhbetHWiYStRehrf XRJVjhHqUnBm55SBTzgIfbLbZytSm+t+1g5En1/dti1LQ3yqEKewzox6qKvzIixfpjW0 Fe9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=csJu0jMX; dkim=neutral (no key) header.i=@linutronix.de header.b=t5sHQTMa; 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 b7si9493842ilr.75.2021.08.28.06.56.53; Sat, 28 Aug 2021 06:57:05 -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=csJu0jMX; dkim=neutral (no key) header.i=@linutronix.de header.b=t5sHQTMa; 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 S234283AbhH1N4s (ORCPT + 99 others); Sat, 28 Aug 2021 09:56:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229505AbhH1N4r (ORCPT ); Sat, 28 Aug 2021 09:56: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 CE15BC061756 for ; Sat, 28 Aug 2021 06:55:56 -0700 (PDT) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1630158953; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=szT5lkD+YWto/0wcn5LngBYE8usayOdbrKOZ9uNLgNI=; b=csJu0jMX4yt4WEZoYCHowPRFviaigHrC4t5wJ2Z6nfuzYm2AHunep4zQhaoQCTVrWz2XvK 3mwfK424sBX93//QS9c4fDKB/bT8+40dg5Idr6Hl/GQy8S4KaHl09dqXFLiPHOg13e39Nd lESjSOscH5K3AHvhyVE2XOOTl9Zvi30DO9zs87tiY3lPSzZNBfZiiIGm7tJbSYMsG7bEpL TisAnRhToY/uLNalB9omnR/oOmoLruGLdMQm6RBbNFQ7yy9NYhrjQVdBfNbbR8x5S2fsFi B3wh2ytt6uZty4ZK7HeNQxQtRypho8ewv2ZvZVnkoG9o5IszrEJJObZ67BBkcg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1630158953; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=szT5lkD+YWto/0wcn5LngBYE8usayOdbrKOZ9uNLgNI=; b=t5sHQTMaI0H8e5OxYviLacK2pQTLScvYqMXthgFniEO3MH4hs5NEVBj4sPNCBrAbmS0z7r lsbqRurp0ZgRFaBA== To: LKML Cc: Peter Zijlstra , Valentin Schneider , Daniel Bristot de Oliveira , Juri Lelli , Vincent Guittot , Steven Rostedt , Ben Segall , Ingo Molnar , Mel Gorman , Dietmar Eggemann Subject: [PATCH V2] sched: Prevent balance_push() on remote runqueues In-Reply-To: <87eeae11cr.ffs@tglx> References: <87tujb0yn1.ffs@tglx> <87eeae11cr.ffs@tglx> Date: Sat, 28 Aug 2021 15:55:52 +0200 Message-ID: <87zgt1hdw7.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Cc: stable@vger.kernel.org Cc: Juri Lelli Cc: Vincent Guittot Cc: Peter Zijlstra Cc: Steven Rostedt Cc: Ben Segall Cc: Ingo Molnar Cc: Mel Gorman Cc: Daniel Bristot de Oliveira Cc: Dietmar Eggemann --- V2: Use the correct check for the outgoing CPU --- kernel/sched/core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -8435,7 +8435,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); @@ -8443,9 +8442,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; /*