powerd isn't correct count load

Andrey Zonov andrey at zonov.org
Wed May 16 19:56:04 UTC 2012


Hi,

I just ran powerd(8) in verbose mode and found that it isn't correct 
count load.

# powerd -v
powerd: unable to determine AC line status
load 323%, current freq 2409 MHz ( 0), wanted freq 4818 MHz
load 222%, current freq 2409 MHz ( 0), wanted freq 4818 MHz
load 213%, current freq 2409 MHz ( 0), wanted freq 4818 MHz
load 151%, current freq 2409 MHz ( 0), wanted freq 4818 MHz
load 170%, current freq 2409 MHz ( 0), wanted freq 4818 MHz

I think load should be divided by the number of CPUs.

Attached patch solves the problem.

-- 
Andrey Zonov
-------------- next part --------------
Index: usr.sbin/powerd/powerd.c
===================================================================
--- usr.sbin/powerd/powerd.c	(revision 235394)
+++ usr.sbin/powerd/powerd.c	(working copy)
@@ -168,6 +168,7 @@
 			*load += 100 - (cp_times[cpu * CPUSTATES + CP_IDLE] - 
 			    cp_times_old[cpu * CPUSTATES + CP_IDLE]) * 100 / total;
 		}
+		*load /= ncpus;
 	}
 
 	memcpy(cp_times_old, cp_times, cp_times_len);


More information about the freebsd-stable mailing list