Power Management in Tizen and Linux Kernel (Tizen 2.3)
Minsoo Ryu
Real-Time Computing and Communications Lab. Hanyang University
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr Outline
Introduction ACPI (Advanced Configuration Power Interface) DVFS (Dynamic Voltage Frequency Scaling) Power Management in Tizen Lab Assignment
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 22 Why Power Management?
Battery-operated devices . Smartphones, digital cameras, and laptops use batteries . Power savings and battery run times are paramount
Increasing energy use of servers . Servers and data centers in U.S. reached 1.5% of the national electricity consumption in 2006 . The electricity consumption of servers doubled between 2000 and 2006
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 33 Power Consumption in Smartphones
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 44 Power Consumption of Memory
In a server system . Memory consumes 19% of system power on average . Some work notes up to 40% of total system power
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 55 Idle Power Consumption
Only 30% of servers in data centers are fully utilized while keeping the other 70% in idle state . Idle servers consume between 60% and 66% of the peak load power consumption
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 66 Two Dimensions of Power Management
Power management when the system is idle . Select the most efficient idle state
Power management when the system is active . Dynamically change operating frequency and/or voltage
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 77 ACPI (Advanced Configuration Power Interface)
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 88 APM and ACPI
APM (Advanced Power Management) . Activated when system becomes idle • e.g.) screen saver => sleep => suspend . Controlled by firmware (BIOS) • need reboot for reconfiguration . OS has no knowledge
ACPI (Advanced Config. and Power Interfaces) . Controlled by OS . First released in 1996 by Compaq/HP, Intel, Microsoft, …
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 99 ACPI
Standard interface specification . Brings power management under the control of the operating system . The specification is central to Operating System-directed configuration and Power Management (OSPM)
Applications
OS Power Management ACPI Software drivers Hardware: CPU, BIOS etc.
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 1010 ACPI Functions
System power management . The entire computer
Processor power management . When OS is idle but not sleeping, it puts processors in low- power states
Device power management . ACPI tables describe motherboard devices, their power states, the power planes the devices are connected to
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 1111 Firmware-Level ACPI Architecture
Three components . ACPI tables • Contain definition blocks that describe all the hardware that can be managed through ACPI • Include both data and machine-independent byte-code • OS must have an interpreter for the AML bytecode . ACPI BIOS • Performs basic management operations on the hardware • Include code to help boot the system and to put the system to sleep or wake it up . ACPI registers • A set of hardware management registers defined by the ACPI specification
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 1212 Firmware-Level ACPI Architecture
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 1313 ACPI States
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 1414 Global States
G0: Working (S0) . Processor power states (C-state): C0, C1, C2, C3
G1: Sleeping (e.g., suspend, hibernate) . Sleep State (S-state): S0, S1, S2, S3, S4
G2: Soft off (S5) . Almost the same as G3 Mechanical Off, except that the power supply unit (PSU) still supplies power at a minimum . Other components may remain powered so the computer can "wake" on input from the keyboard, clock, modem, LAN, or USB device
G3: Mechanical off
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 1515 Processor States (C-state)
Global state is G0 (working) Four processor states . C0: Operating • Performance state (P-State) • P0: highest performance, highest power • P1 ~ Pn: lower performance, lower power . C1: Halt • The processor is not executing instructions, but can return to an executing state essentially instantaneously . C2: Stop-Clock (optional) • The processor maintains all software-visible state, but may take longer to wake up . C3: Sleep (optional) • The processor does not need to keep its cache coherent, but maintains other state
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 1616 Performance States (P-State)
Intel Pentium M at 1.6 GHz
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 1717 Device States (D-State)
The device states D0–D3 are device-dependent . D0: Fully On • The operating state . D1 and D2 • Intermediate power-states whose definition varies by device . D3: Off • The device is powered off and unresponsive to its bus • D3 Hot: Aux power is provided • D3 Cold: No power provided
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 1818 Sleeping States (S-State)
Four sleeping states . S1: Power on Suspend (POS) • All the processor caches are flushed • The power to the CPU(s) and RAM is maintained • Wakeup takes about 1 ~ 2 seconds on desktops . S2: CPU powered off • Dirty cache is flushed to RAM (Often not used) . S3: Suspend to RAM (STR), or Standby, Sleep • RAM remains powered • Wakeup takes about 3 ~ 5 seconds on desktops . S4: Suspend to Disk (STD) or hibernation • All content of the main memory is saved to non-volatile memory such as a hard drive, and is powered down
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 1919 DVFS (Dynamic Voltage Frequency Scaling)
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 2020 Power Consumption in CMOS
Power consumption per every cycle in a digital circuit . C (output capacity) . V (supply voltage) . f (clock frequency)
Energy consumption . E V 2
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 2121 Power Consumption in CMOS
Relationship between V and f . V f . Lowering the supply voltage increases the circuit delay . The clock frequency must be reduced accordingly
Observations . Execution times scale linearly to the supply voltage . The energy consumption scales quadratically to the supply voltage
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 2222 Dynamic Voltage Frequency Scaling
Voltage scheduling graph by Pering, et al. . {S, C, D} = {start time, execution time, deadline} . {E} = energy
Optimal speed settings . Sum-of-squares optimization . Given the constraint
• fi k 2 . fi is minimized when
• f1 f2 ... fn
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 2323 Four Considerations for DVFS
Workload amount . Adjust the processor frequency depending on the load
Workload characteristics . Compute-intensive vs. memory-intensive
Deadline constraints . Lowest possible frequency for meeting deadlines
Load balancing . Migrate or scale?
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 2424 Workload Amount and DVFS
Static approaches . Performance policy • CPU runs at the maximum frequency regardless of load . Power save policy • CPU runs at the minimum frequency regardless of load
Dynamic approaches . On demand policy • Increase the clock speed to the maximum frequency when the system load goes above the predefined threshold • Decrease the clock speed gradually when the system load becomes below the predefined threshold . Conservative policy • Gracefully increase the CPU speed rather than jumping to the maximum speed
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 2525 Workload Characteristics and DVFS
Two types of workload . Compute-intensive • The program execution is exclusively bound to the processor . Memory-intensive • The program makes heavy access to memory • The processor would spend a significant fraction of the time waiting for memory
A simple solution . High processor frequency and low memory frequency for compute-intensive load . Low processor frequency and high memory frequency for memory-intensive load
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 2626 CPU- vs. Memory-Intensive
Execution time variation . CPU frequency ranging from 733 MHz to 333 MHz
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 2727 GPU- and Memory-Intensive
Compute-intensive applications . Dense matrix multiplication . Run on NVIDIA GeForce GTX 280 GPU
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 2828 GPU- and Memory-Intensive
Memory-intensive applications . Dense matrix transpose . Run on NVIDIA GeForce GTX 280 GPU
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 2929 Deadline Constraints and DVFS
The CPU runs at “just-enough” speed to meet deadline constraints
max max freq. freq. min min freq. freq.
arrival deadline time arrival deadline time
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 3030 Load Balancing and DVFS
DVFS can be independently applied to each processor on multicore hardware . But this may not lead to optimal power saving from a global point of view
A simple scenario . We need to decide whether to transfer a thread from processor A to an idle processor B, or increase the frequency of A
. Compute Pmigrate_from_A_to_B and Pincrease_A_freq
. Transfer if Pmigrate_from_A_to_B < Pincrease_A_freq . Otherwise, increase the frequency of A
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 3131 DVFS Overhead (Intel Core2 Duo E6850)
uc (underclocking) ir (inductor loss) Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 3232 DVFS Overhead (Exynos 4210)
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 3333 POWER MANAGEMENT IN TIZEN V2.3
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 3434 Overview of Tizen’s Power Management (Tizen 2.3)
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 3535 Power Management in Tizen 2.3
User space applications can request a specific power state to Power Manager
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 3636 Power Manager
Power manager controls LCD and system operation state which are relevant with power according to configurations
There are 5 power states in power manager . START . NORMAL . LCDDIM . LCDOFF . SLEEP
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 3737 Power Manager
Transition procedure is done as follow steps 1. Call check 2. Transition 3. Call enter action function
In the call check phase, check transition to next state is possible
If it is possible, change the current state to the next state according to transition table and do the entering action
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 3838 Power Manager
The states are changed by input or timeout event as shown in previous diagram
Transition table indicates next states
State Timeout Input START START START NORMAL LCDDIM NORMAL LCDDIM LCDOFF NORMAL LCDOFF SLEEP NORMAL SLEEP LCDOFF NORMAL
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 3939 Power Manager
In each state’s action function, it does corresponding operation . NORMAL: backlight on and restore the previous brightness . LCDDIM: dim the brightness . LCDOFF: turn off the backlight . SLEEP: set system mode to suspend
Power manager changes not only backlight state but system operation state properly (i.e. suspend, pre_suspend, post_resume)
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 4040 Sleep State: Suspend-to-RAM
Suspend-to-RAM 1. Sync File system / Freeze user processes 2. Suspend devices 3. Stop IRQ 4. Suspend system core 5. Configure sleep / Save PC
Waking-up 1. Wakeup Interrupt 2. CPU boot-up / load bootloader 3. Bootloader Restore PC 4. Conduct operations in reverse order of Suspend-to-RAM
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 4141 Sleep State: Suspend-to-RAM
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 4242 Power Management in the Linux Kernel
Tizen is based on Linux kernel . The linux power management techniques are applied . Idle state • ACPI – sleeping states . Active state • CPUfreq, Devfreq • DVFS governor
Tizen kernel can also be modified & ported to device separately
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 4343 Power Management in the Linux Kernel
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 4444 LAB 2: IMPLEMENTING AN ADDITIONAL POWER STATE IN TIZEN
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 4545 Lab Assignment
Implement an additional power state, SEMIDIM, in power manager . SEMIDIM state is an intermediate state between NORMAL and LCDDIM . SEMIDIM state sets the backlight brighter than LCDDIM • Half of NORMAL brightness . SEMIDIM state lasts for the same time duration as LCDDIM
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 4646 Lab Assignment
Notification from Launcher UI Timeout event Input device event Kernel / HW START
NORMAL
SEMIDIM
SLEEP
LCD_DIM
LCD_OFF
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 4747 Lab Assignment
Notification from Launcher UI Timeout event Input device event Kernel / HW START
NORMAL
SEMIDIM
The new part to be implementedSLEEP
LCD_DIM
LCD_OFF
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 4848 Lab Assignment
State transition table with SEMIDIM
State Timeout Input NORMAL SEMIDIM NORMAL SEMIDIM LCDDIM NORMAL LCDDIM LCDOFF NORMAL LCDOFF SLEEP NORMAL
Other states are not changed except NORMAL state’s timeout transition
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 4949 Power Manager
In Tizen 2.3, power manager is integrated in display control . Power manager code is in the display component of deviced . framework/system/deviced/display
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 5050 Power Manager
Get source code
Change the branch to Tizen version 2.3
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 5151 Power Manager
The main code is core.c
It includes the definition of power states and power management operations
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 5252 Power Manager
In display_init(), the power manager is initiated with backlight and power operations
Register setting callback
Set the timeout duration
Initiate polling function
dbus for api
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 5353 Power Manager
Each state has 3 functions for transition . int (*trans) (int evt): transition function . int (*action) (int timeout): enter action . int (*check) (int next): transition check function
In the trans function, the check and action functions are called as subroutines
All the states have the same default functions . default_trans(), default_action(), default_check()
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 5454 Power Manager
State transition triggered
default_trans()
default_check() Check the next state is available default_action() Do the corresponding actions of the changed state
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 5555 Power Manager
In default_action(), the backlight and system power states are changed as the current state
Backlight operations are called to change backlight brightness . S_NORMAL calls update() to light up the display . S_LCDDIM calls dim() to make the display dim
The proper operation for SEMIDIM state should be implemented
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 5656 Power Manager
Timeout value for S_NORMAL and S_LCDDIM is determined by entire LCD on duration . S_NORMAL
. S_LCDDIM
SEMIDIM state last same time with LCDDIM, and entire LCD on time should be properly distributed
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 5757 Power Manager
By the key-filter, the inputs are ignored if the LCD is off state
Therefore, S_SEMIDIM also should be included in LCD on state
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr 5858