Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp822171ybn; Tue, 24 Sep 2019 10:02:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqzPkTOw1Md/CbxSpC6L/MMkS4S01sQsBUM51CalYK3n7ZZOgfDSaHH3hEsJioYcGVGyOFIz X-Received: by 2002:adf:ab0b:: with SMTP id q11mr3217479wrc.336.1569344534692; Tue, 24 Sep 2019 10:02:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569344534; cv=none; d=google.com; s=arc-20160816; b=U6EwwEqa8ZAnN1/TA3jr9Nf6pX4666cWXEnVeKdqiar5UAORjBx4VO+zzB9pOWpJhc jadL7VQUqEq3/A5xOYAxhEftRzhGQ3WxP/DRpO8IH9oo9AMMCdu8RAFwlzvQaLq1t/9q sFDAJ0i8XaJzSzh5O9cInVCC4AK/tB+fgulC5MG+6pTmYVFckyYLVPQ0pHRLN5r1nauF 0CuCdIjnwLz7HuDG9RjzJZOdyUd8VwValAT42TodkVbsNJQVTUnfz4biktKhn8FUJP9T Qa6hQKgLkmx/BY5bpIdu4VDdbBJrVmJpGQmXIPXTF033c3mNXiHIN5to4xXnjPuMcKvT K+tg== 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=1S8GyhrPFIuClOXBd55cnTqSwpz9cvVD/hK2DcErZH8=; b=WR4Ma1k67Y3sb8MGuwj2YYGDtqydQpCi3XojZBzUqH3BHKXmSP47Uc8hqagmOZDTqb dUJXOHruZOyc/yrRHt05JifV4tVe/oMIK94kKLMnOl3YqpD3E98JXap3YM2g5MlyyerB 9TbWiAUxKvUBbNAF4u5nC+UhXlY3ituVBlq0nRaapxYVzS2/m2fqGGvy+rSRGbrgarwb h2M73be2L/hgadsm0tIO/cWXQW/vlEsxXr3F5OsbSsV+yKy/lOpH6tQwR2wanW33qqeT iaNzlm0kKDlcLbBNoNSvPGSA9J50znrGTCMmGhC4yVC7RRATCQdSv4g0mBk/9JrihdDh mM0Q== 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 e57si1407557ede.356.2019.09.24.10.01.51; Tue, 24 Sep 2019 10:02:14 -0700 (PDT) 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 S1727800AbfIWLw2 (ORCPT + 99 others); Mon, 23 Sep 2019 07:52:28 -0400 Received: from foss.arm.com ([217.140.110.172]:40928 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725873AbfIWLw2 (ORCPT ); Mon, 23 Sep 2019 07:52:28 -0400 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 A6E51142F; Mon, 23 Sep 2019 04:52:27 -0700 (PDT) Received: from e107158-lin.cambridge.arm.com (e107158-lin.cambridge.arm.com [10.1.194.52]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9CC3E3F694; Mon, 23 Sep 2019 04:52:26 -0700 (PDT) Date: Mon, 23 Sep 2019 12:52:24 +0100 From: Qais Yousef To: Dietmar Eggemann Cc: Steven Rostedt , Ingo Molnar , Peter Zijlstra , Vincent Guittot , Alessio Balsini , linux-kernel@vger.kernel.org Subject: Re: [PATCH] sched: rt: Make RT capacity aware Message-ID: <20190923115223.a5fwrrxmg5dj765q@e107158-lin.cambridge.arm.com> References: <20190903103329.24961-1-qais.yousef@arm.com> <20190904072524.09de28aa@oasis.local.home> <20190904154052.ygbhtduzkfj3xs5d@e107158-lin.cambridge.arm.com> <20190918145233.kgntor5nb2gmnczd@e107158-lin.cambridge.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20171215 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/20/19 14:52, Dietmar Eggemann wrote: > > 2. The fallback mechanism means we either have to call cpupri_find() > > twice once to find filtered lowest_rq and the other to return the > > none filtered version. > > This is what I have in mind. (Only compile tested! ... and the 'if > (cpumask_any(lowest_mask) >= nr_cpu_ids)' condition has to be considered > as well): > > @@ -98,8 +103,26 @@ int cpupri_find(struct cpupri *cp, struct > task_struct *p, > continue; > > if (lowest_mask) { > + int cpu, max_cap_cpu = -1; > + unsigned long max_cap = 0; > + > cpumask_and(lowest_mask, p->cpus_ptr, vec->mask); > > + for_each_cpu(cpu, lowest_mask) { > + unsigned long cap = > arch_scale_cpu_capacity(cpu); > + > + if (!rt_task_fits_capacity(p, cpu)) > + cpumask_clear_cpu(cpu, lowest_mask); > + > + if (cap > max_cap) { > + max_cap = cap; > + max_cap_cpu = cpu; > + } > + } > + > + if (cpumask_empty(lowest_mask) && max_cap) > + cpumask_set_cpu(max_cap_cpu, lowest_mask); I had a patch that I was testing but what I did is to continue rather than return a max_cap_cpu. e.g: if no cpu at current priority fits the task: continue; else: return the lowest_mask which contains fitting cpus only if no fitting cpu was find: return 0; Or we can tweak your approach to be if no cpu at current priority fits the task: if the cpu the task is currently running on doesn't fit it: return lowest_mask with max_cap_cpu set; So we either: 1. Continue the search until we find a fitting CPU; bail out otherwise. 2. Or we attempt to return a CPU only if the CPU the task is currently running on doesn't fit it. We don't want to migrate the task from a fitting to a non-fitting one. We can also do something hybrid like: 3. Remember the outcome of 2 but don't return immediately and attempt to find a fitting CPU at a different priority level. Personally I see 1 is the simplest and good enough solution. What do you think? I think this is 'continue' to search makes doing it at cpupri_find() more robust than having to deal with whatever mask we first found in find_lowest_rq() - so I'm starting to like this approach better. Thanks for bringing it up. Cheers -- Qais Yousef