Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp6096894ybv; Tue, 18 Feb 2020 09:48:48 -0800 (PST) X-Google-Smtp-Source: APXvYqygEpf/RcDc7STVB8o3NTnfiT1HP1o0mNMaArYxmz7Dg86Ed2irExpYAJDxr/xSOdSB+nwB X-Received: by 2002:a54:450f:: with SMTP id l15mr2076011oil.126.1582048128048; Tue, 18 Feb 2020 09:48:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582048128; cv=none; d=google.com; s=arc-20160816; b=ZQGszj7j/Mr+SVKorghAP3/b/Tl5DxKTiKM2B39dkj33bpHYzYvgolCRbhdEFIzaf9 hnoT0UPmZ8Xx0gqexe5BlEJoXxd2AILvbDykCfKcSJi3+GLPR7l+uN2T2FQMOLhkD5Fx 1TthwycqmlsW07faJEkZPEeTmN6GvBVkkvK7bAmy2T//l4+huokgrk9to+wKGQlTXa88 nXDfxLFnL3K/2KXx4CnO0orGacUQX8DPKcYZSxZ1QoFH17OVhoHIKrhbbsRoYK9zMO/l e82nMsftOSvx2jXsHB/Lbz0zff5EQLX+F14jw/FgIK49NpVlvrO+MvMBscmlWqTjmVVd p/tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=431yzdmXJGbiBHs9/5PhVFpNfUTvvLsQSGHgJuEr9GA=; b=fCCl77F2dIZXKEvZU+yROt6BylHisrhxo0vYrDwAcfl0gOPix2xqmHRf6txihJLGr8 TPxmmfazE+guncXOCmmCLlyxSgyrSEleo/jhJbUc/t89S6imRwuxW8KfqxYRwaIRN89D RX4l5u3THbABBAvvh2KIlUHPDRJTpGbw2pJKZt+emk5XGUAakDCOSXfCyEojx3mok5am NYMzpbZxZ0nSk9mkd2xvjsWYrZRh0oU2m99UFvWv4uPACwH9QnzfWsAOmhZURwbvlo8O 502uksZUXmR5t7SGpPc8CvsH/DNW+Ep7AsR88VV4JMW0t068LzAykBY6Tje5kPcMRB4M YzmQ== 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 i12si8186167oik.171.2020.02.18.09.48.36; Tue, 18 Feb 2020 09:48:48 -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 S1726652AbgBRRrY (ORCPT + 99 others); Tue, 18 Feb 2020 12:47:24 -0500 Received: from foss.arm.com ([217.140.110.172]:57404 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726521AbgBRRrY (ORCPT ); Tue, 18 Feb 2020 12:47:24 -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 9E1E731B; Tue, 18 Feb 2020 09:47:23 -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 4F4283F68F; Tue, 18 Feb 2020 09:47:22 -0800 (PST) Date: Tue, 18 Feb 2020 17:47:19 +0000 From: Qais Yousef To: Pavan Kondeti Cc: Ingo Molnar , Peter Zijlstra , Steven Rostedt , Dietmar Eggemann , Juri Lelli , Vincent Guittot , Ben Segall , Mel Gorman , linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/3] sched/rt: fix pushing unfit tasks to a better CPU Message-ID: <20200218174718.ma6cpr2qwnueertn@e107158-lin.cambridge.arm.com> References: <20200214163949.27850-1-qais.yousef@arm.com> <20200214163949.27850-4-qais.yousef@arm.com> <20200217092329.GC28029@codeaurora.org> <20200217135306.cjc2225wdlwqiicu@e107158-lin.cambridge.arm.com> <20200218041620.GD28029@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200218041620.GD28029@codeaurora.org> User-Agent: NeoMutt/20171215 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/18/20 09:46, Pavan Kondeti wrote: > The original RT task placement i.e without capacity awareness, places the task > on the previous CPU if the task can preempt the running task. I interpreted it > as that "higher prio RT" task should get better treatment even if it results > in stopping the lower prio RT execution and migrating it to another CPU. > > Now coming to your patch (merged), we force find_lowest_rq() if the previous > CPU can't fit the task though this task can right away run there. When the > lowest mask returns an unfit CPU (with your new patch), We have two choices, > either to place it on this unfit CPU (may involve migration) or place it on > the previous CPU to avoid the migration. We are selecting the first approach. > > The task_cpu(p) check in find_lowest_rq() only works when the previous CPU > does not have a RT task. If it is running a lower prio RT task than the > waking task, the lowest_mask may not contain the previous CPU. > > I don't if any workload hurts due to this change in behavior. So not sure > if we have to restore the original behavior. Something like below will do. Is this patch equivalent to yours? If yes, then I got you. If not, then I need to re-read this again.. diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index ace9acf9d63c..854a0c9a7be6 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -1476,6 +1476,13 @@ 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 && !rt_task_fits_capacity(p, target)) + goto out_unlock; + /* * Don't bother moving it if the destination CPU is * not running a lower priority task. @@ -1484,6 +1491,8 @@ select_task_rq_rt(struct task_struct *p, int cpu, int sd_flag, int flags) p->prio < cpu_rq(target)->rt.highest_prio.curr) cpu = target; } + +out_unlock: rcu_read_unlock(); out: > > diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c > index 4043abe..c80d948 100644 > --- a/kernel/sched/rt.c > +++ b/kernel/sched/rt.c > @@ -1475,11 +1475,15 @@ select_task_rq_rt(struct task_struct *p, int cpu, int sd_flag, int flags) > int target = find_lowest_rq(p); > > /* > - * Don't bother moving it if the destination CPU is > - * not running a lower priority task. > + * Don't bother moving it > + * > + * - If the destination CPU is not running a lower priority task > + * - The task can't fit on the destination CPU and it can run > + * right away on it's previous CPU. > */ > - if (target != -1 && > - p->prio < cpu_rq(target)->rt.highest_prio.curr) > + if (target != -1 && target != cpu && > + p->prio < cpu_rq(target)->rt.highest_prio.curr && > + (test || rt_task_fits_capacity(p, target))) > cpu = target; > } > rcu_read_unlock(); > > Thanks, > Pavan > > -- > Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc. > Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.