From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752137AbdLASc0 (ORCPT ); Fri, 1 Dec 2017 13:32:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:45612 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750872AbdLAScZ (ORCPT ); Fri, 1 Dec 2017 13:32:25 -0500 DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9DAF12133D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=goodmis.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=rostedt@goodmis.org Date: Fri, 1 Dec 2017 13:32:22 -0500 From: Steven Rostedt To: LKML , linux-rt-users Cc: Ingo Molnar , Peter Zijlstra , Sebastian Andrzej Siewior , Daniel Wagner , Thomas Gleixner Subject: [PATCH] sched/rt: Do not do push/pull when there is only one CPU Message-ID: <20171201133222.66d41219@gandalf.local.home> X-Mailer: Claws Mail 3.14.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Daniel Wagner reported a crash on the beaglebone black. This is a single CPU architecture, and does not have a functional: arch_send_call_function_single_ipi() and can crash if that is called. As it only has one CPU, it shouldn't be called, but if the kernel is compiled for SMP, the push/pull RT scheduling logic now calls it for irq_work if the one CPU is overloaded, it can use that function to call itself and crash the kernel. There's no reason for the push/pull logic to even be called if there's only one CPU online. Have it bail if it sees that's the case. Link: http://lkml.kernel.org/r/8c913cc2-b2e3-8c2e-e503-aff1428f8ff5@monom.org Fixes: 4bdced5c9 ("sched/rt: Simplify the IPI based RT balancing logic") Cc: stable@vger.kernel.org Reported-by: Daniel Wagner --- diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index 4056c19ca3f0..50d2f8179f70 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -1784,6 +1784,10 @@ static int push_rt_task(struct rq *rq) if (!rq->rt.overloaded) return 0; + /* If we are the only CPU, don't bother */ + if (num_online_cpus() == 1) + return 0; + next_task = pick_next_pushable_task(rq); if (!next_task) return 0; @@ -2038,6 +2042,10 @@ static void pull_rt_task(struct rq *this_rq) if (likely(!rt_overloaded(this_rq))) return; + /* If we are the only CPU, don't bother */ + if (num_online_cpus() == 1) + return; + /* * Match the barrier from rt_set_overloaded; this guarantees that if we * see overloaded we must also see the rto_mask bit.