Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2574715imm; Wed, 16 May 2018 15:26:35 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrwkRomS8Vfqg2LyP63eBD4k70qu4UukUFWu3VFYM0IaUZYss8oYRSG0SFTJVcULUEljuW8 X-Received: by 2002:a62:c050:: with SMTP id x77-v6mr2727378pff.67.1526509595046; Wed, 16 May 2018 15:26:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526509594; cv=none; d=google.com; s=arc-20160816; b=qIlER4hcwmq2aPhw9xTIHGEouDXzJHy43kS0d2/kLJHw35KtuWgSxu/ECQaC1U/5k1 Lg0lRmk7ymQsD1MSRywuFF5tTcc0hHCQUBNc8113eQQ2+ns9775yvQUQX0kOA1pwWfue t5STMg/80dHqSdg0xE/dFZwm4WBGYZfNnv/cRm8HSu+NDQ8Qx8j0fzwV336KatT6B50A uyZiJm24UMYDLZZwfDb1v3qlI3UUEVB9zPGEYlKiNKLcI2QKEscfOJS0tNebFmkop54C 2X/aPuOQU1nwKTJ7HR5TC8TdaM4hto7lMh+NLpRCaTRVM+whoU+VAzPV3PAbJcvXa9Ot 6bKA== 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 :references:in-reply-to:date:cc:to:from:subject:message-id :arc-authentication-results; bh=swCxpfL6slkY17b5Ouyju11JaHvzWY5U3ujWmDRR0LE=; b=S5FgacQh8kb7T9BjVR8KxgauxVZcnKTxFOmy1myhiIS5DmktQ70dEq8rY12djlE7EL rTJxdpZGGD8N26P+7SQWDK07swxACY+REnRzrhaIwF2CY9YgfRWFbBJJnHC8Q/1BogXv 8kVfdswjWeUOIBy43rY3lFMZ4ft3zdfxwMOCNxItvT87l/mShBRaW61eNNeGxpvSJB5T o7FggMu8ZQ1x9AG2usCuPgwHJ6S5anj6cgtadE1VjVDujbu9VvLChGDf278s/jBXlYvf QGHEKsi9kB4yRsc5UXGDWZdYRnbxXtncS51duGUl+3CYQOWmwX4IOMhFPxV6sYBToMSu 9nUA== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j127-v6si2716841pgc.204.2018.05.16.15.26.20; Wed, 16 May 2018 15:26:34 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751665AbeEPW0C (ORCPT + 99 others); Wed, 16 May 2018 18:26:02 -0400 Received: from mga14.intel.com ([192.55.52.115]:55747 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751153AbeEPW0A (ORCPT ); Wed, 16 May 2018 18:26:00 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 May 2018 15:25:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,407,1520924400"; d="scan'208";a="41851758" Received: from spandruv-desk.jf.intel.com ([10.54.75.31]) by orsmga008.jf.intel.com with ESMTP; 16 May 2018 15:25:57 -0700 Message-ID: <1526509557.61700.95.camel@linux.intel.com> Subject: Re: [RFC/RFT] [PATCH 06/10] cpufreq / sched: Add interface to get utilization values From: Srinivas Pandruvada To: Viresh Kumar Cc: tglx@linutronix.de, mingo@redhat.com, peterz@infradead.org, bp@suse.de, lenb@kernel.org, rjw@rjwysocki.net, mgorman@techsingularity.net, x86@kernel.org, linux-pm@vger.kernel.org, juri.lelli@arm.com, linux-kernel@vger.kernel.org Date: Wed, 16 May 2018 15:25:57 -0700 In-Reply-To: <20180516064055.gbmemcxsv2qvx67g@vireshk-i7> References: <20180516044911.28797-1-srinivas.pandruvada@linux.intel.com> <20180516044911.28797-7-srinivas.pandruvada@linux.intel.com> <20180516064055.gbmemcxsv2qvx67g@vireshk-i7> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.24.6 (3.24.6-1.fc26) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2018-05-16 at 12:10 +0530, Viresh Kumar wrote: > On 15-05-18, 21:49, Srinivas Pandruvada wrote: > > Added cpufreq_get_sched_util() to get the CFS, DL and max > > utilization > > values for a CPU. This is required for getting utilization values > > for cpufreq drivers outside of kernel/sched folder. > > > > Signed-off-by: Srinivas Pandruvada > .com> > > --- > > include/linux/sched/cpufreq.h | 2 ++ > > kernel/sched/cpufreq.c | 23 +++++++++++++++++++++++ > > 2 files changed, 25 insertions(+) > > > > diff --git a/include/linux/sched/cpufreq.h > > b/include/linux/sched/cpufreq.h > > index 5966744..a366600 100644 > > --- a/include/linux/sched/cpufreq.h > > +++ b/include/linux/sched/cpufreq.h > > @@ -20,6 +20,8 @@ void cpufreq_add_update_util_hook(int cpu, struct > > update_util_data *data, > > void (*func)(struct update_util_data *data, > > u64 time, > > unsigned int flags)); > > void cpufreq_remove_update_util_hook(int cpu); > > +void cpufreq_get_sched_util(int cpu, unsigned long *util_cfs, > > + unsigned long *util_dl, unsigned long > > *max); > > #endif /* CONFIG_CPU_FREQ */ > > > > #endif /* _LINUX_SCHED_CPUFREQ_H */ > > diff --git a/kernel/sched/cpufreq.c b/kernel/sched/cpufreq.c > > index 5e54cbc..36e2839 100644 > > --- a/kernel/sched/cpufreq.c > > +++ b/kernel/sched/cpufreq.c > > @@ -60,3 +60,26 @@ void cpufreq_remove_update_util_hook(int cpu) > > rcu_assign_pointer(per_cpu(cpufreq_update_util_data, cpu), > > NULL); > > } > > EXPORT_SYMBOL_GPL(cpufreq_remove_update_util_hook); > > + > > +/** > > + * cpufreq_get_sched_util - Get utilization values. > > + * @cpu: The targeted CPU. > > + * > > + * Get the CFS, DL and max utilization. > > + * This function allows cpufreq driver outside the kernel/sched to > > access > > + * utilization value for a CPUs run queue. > > + */ > > +void cpufreq_get_sched_util(int cpu, unsigned long *util_cfs, > > + unsigned long *util_dl, unsigned long > > *max) > > +{ > > +#ifdef CONFIG_CPU_FREQ_GOV_SCHEDUTIL > > What will happen when schedutil is compiled in the kernel but > ondemand > is the one getting used currently ? It should still work. The only reason I have to use ifdef because of compile issues when CONFIG_CPU_FREQ_SCHEDUTIL is not defined. The reason for that is that cpu_util_cfs() and cpu_util_dl() is defined under #ifdef CONFIG_CPU_FREQ_GOV_SCHEDUTIL. The actual code inside the cpu_util_cfs() and cpu_util_dl() uses rq->cfs.avg.util_avg and rq->cfs.avg.util_avg, which are updated irrespective of cpufreq governor. May be better to remove ifdefs for cpu_util_dl() and cpu_util_cfs(). Thanks, Srinivas > > > + struct rq *rq = cpu_rq(cpu); > > + > > + *max = arch_scale_cpu_capacity(NULL, cpu); > > + *util_cfs = cpu_util_cfs(rq); > > + *util_dl = cpu_util_dl(rq); > > +#else > > + *util_cfs = *util_dl = 1; > > +#endif > > +} > > +EXPORT_SYMBOL_GPL(cpufreq_get_sched_util); > > -- > > 2.9.5 > >