lca13: memory hotplug on android
DESCRIPTION
Resource: LCA13 Name: Memory Hotplug on Android Date: 08-03-2013 Speaker: Zach PfefferTRANSCRIPT
Memory Hotplug on Android
Memory Hotplug
● Increase/decrease the amount of memory at runtime
○ Two modes■ Logical Memory Hotplug■ Physical Memory Hotplug
Server Memory Hotplug
● Change the amount of memory● Install/remove DIMMs or NUMA-nodes
Mobile Memory Hotplug
● Increase/decrease the amount of memory at runtime
○ Power down memory to save power■ logical memory hotplug
Memory Hotplug Mobile Challenges
● Userspace driven○ echo offline >
/sys/devices/system/memory/memoryXXX/state
● Minutes to offline● Can fail
RAM Power Management
● Temperature Compensated Self Refresh (TCSR)
● Partial Array Self Refresh (PASR)● Deep Power-Down (DPD)
RAM Power Management [1]
● Automatic○ Temperature Compensated Self
Refresh (TCSR)■ When a RAM is cold the refresh
interval can be extended (saving power) [2]
■ Automatic
RAM Power Management [1]
● Manual○ Partial Array Self Refresh (PASR)
■ Can power down chunks (64 MB)■ Works with interleaved
○ Deep Power-Down (DPD)
RAM Power Management [1]
● Does this matter?○ 5% savings [2] (50 mW out of 1 W)
■ This is at runtime■ Can ship devices with less memory
● Yes Tim Bird, I can ship a 32 MB Android device
RAM Power Management [1]
● If big.LITTLE save 150 mW○ Assumptions
■ A9 core uses 300 mW■ A15 of this order■ A7 cores use 150 mW (look at the
radio usage)■ This is 15% power savings
Hack Approach
● Set aside a buffer apart from the kernel on PASR boundary
● On suspend, activate PASR○ Assumes buffer contents not important
Linux Approach
● Use a balloon that allocates from a Contiguous Memory Allocation (CMA) region during suspend
Mel Gorman's Idea (from Maxime)
1. Declare CMA big enough for PASR or DPD
2. At runtime, no CMA allocationsa. Linux uses the memory (cache,
userspace i.e. movable) (Questions)3. On idle, inflate the balloon
a. Allocate CMA buffers in the regionb. Pages are migrated (userspace) or
dropped (cache)
Mel Gorman's Idea Cont...4. If there's memory pressure during balloon
inflation Android's low memory killer kills lower rated processes or balloon inflation can stop
5. On wake-up deflate the balloon or wait until there's memory pressure to deflate it
Issues1. QoS
a. Some apps that need huge memory allocations can't fail (Camera)
2. Latencya. Some apps that need huge memory
allocations need to launch "fast."3. Hand of God
a. Two level VM scheme in Linux?
Future1. SMMU's coming, will help
Maxime Coquelin, ST-E
● First RFC○ http://lwn.net/Articles/478049/○ https://lkml.org/lkml/2012/1/30/215
● Second RFC [3]○ In progress
Docs
1. TN-46-12: Mobile DRAM Power-Saving Features/Calculations Introduction2. TECHNICAL NOTE Low Power Function of Mobile RAM Auto Temperature Compensated Self Refresh (ATCSR)
Technical Note E0599E20 (Ver.2.0)3. http://elinux.org/images/f/f3/Lf_elc12_pallardy.pdf