Personal computing discussed
Moderators: renee, SecretSquirrel, notfred
NTMBK wrote:Have you tried it under a different OS, to see if you get similar behaviour?
fullbodydenim wrote:I'm assuming Cool 'N' Quiet is enabled in the BIOS?
alan242 wrote:Are the both systems using the same CPU scaling governor? Is it possible the one system has a device like a USB joystick or a different daemon that is preventing the CPU from idling?
alan242 wrote:Try powertop (https://01.org/powertop) to see if can find anything that is not allowing the CPU to reach idle. It is an intel maintained tool, but it will work on AMD CPUs as well.
Concupiscence wrote:It sounds like your cooling is fine, so that's ruled out as a possibility. A few questions you've probably already checked on...
Concupiscence wrote:* Are you running the latest AMD firmware for the CPU? I know it wasn't installed and running by default in 14.04.
Concupiscence wrote:* Have you undervolted the CPU?
Concupiscence wrote:* Have you tried seeing what sustained load across all cores does? Run Handbrake on a test video and see how the cores behave.
just brew it! wrote:Concupiscence wrote:* Are you running the latest AMD firmware for the CPU? I know it wasn't installed and running by default in 14.04.
No idea. Will look into this. What firmware are you talking about? Microcode patches? Isn't that something that is normally handled by the BIOS/EFI?
Concupiscence wrote:just brew it! wrote:Concupiscence wrote:* Are you running the latest AMD firmware for the CPU? I know it wasn't installed and running by default in 14.04.
No idea. Will look into this. What firmware are you talking about? Microcode patches? Isn't that something that is normally handled by the BIOS/EFI?
Typically yes, though if you check the Additional Drivers utility in 16.04 (and at least the two prior versions, IIRC) you'll find AMD microcode updates squirreled away. My guess is that it downloads them as part of a firmware bundle and applies them early in the kernel boot process. From my personal experience it made a significant difference in games that thumped plural CPUs hard, but outside of that use case it didn't affect too much. It still might be worth applying here just to ensure good behavior.
Concupiscence wrote:You'll most likely be fine with the Asus defaults, though undervolting certainly helped my average power use and kept peak voltage down substantially; running the numbers on an online TDP calculator, it thumped it down to ~100 watts under full load. I definitely noticed a difference in both noise and heat after doing it.
JBI wrote:Ahh, interesting. Will definitely do this.
Glorious wrote:`sudo apt-get install amd64-microcode`
The corresponding one for Intel one is:
`sudo apt-get install intel-microcode`
I always do this for any system.
BobbinThreadbare wrote:So I guess the obvious thing to do would be switch to the conservative governor?
just brew it! wrote:BobbinThreadbare wrote:So I guess the obvious thing to do would be switch to the conservative governor?
Possibly. Haven't had time to dig further.
BobbinThreadbare wrote:I'm curious to see how mixing governors goes.
Keep us posted.
#!/bin/bash
#
# cpugovmon - change CPU governor based on inactivity time and system load
# Copyright (C) 2016 Michael Uchima
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# See <http://www.gnu.org/licenses/> for a copy of the GNU General
# Public License.
# Tunable parameters
SECS_CONSERVATIVE=15 # secs of DE inactivity for conservative governor
SECS_POWERSAVE=900 # secs of DE inactivity for powersave governor
LOAD_NOSAVE=200 # sys load (x100) that bumps us up from powersave to conservative
# Need the xprintidle tool; if not installed, bail
if [[ "`which xprintidle`" == "" ]]; then
echo "+++ xprintidle not installed, cpugovmon exiting +++"
exit 1
fi
# Let 'em know we're running
if [[ "`whoami`" != "root" ]]; then
echo "`date` - +++ cpugovmon started (non-root) +++"
else
echo "`date` - +++ cpugovmon started +++"
fi
NEWGOV=""
PREVGOV=""
NEWLOAD=0
PREVLOAD=0
while true; do
# Gather current system state
TIME_NOW=`date`
IDLE=$((`xprintidle`/1000))
NEWLOAD=`cat /proc/loadavg | sed -e 's/ .*$//;s/\.//;s/^0*//'`
# Log transitions above/below the "no powersave" threshold
if [[ $NEWLOAD -ge $LOAD_NOSAVE && $PREVLOAD -lt $LOAD_NOSAVE ]]; then
echo "$TIME_NOW - load above threshold"
fi
if [[ $NEWLOAD -lt $LOAD_NOSAVE && $PREVLOAD -ge $LOAD_NOSAVE ]]; then
echo "$TIME_NOW - load below threshold"
fi
# Decide which governor we want
if [[ $IDLE -ge $SECS_POWERSAVE && $NEWLOAD -lt $LOAD_NOSAVE ]]; then
NEWGOV=powersave
elif [[ $IDLE -gt $SECS_CONSERVATIVE ]]; then
NEWGOV=conservative
else
NEWGOV=ondemand
fi
# If desired governor changed, set it
if [[ "$NEWGOV" != "$PREVGOV" ]]; then
if [[ "`whoami`" == "root" ]]; then
echo "$TIME_NOW - setting CPU governor to $NEWGOV"
for CPU in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do
echo $NEWGOV >$CPU
done
else
echo "$TIME_NOW - would set CPU governor to $NEWGOV if running as root"
fi
PREVGOV=$NEWGOV
fi
PREVLOAD=$NEWLOAD
# Wait a half second so we're not hammering the system
sleep 0.5
done
just brew it! wrote:All righty then... I was in a hacking mood tonight, so I decided to go DIY on this. Rather than picking one of the stock CPU power management governors and tuning it, I concluded that what I really want is a meta-governor, which switches between governors based on system activity and load.
I wrote a simple daemon (as a bash script), which watches the desktop environment for keyboard and mouse activity. Any input device activity causes the "ondemand" governor (which favors responsiveness over power saving) to be used. After a certain number of seconds of inactivity, we fall back to the "conservative" governor, and eventually to the "powersave" governor (which pins clocks to their minimum frequency). But wait... if we have a resource intensive background job (e.g. media encode) running, we don't want the "powersave" governor to kick in, since that would slow things down. So we also watch system load, and if it exceeds a certain threshold, we hold off on enabling the "powersave" governor.
I've initially got the thresholds set to 15 seconds (for the drop to "conservative"), 15 minutes (to drop to "powersave"), and a system load load of 2.00 to keep the system out of "powersave"). The daemon polls every 0.5 second, so that's the maximum latency for switching out of the lower-power governor states back to "ondemand".
Gonna run with this for a while, and see if I experience any issues.
The script runs in a "debug" mode if executed as a non-root user, where it merely logs what changes it would make to the CPU power management state if it could.
Here's the script... releasing it under GPL:Code: Select all#!/bin/bash
#
# cpugovmon - change CPU governor based on inactivity time and system load
# Copyright (C) 2016 Michael Uchima
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# See <http://www.gnu.org/licenses/> for a copy of the GNU General
# Public License.
# Tunable parameters
SECS_CONSERVATIVE=15 # secs of DE inactivity for conservative governor
SECS_POWERSAVE=900 # secs of DE inactivity for powersave governor
LOAD_NOSAVE=200 # sys load (x100) that bumps us up from powersave to conservative
# Need the xprintidle tool; if not installed, bail
if [[ "`which xprintidle`" == "" ]]; then
echo "+++ xprintidle not installed, cpugovmon exiting +++"
exit 1
fi
# Let 'em know we're running
if [[ "`whoami`" != "root" ]]; then
echo "`date` - +++ cpugovmon started (non-root) +++"
else
echo "`date` - +++ cpugovmon started +++"
fi
NEWGOV=""
PREVGOV=""
NEWLOAD=0
PREVLOAD=0
while true; do
# Gather current system state
TIME_NOW=`date`
IDLE=$((`xprintidle`/1000))
NEWLOAD=`cat /proc/loadavg | sed -e 's/ .*$//;s/\.//;s/^0*//'`
# Log transitions above/below the "no powersave" threshold
if [[ $NEWLOAD -ge $LOAD_NOSAVE && $PREVLOAD -lt $LOAD_NOSAVE ]]; then
echo "$TIME_NOW - load above threshold"
fi
if [[ $NEWLOAD -lt $LOAD_NOSAVE && $PREVLOAD -ge $LOAD_NOSAVE ]]; then
echo "$TIME_NOW - load below threshold"
fi
# Decide which governor we want
if [[ $IDLE -ge $SECS_POWERSAVE && $NEWLOAD -lt $LOAD_NOSAVE ]]; then
NEWGOV=powersave
elif [[ $IDLE -gt $SECS_CONSERVATIVE ]]; then
NEWGOV=conservative
else
NEWGOV=ondemand
fi
# If desired governor changed, set it
if [[ "$NEWGOV" != "$PREVGOV" ]]; then
if [[ "`whoami`" == "root" ]]; then
echo "$TIME_NOW - setting CPU governor to $NEWGOV"
for CPU in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do
echo $NEWGOV >$CPU
done
else
echo "$TIME_NOW - would set CPU governor to $NEWGOV if running as root"
fi
PREVGOV=$NEWGOV
fi
PREVLOAD=$NEWLOAD
# Wait a half second so we're not hammering the system
sleep 0.5
done
BobbinThreadbare wrote:That's some cool work, but I think dropping to powersave might be excessive. Conservative is going to keep your cores at low frequencies already.
#!/bin/bash
#
# wattbar - show CPU power usage in a terminal window as a bargraph
# Copyright (C) 2016 Michael Uchima
#
# Uses AMD's on-die CPU power sensor, available in Bulldozer and
# later cores. Sensors package must be installed and properly
# configured for this to work!
#
# Top bar is instantaneous power, bottom bar is 10 second rolling
# average. Samples 5x/second, updates display once a second.
#
# Note: For systems which are very lightly loaded, it is possible
# that this script may account for a non-trivial fraction of the
# system load!
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# See <http://www.gnu.org/licenses/> for a copy of the GNU General
# Public License.
# Initialize array used for rolling average calc
I=0
while [[ $I -lt 50 ]]; do
SLOT[$I]=0
I=$((I+1))
done
# Initialize other temporaries
SUM=0
SLOTS=0
I=0
# Loop forever until killed
while true; do
# You will need to play with the following line depending on how your
# motherboard does CPU power monitoring; goal is to get current CPU power
# into the WATTS variable, as an integer.
WATTS=`sensors fam15h_power-pci-00c4 | tail -n +3 | head -n 1 | sed -e 's/^.*: *//;s/\..*$//'`
# Do the calcs
SUM=$((SUM-SLOT[I]+WATTS))
SLOT[I]=$WATTS
I=$(((I+1)%50))
if [[ $SLOTS -lt 50 ]]; then
SLOTS=$((SLOTS+1))
fi
# Update display every 5th sample
if [[ $((I%5)) -eq 0 ]]; then
BARLEN=$((WATTS/2))
WATTSAVG=$((SUM/SLOTS))
BARLENAVG=$((WATTSAVG/2))
clear
printf "%3d %s\n" $WATTS `echo -n "======================================================================" | head -c $BARLEN`
printf "%3d %s\n" $WATTSAVG `echo -n "======================================================================" | head -c $BARLENAVG`
fi
# Wait 200 ms
sleep 0.2
done