Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp867674ybg; Fri, 18 Oct 2019 08:32:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqy0P8Beh2nR3UXCLL0925Ap1N56V+fw1TznKa1CtFwV30bpbeYuNSNWKceVp367ept/o/v0 X-Received: by 2002:a17:906:8608:: with SMTP id o8mr9417440ejx.179.1571412760728; Fri, 18 Oct 2019 08:32:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571412760; cv=none; d=google.com; s=arc-20160816; b=s41Did01to3IwDUonV58ar8oWi9Q1Gt6hAlsr964TVEQ7itWbrSRAPw4xs9P96Vs2g DqHQ6MvHJ9Ac8cK6hatWMgfFuR1g0SVuI23EZM+QmQKgaqrHY89qfsLeaYwmHkESv1GT x3UyT5mM1XQhXRu1ha9n1nqSGxB3ISN9czgtnWVSibhBteLkzzom0RvhM1gN8YafNZgB 9mJfdNxa5hbjcwFBhJFIehQiJIJJBvZd+8TBIx+0IOyIpBvWwfJbETVSFREm/y0ABsAQ 3mmVw2dBZjd4STAtSpWu8bvBSSqzZW3qFl273hhnSSFaf6CdvLNOc0yP1srGm23DLmu6 7GaQ== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject; bh=w1EjF3fg57S4q900U1gsC3+RyihiW7zv7j5D16VeRTs=; b=e/VITuI3MGBOuaFhEgncx0beGVE0y7JmiEKIW34GH37+Owaoh87Hg7OJQhTgGrjC0m VqOkTgAkntesE9PcqvpcYbT5hv/awDPEO/fKQqOqy4yhH4G2DULkppuY7U303aN9qZHA vuJcLyeax7CdUWdUWK6OgQipzlFrEMaxYL2JbqLvb2EH5aF4H+OeBWnd7cXiqwbWalZy BPmNx2KJHJ4lNq8Mqx2CiuaxaQyveY7w5NajbWq7BCSocUQnhQBjrYAL6Kcd+Im1f2s5 jYYgxXaqyfX/fZCgvS/EmLjAWyqVjPpOG2lnu+F15v6THfmOm/ZF302wCzBD7lgiWveT Avag== 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 z42si4309481edz.23.2019.10.18.08.32.17; Fri, 18 Oct 2019 08:32:40 -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 S2392794AbfJQKWo (ORCPT + 99 others); Thu, 17 Oct 2019 06:22:44 -0400 Received: from [217.140.110.172] ([217.140.110.172]:38356 "EHLO foss.arm.com" rhost-flags-FAIL-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1726248AbfJQKWn (ORCPT ); Thu, 17 Oct 2019 06:22:43 -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 D70DC1BF7; Thu, 17 Oct 2019 03:22:18 -0700 (PDT) Received: from [10.1.195.43] (unknown [10.1.195.43]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 65DB13F718; Thu, 17 Oct 2019 03:22:17 -0700 (PDT) Subject: Re: [RFC PATCH v3 2/6] sched/cpufreq: Attach perf domain to sugov policy To: Dietmar Eggemann , linux-kernel@vger.kernel.org Cc: linux-pm@vger.kernel.org, mingo@redhat.com, peterz@infradead.org, rjw@rjwysocki.net, viresh.kumar@linaro.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, qperret@qperret.net, patrick.bellasi@matbug.net, dh.han@samsung.com References: <20191011134500.235736-1-douglas.raillard@arm.com> <20191011134500.235736-3-douglas.raillard@arm.com> <4ebf6419-c8e0-3998-41e0-3f7b49b34084@arm.com> From: Douglas Raillard Organization: ARM Message-ID: <686407a7-3074-0fa2-e041-a9931f467aea@arm.com> Date: Thu, 17 Oct 2019 11:22:16 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.0 MIME-Version: 1.0 In-Reply-To: <4ebf6419-c8e0-3998-41e0-3f7b49b34084@arm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB-large Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Dietmar, On 10/17/19 9:57 AM, Dietmar Eggemann wrote: > On 11/10/2019 15:44, Douglas RAILLARD wrote: > > [...] > >> @@ -66,6 +70,38 @@ static DEFINE_PER_CPU(struct sugov_cpu, sugov_cpu); >> >> /************************ Governor internals ***********************/ >> >> +#ifdef CONFIG_ENERGY_MODEL >> +static void sugov_policy_attach_pd(struct sugov_policy *sg_policy) >> +{ >> + struct em_perf_domain *pd; >> + struct cpufreq_policy *policy = sg_policy->policy; > > Shouldn't always order local variable declarations from longest to > shortest line? Can't find any reference to that rule in the coding style, although I'm happy to change order if that's deemed useful. > >> + >> + sg_policy->pd = NULL; >> + pd = em_cpu_get(policy->cpu); >> + if (!pd) >> + return; >> + >> + if (cpumask_equal(policy->related_cpus, to_cpumask(pd->cpus))) >> + sg_policy->pd = pd; >> + else >> + pr_warn("%s: Not all CPUs in schedutil policy %u share the same perf domain, no perf domain for that policy will be registered\n", >> + __func__, policy->cpu); > > Maybe {} because of 2 lines? +1 >> +} >> + >> +static struct em_perf_domain *sugov_policy_get_pd( >> + struct sugov_policy *sg_policy) > > > Maybe this way? This format is already used in this file. > > static struct em_perf_domain * > sugov_policy_get_pd(struct sugov_policy *sg_policy) > I also prefer this kind of non-indented form that always stays indented across renames :) >> +{ >> + return sg_policy->pd; >> +} >> +#else /* CONFIG_ENERGY_MODEL */ >> +static void sugov_policy_attach_pd(struct sugov_policy *sg_policy) {} >> +static struct em_perf_domain *sugov_policy_get_pd( >> + struct sugov_policy *sg_policy) >> +{ >> + return NULL; >> +} >> +#endif /* CONFIG_ENERGY_MODEL */ >> + >> static bool sugov_should_update_freq(struct sugov_policy *sg_policy, u64 time) >> { >> s64 delta_ns; >> @@ -859,6 +895,9 @@ static int sugov_start(struct cpufreq_policy *policy) >> sugov_update_shared : >> sugov_update_single); >> } >> + >> + sugov_policy_attach_pd(sg_policy); >> + >> return 0; >> } > > A sugov_policy_detach_pd() called from sugov_stop() (doing for instance > the g_policy->pd = NULL) is not needed? From what I could see, sugov_stop() will always be followed by sugov_start() before it's used again, so that does not seem more risky than not de-initializing sg_cpu's for example.