Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4631063yba; Tue, 7 May 2019 23:27:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqxS62THRR/1FAz/ZV2gZmBdwGV9dA80fWbnfl+WTepUhXMOU2DgOuj+5cdExj4RLeva5PMR X-Received: by 2002:a63:f707:: with SMTP id x7mr44295774pgh.343.1557296872089; Tue, 07 May 2019 23:27:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557296872; cv=none; d=google.com; s=arc-20160816; b=OVF/akXAZd9D9gHLNWX/U8iAnfM9VnA0OSwzBg2brN/ccd4IBrxlQiU2zmQ6AmokvK WnwjRIesBQUD1+bHDDOKvJtT1FuvYmSWLMopClv69Zrab1WomSJkf7ZApYmMO+7VnwaV dXZ4YWnjtTeioI4Ie1ffqo5pLHagoMSWpyx9WCDEH7QKmvu8ndqqlA+0uQl81dE45N+o bOOOAWMY2sLEpGdazpYubsl8oQXmr14rX3EPq9NT6moWrw19n5S65sEvOTBCYvKDCS9X VPtigJ/ZiaKpgPN00gZd1C0weeYK3hq4Zpc1PXo78poZbYSgFSGE/TrFIGA7RbyzQYlw 0IpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=FRZJyBqfqOd0hJtzNiU+vMnNkTVEDMUL1DJt4tvMUgU=; b=umq4OfCbhrS5FnRtlVVikrLCMe1UkU2ugUlai3Wmp8BMHxh66lqLO/CuWkX6HoQouF O6rTk5Gp3oWafuVPdO7gWGwUwpy7P/DJd3ENcLCMRgo51U4wxz+CTA+IDN6ekH3FCmpv W1pEgc+Lgj4WP4fFCicDgNqSKa3BiPm3JXoQk/JvCwRmX2HZNbKJMNgNoinNxfGoaMlC uDlynbXkvzuzAYsGI0EJd4WKNaj3U63E4uetY+YKbHHQSkR9IoVklE3vX7rJExn2M44f rt5z0HMf40ijOAkePGOUKfvX8nN6FnJ5BhR9AJpoyihVAVyV9S+g2l+G5L125V2pQfD9 q2Lg== 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 r3si21527245pfn.139.2019.05.07.23.27.36; Tue, 07 May 2019 23:27:52 -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 S1726879AbfEHG0V (ORCPT + 99 others); Wed, 8 May 2019 02:26:21 -0400 Received: from mail.sssup.it ([193.205.80.98]:29721 "EHLO mail.santannapisa.it" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726082AbfEHG0V (ORCPT ); Wed, 8 May 2019 02:26:21 -0400 Received: from [195.57.117.251] (account l.abeni@santannapisa.it HELO nowhere) by santannapisa.it (CommuniGate Pro SMTP 6.1.11) with ESMTPSA id 138914029; Wed, 08 May 2019 08:26:18 +0200 Date: Wed, 8 May 2019 08:26:05 +0200 From: luca abeni To: Quentin Perret Cc: linux-kernel@vger.kernel.org, Greg Kroah-Hartman , "Rafael J . Wysocki" , Ingo Molnar , Peter Zijlstra , Vincent Guittot , "Paul E . McKenney" , Joel Fernandes , Luc Van Oostenryck , Morten Rasmussen , Juri Lelli , Daniel Bristot de Oliveira , Patrick Bellasi , Tommaso Cucinotta Subject: Re: [RFC PATCH 6/6] sched/dl: Try not to select a too fast core Message-ID: <20190508082605.623ed4d5@nowhere> In-Reply-To: <20190507155732.7ravrnld54rb6k5a@queper01-lin> References: <20190506044836.2914-1-luca.abeni@santannapisa.it> <20190506044836.2914-7-luca.abeni@santannapisa.it> <20190507155732.7ravrnld54rb6k5a@queper01-lin> Organization: Scuola Superiore S.Anna X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Quentin, On Tue, 7 May 2019 16:57:34 +0100 Quentin Perret wrote: > On Monday 06 May 2019 at 06:48:36 (+0200), Luca Abeni wrote: > > From: luca abeni > > > > When a task can fit on multiple CPU cores, try to select the slowest > > core that is able to properly serve the task. This avoids useless > > future migrations, leaving the "fast cores" idle for more > > heavyweight tasks. > > But only if the _current_ capacity of big CPUs (at the current freq) > is higher than the current capacity of the littles, is that right ? > So we don't really have a guarantee to pack small tasks on little > cores ... Yes, the capacity is estimated at the current frequency, so this is a potential problem. > What is the rationale for looking at the current freq in > dl_task_fit() ? Mainly two reasons: the first one is to try to reduce frequency switches (I did not perform measurements on the hikey960, I remember that on other CPUs a frequency switch can take a considerable amount of time). Then, I wanted to have a mechanism that can work with all the possible cpufreq governors... So, I did not assume that the frequency can change (for example, I remember that without considering the current frequency I had issues when using the "userspace" governor). Maybe I just do not know this kernel subsystem well enough, but I did not find any way to know the maximum frequency that the current governor can set (I mean, I found a "maximum frequency" field that tells me the maximum frequency that the cpufreq driver can set, but I do not know if the governor will be able to set it --- again, consider the "userspace" governor). If there is a way to know this value, then I can use it for checking if a task can fit in a core. Thanks, Luca > Energy reasons ? If so, I'd argue you should look at > the energy model to break the tie between CPU candidates ... ;) > > And in the mean time, you could just look at arch_scale_cpu_capacity() > to check if a task fits ? > > > Signed-off-by: luca abeni > > --- > > kernel/sched/cpudeadline.c | 17 ++++++++++++----- > > 1 file changed, 12 insertions(+), 5 deletions(-) > > > > diff --git a/kernel/sched/cpudeadline.c b/kernel/sched/cpudeadline.c > > index 2a4ac7b529b7..897ed71af515 100644 > > --- a/kernel/sched/cpudeadline.c > > +++ b/kernel/sched/cpudeadline.c > > @@ -143,17 +143,24 @@ int cpudl_find(struct cpudl *cp, struct > > task_struct *p, struct cpumask *later_mask) > > { > > const struct sched_dl_entity *dl_se = &p->dl; > > + struct cpumask tmp_mask; > > Hmm, these can get pretty big, so not sure about having one on the > stack ... > > > > > if (later_mask && > > - cpumask_and(later_mask, cp->free_cpus, > > &p->cpus_allowed)) { > > + cpumask_and(&tmp_mask, cp->free_cpus, > > &p->cpus_allowed)) { int cpu, max_cpu = -1; > > - u64 max_cap = 0; > > + u64 max_cap = 0, min_cap = SCHED_CAPACITY_SCALE * > > SCHED_CAPACITY_SCALE; > > - for_each_cpu(cpu, later_mask) { > > + cpumask_clear(later_mask); > > + for_each_cpu(cpu, &tmp_mask) { > > u64 cap; > > > > - if (!dl_task_fit(&p->dl, cpu, &cap)) > > - cpumask_clear_cpu(cpu, later_mask); > > + if (dl_task_fit(&p->dl, cpu, &cap) && (cap > > <= min_cap)) { > > + if (cap < min_cap) { > > + min_cap = cap; > > + cpumask_clear(later_mask); > > + } > > + cpumask_set_cpu(cpu, later_mask); > > + } > > > > if (cap > max_cap) { > > max_cap = cap; > > -- > > 2.20.1 > > > > Thanks, > Quentin