Connected Tizen: Bringing Tizen to Your Connected Devices Using the Yocto Project
4.Tizen Power Management (Tizen 2.3)Tizen_2... · Power Management in Tizen and Linux Kernel (Tizen...
Transcript of 4.Tizen Power Management (Tizen 2.3)Tizen_2... · Power Management in Tizen and Linux Kernel (Tizen...
Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
Power Management in Tizenand Linux Kernel (Tizen 2.3)
Minsoo Ryu
Real-Time Computing and Communications Lab.Hanyang University
2Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 2Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
Outline
Introduction ACPI (Advanced Configuration Power Interface) DVFS (Dynamic Voltage Frequency Scaling) Power Management in Tizen Lab Assignment
3Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 3Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
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
4Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 4Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
Power Consumption in Smartphones
5Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 5Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
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
6Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 6Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
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
7Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 7Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
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
8Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 8Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
ACPI(Advanced Configuration Power Interface)
9Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 9Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
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, …
10Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 10Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
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)
OS Power Management
Hardware: CPU, BIOS etc.
Software driversACPI
Applications
11Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 11Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
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
12Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 12Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
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
13Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 13Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
Firmware-Level ACPI Architecture
14Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 14Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
ACPI States
15Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 15Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
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
16Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 16Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
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
17Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 17Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
Performance States (P-State)
Intel Pentium M at 1.6 GHz
18Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 18Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
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
19Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 19Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
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
20Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 20Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
DVFS(Dynamic Voltage Frequency Scaling)
21Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 21Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
Power Consumption in CMOS
Power consumption per every cycle in a digital circuit C (output capacity) V (supply voltage) f (clock frequency)
Energy consumption 2VE
22Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 22Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
Power Consumption in CMOS
Relationship between V and 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
fV
23Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 23Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
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
• is minimized when
•
kfi
2if
nfff ...21
24Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 24Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
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?
25Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 25Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
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
26Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 26Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
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
27Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 27Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
CPU- vs. Memory-Intensive
Execution time variation CPU frequency ranging from 733 MHz to 333 MHz
28Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 28Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
GPU- and Memory-Intensive
Compute-intensive applications Dense matrix multiplication Run on NVIDIA GeForce GTX 280 GPU
29Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 29Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
GPU- and Memory-Intensive
Memory-intensive applications Dense matrix transpose Run on NVIDIA GeForce GTX 280 GPU
30Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 30Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
Deadline Constraints and DVFS
The CPU runs at “just-enough” speed to meet deadline constraints
timedeadlinearrival
maxfreq.
timedeadlinearrival
maxfreq.
minfreq.
minfreq.
31Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 31Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
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
32Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 32Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
DVFS Overhead (Intel Core2 Duo E6850)
uc (underclocking) ir (inductor loss)
33Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 33Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
DVFS Overhead (Exynos 4210)
34Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 34Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
POWER MANAGEMENT IN TIZEN V2.3
35Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 35Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
Overview of Tizen’s Power Management(Tizen 2.3)
36Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 36Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
Power Management in Tizen 2.3
User space applications can request a specific power state to Power Manager
37Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 37Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
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
38Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 38Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
Power Manager
Transition procedure is done as follow steps1. Call check2. Transition3. 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
39Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 39Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
Power Manager
The states are changed by input or timeout event as shown in previous diagram
Transition table indicates next states
State Timeout InputSTART START START
NORMAL LCDDIM NORMALLCDDIM LCDOFF NORMALLCDOFF SLEEP NORMALSLEEP LCDOFF NORMAL
40Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 40Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
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)
41Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 41Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
Sleep State: Suspend-to-RAM
Suspend-to-RAM1. Sync File system / Freeze user processes2. Suspend devices3. Stop IRQ4. Suspend system core5. Configure sleep / Save PC
Waking-up1. Wakeup Interrupt2. CPU boot-up / load bootloader3. Bootloader Restore PC4. Conduct operations in reverse order of Suspend-to-RAM
42Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 42Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
Sleep State: Suspend-to-RAM
43Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 43Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
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
44Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 44Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
Power Management in the Linux Kernel
45Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 45Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
LAB 2: IMPLEMENTING AN ADDITIONAL POWER STATE IN
TIZEN
46Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 46Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
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
47Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 47Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
Lab Assignment
START
NORMAL
LCD_DIM
LCD_OFF
SLEEP
SEMIDIM
Notification from Launcher UITimeout eventInput device eventKernel / HW
48Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 48Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
Lab Assignment
START
NORMAL
LCD_DIM
LCD_OFF
SLEEP
SEMIDIM
Notification from Launcher UITimeout eventInput device eventKernel / HW
The new part to be implemented
49Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 49Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
Lab Assignment
State transition table with SEMIDIM
Other states are not changed except NORMAL state’s timeout transition
State Timeout InputNORMAL SEMIDIM NORMALSEMIDIM LCDDIM NORMALLCDDIM LCDOFF NORMALLCDOFF SLEEP NORMAL
50Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 50Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
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
51Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 51Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
Power Manager
Get source code
Change the branch to Tizen version 2.3
52Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 52Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
Power Manager
The main code is core.c
It includes the definition of power states and power management operations
53Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 53Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
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
54Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 54Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
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()
55Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 55Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
Power Manager
State transitiontriggered
default_trans()
default_check()
default_action()
Check the next stateis available
Do the correspondingactions of the changed state
56Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 56Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
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
57Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 57Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
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
58Real-Time Computing and Communications Lab., Hanyang University
http://rtcc.hanyang.ac.kr 58Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr
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