Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1505489imm; Tue, 15 May 2018 21:51:47 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq9S8zhorElcFfUeOf6KH5A0hqpcXUXXcVjhaFeslO5Lf1ftnm7mkEOqJX0X8Jb0SSBgIuT X-Received: by 2002:a17:902:1e2:: with SMTP id b89-v6mr14275556plb.279.1526446307389; Tue, 15 May 2018 21:51:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526446307; cv=none; d=google.com; s=arc-20160816; b=dmvKNEbJzOsgMCxWfPT4eDKXSMr5wio6k+Ww5l2jWjC93GldREYZeOwHzCjT07CREX uDFw1Y4vUy/3Cb4KaDhZb9kWshHFygaQbAm0OMCgFPx3E14RSwG9ytQYt8XQxzw/jUxj Av+nAdmVTM3so+IVE2cRfSXW6KJCw1gvELtglY6ZcYF1yrY+MWQ7RBmGeDyWApQoLHjX GQImrIIa1JtWR6rdOwg9BJ5xb1/xeGVfYI6RH+DHU39ntgU2SIN6aZYWzQhvDqMeDPuS cCQ+XxFq0ycWJCREA5TI2q+KmWBULxKXKeo7KYmMHYzZ/5QZPnO442XSTc99k1NfcE/P PXRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=x3KmEFyi87799fl9QsPsX79MoA0K30ueZAqwng8WKNM=; b=IVA9kHogLIGxKilNF0FIDmZqCDDqyJptK5Jn5j+kKzyVyF7Y9HdgwwdLG1nXsseda/ S3N1fO5sOeE2wzQ0aM8z2WWfQhD/4UNF04rtEF4K+nv3JUhqLkFPctVKpVjDALkWKa/R OCX/YGh0RmKPadH4dY9opc9UCx+6rv6RhElBt1CxS61grcnWiu7juL3LUl85YCdx+jzA unUF+1OpQD+IxHNRqKxjUILKAe4xk3kRhn9CTPNxL+1l1x1l8JXL5dMd4Lgpdf3aqENH NQojOVxAAvLqgnKYpRumwOkhNPzUs379j3t4HpsKg4Kj/8WFLR0nOFDxDxDDO0KXgtNV 81Pg== 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 o12-v6si1679585pls.422.2018.05.15.21.51.32; Tue, 15 May 2018 21:51:47 -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 S1752500AbeEPEuc (ORCPT + 99 others); Wed, 16 May 2018 00:50:32 -0400 Received: from mga04.intel.com ([192.55.52.120]:1167 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751667AbeEPEtU (ORCPT ); Wed, 16 May 2018 00:49:20 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 May 2018 21:49:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,404,1520924400"; d="scan'208";a="41300347" Received: from sunandaa-mobl.amr.corp.intel.com (HELO spandruv-mobl.jf.intel.com) ([10.252.135.192]) by orsmga007.jf.intel.com with ESMTP; 15 May 2018 21:49:19 -0700 From: Srinivas Pandruvada To: srinivas.pandruvada@linux.intel.com, tglx@linutronix.de, mingo@redhat.com, peterz@infradead.org, bp@suse.de, lenb@kernel.org, rjw@rjwysocki.net, mgorman@techsingularity.net Cc: x86@kernel.org, linux-pm@vger.kernel.org, viresh.kumar@linaro.org, juri.lelli@arm.com, linux-kernel@vger.kernel.org Subject: [RFC/RFT] [PATCH 06/10] cpufreq / sched: Add interface to get utilization values Date: Tue, 15 May 2018 21:49:07 -0700 Message-Id: <20180516044911.28797-7-srinivas.pandruvada@linux.intel.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20180516044911.28797-1-srinivas.pandruvada@linux.intel.com> References: <20180516044911.28797-1-srinivas.pandruvada@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 + 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