Received: by 10.213.65.68 with SMTP id h4csp817106imn; Fri, 23 Mar 2018 17:37:26 -0700 (PDT) X-Google-Smtp-Source: AG47ELthdQDxKy8jRMmgM6KPmxnda6fffyfXsYRMeTXwSifMuUeV0HjQ5TCjg81tnxnQu7/qKjor X-Received: by 2002:a17:902:2e43:: with SMTP id q61-v6mr30944219plb.404.1521851846712; Fri, 23 Mar 2018 17:37:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521851846; cv=none; d=google.com; s=arc-20160816; b=WrzVIeNL/Bl8LCZRxIHnor/VfcHIXaIfpKIDhUnJpdf+mZLVA+Ffb08E1ijTgGCdjx 2eayWv6A7fMavdilaXAPCXCk3AZ7x9MqcHpalN5d3F49o+KRlhtiw32e3WImtaCJX279 +5nsi0B7njB4bG9GQKUImi/SjbFIdnxLLNMLkdhmQquyGnppI/Z8mkh4moj81dWAjbLs GjeJWhjZ4js6EPTE9C8xjr4LDtJZ4z7BtAloFlKawJm3hU9JIE7O2zGY87dbSJaRG2j4 3yeos2R2Fd/JVR8o7tgIAtH1cwzqrYBdFfywpp+NIoxvgV+qPUgD5Bpc9a+B6tBulSr3 d12g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=6RLDRWSS2Rr6ebE7p49TSN382UORnY5SJ5mCV/HiBpk=; b=q+zM0dw74fsxEbbBcFqFVl0EWUSFYjC8dcBo3MlKXkO/PvXXAftr+rX6YFKbmUlpRH 5+882vsk5DkpjEBKecxVF0P5nwgioLa/mDvz6W0M/rcKrzbNC2ljavG6N2qyhYzO6/Pn 4el8GBdg8lS97AqPHb+1kuNOHUcKZRXOj4E9xQHWgamhgUi+gSAY20qZPBuTdyr32EzT fbLkw8zkOOiSd6i97xNtVRzxl9VeKzQFHuLF9EEjhhB9J01dK12tXj8E2xYOGqalHhAT UPVA+HVCsfiYnVogwD7RNajZc38JYOnnG1I3pNdwPGLzAmJj+SkUH88zFBmwfBd2eq5T UdpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=TusWDv88; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n22si6757450pgc.121.2018.03.23.17.37.12; Fri, 23 Mar 2018 17:37:26 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=TusWDv88; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751909AbeCXAgS (ORCPT + 99 others); Fri, 23 Mar 2018 20:36:18 -0400 Received: from mail-it0-f68.google.com ([209.85.214.68]:35097 "EHLO mail-it0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751632AbeCXAgP (ORCPT ); Fri, 23 Mar 2018 20:36:15 -0400 Received: by mail-it0-f68.google.com with SMTP id v194-v6so4641987itb.0 for ; Fri, 23 Mar 2018 17:36:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=6RLDRWSS2Rr6ebE7p49TSN382UORnY5SJ5mCV/HiBpk=; b=TusWDv88x40WEfDWSgXluZ1TbJvp4Kc9+7sZK9OCWGBjm6aH/Pv5ZOmUp62MK0EGQ3 +QZXtSQUekLfKHt10ppM8Tjs0SUk0o20SD2xnUXRy51n3r8GTzE58Wlq8aQheIHzphVg cLRpQfE1QDhNEEzqV0lPrf7YCIhvDUSS4Bo6KN/+uqzreeJX+XCI25ZKBnnEQLVZiFNk 3gIvCD7GoQ2dzE9CMzJPInaNPuiSS6x2J3HJMAUy4zIHnHag4vDGRbhyfkeJdjyclIFv 93PaqoR/+UKUMkKetu4y9k/KAhAOLpLOR8wcpwCOQB9xAgL4PpenrZMLlNP/B0iHTbJJ Wyzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=6RLDRWSS2Rr6ebE7p49TSN382UORnY5SJ5mCV/HiBpk=; b=tzsHL4VwDTTpNdtx8xKrxRppzBv7J4J55VtEcnvNtQUU8Ex0fXpZAbb2/Q323wYQY2 rwHHtfNzmud0TFWifcuif6I+q5tgntzrM9dreFRf0MmZ35Xyv0TSCKQ0CYHzeqpOc5u4 0ugsbjirgahxUxPbWh5TETBsLwaW9h65Ss8GaKv0mnrSUkP32U9WWZVS4ZtgIAkO7UDa r0kGvNgiFXGx2TueHoy4vl17kaJFOMLAIHGmAwCIoZtPusigYOy3aXr0t5S/w9XOKD1n nk/x2dYKrO+8+sk2nBRNakDlkRWu7Q2xmDhzKWF9FOu/5cF28hYTOhCK2pOhqKF8zjip jIAQ== X-Gm-Message-State: AElRT7EhqcZsMMjKZqelj3s0Zu+6DIbNbw8EVoVy2UyAhnL6ITBrS68h bfkYS7xCvL2qfTeAlObAiovIe4UQYGJUdjWsTN7lvA== X-Received: by 2002:a24:9184:: with SMTP id i126-v6mr15802432ite.41.1521851774568; Fri, 23 Mar 2018 17:36:14 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.11.158 with HTTP; Fri, 23 Mar 2018 17:36:13 -0700 (PDT) In-Reply-To: <20180323160059.GQ4589@e105550-lin.cambridge.arm.com> References: <20180320094312.24081-1-dietmar.eggemann@arm.com> <20180320094312.24081-6-dietmar.eggemann@arm.com> <20180323160059.GQ4589@e105550-lin.cambridge.arm.com> From: Joel Fernandes Date: Fri, 23 Mar 2018 17:36:13 -0700 Message-ID: Subject: Re: [RFC PATCH 5/6] sched/fair: Select an energy-efficient CPU on task wake-up To: Morten Rasmussen Cc: Dietmar Eggemann , LKML , Peter Zijlstra , Quentin Perret , Thara Gopinath , Linux PM , Chris Redpath , Patrick Bellasi , Valentin Schneider , "Rafael J . Wysocki" , Greg Kroah-Hartman , Vincent Guittot , Viresh Kumar , Todd Kjos Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 23, 2018 at 9:00 AM, Morten Rasmussen wrote: > On Thu, Mar 22, 2018 at 09:27:43AM -0700, Joel Fernandes wrote: >> > >> > In case an energy model is available, waking tasks are re-routed into a >> > new energy-aware placement algorithm. The eligible CPUs to be used in the >> > energy-aware wakeup path are restricted to the highest non-overutilized >> > sched_domain containing prev_cpu and this_cpu. If no such domain is found, >> > the tasks go through the usual wake-up path, hence energy-aware placement >> > happens only in lightly utilized scenarios. >> > >> > The selection of the most energy-efficient CPU for a task is achieved by >> > estimating the impact on system-level active energy resulting from the >> > placement of the task on each candidate CPU. The best CPU energy-wise is >> > then selected if it saves a large enough amount of energy with respect to >> > prev_cpu. >> > >> > Although it has already shown significant benefits on some existing >> > targets, this brute force approach clearly cannot scale to platforms with >> > numerous CPUs. This patch is an attempt to do something useful as writing >> > a fast heuristic that performs reasonably well on a broad spectrum of >> > architectures isn't an easy task. As a consequence, the scope of usability >> > of the energy-aware wake-up path is restricted to systems with the >> > SD_ASYM_CPUCAPACITY flag set. These systems not only show the most >> > promising opportunities for saving energy but also typically feature a >> > limited number of logical CPUs. >> > >> > Cc: Ingo Molnar >> > Cc: Peter Zijlstra >> > Signed-off-by: Quentin Perret >> > Signed-off-by: Dietmar Eggemann >> > --- >> > kernel/sched/fair.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++--- >> > 1 file changed, 71 insertions(+), 3 deletions(-) >> > >> > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c >> > index 76bd46502486..65a1bead0773 100644 >> > --- a/kernel/sched/fair.c >> > +++ b/kernel/sched/fair.c >> > @@ -6513,6 +6513,60 @@ static unsigned long compute_energy(struct task_struct *p, int dst_cpu) >> > return energy; >> > } >> > >> > +static bool task_fits(struct task_struct *p, int cpu) >> > +{ >> > + unsigned long next_util = cpu_util_next(cpu, p, cpu); >> > + >> > + return util_fits_capacity(next_util, capacity_orig_of(cpu)); >> > +} >> > + >> > +static int find_energy_efficient_cpu(struct sched_domain *sd, >> > + struct task_struct *p, int prev_cpu) >> > +{ >> > + unsigned long cur_energy, prev_energy, best_energy; >> > + int cpu, best_cpu = prev_cpu; >> > + >> > + if (!task_util(p)) >> > + return prev_cpu; >> > + >> > + /* Compute the energy impact of leaving the task on prev_cpu. */ >> > + prev_energy = best_energy = compute_energy(p, prev_cpu); >> >> Is it possible that before the wakeup, the task's affinity is changed >> so that p->cpus_allowed no longer contains prev_cpu ? In that case >> prev_energy wouldn't matter since previous CPU is no longer an option? > > It is possible to wake-up with a disallowed prev_cpu. In fact > select_idle_sibling() may happily return a disallowed cpu in that case. > The mistake gets fixed in select_task_rq() which uses > select_fallback_rq() to find an allowed cpu instead. > > Could we fix the issue in find_energy_efficient_cpu() by a simple test > like below > > if (cpumask_test_cpu(prev_cpu, &p->cpus_allowed)) > prev_energy = best_energy = compute_energy(p, prev_cpu); > else > prev_energy = best_energy = ULONG_MAX; Yes, I think setting to ULONG_MAX in this case is Ok with me. thanks, - Joel