C states not used

Crivens

Administrator
Staff member
Administrator
Moderator
I noticed that some time ago my laptops did stop using C states, and looking it up with sysctrl shows that f.e. C2 is unused in 30 seconds idle time. Yes, powerd is running, est is loaded, Cmax is set in tuneables to C3. It happens on a core2duo as well as core1solo. I can supply more info when I am back on my machines.

Did I miss some migration action on 11.1?
 
Okay, here as promised the data:
Machine is running
Code:
FreeBSD Wanderer 11.1-RELEASE-p10 FreeBSD 11.1-RELEASE-p10 #26 r333924

This is loader.conf
Code:
kern.geom.label.gptid.enable="0"
zfs_load="YES"
acpi_video_load="YES"
kern.vty="vt"

#hw.pci.enable_io_modes="0"
hint.p4tcc.0.disabled=1
hint.apic.0.clock=0
hint.atrtc.0.clock=0

#acpi Override
hw.acpi.osname="Linux"
hw.usb.timings.extra_power_up_time="700"
vm.pmap.pti=0

Whats in /etc/sysctrl.conf
Code:
hw.acpi.video.lcd0.brightness=7
compat.linux.osrelease=2.6.18
kern.module_path=/boot/kernel;/boot/modules;/usr/local/modules

#hw.usb.no_suspend_wait=1
#hw.pci.do_power_suspend=0
#hw.pci.do_power_resume=0
hw.acpi.reset_video=1

vfs.usermount=1

And what is set in /etc/rc.conf
Code:
keymap="german.iso.acc.kbd"
ifconfig_re0="DHCP"
sshd_enable="YES"
moused_enable="YES"
powerd_enable="YES"

# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="AUTO"
zfs_enable="YES"

battmond_enable="YES"

inetd_enable="YES"
linux_enable="YES"

anacron_enable="YES"
background_dhclient="YES"
clear_tmp_enable="YES"
cron_enable="NO"
cupsd_enable="YES"
lpd_enable="YES"

firewall_enable="YES"
firewall_type="workstation"
# ssh and syncthing
firewall_myservices="22 22000/tcp 21027/udp"
firewall_allowservices="A B C"

fusefs_enable="YES"

powerd_flags="-a adaptive -b adaptive -n adaptive"

devfs_system_ruleset="system"

economy_cx_lowest="Cmax"
performance_cx_lowest="Cmax"

#wlan
wlans_iwn0="wlan0"
ifconfig_wlan0="WPA SYNCDHCP"

keymap=de.noacc.kbd

tmpmfs="YES"
tmpsize="1024m"

wpa_supplicant="YES"

# List of kernel modules to load
kld_list="fuse iwn4965fw if_iwn"

What I see in sysctrl is this: sysctrl -a |grep cx
Code:
hw.acpi.cpu.cx_lowest: C8
dev.cpu.1.cx_method: C1/mwait/hwc C2/mwait/hwc C3/mwait/hwc/bma
dev.cpu.1.cx_usage_counters: 228378 0 0
dev.cpu.1.cx_usage: 100.00% 0.00% 0.00% last 284us
dev.cpu.1.cx_lowest: C8
dev.cpu.1.cx_supported: C1/1/1 C2/2/1 C3/3/162
dev.cpu.0.cx_method: C1/mwait/hwc C2/mwait/hwc C3/mwait/hwc/bma
dev.cpu.0.cx_usage_counters: 666229 0 0
dev.cpu.0.cx_usage: 100.00% 0.00% 0.00% last 2us
dev.cpu.0.cx_lowest: C8
dev.cpu.0.cx_supported: C1/1/1 C2/2/1 C3/3/162

Anyone having an idea what's going on?
 
The problem is not the waking from C state but the not-using. This is from a laptop core2duo about 10 years of age. It can sit idle for minutes and not use any C state, only about close to 30 watts of power :(

The old T60 core1solo is the same...

Edit: that is close to 160% of the previous power intake.
 
Last edited:
I am bisecting my way trough the memstick images, booting them into live media and checking the sysctrl settings. With 10.4 it works, with 11.0 it does not. Investigation continues.
 
I was thinking in terms of newer code having to accomodate the loading/implemention/utilization of firmware. Perhaps it is not ready/disabled or needs more testing/debugging.
 
It is not about sleep states of the system (a.k.a. S3, S4, ...) but power saving in the CPU, and in older ones that is. The acpi code of 10.4 did the right thing, and somewhat after that there came a regression. Maybe not only I should check this again, who in the forum has the same old hardware and the same effect? Am I the only one (looking)?
 
The old code sadly does not build, so I need to dig deeper. Maybe until I find Jimmy Hoffa or the S3 which worked on 10.4 but not now. I call this a pretty heavy regression.
 
Whats going on: for some reason it doesn't switch to C2 (or further). That might happen if the board does not know these states (obviousely not the case) or if hw.acpi.cpu.cx_lowest=C1 is set (obviousely not the case).

The C2/C3 states should work independent of powerd and without any laptop power saving modes. They exist on genuine desktop boards as well, and there it should be enough to put this into /etc/sysctl.conf:
hw.acpi.cpu.cx_lowest=C3

Sadly my vintage machine has now a workstation/server board that does not know any C states. It did work well on a pentium-2 (but that was retired with Rel 9 or 10).

That C8 in your output looks strange (but might work nevertheless). What does happen if You set it manually to hw.acpi.cpu.cx_lowest=C3 (or C1 or C2)?
 
I think the code tries to enumerate the states and gets something wrong. The list of C states comes from the acpi defs in ROM, so it does not need to match the found states. Now when the code only detects C1 and keeps that as maximum, you can overwrite that with anything - it will not matter but lead people into thinking all is well. So whoever uses a laptop, please check this. It only takes 10 seconds or so.
 
Seem the same behaviour with my Celeron 530.
Code:
$ uname -rm
11.1-RELEASE-p10 amd64
$ sysctl -a | fgrep cx
has_pipe_cxsr: no
hw.acpi.cpu.cx_lowest: C8
dev.cpu.0.cx_method: C1/mwait/hwc C2/mwait/hwc/bma
dev.cpu.0.cx_usage_counters: 1969022 0
dev.cpu.0.cx_usage: 100.00% 0.00% last 1578us
dev.cpu.0.cx_lowest: C8
dev.cpu.0.cx_supported: C1/1/1 C2/2/17

/etc/rc.conf
Code:
#--- General settings -------------------------------------------------
cron_flags="-m ''"
devfs_system_ruleset="system"
dumpdev="AUTO"
economy_cx_lowest="Cmax"
gptboot_enable="NO"
kern_securelevel_enable="YES"
kern_securelevel="1"
kld_list="dtraceall.ko i915kms.ko vboxdrv.ko"
openntpd_enable="YES"
openntpd_flags="-sv"
performance_cx_lowest="Cmax"
savecore_enable="NO"
sendmail_enable="NO"
sendmail_submit_enable="NO"
sendmail_outbound_enable="NO"
sendmail_msp_queue_enable="NO"
syslogd_flags="-ss"
update_motd="NO"
virecover_enable="NO"
vnstat_enable="YES"
xdm_enable="YES"
zfs_enable="YES"

#--- Network settings -------------------------------------------------
cloned_interfaces="lo1"
icmp_log_redirect="YES"
ifconfig_lo1="inet 10.0.0.0/29"
ifconfig_ue0="SYNCDHCP group egress"
#ifconfig_wlan0="WPA SYNCDHCP group egress"
ip6addrctl_enable="NO"
log_in_vain="1"
pf_enable="YES"
wlans_ath0="wlan0"
/etc/sysctl.conf
Code:
#--- Hardware --------------------------
dev.cpu.0.freq=216

hw.snd.vpc_autoreset=0

#--- Kernel ----------------------------
kern.coredump=0
kern.ipc.shm_use_phys=1
kern.maxprocperuid=150
kern.randompid=376
kern.vt.enable_bell=0

#--- Network ---------------------------
net.inet.icmp.drop_redirect=1
net.inet.ip.check_interface=1
net.inet.ip.process_options=0
net.inet.ip.random_id=1
net.inet.ip.redirect=0
net.inet.tcp.blackhole=2
net.inet.tcp.delayed_ack=0
net.inet.tcp.drop_synfin=1
net.inet.tcp.icmp_may_rst=0
net.inet.tcp.rfc1323=0
net.inet.tcp.sack.enable=0
net.inet.udp.blackhole=1
net.inet6.icmp6.rediraccept=0
net.inet6.ip6.redirect=0

#net.inet.sctp.blackhole=2

#--- Security --------------------------
security.bsd.hardlink_check_gid=1
security.bsd.hardlink_check_uid=1
security.bsd.see_other_uids=0
security.bsd.see_other_gids=0
security.bsd.stack_guard_page=1
security.bsd.unprivileged_proc_debug=0
security.bsd.unprivileged_read_msgbuf=0
security.jail.allow_raw_sockets=0
security.jail.chflags_allowed=0
security.jail.set_hostname_allowed=0

#--- VFS -------------------------------
vfs.usermount=1
/boot/loader.conf
Code:
autoboot_delay="2"

hint.acpi_throttle.0.disabled="0"
hint.p4tcc.0.disabled="0"

hw.pci.do_power_nodriver="3"
hw.psm.tap_enabled=1

vfs.root.mountfrom="zfs:zroot/ROOT/default"
vfs.zfs.arc_max="700M"
vfs.zfs.arc_min="300M"
vfs.zfs.resilver_delay=0
vfs.zfs.resilver_min_time_ms=5000
vfs.zfs.scrub_delay=0
vfs.zfs.top_maxinflight=128

zfs_load="YES"

Setting hw.acpi.cpu.cx_lowest to C2 makes no difference...
 
I don't know if this can be useful, but booting an old 10.2-RELEASE (i386 however, while actually using AMD64) 3 C states are detected, instead of 2, and they are all used.
 
Just checking -current after I saw commit r314211. Continuing with fingers crossed.
 
Now I have cx_max being C8. Otherwise no change. :(
 
That is loaded and working. Sad thing is the laptop now draws (about) two times the power it used to. Suspend is borked also (used to work with 10.4). So I guess I will roll back to 10.4 and stay there. Since I not only bought one of these little road warriors but a trunk full, I am a little disapointed.
 
Sorry, no idea. Never mounted enough anger to file a PR. I would supply ACPI dumps, however, and gladly.
 
I just today moved the SSD to a refurbished X230 and it works very well there. But it also lists C8 as max, but only knows about C1-C3. I will check what I can do about the T60 I still have lurking around.
 
When I put:

# cat /boot/loader.conf | grep acpi_throttle
hint.acpi_throttle.0.disabled="0"


My CPU only know about C1 and C2, but the current frequency is low

dev.cpu.0.cx_method: C1/mwait/hwc C2/mwait/hwc
dev.cpu.0.cx_usage_counters: 2667 79626
dev.cpu.0.cx_usage: 3.24% 96.75% last 1899us
dev.cpu.0.cx_lowest: C8
dev.cpu.0.cx_supported: C1/1/1 C2/2/80
dev.cpu.0.freq_levels: 2601/35000 2600/35000 2500/33218 2400/31470 2300/29755 2200/28074 2100/26426 2000/24816 1900/23556 1800/22002 1700/20480 1600/18989 1500/17534 1400/16106 1300/15009 1200/13638 1050/11933 900/10228 750/8523 600/6819 450/5114 300/3409 150/1704
dev.cpu.0.freq: 150


When I changed to:

# cat /boot/loader.conf | grep acpi_throttle
hint.acpi_throttle.0.disabled="1"


My CPU detect C1, C2 and C3 but the current frequency is higt

dev.cpu.0.cx_method: C1/mwait/hwc C2/mwait/hwc C3/mwait/hwc
dev.cpu.0.cx_usage_counters: 5377 1366 309651
dev.cpu.0.cx_usage: 1.69% 0.43% 97.86% last 588us
dev.cpu.0.cx_lowest: C8
dev.cpu.0.cx_supported: C1/1/1 C2/2/59 C3/3/87
dev.cpu.0.freq_levels: 2601/35000 2600/35000 2500/33218 2400/31470 2300/29755 2200/28074 2100/26426 2000/24816 1900/23556 1800/22002 1700/20480 1600/18989 1500/17534 1400/16106 1300/15009 1200/13638
dev.cpu.0.freq: 1200
dev.cpu.0.temperature: 48.0C
 

# cat /boot/loader.conf | grep acpi_throttle
hint.acpi_throttle.0.disabled="1"


This setting was regularly done during upgrade to Rel. 10. It was accompanied by a paper, which explained that the very low frequencies which were enabled by setting this to "0" would not contribute to actual power savings.

I would not trust in any power influx readings. I would just compare temperature, under otherwise equal circumstances (as the power can go nowhere else).
 
Frequencies below 1200, for your setup, are emulated by halting the cpu for some percentage of a duty cycle, if memory serves me right. As long as nothing is to be done, it is not important if the CPU sleeps at 1200 for the complete slice or only a tiny part of it while being halted elsewhile.

If the C states do not work, however, that makes a huuuge difference.
 
Back
Top