View
2.096
Download
0
Category
Preview:
Citation preview
IntroductiontoKernelPowerManagement
KevinHilman,Linarokhilman@kernel.org
KernelRecipes2015,Paris
Idle 1
µC
CPUL2$
GPU DSPCPUL2$
Memory
DynamicPM-basedon"activity"-ActivePMSavepowerwhendoing "something "
-IdlePMSavepowerwhendoing "nothing "
Static
Complexityisgrowing...-moreCPUs-moreintegrateddevices-morepowerdomains-microcontrollers-firmware,etc.
Kernel�is�evolving....
StaticPM,SystemPM-traditionalsuspend/resumeCONFIG_PM_SLEEP=y-systemwide,alldevices-initiatedbyuserspace-anydevicecanpreventsuspend
-userspaceis"frozen"(c.f.Documentation/power/freezing-of-tasks.txt)
MUSTRead:Documentation/power/devices.txt
2
µC
IntroductiontoKernel
PowerManagement
KevinHilman,L inaro
khilman@kernel.org
Ker nel Recipes 2015, Par is
CPUL2$
GPU DSPCPUL2$
Memory
Phew...
thatwasalljustabaddream
AnyQuestions?
DynamicPM- bas ed on "act i vi t y"- Act i ve PM Save power when doi ng "s om et hi ng"
- I dl e PM Save power when doi ng "not hi ng"
structdev_pm_opsExistsinstructd evice_ d river, structb us_ typ e, . . .
structdev_pm_ops{int(*prepare)(structdevice*dev);void(*complete)(structdevice*dev);int(*suspend)(structdevice*dev);int(*resume)(structdevice*dev);...int(*suspend_late)(structdevice*dev);int(*resume_early)(structdevice*dev);...};
->begin()
->prepare()
->enter()
->wake()
->finish()
->end()
echomem>/sys/power/state
->prepare()
->suspend()
->suspend_late()
->suspend_noirq()
->resume_noirq()
->resume_early()
->resume()
->complete()
Pla tfo rmspec i fic : structplatform_suspend_ops
Per-devic e :structdev_pm_ops
pm_wakeup_event()
WakeupfromSuspendSub system/Drivercontrol:-device_init_wakeup(dev,bool)-dev_pm_set_wake_irq()-dev_pm_clear_wake_irq()
Whenwak eup occurs(e.g. inISR):-pm_wakeup_event()
Enab le/d isab lefromusersp ace:-/sys/devices/.../power/wakeup
ActivePM:UnderlyingFrameworks
Frequenc ysc a l ing :c loc k framework-clk_get_rate()-clk_set_rate()
Vo l tage sc a l ing :regu la to rframework-regulator_get_voltage()-regulator_set_voltage()-Documentation/power/regulator/consumer.txt
Examp le.. . drivers/cpufreq/cpufreq-dt.c
OperatingPerformancePointsOPPs
-tup leoffreq uency,minimumvoltage-Describ ed inDTcpu0:cpu@0{operating-points=</*kHzuV*/30000010250006000001200000800000131300010080001375000>;}
c.f.Documentation/power/opp.txt
CPUDVFS usingCPUFreq
-S elect"b est"OPPb ased onreq uirements
-p luggab legovernorsforselecting"b est"OPP-p erformance,p owersave, . . . -ond emand :h eursiticsb ased onload ,tunab le- interactive:ond emand ++,tuned forlatency
Documentation/cpu-freq/core.txt
. . . wh atab outd eviceDVFS?. . . . d evfreq
IdlePM:ticklessidle
CONFIG_NOHZ_IDLE=y
-stop p eriod ictick wh enid le-onlywak esfornext"event"orinterrup t
IdleforCPUs
CPUid lestatesh ave"d ep th "-morep owersavings- longerwak eup latency
S tateDefinitionsinDT-legacy:p latform-sp ecificd river
S tateentry-p latform-sp ecifich ook s-b ased oncompatiblestring
Idlefordevices:RuntimePM
-p er-d eviceid le-singled eviceatatime-id lenesscontrolled b yd river, b ased onactivity
-d evicesare ind epend ent-oned evicecannotp reventoth ersfromruntimesusp end ing
-d oesNOTaffectusersp ace
Don' twak eup .. .onlytop resssnoozeand gob ack tosleep
CPUid le :Howdeepto sleep?
drivers/cpuidle/governors/menu.c1)Break even po in t(basedon en te r/exi t times)- looks at pr edict able event s ( e. g. t im er s)- compar es against m in r esidency
2)La tenc yto le ranc e - checks Q oS (PM_QOS_CPU_DMA_LATENCY)- compar es against m in r esidency
3) Perfo rmanc e Impac t:- black m agic "m ult iplier " based on load- f avor shallower st at es under heavy load
Limitations:-notverySMPormulti-clusteraware
i d l e - s t a t e s {
C P U _ S T B Y : s t a n d b y {
c o m p a t i b l e = " q c o m , i d l e - s t a t e - s t b y " ,
" a r m , i d l e - s t a t e " ;
e n t r y - l a t e n c y - u s = < 1 > ;
e x i t - l a t e n c y - u s = < 1 > ;
m i n - r e s i d e n c y - u s = < 2 > ;
} ;
C P U _ S P C : s p c {
c o m p a t i b l e = " q c o m , i d l e - s t a t e - s p c " ,
" a r m , i d l e - s t a t e " ;
e n t r y - l a t e n c y - u s = < 1 5 0 > ;
e x i t - l a t e n c y - u s = < 2 0 0 > ;
m i n - r e s i d e n c y - u s = < 2 0 0 0 > ;
} ;
} ;
c p u @ 0 {
[ . . . ]
c p u - i d l e - s t a t e s = < & C P U _ S T B Y & C P U _ S P C > ;
} ;
D o c u m e n t a t i o n / d e v i c e t r e e / b i n d i n g s / a r m / i d l e - s t a t e s . t x t
structdev_pm_ops{
...
int(*runtime_suspend)(structdevice*dev);
int(*runtime_resume)(structdevice*dev);
int(*runtime_idle)(structdevice*dev);
};
RuntimePMAPI
Te l l PM c o re whe the rdevic e is in use"I'mabou tto u se it" -pm_runtime_get(),_sync() - I ncr em ent use count , pm _r unt im e_r esume( )
"I'mdone .. .f o rn ow"-pm_runtime_put(),_sync()-Decr em ent use count , pm _r unt im e_idle( )Sim ilar t o legacy clock f r am ewor k usage f or clock gat ing-clk_enable(),clk_disable()
Exc e l len t: Documentation/power/pm_runtime.txt
RuntimePM:callbacks
Use c oun t:1 -->0-->runtime_suspend()- pr epar e f or low- power st at e- ensur e wakeups enabled- save cont ext
Use c oun t:0 -->1-->runtime_resume()- r est or e cont ext- et c.
Aut osuspend - - - def er r ed r unt im e suspend- pm_runtime_set_autosuspend_delay()- pm_runtime_mark_last_busy()- pm_runtime_put_autosuspend()
Idlefordevices:Grouping
Devic esa re o ften groupedin to doma ins-powerga tedasa group-c an be nested-powerga ting hasla tenc yimpl ic a tions-e xte rna l regu la to rrampup,e tc .Documentation/power/devices.txt
Static DynamicSuspendResume
ActiveIdle
OPPs
CPUfreqRuntimePM
Wakeups
IdleCPUs Idledevices
CPUidle
PMdomainsNOHZ_IDLE
PMQoS
Clocks Regulators
µC
CPUL2$
GPU DSPCPUL2$
Memory
structdev_pm_domain{
structdev_pm_opsops;
...
};
GenericPMDomains(genpd)
Generic implemen ta tion o fPM domains-Basedon run time PM-When a l l devic esin doma in a re run time suspended...genpd->power_off()-When fi rstdevic e in doma in isrun time resumed...genpd->power_on()
genpdgove rno rs-a l l owc ustomdec ision mak ing be fo re powerga ting -e .g .pe r-devic e QoSc onstra in ts
genpdinDTExample genpd:power:power-controller@12340000{
compatible="foo,power-controller";
reg=<0x123400000x1000>;
#power-domain-cells=<1>;
};
Example use bydevic e :leaky-device@12350000{
compatible="foo,i-leak-current";
reg=<0x123500000x1000>;
power-domains=<&power0>;
};
Fr om : Documentation/devicetree/bindings/power/power-domain.txt
RuntimePM,genpdideas
Uni fy id le fo rCPUsanddevic es
- use r unt im e PM f or CPUs
- use r unt im e PM f or CPU- connect ed " ext r as"
( e. g. G I C, PMUs, VFP, Cor eSight , et c. )
- combine int o a " CPU genpd"
Extendto CPUCluste rs
- m odel clust er s as genpd m ade up of " CPU genpd" s
plus shar ed L2$
- when CPUs in clust er ar e idle ( r unt im e suspended)
clust er genpd can hit low- power st at e ( of f )
NextSteps
Quality:PMQoS
System-wide :e .g PM_QOS_CPU_DMA_LATENCY- Used by CPUidle t o det erm ine dept h of idle st at e
Per-devic e- at t ach Q oS const r aint s wit h specif ic devices- genpd: pr event PM domain power of f - PM_QOS_FLAG_NO_POWER_OFF
- e. g. genpd: per - device wakeup lat ency - DEV_PM_QOS_RESUME_LATENCY - f or use by genpd " gover nor s"
Documentation/power/pm_qos_interface.txt
Energy-awarescheduling:EAS
Anon -go ing e ffo rt to improve ene rgye ffic ienc yo fthe sc hedu le r.
-Teac h the sc hedu le rnewheu ristic sfo rtask p lac ementto
tak e advan tage o fene rgy-saving hardware
-In tegra te CPUid le andCPUfreqwi th the sc hedu le r
-sc hedu le rtrac k sloadsta tistic sfo r i tsown dec ision mak ing
(e .g .task p lac ement, l oadba lanc ing ,e tc .)
-CPUid le /CPUfreqgove rno rdec isionsa re basedon the i r
own load-basedc a lc u la tions,heu ristic s(andsome b lac k magic ).
These a re to be replac edbysc hedu le r-driven da ta
WorkinProgress
Complexityisgrowing...-moreCPUs-moreintegrateddevices-morepowerdomains-microcontrollers-firmware,etc.
Kernel�is�evolving....
Drivermodel: keyconcept
S taticPM,S ystemPM-trad itionalsusp end /resumeCONFIG_PM_SLEEP=y-systemwid e,alld evices-initiated b yusersp ace-anyd evicecanp reventsusp end
-usersp aceis"frozen" ( c. f . Documentation/power/freezing-of-tasks.txt)
MUSTRead :Documentation/power/devices.txt
Linux:PM domains-ove rride opsfo ra g roupo fdevic es- i fPM domain presen t,PM c o re usesdoma in c a l lbac k sinsteado ftype /c lass/bus
Documentation/cpuidle/*.txt
3
StaticStaticPM,SystemPM-traditionalsuspend/resumeCONFIG_PM_SLEEP=y-systemwide,alldevices-initiatedbyuserspace-anydevicecanpreventsuspend
-userspaceis"frozen"(c.f.Documentation/power/freezing-of-tasks.txt)
MUSTRead:Documentation/power/devices.txt
4
structdev_pm_opsExistsinstructdevice_driver,structbus_type,...
structdev_pm_ops{
int(*prepare)(structdevice*dev);
void(*complete)(structdevice*dev);
int(*suspend)(structdevice*dev);
int(*resume)(structdevice*dev);
...
int(*suspend_late)(structdevice*dev);
int(*resume_early)(structdevice*dev);
...
};
Drivermodel:keyconcept5
->begin()
->prepare()
->enter()->wake()
->finish()
->end()
echomem>/sys/power/state
->prepare()->suspend()
->suspend_late()->suspend_noirq()
->resume_noirq()->resume_early()
->resume()->complete()
Platformspecific:structplatform_suspend_ops
Per-device:structdev_pm_ops
SuspendResume
6
WakeupfromSuspendSubsystem/Drivercontrol:-device_init_wakeup(dev,bool)-dev_pm_set_wake_irq()-dev_pm_clear_wake_irq()
Whenwakeupoccurs(e.g.inISR):-pm_wakeup_event()
Enable/disablefromuserspace:-/sys/devices/.../power/wakeup
7
µC
IntroductiontoKernel
PowerManagement
KevinHilman,L inaro
khilman@kernel.org
Ker nel Recipes 2015, Par is
CPUL2$
GPU DSPCPUL2$
Memory
Phew...
thatwasalljustabaddream
AnyQuestions?
DynamicPM- bas ed on "act i vi t y"- Act i ve PM Save power when doi ng "s om et hi ng"
- I dl e PM Save power when doi ng "not hi ng"
structdev_pm_opsExistsinstructd evice_ d river, structb us_ typ e, . . .
structdev_pm_ops{int(*prepare)(structdevice*dev);void(*complete)(structdevice*dev);int(*suspend)(structdevice*dev);int(*resume)(structdevice*dev);...int(*suspend_late)(structdevice*dev);int(*resume_early)(structdevice*dev);...};
->begin()
->prepare()
->enter()
->wake()
->finish()
->end()
echomem>/sys/power/state
->prepare()
->suspend()
->suspend_late()
->suspend_noirq()
->resume_noirq()
->resume_early()
->resume()
->complete()
Pla tfo rmspec i fic : structplatform_suspend_ops
Per-devic e :structdev_pm_ops
pm_wakeup_event()
WakeupfromSuspendSub system/Drivercontrol:-device_init_wakeup(dev,bool)-dev_pm_set_wake_irq()-dev_pm_clear_wake_irq()
Whenwak eup occurs(e.g. inISR):-pm_wakeup_event()
Enab le/d isab lefromusersp ace:-/sys/devices/.../power/wakeup
ActivePM:UnderlyingFrameworks
Frequenc ysc a l ing :c loc k framework-clk_get_rate()-clk_set_rate()
Vo l tage sc a l ing :regu la to rframework-regulator_get_voltage()-regulator_set_voltage()-Documentation/power/regulator/consumer.txt
Examp le.. . drivers/cpufreq/cpufreq-dt.c
OperatingPerformancePointsOPPs
-tup leoffreq uency,minimumvoltage-Describ ed inDTcpu0:cpu@0{operating-points=</*kHzuV*/30000010250006000001200000800000131300010080001375000>;}
c.f.Documentation/power/opp.txt
CPUDVFS usingCPUFreq
-S elect"b est"OPPb ased onreq uirements
-p luggab legovernorsforselecting"b est"OPP-p erformance,p owersave, . . . -ond emand :h eursiticsb ased onload ,tunab le- interactive:ond emand ++,tuned forlatency
Documentation/cpu-freq/core.txt
. . . wh atab outd eviceDVFS?. . . . d evfreq
IdlePM:ticklessidle
CONFIG_NOHZ_IDLE=y
-stop p eriod ictick wh enid le-onlywak esfornext"event"orinterrup t
IdleforCPUs
CPUid lestatesh ave"d ep th "-morep owersavings- longerwak eup latency
S tateDefinitionsinDT-legacy:p latform-sp ecificd river
S tateentry-p latform-sp ecifich ook s-b ased oncompatiblestring
Idlefordevices:RuntimePM
-p er-d eviceid le-singled eviceatatime-id lenesscontrolled b yd river, b ased onactivity
-d evicesare ind epend ent-oned evicecannotp reventoth ersfromruntimesusp end ing
-d oesNOTaffectusersp ace
Don' twak eup .. .onlytop resssnoozeand gob ack tosleep
CPUid le :Howdeepto sleep?
drivers/cpuidle/governors/menu.c1)Break even po in t(basedon en te r/exi t times)- looks at pr edict able event s ( e. g. t im er s)- compar es against m in r esidency
2)La tenc yto le ranc e - checks Q oS (PM_QOS_CPU_DMA_LATENCY)- compar es against m in r esidency
3) Perfo rmanc e Impac t:- black m agic "m ult iplier " based on load- f avor shallower st at es under heavy load
Limitations:-notverySMPormulti-clusteraware
i d l e - s t a t e s {
C P U _ S T B Y : s t a n d b y {
c o m p a t i b l e = " q c o m , i d l e - s t a t e - s t b y " ,
" a r m , i d l e - s t a t e " ;
e n t r y - l a t e n c y - u s = < 1 > ;
e x i t - l a t e n c y - u s = < 1 > ;
m i n - r e s i d e n c y - u s = < 2 > ;
} ;
C P U _ S P C : s p c {
c o m p a t i b l e = " q c o m , i d l e - s t a t e - s p c " ,
" a r m , i d l e - s t a t e " ;
e n t r y - l a t e n c y - u s = < 1 5 0 > ;
e x i t - l a t e n c y - u s = < 2 0 0 > ;
m i n - r e s i d e n c y - u s = < 2 0 0 0 > ;
} ;
} ;
c p u @ 0 {
[ . . . ]
c p u - i d l e - s t a t e s = < & C P U _ S T B Y & C P U _ S P C > ;
} ;
D o c u m e n t a t i o n / d e v i c e t r e e / b i n d i n g s / a r m / i d l e - s t a t e s . t x t
structdev_pm_ops{
...
int(*runtime_suspend)(structdevice*dev);
int(*runtime_resume)(structdevice*dev);
int(*runtime_idle)(structdevice*dev);
};
RuntimePMAPI
Te l l PM c o re whe the rdevic e is in use"I'mabou tto u se it" -pm_runtime_get(),_sync() - I ncr em ent use count , pm _r unt im e_r esume( )
"I'mdone .. .f o rn ow"-pm_runtime_put(),_sync()-Decr em ent use count , pm _r unt im e_idle( )Sim ilar t o legacy clock f r am ewor k usage f or clock gat ing-clk_enable(),clk_disable()
Exc e l len t: Documentation/power/pm_runtime.txt
RuntimePM:callbacks
Use c oun t:1 -->0-->runtime_suspend()- pr epar e f or low- power st at e- ensur e wakeups enabled- save cont ext
Use c oun t:0 -->1-->runtime_resume()- r est or e cont ext- et c.
Aut osuspend - - - def er r ed r unt im e suspend- pm_runtime_set_autosuspend_delay()- pm_runtime_mark_last_busy()- pm_runtime_put_autosuspend()
Idlefordevices:Grouping
Devic esa re o ften groupedin to doma ins-powerga tedasa group-c an be nested-powerga ting hasla tenc yimpl ic a tions-e xte rna l regu la to rrampup,e tc .Documentation/power/devices.txt
Static DynamicSuspendResume
ActiveIdle
OPPs
CPUfreqRuntimePM
Wakeups
IdleCPUs Idledevices
CPUidle
PMdomainsNOHZ_IDLE
PMQoS
Clocks Regulators
µC
CPUL2$
GPU DSPCPUL2$
Memory
structdev_pm_domain{
structdev_pm_opsops;
...
};
GenericPMDomains(genpd)
Generic implemen ta tion o fPM domains-Basedon run time PM-When a l l devic esin doma in a re run time suspended...genpd->power_off()-When fi rstdevic e in doma in isrun time resumed...genpd->power_on()
genpdgove rno rs-a l l owc ustomdec ision mak ing be fo re powerga ting -e .g .pe r-devic e QoSc onstra in ts
genpdinDTExample genpd:power:power-controller@12340000{
compatible="foo,power-controller";
reg=<0x123400000x1000>;
#power-domain-cells=<1>;
};
Example use bydevic e :leaky-device@12350000{
compatible="foo,i-leak-current";
reg=<0x123500000x1000>;
power-domains=<&power0>;
};
Fr om : Documentation/devicetree/bindings/power/power-domain.txt
RuntimePM,genpdideas
Uni fy id le fo rCPUsanddevic es
- use r unt im e PM f or CPUs
- use r unt im e PM f or CPU- connect ed " ext r as"
( e. g. G I C, PMUs, VFP, Cor eSight , et c. )
- combine int o a " CPU genpd"
Extendto CPUCluste rs
- m odel clust er s as genpd m ade up of " CPU genpd" s
plus shar ed L2$
- when CPUs in clust er ar e idle ( r unt im e suspended)
clust er genpd can hit low- power st at e ( of f )
NextSteps
Quality:PMQoS
System-wide :e .g PM_QOS_CPU_DMA_LATENCY- Used by CPUidle t o det erm ine dept h of idle st at e
Per-devic e- at t ach Q oS const r aint s wit h specif ic devices- genpd: pr event PM domain power of f - PM_QOS_FLAG_NO_POWER_OFF
- e. g. genpd: per - device wakeup lat ency - DEV_PM_QOS_RESUME_LATENCY - f or use by genpd " gover nor s"
Documentation/power/pm_qos_interface.txt
Energy-awarescheduling:EAS
Anon -go ing e ffo rt to improve ene rgye ffic ienc yo fthe sc hedu le r.
-Teac h the sc hedu le rnewheu ristic sfo rtask p lac ementto
tak e advan tage o fene rgy-saving hardware
-In tegra te CPUid le andCPUfreqwi th the sc hedu le r
-sc hedu le rtrac k sloadsta tistic sfo r i tsown dec ision mak ing
(e .g .task p lac ement, l oadba lanc ing ,e tc .)
-CPUid le /CPUfreqgove rno rdec isionsa re basedon the i r
own load-basedc a lc u la tions,heu ristic s(andsome b lac k magic ).
These a re to be replac edbysc hedu le r-driven da ta
WorkinProgress
Complexityisgrowing...-moreCPUs-moreintegrateddevices-morepowerdomains-microcontrollers-firmware,etc.
Kernel�is�evolving....
Drivermodel: keyconcept
S taticPM,S ystemPM-trad itionalsusp end /resumeCONFIG_PM_SLEEP=y-systemwid e,alld evices-initiated b yusersp ace-anyd evicecanp reventsusp end
-usersp aceis"frozen" ( c. f . Documentation/power/freezing-of-tasks.txt)
MUSTRead :Documentation/power/devices.txt
Linux:PM domains-ove rride opsfo ra g roupo fdevic es- i fPM domain presen t,PM c o re usesdoma in c a l lbac k sinsteado ftype /c lass/bus
Documentation/cpuidle/*.txt
8
DynamicPM-basedon"activity"-ActivePMSavepowerwhendoing"something"
-IdlePMSavepowerwhendoing"nothing"
Dynamic9
ActivePM:UnderlyingFrameworks
Frequencyscaling:clockframework-clk_get_rate()-clk_set_rate()
Voltagescaling:regulatorframework-regulator_get_voltage()-regulator_set_voltage()-Documentation/power/regulator/consumer.txt
Example...drivers/cpufreq/cpufreq-dt.c
OperatingPerformancePointsOPPs
-tupleoffrequency,minimumvoltag e-DescribedinDTcpu0:cpu@0{operating-points=</*kHzuV*/30000010250006000001200000800000131300010080001375000>;}
c.f.Documentation/power/opp.txt
CPUDVFSusing CPUFreq
-Select"best"OPPbasedonrequirements
-pluggablegovernorsforselecting"best"OPP-performance,powersave,...-ondemand:heursiticsbasedonload,tunable-interactive:ondemand++,tunedforlatency
Documentation/cpu-freq/core.txt
...whataboutdeviceDVFS?....devfreq
Active
OPPs
CPUfreq
Clocks Regulators
10
OperatingPerformancePointsOPPs
-tupleoffrequency,minimumvoltage-DescribedinDTcpu0:cpu@0{operating-points=</*kHzuV*/30000010250006000001200000800000131300010080001375000>;}
c.f.Documentation/power/opp.txt
OPPs11
CPUDVFSusingCPUFreq
-Select"best"OPPbasedonrequirements
-pluggablegovernorsforselecting"best"OPP-performance,powersave,...-ondemand:heursiticsbasedonload,tunable-interactive:ondemand++,tunedforlatency
Documentation/cpu-freq/core.txt
...whataboutdeviceDVFS?....devfreq
12
ActivePM:UnderlyingFrameworks
Frequencyscaling:clockframework-clk_get_rate()-clk_set_rate()
Voltagescaling:regulatorframework-regulator_get_voltage()-regulator_set_voltage()-Documentation/power/regulator/consumer.txt
Example...drivers/cpufreq/cpufreq-dt.c
Regulators13
µC
IntroductiontoKernel
PowerManagement
KevinHilman,L inaro
khilman@kernel.org
Ker nel Recipes 2015, Par is
CPUL2$
GPU DSPCPUL2$
Memory
Phew...
thatwasalljustabaddream
AnyQuestions?
DynamicPM- bas ed on "act i vi t y"- Act i ve PM Save power when doi ng "s om et hi ng"
- I dl e PM Save power when doi ng "not hi ng"
structdev_pm_opsExistsinstructd evice_ d river, structb us_ typ e, . . .
structdev_pm_ops{int(*prepare)(structdevice*dev);void(*complete)(structdevice*dev);int(*suspend)(structdevice*dev);int(*resume)(structdevice*dev);...int(*suspend_late)(structdevice*dev);int(*resume_early)(structdevice*dev);...};
->begin()
->prepare()
->enter()
->wake()
->finish()
->end()
echomem>/sys/power/state
->prepare()
->suspend()
->suspend_late()
->suspend_noirq()
->resume_noirq()
->resume_early()
->resume()
->complete()
Pla tfo rmspec i fic : structplatform_suspend_ops
Per-devic e :structdev_pm_ops
pm_wakeup_event()
WakeupfromSuspendSub system/Drivercontrol:-device_init_wakeup(dev,bool)-dev_pm_set_wake_irq()-dev_pm_clear_wake_irq()
Whenwak eup occurs(e.g. inISR):-pm_wakeup_event()
Enab le/d isab lefromusersp ace:-/sys/devices/.../power/wakeup
ActivePM:UnderlyingFrameworks
Frequenc ysc a l ing :c loc k framework-clk_get_rate()-clk_set_rate()
Vo l tage sc a l ing :regu la to rframework-regulator_get_voltage()-regulator_set_voltage()-Documentation/power/regulator/consumer.txt
Examp le.. . drivers/cpufreq/cpufreq-dt.c
OperatingPerformancePointsOPPs
-tup leoffreq uency,minimumvoltage-Describ ed inDTcpu0:cpu@0{operating-points=</*kHzuV*/30000010250006000001200000800000131300010080001375000>;}
c.f.Documentation/power/opp.txt
CPUDVFS usingCPUFreq
-S elect"b est"OPPb ased onreq uirements
-p luggab legovernorsforselecting"b est"OPP-p erformance,p owersave, . . . -ond emand :h eursiticsb ased onload ,tunab le- interactive:ond emand ++,tuned forlatency
Documentation/cpu-freq/core.txt
. . . wh atab outd eviceDVFS?. . . . d evfreq
IdlePM:ticklessidle
CONFIG_NOHZ_IDLE=y
-stop p eriod ictick wh enid le-onlywak esfornext"event"orinterrup t
IdleforCPUs
CPUid lestatesh ave"d ep th "-morep owersavings- longerwak eup latency
S tateDefinitionsinDT-legacy:p latform-sp ecificd river
S tateentry-p latform-sp ecifich ook s-b ased oncompatiblestring
Idlefordevices:RuntimePM
-p er-d eviceid le-singled eviceatatime-id lenesscontrolled b yd river, b ased onactivity
-d evicesare ind epend ent-oned evicecannotp reventoth ersfromruntimesusp end ing
-d oesNOTaffectusersp ace
Don' twak eup .. .onlytop resssnoozeand gob ack tosleep
CPUid le :Howdeepto sleep?
drivers/cpuidle/governors/menu.c1)Break even po in t(basedon en te r/exi t times)- looks at pr edict able event s ( e. g. t im er s)- compar es against m in r esidency
2)La tenc yto le ranc e - checks Q oS (PM_QOS_CPU_DMA_LATENCY)- compar es against m in r esidency
3) Perfo rmanc e Impac t:- black m agic "m ult iplier " based on load- f avor shallower st at es under heavy load
Limitations:-notverySMPormulti-clusteraware
i d l e - s t a t e s {
C P U _ S T B Y : s t a n d b y {
c o m p a t i b l e = " q c o m , i d l e - s t a t e - s t b y " ,
" a r m , i d l e - s t a t e " ;
e n t r y - l a t e n c y - u s = < 1 > ;
e x i t - l a t e n c y - u s = < 1 > ;
m i n - r e s i d e n c y - u s = < 2 > ;
} ;
C P U _ S P C : s p c {
c o m p a t i b l e = " q c o m , i d l e - s t a t e - s p c " ,
" a r m , i d l e - s t a t e " ;
e n t r y - l a t e n c y - u s = < 1 5 0 > ;
e x i t - l a t e n c y - u s = < 2 0 0 > ;
m i n - r e s i d e n c y - u s = < 2 0 0 0 > ;
} ;
} ;
c p u @ 0 {
[ . . . ]
c p u - i d l e - s t a t e s = < & C P U _ S T B Y & C P U _ S P C > ;
} ;
D o c u m e n t a t i o n / d e v i c e t r e e / b i n d i n g s / a r m / i d l e - s t a t e s . t x t
structdev_pm_ops{
...
int(*runtime_suspend)(structdevice*dev);
int(*runtime_resume)(structdevice*dev);
int(*runtime_idle)(structdevice*dev);
};
RuntimePMAPI
Te l l PM c o re whe the rdevic e is in use"I'mabou tto u se it" -pm_runtime_get(),_sync() - I ncr em ent use count , pm _r unt im e_r esume( )
"I'mdone .. .f o rn ow"-pm_runtime_put(),_sync()-Decr em ent use count , pm _r unt im e_idle( )Sim ilar t o legacy clock f r am ewor k usage f or clock gat ing-clk_enable(),clk_disable()
Exc e l len t: Documentation/power/pm_runtime.txt
RuntimePM:callbacks
Use c oun t:1 -->0-->runtime_suspend()- pr epar e f or low- power st at e- ensur e wakeups enabled- save cont ext
Use c oun t:0 -->1-->runtime_resume()- r est or e cont ext- et c.
Aut osuspend - - - def er r ed r unt im e suspend- pm_runtime_set_autosuspend_delay()- pm_runtime_mark_last_busy()- pm_runtime_put_autosuspend()
Idlefordevices:Grouping
Devic esa re o ften groupedin to doma ins-powerga tedasa group-c an be nested-powerga ting hasla tenc yimpl ic a tions-e xte rna l regu la to rrampup,e tc .Documentation/power/devices.txt
Static DynamicSuspendResume
ActiveIdle
OPPs
CPUfreqRuntimePM
Wakeups
IdleCPUs Idledevices
CPUidle
PMdomainsNOHZ_IDLE
PMQoS
Clocks Regulators
µC
CPUL2$
GPU DSPCPUL2$
Memory
structdev_pm_domain{
structdev_pm_opsops;
...
};
GenericPMDomains(genpd)
Generic implemen ta tion o fPM domains-Basedon run time PM-When a l l devic esin doma in a re run time suspended...genpd->power_off()-When fi rstdevic e in doma in isrun time resumed...genpd->power_on()
genpdgove rno rs-a l l owc ustomdec ision mak ing be fo re powerga ting -e .g .pe r-devic e QoSc onstra in ts
genpdinDTExample genpd:power:power-controller@12340000{
compatible="foo,power-controller";
reg=<0x123400000x1000>;
#power-domain-cells=<1>;
};
Example use bydevic e :leaky-device@12350000{
compatible="foo,i-leak-current";
reg=<0x123500000x1000>;
power-domains=<&power0>;
};
Fr om : Documentation/devicetree/bindings/power/power-domain.txt
RuntimePM,genpdideas
Uni fy id le fo rCPUsanddevic es
- use r unt im e PM f or CPUs
- use r unt im e PM f or CPU- connect ed " ext r as"
( e. g. G I C, PMUs, VFP, Cor eSight , et c. )
- combine int o a " CPU genpd"
Extendto CPUCluste rs
- m odel clust er s as genpd m ade up of " CPU genpd" s
plus shar ed L2$
- when CPUs in clust er ar e idle ( r unt im e suspended)
clust er genpd can hit low- power st at e ( of f )
NextSteps
Quality:PMQoS
System-wide :e .g PM_QOS_CPU_DMA_LATENCY- Used by CPUidle t o det erm ine dept h of idle st at e
Per-devic e- at t ach Q oS const r aint s wit h specif ic devices- genpd: pr event PM domain power of f - PM_QOS_FLAG_NO_POWER_OFF
- e. g. genpd: per - device wakeup lat ency - DEV_PM_QOS_RESUME_LATENCY - f or use by genpd " gover nor s"
Documentation/power/pm_qos_interface.txt
Energy-awarescheduling:EAS
Anon -go ing e ffo rt to improve ene rgye ffic ienc yo fthe sc hedu le r.
-Teac h the sc hedu le rnewheu ristic sfo rtask p lac ementto
tak e advan tage o fene rgy-saving hardware
-In tegra te CPUid le andCPUfreqwi th the sc hedu le r
-sc hedu le rtrac k sloadsta tistic sfo r i tsown dec ision mak ing
(e .g .task p lac ement, l oadba lanc ing ,e tc .)
-CPUid le /CPUfreqgove rno rdec isionsa re basedon the i r
own load-basedc a lc u la tions,heu ristic s(andsome b lac k magic ).
These a re to be replac edbysc hedu le r-driven da ta
WorkinProgress
Complexityisgrowing...-moreCPUs-moreintegrateddevices-morepowerdomains-microcontrollers-firmware,etc.
Kernel�is�evolving....
Drivermodel: keyconcept
S taticPM,S ystemPM-trad itionalsusp end /resumeCONFIG_PM_SLEEP=y-systemwid e,alld evices-initiated b yusersp ace-anyd evicecanp reventsusp end
-usersp aceis"frozen" ( c. f . Documentation/power/freezing-of-tasks.txt)
MUSTRead :Documentation/power/devices.txt
Linux:PM domains-ove rride opsfo ra g roupo fdevic es- i fPM domain presen t,PM c o re usesdoma in c a l lbac k sinsteado ftype /c lass/bus
Documentation/cpuidle/*.txt
14
IntroductiontoKernel
PowerManagement
KevinHilman,Linaro
khilman@kernel.org
KernelRecipes2015,Paris
IdlePM:ticklessidle
CONFIG_NOHZ_IDLE=y
-stopperiodictickwhenidle-onlywakesfornext"event"orinterrupt
IdleforCPUs
CPUidlestateshave"depth"-morepowersavings-longerwakeuplatency
StateDefinitionsinDT-legacy:p latform-specificdriver
Stateentry-p latform-specifichooks-basedoncompatiblestring
Idlefordevices:RuntimePM
-per-deviceid le-singledeviceatatime-id lenesscontrolled bydriver,basedonactivity
-devicesareindependent-onedevicecannotpreventothersfromruntimesuspending
-doesNOTaffectuserspace
Don'twakeup...onlytopresssnoozeandgobacktosleep
CPUidle:Howdeeptosleep?
drivers/cpuidle/governors/menu.c1)Breakevenpoint(basedonenter/exittimes)-looksatpredictableevents(e.g.timers)-comparesagainstminresidency
2)Latencytolerance-checksQoS(PM_QOS_CPU_DMA_LATENCY)-comparesagainstminresidency
3)PerformanceImpact:-blackmagic"multiplier"basedonload-favorshallowerstatesunderheavyload
Limitations:-notverySMPormulti-clusteraware
idle-states{
CPU_STBY:standby{
compatible="qcom,idle-state-stby",
"arm,idle-state";
entry-latency-us=<1>;
exit-latency-us=<1>;
min-residency-us=<2>;
};
CPU_SPC:spc{
compatible="qcom,idle-state-spc",
"arm,idle-state";
entry-latency-us=<150>;
exit-latency-us=<200>;
min-residency-us=<2000>;
};
};
cpu@0{
[...]
cpu-idle-states=<&CPU_STBY&CPU_SPC>;
};
Documentation/devicetree/bindings/arm/idle-states.txt
structdev_pm_ops{...int(*runtime_suspend)(structdevice*dev);int(*runtime_resume)(structdevice*dev);int(*runtime_idle)(structdevice*dev);};
RuntimePMAPI
TellPMcorewhetherdeviceisinuse"I'mabouttouse it"-pm_runtime_get(),_sync()-Incrementusecount,pm_runtime_resume()
"I'mdone...fornow"-pm_runtime_put(),_sync()-Decrementusecount,pm_runtime_idle()
Similartolegacyclockframeworkusageforclockgating-clk_enable(),clk_disable()
Excellent:Documentation/power/pm_runtime.txt
RuntimePM:callbacks
Usecount:1-->0-->runtime_suspend()-prepareforlow-powerstate-ensurewakeupsenabled-savecontext
Usecount:0-->1-->runtime_resume()-restorecontext-etc.
Autosuspend---deferredruntimesuspend-pm_runtime_set_autosuspend_delay()-pm_runtime_mark_last_busy()-pm_runtime_put_autosuspend()
Idlefordevices:Grouping
Devicesareoftengroupedintodomains-powergatedasagroup-canbenested-powergatinghaslatencyimplications-externalregulatorrampup,etc.
Documentation/power/devices.txt
DynamicIdle
RuntimePM
IdleCPUs Idledevices
CPUidle
PMdomainsNOHZ_IDLE
PMQoS
µCCPU
L2$
GPU DSPCPUL2$
Memory
structdev_pm_domain{structdev_pm_opsops;...};
GenericPMDomains(genpd)
Generic implementationofPMdomains-BasedonruntimePM-Whenalldevicesindomainareruntimesuspended...genpd->power_off()-Whenfirstdeviceindomainisruntimeresumed...genpd->power_on()
genpdgovernors-allowcustomdecisionmakingbeforepowergating-e.g.per-deviceQoSconstraints
genpdinDTExamplegenpd:
power:power-controller@12340000{compatible="foo,power-controller";reg=<0x123400000x1000>;#power-domain-cells=<1>;};
Exampleusebydevice:
leaky-device@12350000{compatible="foo,i-leak-current";reg=<0x123500000x1000>;power-domains=<&power0>;};
From:Documentation/devicetree/bindings/power/power-domain.txt
RuntimePM,genpdideas
UnifyidleforCPUsanddevices
-useruntimePMforCPUs
-useruntimePMforCPU-connected"extras"
(e.g.GIC,PMUs,VFP,CoreSight,etc.)
-combineintoa"CPUgenpd"
ExtendtoCPUClusters
-modelclustersasgenpdmadeupof"CPUgenpd"s
plussharedL2$
-whenCPUsinclusterareidle(runtimesuspended)
clustergenpdcanhitlow-powerstate(off)
NextSteps
Quality:PMQoS
System-wide:e.gPM_QOS_CPU_DMA_LATENCY-UsedbyCPUidletodeterminedepthofidlestate
Per-device-attachQoSconstraintswithspecificdevices-genpd:preventPMdomainpoweroff-PM_QOS_FLAG_NO_POWER_OFF
-e.g.genpd:per-devicewakeuplatency-DEV_PM_QOS_RESUME_LATENCY-forusebygenpd"governors"
Documentation/power/pm_qos_interface.txt
Energy-awarescheduling:EAS
Anon-goingefforttoimproveenergyeffic iencyofthescheduler.
-Teachtheschedulernewheuristicsfortaskplacementto
takeadvantageofenergy-savinghardware
-IntegrateCPUidleandCPUfreqwiththescheduler
-schedulertracksloadstatisticsforitsowndecisionmaking
(e.g.taskplacement,loadbalancing,etc.)
-CPUidle/CPUfreqgovernordecisionsarebasedontheir
ownload-basedcalculations,heuristics(andsomeblackmagic).
Thesearetobereplacedbyscheduler-drivendata
WorkinProgress
Linux:PMdomains-overrideopsforagroupofdevices-ifPMdomainpresent,PMcoreusesdomaincallbacksinsteadoftype/class/bus
Documentation/cpuidle/*.txt
15
IdleforCPUs
CPUidlestateshave"depth"-morepowersavings-longerwakeuplatency
StateDefinitionsinDT-legacy:platform-specificdriver
Stateentry-platform-specifichooks-basedoncompatiblestring
idle-states{CPU_STBY:standby{compatible="qcom,idle-state-stby","arm,idle-state";entry-latency-us=<1>;exit-latency-us=<1>;min-residency-us=<2>;};
CPU_SPC:spc{compatible="qcom,idle-state-spc","arm,idle-state";entry-latency-us=<150>;exit-latency-us=<200>;min-residency-us=<2000>;};};
cpu@0{[...]cpu-idle-states=<&CPU_STBY&CPU_SPC>;};
Documentation/devicetree/bindings/arm/idle-states.txt
IdleCPUs
CPUidle16
CPUidle:Howdeeptosleep?
drivers/cpuidle/governors/menu.c1)Breakevenpoint(basedonenter/exittimes)-looksatpredictableevents(e.g.timers)-comparesagainstminresidency
2)Latencytolerance-checksQoS(PM_QOS_CPU_DMA_LATENCY)-comparesagainstminresidency
3)PerformanceImpact:-blackmagic"multiplier"basedonload-favorshallowerstatesunderheavyload
Limitations:-notverySMPormulti-clusteraware
Documentation/cpuidle/*.txt
17
IdlePM:ticklessidle
CONFIG_NOHZ_IDLE=y
-stopperiodictickwhenidle-onlywakesfornext"event"orinterrupt
Don'twakeup...onlytopresssnoozeandgobacktosleep
18
IntroductiontoKernel
PowerManagement
KevinHilman,Linaro
khilman@kernel.org
KernelRecipes2015,Paris
IdlePM:ticklessidle
CONFIG_NOHZ_IDLE=y
-stopperiodictickwhenidle-onlywakesfornext"event"orinterrupt
IdleforCPUs
CPUidlestateshave"depth"-morepowersavings-longerwakeuplatency
StateDefinitionsinDT-legacy:p latform-specificdriver
Stateentry-p latform-specifichooks-basedoncompatiblestring
Idlefordevices:RuntimePM
-per-deviceid le-singledeviceatatime-id lenesscontrolled bydriver,basedonactivity
-devicesareindependent-onedevicecannotpreventothersfromruntimesuspending
-doesNOTaffectuserspace
Don'twakeup...onlytopresssnoozeandgobacktosleep
CPUidle:Howdeeptosleep?
drivers/cpuidle/governors/menu.c1)Breakevenpoint(basedonenter/exittimes)-looksatpredictableevents(e.g.timers)-comparesagainstminresidency
2)Latencytolerance-checksQoS(PM_QOS_CPU_DMA_LATENCY)-comparesagainstminresidency
3)PerformanceImpact:-blackmagic"multiplier"basedonload-favorshallowerstatesunderheavyload
Limitations:-notverySMPormulti-clusteraware
idle-states{
CPU_STBY:standby{
compatible="qcom,idle-state-stby",
"arm,idle-state";
entry-latency-us=<1>;
exit-latency-us=<1>;
min-residency-us=<2>;
};
CPU_SPC:spc{
compatible="qcom,idle-state-spc",
"arm,idle-state";
entry-latency-us=<150>;
exit-latency-us=<200>;
min-residency-us=<2000>;
};
};
cpu@0{
[...]
cpu-idle-states=<&CPU_STBY&CPU_SPC>;
};
Documentation/devicetree/bindings/arm/idle-states.txt
structdev_pm_ops{...int(*runtime_suspend)(structdevice*dev);int(*runtime_resume)(structdevice*dev);int(*runtime_idle)(structdevice*dev);};
RuntimePMAPI
TellPMcorewhetherdeviceisinuse"I'mabouttouse it"-pm_runtime_get(),_sync()-Incrementusecount,pm_runtime_resume()
"I'mdone...fornow"-pm_runtime_put(),_sync()-Decrementusecount,pm_runtime_idle()
Similartolegacyclockframeworkusageforclockgating-clk_enable(),clk_disable()
Excellent:Documentation/power/pm_runtime.txt
RuntimePM:callbacks
Usecount:1-->0-->runtime_suspend()-prepareforlow-powerstate-ensurewakeupsenabled-savecontext
Usecount:0-->1-->runtime_resume()-restorecontext-etc.
Autosuspend---deferredruntimesuspend-pm_runtime_set_autosuspend_delay()-pm_runtime_mark_last_busy()-pm_runtime_put_autosuspend()
Idlefordevices:Grouping
Devicesareoftengroupedintodomains-powergatedasagroup-canbenested-powergatinghaslatencyimplications-externalregulatorrampup,etc.
Documentation/power/devices.txt
DynamicIdle
RuntimePM
IdleCPUs Idledevices
CPUidle
PMdomainsNOHZ_IDLE
PMQoS
µCCPU
L2$
GPU DSPCPUL2$
Memory
structdev_pm_domain{structdev_pm_opsops;...};
GenericPMDomains(genpd)
Generic implementationofPMdomains-BasedonruntimePM-Whenalldevicesindomainareruntimesuspended...genpd->power_off()-Whenfirstdeviceindomainisruntimeresumed...genpd->power_on()
genpdgovernors-allowcustomdecisionmakingbeforepowergating-e.g.per-deviceQoSconstraints
genpdinDTExamplegenpd:
power:power-controller@12340000{compatible="foo,power-controller";reg=<0x123400000x1000>;#power-domain-cells=<1>;};
Exampleusebydevice:
leaky-device@12350000{compatible="foo,i-leak-current";reg=<0x123500000x1000>;power-domains=<&power0>;};
From:Documentation/devicetree/bindings/power/power-domain.txt
RuntimePM,genpdideas
UnifyidleforCPUsanddevices
-useruntimePMforCPUs
-useruntimePMforCPU-connected"extras"
(e.g.GIC,PMUs,VFP,CoreSight,etc.)
-combineintoa"CPUgenpd"
ExtendtoCPUClusters
-modelclustersasgenpdmadeupof"CPUgenpd"s
plussharedL2$
-whenCPUsinclusterareidle(runtimesuspended)
clustergenpdcanhitlow-powerstate(off)
NextSteps
Quality:PMQoS
System-wide:e.gPM_QOS_CPU_DMA_LATENCY-UsedbyCPUidletodeterminedepthofidlestate
Per-device-attachQoSconstraintswithspecificdevices-genpd:preventPMdomainpoweroff-PM_QOS_FLAG_NO_POWER_OFF
-e.g.genpd:per-devicewakeuplatency-DEV_PM_QOS_RESUME_LATENCY-forusebygenpd"governors"
Documentation/power/pm_qos_interface.txt
Energy-awarescheduling:EAS
Anon-goingefforttoimproveenergyeffic iencyofthescheduler.
-Teachtheschedulernewheuristicsfortaskplacementto
takeadvantageofenergy-savinghardware
-IntegrateCPUidleandCPUfreqwiththescheduler
-schedulertracksloadstatisticsforitsowndecisionmaking
(e.g.taskplacement,loadbalancing,etc.)
-CPUidle/CPUfreqgovernordecisionsarebasedontheir
ownload-basedcalculations,heuristics(andsomeblackmagic).
Thesearetobereplacedbyscheduler-drivendata
WorkinProgress
Linux:PMdomains-overrideopsforagroupofdevices-ifPMdomainpresent,PMcoreusesdomaincallbacksinsteadoftype/class/bus
Documentation/cpuidle/*.txt
19
Idlefordevices:RuntimePM
-per-deviceidle-singledeviceatatime-idlenesscontrolledbydriver,basedonactivity
-devicesareindependent-onedevicecannotpreventothersfromruntimesuspending
-doesNOTaffectuserspacestructdev_pm_ops{
...
int(*runtime_suspend)(structdevice*dev);
int(*runtime_resume)(structdevice*dev);
int(*runtime_idle)(structdevice*dev);
};
Idledevices
20
RuntimePMAPI
TellPMcorewhetherdeviceisinuse"I'mabouttouseit"-pm_runtime_get(),_sync()-Incrementusecount,pm_runtime_resume()
"I'mdone...fornow"-pm_runtime_put(),_sync()-Decrementusecount,pm_runtime_idle()
Similartolegacyclockframeworkusageforclockgating-clk_enable(),clk_disable()
Excellent:Documentation/power/pm_runtime.txt
21
RuntimePM:callbacks
Usecount:1-->0-->runtime_suspend()-prepareforlow-powerstate-ensurewakeupsenabled-savecontext
Usecount:0-->1-->runtime_resume()-restorecontext-etc.
Autosuspend---deferredruntimesuspend-pm_runtime_set_autosuspend_delay()-pm_runtime_mark_last_busy()-pm_runtime_put_autosuspend()
22
IntroductiontoKernel
PowerManagement
KevinHilman,Linaro
khilman@kernel.org
KernelRecipes2015,Paris
IdlePM:ticklessidle
CONFIG_NOHZ_IDLE=y
-stopperiodictickwhenidle-onlywakesfornext"event"orinterrupt
IdleforCPUs
CPUidlestateshave"depth"-morepowersavings-longerwakeuplatency
StateDefinitionsinDT-legacy:p latform-specificdriver
Stateentry-p latform-specifichooks-basedoncompatiblestring
Idlefordevices:RuntimePM
-per-deviceid le-singledeviceatatime-id lenesscontrolled bydriver,basedonactivity
-devicesareindependent-onedevicecannotpreventothersfromruntimesuspending
-doesNOTaffectuserspace
Don'twakeup...onlytopresssnoozeandgobacktosleep
CPUidle:Howdeeptosleep?
drivers/cpuidle/governors/menu.c1)Breakevenpoint(basedonenter/exittimes)-looksatpredictableevents(e.g.timers)-comparesagainstminresidency
2)Latencytolerance-checksQoS(PM_QOS_CPU_DMA_LATENCY)-comparesagainstminresidency
3)PerformanceImpact:-blackmagic"multiplier"basedonload-favorshallowerstatesunderheavyload
Limitations:-notverySMPormulti-clusteraware
idle-states{
CPU_STBY:standby{
compatible="qcom,idle-state-stby",
"arm,idle-state";
entry-latency-us=<1>;
exit-latency-us=<1>;
min-residency-us=<2>;
};
CPU_SPC:spc{
compatible="qcom,idle-state-spc",
"arm,idle-state";
entry-latency-us=<150>;
exit-latency-us=<200>;
min-residency-us=<2000>;
};
};
cpu@0{
[...]
cpu-idle-states=<&CPU_STBY&CPU_SPC>;
};
Documentation/devicetree/bindings/arm/idle-states.txt
structdev_pm_ops{...int(*runtime_suspend)(structdevice*dev);int(*runtime_resume)(structdevice*dev);int(*runtime_idle)(structdevice*dev);};
RuntimePMAPI
TellPMcorewhetherdeviceisinuse"I'mabouttouse it"-pm_runtime_get(),_sync()-Incrementusecount,pm_runtime_resume()
"I'mdone...fornow"-pm_runtime_put(),_sync()-Decrementusecount,pm_runtime_idle()
Similartolegacyclockframeworkusageforclockgating-clk_enable(),clk_disable()
Excellent:Documentation/power/pm_runtime.txt
RuntimePM:callbacks
Usecount:1-->0-->runtime_suspend()-prepareforlow-powerstate-ensurewakeupsenabled-savecontext
Usecount:0-->1-->runtime_resume()-restorecontext-etc.
Autosuspend---deferredruntimesuspend-pm_runtime_set_autosuspend_delay()-pm_runtime_mark_last_busy()-pm_runtime_put_autosuspend()
Idlefordevices:Grouping
Devicesareoftengroupedintodomains-powergatedasagroup-canbenested-powergatinghaslatencyimplications-externalregulatorrampup,etc.
Documentation/power/devices.txt
DynamicIdle
RuntimePM
IdleCPUs Idledevices
CPUidle
PMdomainsNOHZ_IDLE
PMQoS
µCCPU
L2$
GPU DSPCPUL2$
Memory
structdev_pm_domain{structdev_pm_opsops;...};
GenericPMDomains(genpd)
Generic implementationofPMdomains-BasedonruntimePM-Whenalldevicesindomainareruntimesuspended...genpd->power_off()-Whenfirstdeviceindomainisruntimeresumed...genpd->power_on()
genpdgovernors-allowcustomdecisionmakingbeforepowergating-e.g.per-deviceQoSconstraints
genpdinDTExamplegenpd:
power:power-controller@12340000{compatible="foo,power-controller";reg=<0x123400000x1000>;#power-domain-cells=<1>;};
Exampleusebydevice:
leaky-device@12350000{compatible="foo,i-leak-current";reg=<0x123500000x1000>;power-domains=<&power0>;};
From:Documentation/devicetree/bindings/power/power-domain.txt
RuntimePM,genpdideas
UnifyidleforCPUsanddevices
-useruntimePMforCPUs
-useruntimePMforCPU-connected"extras"
(e.g.GIC,PMUs,VFP,CoreSight,etc.)
-combineintoa"CPUgenpd"
ExtendtoCPUClusters
-modelclustersasgenpdmadeupof"CPUgenpd"s
plussharedL2$
-whenCPUsinclusterareidle(runtimesuspended)
clustergenpdcanhitlow-powerstate(off)
NextSteps
Quality:PMQoS
System-wide:e.gPM_QOS_CPU_DMA_LATENCY-UsedbyCPUidletodeterminedepthofidlestate
Per-device-attachQoSconstraintswithspecificdevices-genpd:preventPMdomainpoweroff-PM_QOS_FLAG_NO_POWER_OFF
-e.g.genpd:per-devicewakeuplatency-DEV_PM_QOS_RESUME_LATENCY-forusebygenpd"governors"
Documentation/power/pm_qos_interface.txt
Energy-awarescheduling:EAS
Anon-goingefforttoimproveenergyeffic iencyofthescheduler.
-Teachtheschedulernewheuristicsfortaskplacementto
takeadvantageofenergy-savinghardware
-IntegrateCPUidleandCPUfreqwiththescheduler
-schedulertracksloadstatisticsforitsowndecisionmaking
(e.g.taskplacement,loadbalancing,etc.)
-CPUidle/CPUfreqgovernordecisionsarebasedontheir
ownload-basedcalculations,heuristics(andsomeblackmagic).
Thesearetobereplacedbyscheduler-drivendata
WorkinProgress
Linux:PMdomains-overrideopsforagroupofdevices-ifPMdomainpresent,PMcoreusesdomaincallbacksinsteadoftype/class/bus
Documentation/cpuidle/*.txt
23
Idlefordevices:Grouping
Devicesareoftengroupedintodomains-powergatedasagroup-canbenested-powergatinghaslatencyimplications-externalregulatorrampup,etc.
Documentation/power/devices.txt
µCCPU
L2$
GPU DSPCPUL2$
Memory
structdev_pm_domain{structdev_pm_opsops;...};
Linux:PMdomains-overrideopsforagroupofdevices-ifPMdomainpresent,PMcoreusesdomaincallbacksinsteadoftype/class/bus
24
GenericPMDomains(genpd)
GenericimplementationofPMdomains-BasedonruntimePM-Whenalldevicesindomainareruntimesuspended...genpd->power_off()-Whenfirstdeviceindomainisruntimeresumed...genpd->power_on()
genpdgovernors-allowcustomdecisionmakingbeforepowergating-e.g.per-deviceQoSconstraints
25
genpdinDTExamplegenpd:
power:power-controller@12340000{compatible="foo,power-controller";reg=<0x123400000x1000>;#power-domain-cells=<1>;};
Exampleusebydevice:
leaky-device@12350000{compatible="foo,i-leak-current";reg=<0x123500000x1000>;power-domains=<&power0>;};
From:Documentation/devicetree/bindings/power/power-domain.txt
26
Quality:PMQoS
System-wide:e.gPM_QOS_CPU_DMA_LATENCY-UsedbyCPUidletodeterminedepthofidlestate
Per-device-attachQoSconstraintswithspecificdevices-genpd:preventPMdomainpoweroff-PM_QOS_FLAG_NO_POWER_OFF
-e.g.genpd:per-devicewakeuplatency-DEV_PM_QOS_RESUME_LATENCY-forusebygenpd"governors"
Documentation/power/pm_qos_interface.txt
27
µC
IntroductiontoKernel
PowerManagement
KevinHilman,L inaro
khilman@kernel.org
Ker nel Recipes 2015, Par is
CPUL2$
GPU DSPCPUL2$
Memory
Phew...
thatwasalljustabaddream
AnyQuestions?
DynamicPM- bas ed on "act i vi t y"- Act i ve PM Save power when doi ng "s om et hi ng"
- I dl e PM Save power when doi ng "not hi ng"
structdev_pm_opsExistsinstructd evice_ d river, structb us_ typ e, . . .
structdev_pm_ops{int(*prepare)(structdevice*dev);void(*complete)(structdevice*dev);int(*suspend)(structdevice*dev);int(*resume)(structdevice*dev);...int(*suspend_late)(structdevice*dev);int(*resume_early)(structdevice*dev);...};
->begin()
->prepare()
->enter()
->wake()
->finish()
->end()
echomem>/sys/power/state
->prepare()
->suspend()
->suspend_late()
->suspend_noirq()
->resume_noirq()
->resume_early()
->resume()
->complete()
Pla tfo rmspec i fic : structplatform_suspend_ops
Per-devic e :structdev_pm_ops
pm_wakeup_event()
WakeupfromSuspendSub system/Drivercontrol:-device_init_wakeup(dev,bool)-dev_pm_set_wake_irq()-dev_pm_clear_wake_irq()
Whenwak eup occurs(e.g. inISR):-pm_wakeup_event()
Enab le/d isab lefromusersp ace:-/sys/devices/.../power/wakeup
ActivePM:UnderlyingFrameworks
Frequenc ysc a l ing :c loc k framework-clk_get_rate()-clk_set_rate()
Vo l tage sc a l ing :regu la to rframework-regulator_get_voltage()-regulator_set_voltage()-Documentation/power/regulator/consumer.txt
Examp le.. . drivers/cpufreq/cpufreq-dt.c
OperatingPerformancePointsOPPs
-tup leoffreq uency,minimumvoltage-Describ ed inDTcpu0:cpu@0{operating-points=</*kHzuV*/30000010250006000001200000800000131300010080001375000>;}
c.f.Documentation/power/opp.txt
CPUDVFS usingCPUFreq
-S elect"b est"OPPb ased onreq uirements
-p luggab legovernorsforselecting"b est"OPP-p erformance,p owersave, . . . -ond emand :h eursiticsb ased onload ,tunab le- interactive:ond emand ++,tuned forlatency
Documentation/cpu-freq/core.txt
. . . wh atab outd eviceDVFS?. . . . d evfreq
IdlePM:ticklessidle
CONFIG_NOHZ_IDLE=y
-stop p eriod ictick wh enid le-onlywak esfornext"event"orinterrup t
IdleforCPUs
CPUid lestatesh ave"d ep th "-morep owersavings- longerwak eup latency
S tateDefinitionsinDT-legacy:p latform-sp ecificd river
S tateentry-p latform-sp ecifich ook s-b ased oncompatiblestring
Idlefordevices:RuntimePM
-p er-d eviceid le-singled eviceatatime-id lenesscontrolled b yd river, b ased onactivity
-d evicesare ind epend ent-oned evicecannotp reventoth ersfromruntimesusp end ing
-d oesNOTaffectusersp ace
Don' twak eup .. .onlytop resssnoozeand gob ack tosleep
CPUid le :Howdeepto sleep?
drivers/cpuidle/governors/menu.c1)Break even po in t(basedon en te r/exi t times)- looks at pr edict able event s ( e. g. t im er s)- compar es against m in r esidency
2)La tenc yto le ranc e - checks Q oS (PM_QOS_CPU_DMA_LATENCY)- compar es against m in r esidency
3) Perfo rmanc e Impac t:- black m agic "m ult iplier " based on load- f avor shallower st at es under heavy load
Limitations:-notverySMPormulti-clusteraware
i d l e - s t a t e s {
C P U _ S T B Y : s t a n d b y {
c o m p a t i b l e = " q c o m , i d l e - s t a t e - s t b y " ,
" a r m , i d l e - s t a t e " ;
e n t r y - l a t e n c y - u s = < 1 > ;
e x i t - l a t e n c y - u s = < 1 > ;
m i n - r e s i d e n c y - u s = < 2 > ;
} ;
C P U _ S P C : s p c {
c o m p a t i b l e = " q c o m , i d l e - s t a t e - s p c " ,
" a r m , i d l e - s t a t e " ;
e n t r y - l a t e n c y - u s = < 1 5 0 > ;
e x i t - l a t e n c y - u s = < 2 0 0 > ;
m i n - r e s i d e n c y - u s = < 2 0 0 0 > ;
} ;
} ;
c p u @ 0 {
[ . . . ]
c p u - i d l e - s t a t e s = < & C P U _ S T B Y & C P U _ S P C > ;
} ;
D o c u m e n t a t i o n / d e v i c e t r e e / b i n d i n g s / a r m / i d l e - s t a t e s . t x t
structdev_pm_ops{
...
int(*runtime_suspend)(structdevice*dev);
int(*runtime_resume)(structdevice*dev);
int(*runtime_idle)(structdevice*dev);
};
RuntimePMAPI
Te l l PM c o re whe the rdevic e is in use"I'mabou tto u se it" -pm_runtime_get(),_sync() - I ncr em ent use count , pm _r unt im e_r esume( )
"I'mdone .. .f o rn ow"-pm_runtime_put(),_sync()-Decr em ent use count , pm _r unt im e_idle( )Sim ilar t o legacy clock f r am ewor k usage f or clock gat ing-clk_enable(),clk_disable()
Exc e l len t: Documentation/power/pm_runtime.txt
RuntimePM:callbacks
Use c oun t:1 -->0-->runtime_suspend()- pr epar e f or low- power st at e- ensur e wakeups enabled- save cont ext
Use c oun t:0 -->1-->runtime_resume()- r est or e cont ext- et c.
Aut osuspend - - - def er r ed r unt im e suspend- pm_runtime_set_autosuspend_delay()- pm_runtime_mark_last_busy()- pm_runtime_put_autosuspend()
Idlefordevices:Grouping
Devic esa re o ften groupedin to doma ins-powerga tedasa group-c an be nested-powerga ting hasla tenc yimpl ic a tions-e xte rna l regu la to rrampup,e tc .Documentation/power/devices.txt
Static DynamicSuspendResume
ActiveIdle
OPPs
CPUfreqRuntimePM
Wakeups
IdleCPUs Idledevices
CPUidle
PMdomainsNOHZ_IDLE
PMQoS
Clocks Regulators
µC
CPUL2$
GPU DSPCPUL2$
Memory
structdev_pm_domain{
structdev_pm_opsops;
...
};
GenericPMDomains(genpd)
Generic implemen ta tion o fPM domains-Basedon run time PM-When a l l devic esin doma in a re run time suspended...genpd->power_off()-When fi rstdevic e in doma in isrun time resumed...genpd->power_on()
genpdgove rno rs-a l l owc ustomdec ision mak ing be fo re powerga ting -e .g .pe r-devic e QoSc onstra in ts
genpdinDTExample genpd:power:power-controller@12340000{
compatible="foo,power-controller";
reg=<0x123400000x1000>;
#power-domain-cells=<1>;
};
Example use bydevic e :leaky-device@12350000{
compatible="foo,i-leak-current";
reg=<0x123500000x1000>;
power-domains=<&power0>;
};
Fr om : Documentation/devicetree/bindings/power/power-domain.txt
RuntimePM,genpdideas
Uni fy id le fo rCPUsanddevic es
- use r unt im e PM f or CPUs
- use r unt im e PM f or CPU- connect ed " ext r as"
( e. g. G I C, PMUs, VFP, Cor eSight , et c. )
- combine int o a " CPU genpd"
Extendto CPUCluste rs
- m odel clust er s as genpd m ade up of " CPU genpd" s
plus shar ed L2$
- when CPUs in clust er ar e idle ( r unt im e suspended)
clust er genpd can hit low- power st at e ( of f )
NextSteps
Quality:PMQoS
System-wide :e .g PM_QOS_CPU_DMA_LATENCY- Used by CPUidle t o det erm ine dept h of idle st at e
Per-devic e- at t ach Q oS const r aint s wit h specif ic devices- genpd: pr event PM domain power of f - PM_QOS_FLAG_NO_POWER_OFF
- e. g. genpd: per - device wakeup lat ency - DEV_PM_QOS_RESUME_LATENCY - f or use by genpd " gover nor s"
Documentation/power/pm_qos_interface.txt
Energy-awarescheduling:EAS
Anon -go ing e ffo rt to improve ene rgye ffic ienc yo fthe sc hedu le r.
-Teac h the sc hedu le rnewheu ristic sfo rtask p lac ementto
tak e advan tage o fene rgy-saving hardware
-In tegra te CPUid le andCPUfreqwi th the sc hedu le r
-sc hedu le rtrac k sloadsta tistic sfo r i tsown dec ision mak ing
(e .g .task p lac ement, l oadba lanc ing ,e tc .)
-CPUid le /CPUfreqgove rno rdec isionsa re basedon the i r
own load-basedc a lc u la tions,heu ristic s(andsome b lac k magic ).
These a re to be replac edbysc hedu le r-driven da ta
WorkinProgress
Complexityisgrowing...-moreCPUs-moreintegrateddevices-morepowerdomains-microcontrollers-firmware,etc.
Kernel�is�evolving....
Drivermodel: keyconcept
S taticPM,S ystemPM-trad itionalsusp end /resumeCONFIG_PM_SLEEP=y-systemwid e,alld evices-initiated b yusersp ace-anyd evicecanp reventsusp end
-usersp aceis"frozen" ( c. f . Documentation/power/freezing-of-tasks.txt)
MUSTRead :Documentation/power/devices.txt
Linux:PM domains-ove rride opsfo ra g roupo fdevic es- i fPM domain presen t,PM c o re usesdoma in c a l lbac k sinsteado ftype /c lass/bus
Documentation/cpuidle/*.txt
28
IntroductiontoKernelPowerManagementKevinHilman,Linarokhilman@kernel.org
KernelRecipes2015,Paris
pm_wakeup_event()
RuntimePM,genpdideas
UnifyidleforCPUsanddevices-useruntimePMforCPUs-useruntimePMforCPU-connected"extras"(e.g.GIC,PMUs,VFP,CoreSight,etc.)-combineintoa"CPUgenpd"
ExtendtoCPUClusters-modelclustersasgenpdmadeupof"CPUgenpd"splussharedL2$-whenCPUsinclusterareidle(runtimesuspended)clustergenpdcanhitlow-powerstate(off)
NextStepsEnergy-awarescheduling:EAS
Anon-goingefforttoimproveenergyefficiencyofthescheduler.
-Teachtheschedulernewheuristicsfortaskplacementtotakeadvantageofenergy-savinghardware
-IntegrateCPUidleandCPUfreqwiththescheduler-schedulertracksloadstatisticsforitsowndecisionmaking(e.g.taskplacement,loadbalancing,etc.)
-CPUidle/CPUfreqgovernordecisionsarebasedontheirownload-basedcalculations,heuristics(andsomeblackmagic).
Thesearetobereplacedbyscheduler-drivendata
WorkinProgress
29
RuntimePM,genpdideas
UnifyidleforCPUsanddevices-useruntimePMforCPUs-useruntimePMforCPU-connected"extras"(e.g.GIC,PMUs,VFP,CoreSight,etc.)-combineintoa"CPUgenpd"
ExtendtoCPUClusters-modelclustersasgenpdmadeupof"CPUgenpd"splussharedL2$-whenCPUsinclusterareidle(runtimesuspended)clustergenpdcanhitlow-powerstate(off)
NextStepsEnergy-awarescheduling:EAS
Anon-goingefforttoimproveenergyefficiencyofthescheduler.
-Teachtheschedulernewheuristicsfortaskplacementtotakeadvantageofenergy-savinghardware
-IntegrateCPUidleandCPUfreqwiththescheduler-schedulertracksloadstatisticsforitsowndecisionmaking(e.g.taskplacement,loadbalancing,etc.)
-CPUidle/CPUfreqgovernordecisionsarebasedontheirownload-basedcalculations,heuristics(andsomeblackmagic).
Thesearetobereplacedbyscheduler-drivendata
WorkinProgress
30
NextStepsEnergy-awarescheduling:EAS
Anon-goingefforttoimproveenergyefficiencyofthescheduler.
-Teachtheschedulernewheuristicsfortaskplacementtotakeadvantageofenergy-savinghardware
-IntegrateCPUidleandCPUfreqwiththescheduler-schedulertracksloadstatisticsforitsowndecisionmaking(e.g.taskplacement,loadbalancing,etc.)
-CPUidle/CPUfreqgovernordecisionsarebasedontheirownload-basedcalculations,heuristics(andsomeblackmagic).
Thesearetobereplacedbyscheduler-drivendata
WorkinProgress
31
µC
IntroductiontoKernel
PowerManagement
KevinHilman,L inaro
khilman@kernel.org
Ker nel Recipes 2015, Par is
CPUL2$
GPU DSPCPUL2$
Memory
Phew...
thatwasalljustabaddream
AnyQuestions?
DynamicPM- bas ed on "act i vi t y"- Act i ve PM Save power when doi ng "s om et hi ng"
- I dl e PM Save power when doi ng "not hi ng"
structdev_pm_opsExistsinstructd evice_ d river, structb us_ typ e, . . .
structdev_pm_ops{int(*prepare)(structdevice*dev);void(*complete)(structdevice*dev);int(*suspend)(structdevice*dev);int(*resume)(structdevice*dev);...int(*suspend_late)(structdevice*dev);int(*resume_early)(structdevice*dev);...};
->begin()
->prepare()
->enter()
->wake()
->finish()
->end()
echomem>/sys/power/state
->prepare()
->suspend()
->suspend_late()
->suspend_noirq()
->resume_noirq()
->resume_early()
->resume()
->complete()
Pla tfo rmspec i fic : structplatform_suspend_ops
Per-devic e :structdev_pm_ops
pm_wakeup_event()
WakeupfromSuspendSub system/Drivercontrol:-device_init_wakeup(dev,bool)-dev_pm_set_wake_irq()-dev_pm_clear_wake_irq()
Whenwak eup occurs(e.g. inISR):-pm_wakeup_event()
Enab le/d isab lefromusersp ace:-/sys/devices/.../power/wakeup
ActivePM:UnderlyingFrameworks
Frequenc ysc a l ing :c loc k framework-clk_get_rate()-clk_set_rate()
Vo l tage sc a l ing :regu la to rframework-regulator_get_voltage()-regulator_set_voltage()-Documentation/power/regulator/consumer.txt
Examp le.. . drivers/cpufreq/cpufreq-dt.c
OperatingPerformancePointsOPPs
-tup leoffreq uency,minimumvoltage-Describ ed inDTcpu0:cpu@0{operating-points=</*kHzuV*/30000010250006000001200000800000131300010080001375000>;}
c.f.Documentation/power/opp.txt
CPUDVFS usingCPUFreq
-S elect"b est"OPPb ased onreq uirements
-p luggab legovernorsforselecting"b est"OPP-p erformance,p owersave, . . . -ond emand :h eursiticsb ased onload ,tunab le- interactive:ond emand ++,tuned forlatency
Documentation/cpu-freq/core.txt
. . . wh atab outd eviceDVFS?. . . . d evfreq
IdlePM:ticklessidle
CONFIG_NOHZ_IDLE=y
-stop p eriod ictick wh enid le-onlywak esfornext"event"orinterrup t
IdleforCPUs
CPUid lestatesh ave"d ep th "-morep owersavings- longerwak eup latency
S tateDefinitionsinDT-legacy:p latform-sp ecificd river
S tateentry-p latform-sp ecifich ook s-b ased oncompatiblestring
Idlefordevices:RuntimePM
-p er-d eviceid le-singled eviceatatime-id lenesscontrolled b yd river, b ased onactivity
-d evicesare ind epend ent-oned evicecannotp reventoth ersfromruntimesusp end ing
-d oesNOTaffectusersp ace
Don' twak eup .. .onlytop resssnoozeand gob ack tosleep
CPUid le :Howdeepto sleep?
drivers/cpuidle/governors/menu.c1)Break even po in t(basedon en te r/exi t times)- looks at pr edict able event s ( e. g. t im er s)- compar es against m in r esidency
2)La tenc yto le ranc e - checks Q oS (PM_QOS_CPU_DMA_LATENCY)- compar es against m in r esidency
3) Perfo rmanc e Impac t:- black m agic "m ult iplier " based on load- f avor shallower st at es under heavy load
Limitations:-notverySMPormulti-clusteraware
i d l e - s t a t e s {
C P U _ S T B Y : s t a n d b y {
c o m p a t i b l e = " q c o m , i d l e - s t a t e - s t b y " ,
" a r m , i d l e - s t a t e " ;
e n t r y - l a t e n c y - u s = < 1 > ;
e x i t - l a t e n c y - u s = < 1 > ;
m i n - r e s i d e n c y - u s = < 2 > ;
} ;
C P U _ S P C : s p c {
c o m p a t i b l e = " q c o m , i d l e - s t a t e - s p c " ,
" a r m , i d l e - s t a t e " ;
e n t r y - l a t e n c y - u s = < 1 5 0 > ;
e x i t - l a t e n c y - u s = < 2 0 0 > ;
m i n - r e s i d e n c y - u s = < 2 0 0 0 > ;
} ;
} ;
c p u @ 0 {
[ . . . ]
c p u - i d l e - s t a t e s = < & C P U _ S T B Y & C P U _ S P C > ;
} ;
D o c u m e n t a t i o n / d e v i c e t r e e / b i n d i n g s / a r m / i d l e - s t a t e s . t x t
structdev_pm_ops{
...
int(*runtime_suspend)(structdevice*dev);
int(*runtime_resume)(structdevice*dev);
int(*runtime_idle)(structdevice*dev);
};
RuntimePMAPI
Te l l PM c o re whe the rdevic e is in use"I'mabou tto u se it" -pm_runtime_get(),_sync() - I ncr em ent use count , pm _r unt im e_r esume( )
"I'mdone .. .f o rn ow"-pm_runtime_put(),_sync()-Decr em ent use count , pm _r unt im e_idle( )Sim ilar t o legacy clock f r am ewor k usage f or clock gat ing-clk_enable(),clk_disable()
Exc e l len t: Documentation/power/pm_runtime.txt
RuntimePM:callbacks
Use c oun t:1 -->0-->runtime_suspend()- pr epar e f or low- power st at e- ensur e wakeups enabled- save cont ext
Use c oun t:0 -->1-->runtime_resume()- r est or e cont ext- et c.
Aut osuspend - - - def er r ed r unt im e suspend- pm_runtime_set_autosuspend_delay()- pm_runtime_mark_last_busy()- pm_runtime_put_autosuspend()
Idlefordevices:Grouping
Devic esa re o ften groupedin to doma ins-powerga tedasa group-c an be nested-powerga ting hasla tenc yimpl ic a tions-e xte rna l regu la to rrampup,e tc .Documentation/power/devices.txt
Static DynamicSuspendResume
ActiveIdle
OPPs
CPUfreqRuntimePM
Wakeups
IdleCPUs Idledevices
CPUidle
PMdomainsNOHZ_IDLE
PMQoS
Clocks Regulators
µC
CPUL2$
GPU DSPCPUL2$
Memory
structdev_pm_domain{
structdev_pm_opsops;
...
};
GenericPMDomains(genpd)
Generic implemen ta tion o fPM domains-Basedon run time PM-When a l l devic esin doma in a re run time suspended...genpd->power_off()-When fi rstdevic e in doma in isrun time resumed...genpd->power_on()
genpdgove rno rs-a l l owc ustomdec ision mak ing be fo re powerga ting -e .g .pe r-devic e QoSc onstra in ts
genpdinDTExample genpd:power:power-controller@12340000{
compatible="foo,power-controller";
reg=<0x123400000x1000>;
#power-domain-cells=<1>;
};
Example use bydevic e :leaky-device@12350000{
compatible="foo,i-leak-current";
reg=<0x123500000x1000>;
power-domains=<&power0>;
};
Fr om : Documentation/devicetree/bindings/power/power-domain.txt
RuntimePM,genpdideas
Uni fy id le fo rCPUsanddevic es
- use r unt im e PM f or CPUs
- use r unt im e PM f or CPU- connect ed " ext r as"
( e. g. G I C, PMUs, VFP, Cor eSight , et c. )
- combine int o a " CPU genpd"
Extendto CPUCluste rs
- m odel clust er s as genpd m ade up of " CPU genpd" s
plus shar ed L2$
- when CPUs in clust er ar e idle ( r unt im e suspended)
clust er genpd can hit low- power st at e ( of f )
NextSteps
Quality:PMQoS
System-wide :e .g PM_QOS_CPU_DMA_LATENCY- Used by CPUidle t o det erm ine dept h of idle st at e
Per-devic e- at t ach Q oS const r aint s wit h specif ic devices- genpd: pr event PM domain power of f - PM_QOS_FLAG_NO_POWER_OFF
- e. g. genpd: per - device wakeup lat ency - DEV_PM_QOS_RESUME_LATENCY - f or use by genpd " gover nor s"
Documentation/power/pm_qos_interface.txt
Energy-awarescheduling:EAS
Anon -go ing e ffo rt to improve ene rgye ffic ienc yo fthe sc hedu le r.
-Teac h the sc hedu le rnewheu ristic sfo rtask p lac ementto
tak e advan tage o fene rgy-saving hardware
-In tegra te CPUid le andCPUfreqwi th the sc hedu le r
-sc hedu le rtrac k sloadsta tistic sfo r i tsown dec ision mak ing
(e .g .task p lac ement, l oadba lanc ing ,e tc .)
-CPUid le /CPUfreqgove rno rdec isionsa re basedon the i r
own load-basedc a lc u la tions,heu ristic s(andsome b lac k magic ).
These a re to be replac edbysc hedu le r-driven da ta
WorkinProgress
Complexityisgrowing...-moreCPUs-moreintegrateddevices-morepowerdomains-microcontrollers-firmware,etc.
Kernel�is�evolving....
Drivermodel: keyconcept
S taticPM,S ystemPM-trad itionalsusp end /resumeCONFIG_PM_SLEEP=y-systemwid e,alld evices-initiated b yusersp ace-anyd evicecanp reventsusp end
-usersp aceis"frozen" ( c. f . Documentation/power/freezing-of-tasks.txt)
MUSTRead :Documentation/power/devices.txt
Linux:PM domains-ove rride opsfo ra g roupo fdevic es- i fPM domain presen t,PM c o re usesdoma in c a l lbac k sinsteado ftype /c lass/bus
Documentation/cpuidle/*.txt
32
Phew...
thatwasalljustabaddream
AnyQuestions?
Energy-awarescheduling:EAS
Anon-goingefforttoimproveenergyefficiencyofthescheduler.
-Teachtheschedulernewheuristicsfortaskplacementto
takeadvantageofenergy-savinghardware
-IntegrateCPUidleandCPUfreqwiththescheduler
-schedulertracksloadstatisticsforitsowndecisionmaking
(e.g.taskplacement,loadbalancing,etc.)
-CPUidle/CPUfreqgovernordecisionsarebasedontheir
ownload-basedcalculations,heuristics(andsomeblackmagic).
Thesearetobereplacedbyscheduler-drivendata
CreatedwithInkscape&Sozi
SlidesunderCC-BY-SA3.0
http://people.linaro.org/~kevin.hilman/conf/kr2015/
33
Recommended