Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp672489imm; Fri, 8 Jun 2018 03:26:26 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKSq1Dsk9gby/Q9uLJ0TBHQNhJ86XE3TeB3VE9Cq5Qf/iN9k0VlRekXqPZKxxM00ej2AjXG X-Received: by 2002:aa7:82d9:: with SMTP id f25-v6mr5416018pfn.218.1528453586802; Fri, 08 Jun 2018 03:26:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528453586; cv=none; d=google.com; s=arc-20160816; b=SJlvaArKoTqjbMAyhBqsdpRosSkq+j+hGv+6qm3am8Be90NSeS6Wnb4fx6n7AiYcPp pAYhXKdvVum9kZnKP2idnQYkU1IbnFKuGjRDcIt5+EHtMsh1yoFSzyr/HaFXY2f6+YY0 BjrciSBKEf3I/XecWpPyqAa+2PSCIWaXLHMFeaqcdAIYKuCY6sQmtAU8Smwj6G0qWgQ/ NMcqEhW15vTerDb6UOnSr/4NA9QLTPv3VAW8azsLv0wP1I5nLrL59+QLR5IBGFFN9l3d /qdPAqeKpm6HMN4/Df8KBLm/bpAntBs8dECAIsxWLQLRmm2JadIKIQRppyIPyoXChDMP GUDA== 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:arc-authentication-results; bh=XEpANGmuzWbehI5ia5/9Fl7yF+AKc3lPpM4oM3T5B1A=; b=tS1uDGw/WQqdNrG/yeKYws9WuzDpUaUgEFq8Tk3Fj/cVpWuHARyQ+qwJRXtSuwSeWt 6Tp+iBq+BTwTjzEIxkLhBQntytTpfDSWpNtCt4C1rYme4qDx9Vudh7PnNASmGSXLwiSy ZFi6qQZunxS6ELRyy0OQj5dnagcNP4WHdIjgQanqg/9rt9nCSLlBEPq2fHDLia6lyt9W 629gNBI9YYhJ0227+NmiVBgvQB1DldENbFImYTrvNSDBGnCVQdInfG6ZmxlTmH0vbtUQ LprP/xQJR7sKy1f2YgEmUJGPz61FyM3D2a9niWPjq0YSE1fMoyNYBD3WpK334XBp5xP8 KJRA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o87-v6si32181015pfi.295.2018.06.08.03.26.12; Fri, 08 Jun 2018 03:26: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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752371AbeFHKYw (ORCPT + 99 others); Fri, 8 Jun 2018 06:24:52 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:53918 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751056AbeFHKYv (ORCPT ); Fri, 8 Jun 2018 06:24:51 -0400 Received: by mail-wm0-f67.google.com with SMTP id x6-v6so2419180wmc.3 for ; Fri, 08 Jun 2018 03:24:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=XEpANGmuzWbehI5ia5/9Fl7yF+AKc3lPpM4oM3T5B1A=; b=kedBVNJDlEVZTOC3g+bR8Dxg55jGWulDA1wc2bjD9VnNWGsofvTI24SUjmxq/Shh/b lZuYq7gJ1y/1yJLRxDnCtGpA6llc0fMQfL51e23MTXk562aHXRiAh6Nq8Q5IT0DSy772 pRxqF5bd+VApOHdsLZYkU5JcFVP1ru8DO9v5G9itodaJhqb7BuH0Hph2TUY8NcEreQqH /WJ3upwmiIjk5Xb+6NF4x94gT95S6YteLIPjxA5DaGWQEpVNhSeMq+u3m2LHDcRs6EeV SmJl2JIpAZcWch/Iz5WRR5khEwFwOIN2sRVvvClwf0NUbFV28VpELq1IFxjm0OPrMNag Vq9A== X-Gm-Message-State: APt69E2MWw5zSithLEW2WZunYZRDUtnZ17eHiPrLPcOyyu8UqyoOfwD0 q/q6T9pd53IpwOxZKcyTdgVB4w== X-Received: by 2002:a1c:b2d0:: with SMTP id b199-v6mr1095591wmf.108.1528453489940; Fri, 08 Jun 2018 03:24:49 -0700 (PDT) Received: from localhost.localdomain ([151.15.207.242]) by smtp.gmail.com with ESMTPSA id v25-v6sm859839wmh.43.2018.06.08.03.24.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Jun 2018 03:24:48 -0700 (PDT) Date: Fri, 8 Jun 2018 12:24:46 +0200 From: Juri Lelli To: Quentin Perret Cc: peterz@infradead.org, rjw@rjwysocki.net, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, mingo@redhat.com, dietmar.eggemann@arm.com, morten.rasmussen@arm.com, chris.redpath@arm.com, patrick.bellasi@arm.com, valentin.schneider@arm.com, vincent.guittot@linaro.org, thara.gopinath@linaro.org, viresh.kumar@linaro.org, tkjos@google.com, joelaf@google.com, smuckle@google.com, adharmap@quicinc.com, skannan@quicinc.com, pkondeti@codeaurora.org, edubezval@gmail.com, srinivas.pandruvada@linux.intel.com, currojerez@riseup.net, javi.merino@kernel.org Subject: Re: [RFC PATCH v3 09/10] sched/fair: Select an energy-efficient CPU on task wake-up Message-ID: <20180608102446.GE658@localhost.localdomain> References: <20180521142505.6522-1-quentin.perret@arm.com> <20180521142505.6522-10-quentin.perret@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180521142505.6522-10-quentin.perret@arm.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 21/05/18 15:25, Quentin Perret wrote: [...] > +static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu) > +{ > + unsigned long cur_energy, prev_energy, best_energy, cpu_cap, task_util; > + int cpu, best_energy_cpu = prev_cpu; > + struct sched_energy_fd *sfd; > + struct sched_domain *sd; > + > + sync_entity_load_avg(&p->se); > + > + task_util = task_util_est(p); > + if (!task_util) > + return prev_cpu; > + > + /* > + * Energy-aware wake-up happens on the lowest sched_domain starting > + * from sd_ea spanning over this_cpu and prev_cpu. > + */ > + sd = rcu_dereference(*this_cpu_ptr(&sd_ea)); > + while (sd && !cpumask_test_cpu(prev_cpu, sched_domain_span(sd))) > + sd = sd->parent; > + if (!sd) > + return -1; Shouldn't this be return prev_cpu? > + > + 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; > + > + for_each_freq_domain(sfd) { > + unsigned long spare_cap, max_spare_cap = 0; > + int max_spare_cap_cpu = -1; > + unsigned long util; > + > + /* Find the CPU with the max spare cap in the freq. dom. */ I undestand this being a heuristic to cut some overhead, but shouldn't the model tell between packing vs. spreading? Thanks, -Juri