Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1334091

[PATCH 3/9] cpufreq: governor: Fix nice contribution computation in dbs_check_cpu()

From "Rafael J. Wysocki" <rjw@rjwysocki.net>
Newsgroups linux.kernel
Subject [PATCH 3/9] cpufreq: governor: Fix nice contribution computation in dbs_check_cpu()
Date 2016-02-15 02:30 +0100
Message-ID <r2g9d-2nN-27@gated-at.bofh.it> (permalink)
References <r2g9b-2nN-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

The contribution of the CPU nice time to the idle time in dbs_check_cpu()
is computed in a bogus way, as the code may subtract current and previous
nice values for different CPUs.

That doesn't matter for cases when cpufreq policies are not shared,
but may lead to problems otherwise.

Fix the computation and simplify it to avoid taking unnecessary steps.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/cpufreq/cpufreq_governor.c |   18 +++---------------
 1 file changed, 3 insertions(+), 15 deletions(-)

Index: linux-pm/drivers/cpufreq/cpufreq_governor.c
===================================================================
--- linux-pm.orig/drivers/cpufreq/cpufreq_governor.c
+++ linux-pm/drivers/cpufreq/cpufreq_governor.c
@@ -198,22 +198,10 @@ void dbs_check_cpu(struct cpufreq_policy
 		j_cdbs->prev_cpu_idle = cur_idle_time;
 
 		if (ignore_nice) {
-			struct cpu_dbs_info *cdbs = gov->get_cpu_cdbs(cpu);
-			u64 cur_nice;
-			unsigned long cur_nice_jiffies;
+			u64 cur_nice = kcpustat_cpu(j).cpustat[CPUTIME_NICE];
 
-			cur_nice = kcpustat_cpu(j).cpustat[CPUTIME_NICE] -
-					 cdbs->prev_cpu_nice;
-			/*
-			 * Assumption: nice time between sampling periods will
-			 * be less than 2^32 jiffies for 32 bit sys
-			 */
-			cur_nice_jiffies = (unsigned long)
-					cputime64_to_jiffies64(cur_nice);
-
-			cdbs->prev_cpu_nice =
-				kcpustat_cpu(j).cpustat[CPUTIME_NICE];
-			idle_time += jiffies_to_usecs(cur_nice_jiffies);
+			idle_time += cputime_to_usecs(cur_nice - j_cdbs->prev_cpu_nice);
+			j_cdbs->prev_cpu_nice = cur_nice;
 		}
 
 		if (unlikely(!wall_time || wall_time < idle_time))

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/9] cpufreq governor improvements "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-02-15 02:30 +0100
  [PATCH 1/9] cpufreq: governor: Simplify gov_cancel_work() slightly "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-02-15 02:30 +0100
    Re: [PATCH 1/9] cpufreq: governor: Simplify gov_cancel_work()  slightly Viresh Kumar <viresh.kumar@linaro.org> - 2016-02-15 06:50 +0100
  [PATCH 2/9] cpufreq: governor: Avoid atomic operations in hot paths "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-02-15 02:30 +0100
    Re: [PATCH 2/9] cpufreq: governor: Avoid atomic operations in hot  paths Viresh Kumar <viresh.kumar@linaro.org> - 2016-02-15 07:20 +0100
    Re: [PATCH 2/9] cpufreq: governor: Avoid atomic operations in hot  paths Viresh Kumar <viresh.kumar@linaro.org> - 2016-02-15 09:30 +0100
  [PATCH 7/9] cpufreq: governor: Move rate_mult to struct policy_dbs "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-02-15 02:30 +0100
    Re: [PATCH 7/9] cpufreq: governor: Move rate_mult to struct  policy_dbs Viresh Kumar <viresh.kumar@linaro.org> - 2016-02-15 10:00 +0100
  [PATCH 3/9] cpufreq: governor: Fix nice contribution computation in dbs_check_cpu() "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-02-15 02:30 +0100
    Re: [PATCH 3/9] cpufreq: governor: Fix nice contribution computation  in dbs_check_cpu() Viresh Kumar <viresh.kumar@linaro.org> - 2016-02-15 09:30 +0100
  [PATCH 9/9] cpufreq: governor: Use microseconds in sample delay computations "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-02-15 02:30 +0100
    Re: [PATCH 9/9] cpufreq: governor: Use microseconds in sample delay  computations Viresh Kumar <viresh.kumar@linaro.org> - 2016-02-15 10:00 +0100
  [PATCH 8/9] cpufreq: ondemand: Simplify conditionals in od_dbs_timer() "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-02-15 02:30 +0100
    Re: [PATCH 8/9] cpufreq: ondemand: Simplify conditionals in  od_dbs_timer() Viresh Kumar <viresh.kumar@linaro.org> - 2016-02-15 10:00 +0100

csiph-web