SlideShare a Scribd company logo
1 of 26
Download to read offline
Linux power management: are you doing it
right?
Chris Simmonds
Embedded World 2018
Linux power management: are you doing it right? 1 Copyright Ā© 2011-2018, 2net Ltd
License
These slides are available under a Creative Commons Attribution-ShareAlike 3.0 license. You can read the full
text of the license here
http://creativecommons.org/licenses/by-sa/3.0/legalcode
You are free to
ā€¢ copy, distribute, display, and perform the work
ā€¢ make derivative works
ā€¢ make commercial use of the work
Under the following conditions
ā€¢ Attribution: you must give the original author credit
ā€¢ Share Alike: if you alter, transform, or build upon this work, you may distribute the resulting work only
under a license identical to this one (i.e. include this page exactly as it is)
ā€¢ For any reuse or distribution, you must make clear to others the license terms of this work
Linux power management: are you doing it right? 2 Copyright Ā© 2011-2018, 2net Ltd
About Chris Simmonds
ā€¢ Consultant and trainer
ā€¢ Author of Mastering Embedded Linux Programming
ā€¢ Working with embedded Linux since 1999
ā€¢ Android since 2009
ā€¢ Speaker at many conferences and workshops
"Looking after the Inner Penguin" blog at http://2net.co.uk/
https://uk.linkedin.com/in/chrisdsimmonds/
https://google.com/+chrissimmonds
Linux power management: are you doing it right? 3 Copyright Ā© 2011-2018, 2net Ltd
Overview
ā€¢ Reducing power usage is important, especially for battery-powered
devices
ā€¢ In this talk I will introduce
ā€¢ The rules of power management
ā€¢ The major Linux systems that implement power management
ā€¢ Some practical measures you can take
Linux power management: are you doing it right? 4 Copyright Ā© 2011-2018, 2net Ltd
The rules of power management
1. Donā€™t rush if you donā€™t have to
2. Take a break when things are quiet
3. Turn things off when they are not in use
4. Have a snooze when you expect things to be quite for a while
Linux power management: are you doing it right? 5 Copyright Ā© 2011-2018, 2net Ltd
Rule 1: Donā€™t rush
ā€¢ Reducing CPU frequency saves power?
ā€¢ P = CfV2
ā€¢ Reducing voltage, not frequency, saves power
ā€¢ But, lowering frequency allows for lowering the voltage, and therefore
saves power
ā€¢ The tuple of frequency and voltage is called an Operating Performance
Point (OPP)
ā€¢ The ability to change OPP at run-time is called Dynamic Voltage and
Frequency Scaling (DVFS)
Linux power management: are you doing it right? 6 Copyright Ā© 2011-2018, 2net Ltd
OPP deļ¬nitions in device tree
Example from am33xx.dtsi
cpu0_opp_table: opp-table {
compatible = "operating-points-v2-ti-cpu";
syscon = <&scm_conf>;
opp50@300000000 {
opp-hz = /bits/ 64 <300000000>;
opp-microvolt = <950000 931000 969000>;
opp-supported-hw = <0x06 0x0010>;
opp-suspend;
};
opp100@600000000 {
opp-hz = /bits/ 64 <600000000>;
opp-microvolt = <1100000 1078000 1122000>;
opp-supported-hw = <0x06 0x0040>;
};
[...]
};
Linux power management: are you doing it right? 7 Copyright Ā© 2011-2018, 2net Ltd
CPUFreq
ā€¢ In Linux, selecting the best OPP is done by the CPUFreq driver
ā€¢ Enable with kernel option CONFIG_CPU_FREQ=y
ā€¢ Part of the Linux support for each SoC
ā€¢ Control is per CPU, via directory /sys/devices/system/cpu/cpuN/cpufreq
ā€¢ List of possible frequencies (corresponding to OPPs):
# cd /sys/devices/system/cpu/cpu0/cpufreq
# cat scaling_available_frequencies
300000 600000 720000 800000
Linux power management: are you doing it right? 8 Copyright Ā© 2011-2018, 2net Ltd
CPUFreq Governors
ā€¢ The policy for changing the OPP is controlled by a governor
ā€¢ There are a small number of governors coded into Linux:
# cd /sys/devices/system/cpu/cpu0/cpufreq
# cat scaling_available_governors
conservative ondemand userspace powersave performance
Linux power management: are you doing it right? 9 Copyright Ā© 2011-2018, 2net Ltd
Governors
ā€¢ powersave: Always selects the lowest frequency
ā€¢ performance: Always selects the highest frequency
ā€¢ ondemand: Changes frequency based on the CPU utilization. If the
CPU is idle less than 20% of the time, it sets the frequency to the
maximum; if it is idle more than 30% of the time, it decrements the
frequency by 5%
ā€¢ conservative: As ondemand , but switches to higher frequencies in
5% steps rather than going immediately to the maximum
ā€¢ userspace: Frequency is set by a user space program
Linux power management: are you doing it right? 10 Copyright Ā© 2011-2018, 2net Ltd
Example of the potential power saving
ā€¢ BeagleBone Black running a constant load
ā€¢ No governor: using ļ¬xed frequencies
OPP Freq MHz CPU use, % Power, mW
OPP50 300 94 320
OPP100 600 48 345
OPP120 720 40 370
Turbo 800 34 370
Nitro 1000 28 370
15% saving by running the job at 300 MHz instead of 1 GHz
Linux power management: are you doing it right? 11 Copyright Ā© 2011-2018, 2net Ltd
Rule 2: take a break
ā€¢ When the CPU has nothing to do, it enters an idle state
ā€¢ Usually, there are several idle states to choose from
ā€¢ Sometimes known as C-states
ā€¢ Deeper idle states take longer to return to full operation
ā€¢ Example: the CPU L1 cache may be powered down, so it takes time to
re-load the cache when restarting
Linux power management: are you doing it right? 12 Copyright Ā© 2011-2018, 2net Ltd
CPUIdle
ā€¢ In Linux, the transition between idle states is controlled by the CPUIdle
driver
ā€¢ Enable with kernel option CONFIG_CPU_IDLE
ā€¢ Information about idle state C for CPU N is in
/sys/devices/system/cpu/cpuN/cpuidle/stateC
ā€¢ For example the TI AM335x SoC has only two states
ā€¢ State0: WFI (Wait For Interrupt)
ā€¢ State1: C1
Linux power management: are you doing it right? 13 Copyright Ā© 2011-2018, 2net Ltd
CPUIdle governors
ā€¢ The policy for selecting idle states is controlled by the CPUIdle
governor
ā€¢ Cannot be changed at run-time
ā€¢ Only two options
ā€¢ ladder: steps through the idle states one at a time depending on the
time spent in the last idle period. Works well with a regular timer tick
ā€¢ menu: selects an idle state based on the expected idle time. Works well
with tickless systems
Linux power management: are you doing it right? 14 Copyright Ā© 2011-2018, 2net Ltd
Tickless operation
ā€¢ Linux was written assuming a constant tick, typically 100Hz
ā€¢ On an idle system, this is a waste of CPU power; stops the CU
entering deeper sleep states
ā€¢ For tickless operation, conļ¬gure your kernel with CONFIG_NO_HZ_IDLE=y
(on older kernels, CONFIG_NO_HZ=y)
ā€¢ Schedules timer interrupts for the next event, skipping any intermediate
ticks
ā€¢ Potential power saving on a device that is mostly idle: up to 70%
Linux power management: are you doing it right? 15 Copyright Ā© 2011-2018, 2net Ltd
Rule 3: turn things off
ā€¢ Managing the power usage of peripherals is also important
ā€¢ In Linux, the runtime power management (pm runtime) tracks the
state of pm-aware device drivers
ā€¢ Each device driver can register callback functions such as
runtime_suspend and runtime_resume
ā€¢ Kernel conļ¬guration option CONFIG_PM
Linux power management: are you doing it right? 16 Copyright Ā© 2011-2018, 2net Ltd
Controlling pm runtime
ā€¢ PM runtime is exposed via directory power for each device that
supports it
ā€¢ Files in that directory include:
ā€¢ control: "auto": kernel will select state; "on": device always on (pm
runtime disabled)
ā€¢ runtime_status: current state of the device: "active", "suspended", or
"unsupported"
ā€¢ autosuspend_delay_ms: minimum time before suspending device
Linux power management: are you doing it right? 17 Copyright Ā© 2011-2018, 2net Ltd
Runtime PM
ā€¢ For example, the MMC controller on TI AM335x
# cd /sys/devices/platform/ocp/481d8000.mmc/mmc_host/mmc1/mmc1:0001/power
# grep "" *
async:disabled
autosuspend_delay_ms:3000
control:auto
runtime_active_kids:0
runtime_active_time:164440
runtime_enabled:enabled
runtime_status:suspended
runtime_suspended_time:139270
runtime_usage:0
ā€¢ Note that autosuspend_delay_ms is 3 seconds
ā€¢ That runtime_status is "suspended"
Linux power management: are you doing it right? 18 Copyright Ā© 2011-2018, 2net Ltd
Rule 4: Have a snooze
ā€¢ The techniques so far will optimize power usage of a running system
ā€¢ Largest power saving comes from entering a system sleep mode
ā€¢ Example: when closing the lid of a laptop
ā€¢ Example: Android device suspending after activity timeout (default 60
seconds)
Linux power management: are you doing it right? 19 Copyright Ā© 2011-2018, 2net Ltd
Power states
Sleep state S-state Description
freeze Stops (freezes) all activity in user space
standby S1 Powers down all CPUs except the boot CPU
mem S3 Powers down the system, puts RAM into self-refresh
disk S4 Saves memory to disk, followed by complete power down
Linux sleep states, together with equivalent ACPI S-state
ā€¢ mem (suspend to RAM) typically consumes a few milliamps
(dependent on board design and BSP)
ā€¢ disk (suspend to disk) typically consumes no power at all
Linux power management: are you doing it right? 20 Copyright Ā© 2011-2018, 2net Ltd
Controlling power state
ā€¢ In Linux, macro power management is via by the power management
subsystem
ā€¢ Enable with kernel option CONFIG_PM
ā€¢ You can view the sleep states implemented in BSP via /sys/power/state
# cat /sys/power/state
freeze standby mem disk
ā€¢ mem is the one most often used in embedded systems
ā€¢ disk (aka hibernation) is usually too slow and takes too much storage
when using ļ¬‚ash memory
Linux power management: are you doing it right? 21 Copyright Ā© 2011-2018, 2net Ltd
Changing power state
ā€¢ Simply, write the desired state to /sys/power/state
ā€¢ For example, to enter suspend mode:
# echo mem > /sys/power/state
[ 1646.158274] PM: Syncing filesystems ...done.
[ 1646.178387] Freezing user space processes ...(elapsed 0.001 seconds)
done.
[ 1646.188098] Freezing remaining freezable tasks ...
(elapsed 0.001 seconds) done.
[ 1646.197017] Suspending console(s) (use
no_console_suspend to debug)
[ 1646.338657] PM: suspend of devices complete
after 134.322 msecs
[ 1646.343428] PM: late suspend of devices
Linux power management: are you doing it right? 22 Copyright Ā© 2011-2018, 2net Ltd
Waking up
ā€¢ CPU is woken by interrupt or other input
ā€¢ Wakeup sources need to be powered while the main CPU is powered
down
ā€¢ Wakeup sources may include
ā€¢ Real-time clock (RTC)
ā€¢ Certain GPIO pins
ā€¢ UART
ā€¢ Usually managed by a dedicated Power Management chip, PMIC
Linux power management: are you doing it right? 23 Copyright Ā© 2011-2018, 2net Ltd
Wakeup sources
ā€¢ Devices that can act as wakeup sources have
/sys/devices/.../power/wakeup set to "enabled"
ā€¢ For example, GPIOs 0 to 7 on AM335x
# cat /sys/devices/platform/gpio_keys/power/wakeup
enabled
ā€¢ Hence, pressing the power button wakes the device
Linux power management: are you doing it right? 24 Copyright Ā© 2011-2018, 2net Ltd
Conclusion
ā€¢ A well conļ¬gured Linux device will save power
ā€¢ Linux features considered here:
ā€¢ CPUFreq: selects OPP depending on load
ā€¢ CPUIdle: selects idle state based on predicted load
ā€¢ Tickless: eliminates unnecessary timer interrupts
ā€¢ Runtime power management: powers off unused peripherals
ā€¢ Suspend to RAM: puts system in minimum power usage state
Linux power management: are you doing it right? 25 Copyright Ā© 2011-2018, 2net Ltd
Questions?
Further reading: Chapter 11 of Mastering Embedded Linux Programming
Contact:
Web: www.2net.co.uk
Email: training@2net.co.uk
LinkedIn: https://uk.linkedin.com/in/chrisdsimmonds
Linux power management: are you doing it right? 26 Copyright Ā© 2011-2018, 2net Ltd

More Related Content

What's hot

HKG15-505: Power Management interactions with OP-TEE and Trusted Firmware
HKG15-505: Power Management interactions with OP-TEE and Trusted FirmwareHKG15-505: Power Management interactions with OP-TEE and Trusted Firmware
HKG15-505: Power Management interactions with OP-TEE and Trusted FirmwareLinaro
Ā 
linux device driver
linux device driverlinux device driver
linux device driverRahul Batra
Ā 
Qemu Introduction
Qemu IntroductionQemu Introduction
Qemu IntroductionChiawei Wang
Ā 
malloc & vmalloc in Linux
malloc & vmalloc in Linuxmalloc & vmalloc in Linux
malloc & vmalloc in LinuxAdrian Huang
Ā 
SFO15-302: Energy Aware Scheduling: Progress Update
SFO15-302: Energy Aware Scheduling: Progress UpdateSFO15-302: Energy Aware Scheduling: Progress Update
SFO15-302: Energy Aware Scheduling: Progress UpdateLinaro
Ā 
Reducing the boot time of Linux devices
Reducing the boot time of Linux devicesReducing the boot time of Linux devices
Reducing the boot time of Linux devicesChris Simmonds
Ā 
Reconnaissance of Virtio: Whatā€™s new and how itā€™s all connected?
Reconnaissance of Virtio: Whatā€™s new and how itā€™s all connected?Reconnaissance of Virtio: Whatā€™s new and how itā€™s all connected?
Reconnaissance of Virtio: Whatā€™s new and how itā€™s all connected?Samsung Open Source Group
Ā 
Continguous Memory Allocator in the Linux Kernel
Continguous Memory Allocator in the Linux KernelContinguous Memory Allocator in the Linux Kernel
Continguous Memory Allocator in the Linux KernelKernel TLV
Ā 
Basic Linux Internals
Basic Linux InternalsBasic Linux Internals
Basic Linux Internalsmukul bhardwaj
Ā 
HKG15-107: ACPI Power Management on ARM64 Servers (v2)
HKG15-107: ACPI Power Management on ARM64 Servers (v2)HKG15-107: ACPI Power Management on ARM64 Servers (v2)
HKG15-107: ACPI Power Management on ARM64 Servers (v2)Linaro
Ā 
Virtualization Support in ARMv8+
Virtualization Support in ARMv8+Virtualization Support in ARMv8+
Virtualization Support in ARMv8+Aananth C N
Ā 
twlkh-linux-vsyscall-and-vdso
twlkh-linux-vsyscall-and-vdsotwlkh-linux-vsyscall-and-vdso
twlkh-linux-vsyscall-and-vdsoViller Hsiao
Ā 

What's hot (20)

Power Management from Linux Kernel to Android
Power Management from Linux Kernel to AndroidPower Management from Linux Kernel to Android
Power Management from Linux Kernel to Android
Ā 
HKG15-505: Power Management interactions with OP-TEE and Trusted Firmware
HKG15-505: Power Management interactions with OP-TEE and Trusted FirmwareHKG15-505: Power Management interactions with OP-TEE and Trusted Firmware
HKG15-505: Power Management interactions with OP-TEE and Trusted Firmware
Ā 
linux device driver
linux device driverlinux device driver
linux device driver
Ā 
Qemu Introduction
Qemu IntroductionQemu Introduction
Qemu Introduction
Ā 
malloc & vmalloc in Linux
malloc & vmalloc in Linuxmalloc & vmalloc in Linux
malloc & vmalloc in Linux
Ā 
SFO15-302: Energy Aware Scheduling: Progress Update
SFO15-302: Energy Aware Scheduling: Progress UpdateSFO15-302: Energy Aware Scheduling: Progress Update
SFO15-302: Energy Aware Scheduling: Progress Update
Ā 
Reducing the boot time of Linux devices
Reducing the boot time of Linux devicesReducing the boot time of Linux devices
Reducing the boot time of Linux devices
Ā 
Reconnaissance of Virtio: Whatā€™s new and how itā€™s all connected?
Reconnaissance of Virtio: Whatā€™s new and how itā€™s all connected?Reconnaissance of Virtio: Whatā€™s new and how itā€™s all connected?
Reconnaissance of Virtio: Whatā€™s new and how itā€™s all connected?
Ā 
Continguous Memory Allocator in the Linux Kernel
Continguous Memory Allocator in the Linux KernelContinguous Memory Allocator in the Linux Kernel
Continguous Memory Allocator in the Linux Kernel
Ā 
Embedded Linux Kernel - Build your custom kernel
Embedded Linux Kernel - Build your custom kernelEmbedded Linux Kernel - Build your custom kernel
Embedded Linux Kernel - Build your custom kernel
Ā 
Making Linux do Hard Real-time
Making Linux do Hard Real-timeMaking Linux do Hard Real-time
Making Linux do Hard Real-time
Ā 
Linux Internals - Interview essentials 4.0
Linux Internals - Interview essentials 4.0Linux Internals - Interview essentials 4.0
Linux Internals - Interview essentials 4.0
Ā 
Basic Linux Internals
Basic Linux InternalsBasic Linux Internals
Basic Linux Internals
Ā 
HKG15-107: ACPI Power Management on ARM64 Servers (v2)
HKG15-107: ACPI Power Management on ARM64 Servers (v2)HKG15-107: ACPI Power Management on ARM64 Servers (v2)
HKG15-107: ACPI Power Management on ARM64 Servers (v2)
Ā 
Virtualization Support in ARMv8+
Virtualization Support in ARMv8+Virtualization Support in ARMv8+
Virtualization Support in ARMv8+
Ā 
Linux Kernel Overview
Linux Kernel OverviewLinux Kernel Overview
Linux Kernel Overview
Ā 
Overlayfs and VFS
Overlayfs and VFSOverlayfs and VFS
Overlayfs and VFS
Ā 
twlkh-linux-vsyscall-and-vdso
twlkh-linux-vsyscall-and-vdsotwlkh-linux-vsyscall-and-vdso
twlkh-linux-vsyscall-and-vdso
Ā 
Embedded Linux on ARM
Embedded Linux on ARMEmbedded Linux on ARM
Embedded Linux on ARM
Ā 
Qemu Pcie
Qemu PcieQemu Pcie
Qemu Pcie
Ā 

Similar to Linux Power Management: Are You Doing It Right

Optimizing Linux Servers
Optimizing Linux ServersOptimizing Linux Servers
Optimizing Linux ServersDavor Guttierrez
Ā 
Your Linux AMI: Optimization and Performance (CPN302) | AWS re:Invent 2013
Your Linux AMI: Optimization and Performance (CPN302) | AWS re:Invent 2013Your Linux AMI: Optimization and Performance (CPN302) | AWS re:Invent 2013
Your Linux AMI: Optimization and Performance (CPN302) | AWS re:Invent 2013Amazon Web Services
Ā 
Ch4 memory management
Ch4 memory managementCh4 memory management
Ch4 memory managementBullz Musetsho
Ā 
Insider operating system
Insider   operating systemInsider   operating system
Insider operating systemAditi Saxena
Ā 
Computer system architecture
Computer system architectureComputer system architecture
Computer system architecturejeetesh036
Ā 
Module 1 Introduction.ppt
Module 1 Introduction.pptModule 1 Introduction.ppt
Module 1 Introduction.pptshreesha16
Ā 
linux monitoring and performance tunning
linux monitoring and performance tunning linux monitoring and performance tunning
linux monitoring and performance tunning iman darabi
Ā 
Session 7362 Handout 427 0
Session 7362 Handout 427 0Session 7362 Handout 427 0
Session 7362 Handout 427 0jln1028
Ā 
Virtualization Basics
Virtualization BasicsVirtualization Basics
Virtualization BasicsSrikantMishra12
Ā 
MK Sistem Operasi.pdf
MK Sistem Operasi.pdfMK Sistem Operasi.pdf
MK Sistem Operasi.pdfwisard1
Ā 
Introduction to Operating Systems.pdf
Introduction to Operating Systems.pdfIntroduction to Operating Systems.pdf
Introduction to Operating Systems.pdfHarika Pudugosula
Ā 
Basics of micro controllers for biginners
Basics of  micro controllers for biginnersBasics of  micro controllers for biginners
Basics of micro controllers for biginnersGerwin Makanyanga
Ā 
UNIT 3 - General Purpose Processors
UNIT 3 - General Purpose ProcessorsUNIT 3 - General Purpose Processors
UNIT 3 - General Purpose ProcessorsButtaRajasekhar2
Ā 
Considerations when implementing_ha_in_dmf
Considerations when implementing_ha_in_dmfConsiderations when implementing_ha_in_dmf
Considerations when implementing_ha_in_dmfhik_lhz
Ā 
Operating System Unit 1
Operating System Unit 1Operating System Unit 1
Operating System Unit 1SanthiNivas
Ā 
Engg-0505-IT-Operating-Systems-2nd-year.pdf
Engg-0505-IT-Operating-Systems-2nd-year.pdfEngg-0505-IT-Operating-Systems-2nd-year.pdf
Engg-0505-IT-Operating-Systems-2nd-year.pdfnikhil287188
Ā 
Ibm spectrum scale fundamentals workshop for americas part 2 IBM Spectrum Sca...
Ibm spectrum scale fundamentals workshop for americas part 2 IBM Spectrum Sca...Ibm spectrum scale fundamentals workshop for americas part 2 IBM Spectrum Sca...
Ibm spectrum scale fundamentals workshop for americas part 2 IBM Spectrum Sca...xKinAnx
Ā 
OS Content.pdf
OS Content.pdfOS Content.pdf
OS Content.pdfVAIBHAVSAHU55
Ā 
(CMP402) Amazon EC2 Instances Deep Dive
(CMP402) Amazon EC2 Instances Deep Dive(CMP402) Amazon EC2 Instances Deep Dive
(CMP402) Amazon EC2 Instances Deep DiveAmazon Web Services
Ā 

Similar to Linux Power Management: Are You Doing It Right (20)

Optimizing Linux Servers
Optimizing Linux ServersOptimizing Linux Servers
Optimizing Linux Servers
Ā 
Your Linux AMI: Optimization and Performance (CPN302) | AWS re:Invent 2013
Your Linux AMI: Optimization and Performance (CPN302) | AWS re:Invent 2013Your Linux AMI: Optimization and Performance (CPN302) | AWS re:Invent 2013
Your Linux AMI: Optimization and Performance (CPN302) | AWS re:Invent 2013
Ā 
Ch4 memory management
Ch4 memory managementCh4 memory management
Ch4 memory management
Ā 
Insider operating system
Insider   operating systemInsider   operating system
Insider operating system
Ā 
Computer system architecture
Computer system architectureComputer system architecture
Computer system architecture
Ā 
Module 1 Introduction.ppt
Module 1 Introduction.pptModule 1 Introduction.ppt
Module 1 Introduction.ppt
Ā 
linux monitoring and performance tunning
linux monitoring and performance tunning linux monitoring and performance tunning
linux monitoring and performance tunning
Ā 
Session 7362 Handout 427 0
Session 7362 Handout 427 0Session 7362 Handout 427 0
Session 7362 Handout 427 0
Ā 
Virtualization Basics
Virtualization BasicsVirtualization Basics
Virtualization Basics
Ā 
MK Sistem Operasi.pdf
MK Sistem Operasi.pdfMK Sistem Operasi.pdf
MK Sistem Operasi.pdf
Ā 
Introduction to Operating Systems.pdf
Introduction to Operating Systems.pdfIntroduction to Operating Systems.pdf
Introduction to Operating Systems.pdf
Ā 
1 introduction
1 introduction1 introduction
1 introduction
Ā 
Basics of micro controllers for biginners
Basics of  micro controllers for biginnersBasics of  micro controllers for biginners
Basics of micro controllers for biginners
Ā 
UNIT 3 - General Purpose Processors
UNIT 3 - General Purpose ProcessorsUNIT 3 - General Purpose Processors
UNIT 3 - General Purpose Processors
Ā 
Considerations when implementing_ha_in_dmf
Considerations when implementing_ha_in_dmfConsiderations when implementing_ha_in_dmf
Considerations when implementing_ha_in_dmf
Ā 
Operating System Unit 1
Operating System Unit 1Operating System Unit 1
Operating System Unit 1
Ā 
Engg-0505-IT-Operating-Systems-2nd-year.pdf
Engg-0505-IT-Operating-Systems-2nd-year.pdfEngg-0505-IT-Operating-Systems-2nd-year.pdf
Engg-0505-IT-Operating-Systems-2nd-year.pdf
Ā 
Ibm spectrum scale fundamentals workshop for americas part 2 IBM Spectrum Sca...
Ibm spectrum scale fundamentals workshop for americas part 2 IBM Spectrum Sca...Ibm spectrum scale fundamentals workshop for americas part 2 IBM Spectrum Sca...
Ibm spectrum scale fundamentals workshop for americas part 2 IBM Spectrum Sca...
Ā 
OS Content.pdf
OS Content.pdfOS Content.pdf
OS Content.pdf
Ā 
(CMP402) Amazon EC2 Instances Deep Dive
(CMP402) Amazon EC2 Instances Deep Dive(CMP402) Amazon EC2 Instances Deep Dive
(CMP402) Amazon EC2 Instances Deep Dive
Ā 

More from Chris Simmonds

Debugging embedded devices using GDB
Debugging embedded devices using GDBDebugging embedded devices using GDB
Debugging embedded devices using GDBChris Simmonds
Ā 
Debian or Yocto Project? Which is the best for your Embedded Linux project?
Debian or Yocto Project? Which is the best for your Embedded Linux project?Debian or Yocto Project? Which is the best for your Embedded Linux project?
Debian or Yocto Project? Which is the best for your Embedded Linux project?Chris Simmonds
Ā 
Embedded Linux Quick Start Guide v1.5
Embedded Linux Quick Start Guide v1.5Embedded Linux Quick Start Guide v1.5
Embedded Linux Quick Start Guide v1.5Chris Simmonds
Ā 
Running Android on the Raspberry Pi: Android Pie meets Raspberry Pi
Running Android on the Raspberry Pi: Android Pie meets Raspberry PiRunning Android on the Raspberry Pi: Android Pie meets Raspberry Pi
Running Android on the Raspberry Pi: Android Pie meets Raspberry PiChris Simmonds
Ā 
Android rpi-csimmonds-fosdem-2019
Android rpi-csimmonds-fosdem-2019Android rpi-csimmonds-fosdem-2019
Android rpi-csimmonds-fosdem-2019Chris Simmonds
Ā 
Reducing boot time in embedded Linux
Reducing boot time in embedded LinuxReducing boot time in embedded Linux
Reducing boot time in embedded LinuxChris Simmonds
Ā 
Embedded Android: Android beyond the smartphone
Embedded Android: Android beyond the smartphoneEmbedded Android: Android beyond the smartphone
Embedded Android: Android beyond the smartphoneChris Simmonds
Ā 
Software update for IoT Embedded World 2017
Software update for IoT Embedded World 2017Software update for IoT Embedded World 2017
Software update for IoT Embedded World 2017Chris Simmonds
Ā 
Quick and Easy Device Drivers for Embedded Linux Using UIO
Quick and Easy Device Drivers for Embedded Linux Using UIOQuick and Easy Device Drivers for Embedded Linux Using UIO
Quick and Easy Device Drivers for Embedded Linux Using UIOChris Simmonds
Ā 
Software update for IoT: the current state of play
Software update for IoT: the current state of playSoftware update for IoT: the current state of play
Software update for IoT: the current state of playChris Simmonds
Ā 
Read-only rootfs: theory and practice
Read-only rootfs: theory and practiceRead-only rootfs: theory and practice
Read-only rootfs: theory and practiceChris Simmonds
Ā 
Android beyond the smartphone
Android beyond the smartphoneAndroid beyond the smartphone
Android beyond the smartphoneChris Simmonds
Ā 
10 ways hardware engineers can make software integration easier
10 ways hardware engineers can make software integration easier10 ways hardware engineers can make software integration easier
10 ways hardware engineers can make software integration easierChris Simmonds
Ā 
Userspace drivers-2016
Userspace drivers-2016Userspace drivers-2016
Userspace drivers-2016Chris Simmonds
Ā 
The end of embedded Linux (as we know it)
The end of embedded Linux (as we know it)The end of embedded Linux (as we know it)
The end of embedded Linux (as we know it)Chris Simmonds
Ā 
Linux field-update-2015
Linux field-update-2015Linux field-update-2015
Linux field-update-2015Chris Simmonds
Ā 
Tuning Android for low RAM
Tuning Android for low RAMTuning Android for low RAM
Tuning Android for low RAMChris Simmonds
Ā 
The Android graphics path, in depth
The Android graphics path, in depthThe Android graphics path, in depth
The Android graphics path, in depthChris Simmonds
Ā 
Booting Android: bootloaders, fastboot and boot images
Booting Android: bootloaders, fastboot and boot imagesBooting Android: bootloaders, fastboot and boot images
Booting Android: bootloaders, fastboot and boot imagesChris Simmonds
Ā 
A timeline for embedded Linux
A timeline for embedded LinuxA timeline for embedded Linux
A timeline for embedded LinuxChris Simmonds
Ā 

More from Chris Simmonds (20)

Debugging embedded devices using GDB
Debugging embedded devices using GDBDebugging embedded devices using GDB
Debugging embedded devices using GDB
Ā 
Debian or Yocto Project? Which is the best for your Embedded Linux project?
Debian or Yocto Project? Which is the best for your Embedded Linux project?Debian or Yocto Project? Which is the best for your Embedded Linux project?
Debian or Yocto Project? Which is the best for your Embedded Linux project?
Ā 
Embedded Linux Quick Start Guide v1.5
Embedded Linux Quick Start Guide v1.5Embedded Linux Quick Start Guide v1.5
Embedded Linux Quick Start Guide v1.5
Ā 
Running Android on the Raspberry Pi: Android Pie meets Raspberry Pi
Running Android on the Raspberry Pi: Android Pie meets Raspberry PiRunning Android on the Raspberry Pi: Android Pie meets Raspberry Pi
Running Android on the Raspberry Pi: Android Pie meets Raspberry Pi
Ā 
Android rpi-csimmonds-fosdem-2019
Android rpi-csimmonds-fosdem-2019Android rpi-csimmonds-fosdem-2019
Android rpi-csimmonds-fosdem-2019
Ā 
Reducing boot time in embedded Linux
Reducing boot time in embedded LinuxReducing boot time in embedded Linux
Reducing boot time in embedded Linux
Ā 
Embedded Android: Android beyond the smartphone
Embedded Android: Android beyond the smartphoneEmbedded Android: Android beyond the smartphone
Embedded Android: Android beyond the smartphone
Ā 
Software update for IoT Embedded World 2017
Software update for IoT Embedded World 2017Software update for IoT Embedded World 2017
Software update for IoT Embedded World 2017
Ā 
Quick and Easy Device Drivers for Embedded Linux Using UIO
Quick and Easy Device Drivers for Embedded Linux Using UIOQuick and Easy Device Drivers for Embedded Linux Using UIO
Quick and Easy Device Drivers for Embedded Linux Using UIO
Ā 
Software update for IoT: the current state of play
Software update for IoT: the current state of playSoftware update for IoT: the current state of play
Software update for IoT: the current state of play
Ā 
Read-only rootfs: theory and practice
Read-only rootfs: theory and practiceRead-only rootfs: theory and practice
Read-only rootfs: theory and practice
Ā 
Android beyond the smartphone
Android beyond the smartphoneAndroid beyond the smartphone
Android beyond the smartphone
Ā 
10 ways hardware engineers can make software integration easier
10 ways hardware engineers can make software integration easier10 ways hardware engineers can make software integration easier
10 ways hardware engineers can make software integration easier
Ā 
Userspace drivers-2016
Userspace drivers-2016Userspace drivers-2016
Userspace drivers-2016
Ā 
The end of embedded Linux (as we know it)
The end of embedded Linux (as we know it)The end of embedded Linux (as we know it)
The end of embedded Linux (as we know it)
Ā 
Linux field-update-2015
Linux field-update-2015Linux field-update-2015
Linux field-update-2015
Ā 
Tuning Android for low RAM
Tuning Android for low RAMTuning Android for low RAM
Tuning Android for low RAM
Ā 
The Android graphics path, in depth
The Android graphics path, in depthThe Android graphics path, in depth
The Android graphics path, in depth
Ā 
Booting Android: bootloaders, fastboot and boot images
Booting Android: bootloaders, fastboot and boot imagesBooting Android: bootloaders, fastboot and boot images
Booting Android: bootloaders, fastboot and boot images
Ā 
A timeline for embedded Linux
A timeline for embedded LinuxA timeline for embedded Linux
A timeline for embedded Linux
Ā 

Recently uploaded

The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
Ā 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
Ā 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
Ā 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
Ā 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
Ā 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
Ā 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
Ā 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
Ā 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
Ā 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
Ā 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
Ā 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
Ā 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
Ā 
Call Girls in Naraina Delhi šŸ’ÆCall Us šŸ”8264348440šŸ”
Call Girls in Naraina Delhi šŸ’ÆCall Us šŸ”8264348440šŸ”Call Girls in Naraina Delhi šŸ’ÆCall Us šŸ”8264348440šŸ”
Call Girls in Naraina Delhi šŸ’ÆCall Us šŸ”8264348440šŸ”soniya singh
Ā 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
Ā 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
Ā 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
Ā 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsMehedi Hasan Shohan
Ā 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
Ā 

Recently uploaded (20)

The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
Ā 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
Ā 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
Ā 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Ā 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Ā 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Ā 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
Ā 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Ā 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
Ā 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
Ā 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
Ā 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
Ā 
Call Girls In Mukherjee Nagar šŸ“± 9999965857 šŸ¤© Delhi šŸ«¦ HOT AND SEXY VVIP šŸŽ SE...
Call Girls In Mukherjee Nagar šŸ“±  9999965857  šŸ¤© Delhi šŸ«¦ HOT AND SEXY VVIP šŸŽ SE...Call Girls In Mukherjee Nagar šŸ“±  9999965857  šŸ¤© Delhi šŸ«¦ HOT AND SEXY VVIP šŸŽ SE...
Call Girls In Mukherjee Nagar šŸ“± 9999965857 šŸ¤© Delhi šŸ«¦ HOT AND SEXY VVIP šŸŽ SE...
Ā 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
Ā 
Call Girls in Naraina Delhi šŸ’ÆCall Us šŸ”8264348440šŸ”
Call Girls in Naraina Delhi šŸ’ÆCall Us šŸ”8264348440šŸ”Call Girls in Naraina Delhi šŸ’ÆCall Us šŸ”8264348440šŸ”
Call Girls in Naraina Delhi šŸ’ÆCall Us šŸ”8264348440šŸ”
Ā 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
Ā 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
Ā 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Ā 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software Solutions
Ā 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
Ā 

Linux Power Management: Are You Doing It Right

  • 1. Linux power management: are you doing it right? Chris Simmonds Embedded World 2018 Linux power management: are you doing it right? 1 Copyright Ā© 2011-2018, 2net Ltd
  • 2. License These slides are available under a Creative Commons Attribution-ShareAlike 3.0 license. You can read the full text of the license here http://creativecommons.org/licenses/by-sa/3.0/legalcode You are free to ā€¢ copy, distribute, display, and perform the work ā€¢ make derivative works ā€¢ make commercial use of the work Under the following conditions ā€¢ Attribution: you must give the original author credit ā€¢ Share Alike: if you alter, transform, or build upon this work, you may distribute the resulting work only under a license identical to this one (i.e. include this page exactly as it is) ā€¢ For any reuse or distribution, you must make clear to others the license terms of this work Linux power management: are you doing it right? 2 Copyright Ā© 2011-2018, 2net Ltd
  • 3. About Chris Simmonds ā€¢ Consultant and trainer ā€¢ Author of Mastering Embedded Linux Programming ā€¢ Working with embedded Linux since 1999 ā€¢ Android since 2009 ā€¢ Speaker at many conferences and workshops "Looking after the Inner Penguin" blog at http://2net.co.uk/ https://uk.linkedin.com/in/chrisdsimmonds/ https://google.com/+chrissimmonds Linux power management: are you doing it right? 3 Copyright Ā© 2011-2018, 2net Ltd
  • 4. Overview ā€¢ Reducing power usage is important, especially for battery-powered devices ā€¢ In this talk I will introduce ā€¢ The rules of power management ā€¢ The major Linux systems that implement power management ā€¢ Some practical measures you can take Linux power management: are you doing it right? 4 Copyright Ā© 2011-2018, 2net Ltd
  • 5. The rules of power management 1. Donā€™t rush if you donā€™t have to 2. Take a break when things are quiet 3. Turn things off when they are not in use 4. Have a snooze when you expect things to be quite for a while Linux power management: are you doing it right? 5 Copyright Ā© 2011-2018, 2net Ltd
  • 6. Rule 1: Donā€™t rush ā€¢ Reducing CPU frequency saves power? ā€¢ P = CfV2 ā€¢ Reducing voltage, not frequency, saves power ā€¢ But, lowering frequency allows for lowering the voltage, and therefore saves power ā€¢ The tuple of frequency and voltage is called an Operating Performance Point (OPP) ā€¢ The ability to change OPP at run-time is called Dynamic Voltage and Frequency Scaling (DVFS) Linux power management: are you doing it right? 6 Copyright Ā© 2011-2018, 2net Ltd
  • 7. OPP deļ¬nitions in device tree Example from am33xx.dtsi cpu0_opp_table: opp-table { compatible = "operating-points-v2-ti-cpu"; syscon = <&scm_conf>; opp50@300000000 { opp-hz = /bits/ 64 <300000000>; opp-microvolt = <950000 931000 969000>; opp-supported-hw = <0x06 0x0010>; opp-suspend; }; opp100@600000000 { opp-hz = /bits/ 64 <600000000>; opp-microvolt = <1100000 1078000 1122000>; opp-supported-hw = <0x06 0x0040>; }; [...] }; Linux power management: are you doing it right? 7 Copyright Ā© 2011-2018, 2net Ltd
  • 8. CPUFreq ā€¢ In Linux, selecting the best OPP is done by the CPUFreq driver ā€¢ Enable with kernel option CONFIG_CPU_FREQ=y ā€¢ Part of the Linux support for each SoC ā€¢ Control is per CPU, via directory /sys/devices/system/cpu/cpuN/cpufreq ā€¢ List of possible frequencies (corresponding to OPPs): # cd /sys/devices/system/cpu/cpu0/cpufreq # cat scaling_available_frequencies 300000 600000 720000 800000 Linux power management: are you doing it right? 8 Copyright Ā© 2011-2018, 2net Ltd
  • 9. CPUFreq Governors ā€¢ The policy for changing the OPP is controlled by a governor ā€¢ There are a small number of governors coded into Linux: # cd /sys/devices/system/cpu/cpu0/cpufreq # cat scaling_available_governors conservative ondemand userspace powersave performance Linux power management: are you doing it right? 9 Copyright Ā© 2011-2018, 2net Ltd
  • 10. Governors ā€¢ powersave: Always selects the lowest frequency ā€¢ performance: Always selects the highest frequency ā€¢ ondemand: Changes frequency based on the CPU utilization. If the CPU is idle less than 20% of the time, it sets the frequency to the maximum; if it is idle more than 30% of the time, it decrements the frequency by 5% ā€¢ conservative: As ondemand , but switches to higher frequencies in 5% steps rather than going immediately to the maximum ā€¢ userspace: Frequency is set by a user space program Linux power management: are you doing it right? 10 Copyright Ā© 2011-2018, 2net Ltd
  • 11. Example of the potential power saving ā€¢ BeagleBone Black running a constant load ā€¢ No governor: using ļ¬xed frequencies OPP Freq MHz CPU use, % Power, mW OPP50 300 94 320 OPP100 600 48 345 OPP120 720 40 370 Turbo 800 34 370 Nitro 1000 28 370 15% saving by running the job at 300 MHz instead of 1 GHz Linux power management: are you doing it right? 11 Copyright Ā© 2011-2018, 2net Ltd
  • 12. Rule 2: take a break ā€¢ When the CPU has nothing to do, it enters an idle state ā€¢ Usually, there are several idle states to choose from ā€¢ Sometimes known as C-states ā€¢ Deeper idle states take longer to return to full operation ā€¢ Example: the CPU L1 cache may be powered down, so it takes time to re-load the cache when restarting Linux power management: are you doing it right? 12 Copyright Ā© 2011-2018, 2net Ltd
  • 13. CPUIdle ā€¢ In Linux, the transition between idle states is controlled by the CPUIdle driver ā€¢ Enable with kernel option CONFIG_CPU_IDLE ā€¢ Information about idle state C for CPU N is in /sys/devices/system/cpu/cpuN/cpuidle/stateC ā€¢ For example the TI AM335x SoC has only two states ā€¢ State0: WFI (Wait For Interrupt) ā€¢ State1: C1 Linux power management: are you doing it right? 13 Copyright Ā© 2011-2018, 2net Ltd
  • 14. CPUIdle governors ā€¢ The policy for selecting idle states is controlled by the CPUIdle governor ā€¢ Cannot be changed at run-time ā€¢ Only two options ā€¢ ladder: steps through the idle states one at a time depending on the time spent in the last idle period. Works well with a regular timer tick ā€¢ menu: selects an idle state based on the expected idle time. Works well with tickless systems Linux power management: are you doing it right? 14 Copyright Ā© 2011-2018, 2net Ltd
  • 15. Tickless operation ā€¢ Linux was written assuming a constant tick, typically 100Hz ā€¢ On an idle system, this is a waste of CPU power; stops the CU entering deeper sleep states ā€¢ For tickless operation, conļ¬gure your kernel with CONFIG_NO_HZ_IDLE=y (on older kernels, CONFIG_NO_HZ=y) ā€¢ Schedules timer interrupts for the next event, skipping any intermediate ticks ā€¢ Potential power saving on a device that is mostly idle: up to 70% Linux power management: are you doing it right? 15 Copyright Ā© 2011-2018, 2net Ltd
  • 16. Rule 3: turn things off ā€¢ Managing the power usage of peripherals is also important ā€¢ In Linux, the runtime power management (pm runtime) tracks the state of pm-aware device drivers ā€¢ Each device driver can register callback functions such as runtime_suspend and runtime_resume ā€¢ Kernel conļ¬guration option CONFIG_PM Linux power management: are you doing it right? 16 Copyright Ā© 2011-2018, 2net Ltd
  • 17. Controlling pm runtime ā€¢ PM runtime is exposed via directory power for each device that supports it ā€¢ Files in that directory include: ā€¢ control: "auto": kernel will select state; "on": device always on (pm runtime disabled) ā€¢ runtime_status: current state of the device: "active", "suspended", or "unsupported" ā€¢ autosuspend_delay_ms: minimum time before suspending device Linux power management: are you doing it right? 17 Copyright Ā© 2011-2018, 2net Ltd
  • 18. Runtime PM ā€¢ For example, the MMC controller on TI AM335x # cd /sys/devices/platform/ocp/481d8000.mmc/mmc_host/mmc1/mmc1:0001/power # grep "" * async:disabled autosuspend_delay_ms:3000 control:auto runtime_active_kids:0 runtime_active_time:164440 runtime_enabled:enabled runtime_status:suspended runtime_suspended_time:139270 runtime_usage:0 ā€¢ Note that autosuspend_delay_ms is 3 seconds ā€¢ That runtime_status is "suspended" Linux power management: are you doing it right? 18 Copyright Ā© 2011-2018, 2net Ltd
  • 19. Rule 4: Have a snooze ā€¢ The techniques so far will optimize power usage of a running system ā€¢ Largest power saving comes from entering a system sleep mode ā€¢ Example: when closing the lid of a laptop ā€¢ Example: Android device suspending after activity timeout (default 60 seconds) Linux power management: are you doing it right? 19 Copyright Ā© 2011-2018, 2net Ltd
  • 20. Power states Sleep state S-state Description freeze Stops (freezes) all activity in user space standby S1 Powers down all CPUs except the boot CPU mem S3 Powers down the system, puts RAM into self-refresh disk S4 Saves memory to disk, followed by complete power down Linux sleep states, together with equivalent ACPI S-state ā€¢ mem (suspend to RAM) typically consumes a few milliamps (dependent on board design and BSP) ā€¢ disk (suspend to disk) typically consumes no power at all Linux power management: are you doing it right? 20 Copyright Ā© 2011-2018, 2net Ltd
  • 21. Controlling power state ā€¢ In Linux, macro power management is via by the power management subsystem ā€¢ Enable with kernel option CONFIG_PM ā€¢ You can view the sleep states implemented in BSP via /sys/power/state # cat /sys/power/state freeze standby mem disk ā€¢ mem is the one most often used in embedded systems ā€¢ disk (aka hibernation) is usually too slow and takes too much storage when using ļ¬‚ash memory Linux power management: are you doing it right? 21 Copyright Ā© 2011-2018, 2net Ltd
  • 22. Changing power state ā€¢ Simply, write the desired state to /sys/power/state ā€¢ For example, to enter suspend mode: # echo mem > /sys/power/state [ 1646.158274] PM: Syncing filesystems ...done. [ 1646.178387] Freezing user space processes ...(elapsed 0.001 seconds) done. [ 1646.188098] Freezing remaining freezable tasks ... (elapsed 0.001 seconds) done. [ 1646.197017] Suspending console(s) (use no_console_suspend to debug) [ 1646.338657] PM: suspend of devices complete after 134.322 msecs [ 1646.343428] PM: late suspend of devices Linux power management: are you doing it right? 22 Copyright Ā© 2011-2018, 2net Ltd
  • 23. Waking up ā€¢ CPU is woken by interrupt or other input ā€¢ Wakeup sources need to be powered while the main CPU is powered down ā€¢ Wakeup sources may include ā€¢ Real-time clock (RTC) ā€¢ Certain GPIO pins ā€¢ UART ā€¢ Usually managed by a dedicated Power Management chip, PMIC Linux power management: are you doing it right? 23 Copyright Ā© 2011-2018, 2net Ltd
  • 24. Wakeup sources ā€¢ Devices that can act as wakeup sources have /sys/devices/.../power/wakeup set to "enabled" ā€¢ For example, GPIOs 0 to 7 on AM335x # cat /sys/devices/platform/gpio_keys/power/wakeup enabled ā€¢ Hence, pressing the power button wakes the device Linux power management: are you doing it right? 24 Copyright Ā© 2011-2018, 2net Ltd
  • 25. Conclusion ā€¢ A well conļ¬gured Linux device will save power ā€¢ Linux features considered here: ā€¢ CPUFreq: selects OPP depending on load ā€¢ CPUIdle: selects idle state based on predicted load ā€¢ Tickless: eliminates unnecessary timer interrupts ā€¢ Runtime power management: powers off unused peripherals ā€¢ Suspend to RAM: puts system in minimum power usage state Linux power management: are you doing it right? 25 Copyright Ā© 2011-2018, 2net Ltd
  • 26. Questions? Further reading: Chapter 11 of Mastering Embedded Linux Programming Contact: Web: www.2net.co.uk Email: training@2net.co.uk LinkedIn: https://uk.linkedin.com/in/chrisdsimmonds Linux power management: are you doing it right? 26 Copyright Ā© 2011-2018, 2net Ltd