Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp2271294ybf; Mon, 2 Mar 2020 05:28:34 -0800 (PST) X-Google-Smtp-Source: APXvYqwDSIJBgvVEgx4ga1lIL4yPQUhwjtUmyaiCKHVBRKkI1mquQlZYjOIKl0HK+tYecRmB5ioi X-Received: by 2002:aca:4d82:: with SMTP id a124mr12039194oib.103.1583155714790; Mon, 02 Mar 2020 05:28:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583155714; cv=none; d=google.com; s=arc-20160816; b=cdFM+38LGVA/ExcqxeiEo/zeMkiL/6lZ19zWcmA7PDQLal2Y/RxS/sAN0w9fjDJ/YC fNpTZ8phpzcAFDxAkFDEIpqKftKYT0kgQwSpVOcz+jKzM6n3aDoueBX+Zsrjo8juBSiu 1uS7Xc5PlWgCUsFslpIGjkRj/9NTEiFq4PMuhhqm4NBUl2vVBXt2SLqOSAvy4d8CeUkv DEcATbMoRadja9TraxwTT6f1QdZ+Wh3ItOLHVFdJzAlffFKBkzisFpKlIrzOxCQ8emiN d/XJ8M0s2rm5eIagPdo4aycRfWCpFs7TtWH4vHZVxE/Z+3PvMBwN43EtkHBpenOD6mYc SqYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=Sh5Nyq6bil4AIxDCIPQ8wYGpci1XkwKYWP/sR+AlOCw=; b=qBFQAIhIxrRMVYQ0ezqu9OGrJ+A7iCGPlXR5Y3xp6sg5S2n6CdUpFaA2qFocWU7JS/ l1Upqzb9An5FZJ3fLkOLq+MctaC8LXIej/a4t1xf2a/gULITAsPgAbBQ/05M2ZLaW0WQ NRZ7KDBzapeYEBZyLb9ePrd0TiXL9voE1FsXBE+DNbls3Axn43DfyaqMmMirtnZcwPf/ scFSeSzyZC7kGoUSaxhiv11+z4Z9IYv848ofe77LA6CfCKF+etYPcHfGc3hxtYi4Zs0Q ddJwWDhMjpK/OOm1LN+RBPoykF+Y3YK7LwpvxEQVpSjV9qlqfW+tO3C69zmeoOdLSuJo 0T8A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p19si6299480otq.296.2020.03.02.05.28.22; Mon, 02 Mar 2020 05:28:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728039AbgCBN1t (ORCPT + 99 others); Mon, 2 Mar 2020 08:27:49 -0500 Received: from foss.arm.com ([217.140.110.172]:60918 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728022AbgCBN1q (ORCPT ); Mon, 2 Mar 2020 08:27:46 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B51F111FB; Mon, 2 Mar 2020 05:27:45 -0800 (PST) Received: from e107158-lin.cambridge.arm.com (e107158-lin.cambridge.arm.com [10.1.195.21]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4BEED3F534; Mon, 2 Mar 2020 05:27:44 -0800 (PST) From: Qais Yousef To: Ingo Molnar , Peter Zijlstra , Steven Rostedt , Dietmar Eggemann , Pavan Kondeti Cc: Juri Lelli , Vincent Guittot , Ben Segall , Mel Gorman , linux-kernel@vger.kernel.org, Qais Yousef Subject: [PATCH v3 6/6] sched/rt: Fix pushing unfit tasks to a better CPU Date: Mon, 2 Mar 2020 13:27:21 +0000 Message-Id: <20200302132721.8353-7-qais.yousef@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200302132721.8353-1-qais.yousef@arm.com> References: <20200302132721.8353-1-qais.yousef@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If a task was running on unfit CPU we could ignore migrating if the priority level of the new fitting CPU is the *same* as the unfit one. Add an extra check to select_task_rq_rt() to allow the push in case: * p->prio == new_cpu.highest_priority * task_fits(p, new_cpu) Fixes: 804d402fb6f6 ("sched/rt: Make RT capacity-aware") Signed-off-by: Qais Yousef --- kernel/sched/rt.c | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index ce230bec6847..8aaa442e4867 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -1474,20 +1474,35 @@ select_task_rq_rt(struct task_struct *p, int cpu, int sd_flag, int flags) if (test || !rt_task_fits_capacity(p, cpu)) { int target = find_lowest_rq(p); - /* - * Bail out if we were forcing a migration to find a better - * fitting CPU but our search failed. - */ - if (!test && target != -1 && !rt_task_fits_capacity(p, target)) - goto out_unlock; + if (target != -1) { + bool fit_target = rt_task_fits_capacity(p, target); - /* - * Don't bother moving it if the destination CPU is - * not running a lower priority task. - */ - if (target != -1 && - p->prio < cpu_rq(target)->rt.highest_prio.curr) - cpu = target; + /* + * Bail out if we were forcing a migration to find a + * better fitting CPU but our search failed. + */ + if (!test && !fit_target) + goto out_unlock; + + /* + * Don't bother moving it if the destination CPU is + * not running a lower priority task. + */ + if (p->prio < cpu_rq(target)->rt.highest_prio.curr) { + + cpu = target; + + } else if (p->prio == cpu_rq(target)->rt.highest_prio.curr) { + + /* + * If the priority is the same and the new CPU + * is a better fit, then move, otherwise don't + * bother here either. + */ + if (fit_target) + cpu = target; + } + } } out_unlock: -- 2.17.1