Skip to contentSkip to conversation

cpufreq: 64bit divide in intel_pstate_calc_busy()

PATCH In review Artem Savkov 2 participants 2 messages Feb 11, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cpufreq: 64bit divide in intel_pstate_calc_busy()

intel_pstate.c won't compile on i686 because of a linking error:
drivers/cpufreq/intel_pstate.c:459: undefined reference to `__udivdi3'

---
 drivers/cpufreq/intel_pstate.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/cpufreq/intel_pstate.c +3 -1
index 86ad482..dc43208 100644
@@ -456,7 +456,9 @@ static inline void intel_pstate_calc_busy(struct cpudata *cpu,
 	core_pct = div64_u64(sample->aperf * 100, sample->mperf);
 	sample->freq = cpu->pstate.turbo_pstate * core_pct * 1000;
 
-	sample->core_pct_busy = sample->pstate_pct_busy * core_pct / 100;
+	sample->core_pct_busy = div64_u64(
+					sample->pstate_pct_busy * core_pct,
+					100);
 }
 
 static inline void intel_pstate_sample(struct cpudata *cpu)
Signature · 1 line
1.8.1.1
#1 lore raw
Quoted 4 lines · Artem Savkov

intel_pstate.c won't compile on i686 because of a linking error:
drivers/cpufreq/intel_pstate.c:459: undefined reference to `__udivdi3'

I've just applied an equivalent patch from Dirk.

Thanks,
Rafael

Quoted 20 lines
---
 drivers/cpufreq/intel_pstate.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/cpufreq/intel_pstate.c +3 -1
index 86ad482..dc43208 100644
@@ -456,7 +456,9 @@ static inline void intel_pstate_calc_busy(struct cpudata *cpu,
 	core_pct = div64_u64(sample->aperf * 100, sample->mperf);
 	sample->freq = cpu->pstate.turbo_pstate * core_pct * 1000;
 
-	sample->core_pct_busy = sample->pstate_pct_busy * core_pct / 100;
+	sample->core_pct_busy = div64_u64(
+					sample->pstate_pct_busy * core_pct,
+					100);
 }
 
 static inline void intel_pstate_sample(struct cpudata *cpu)
Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.