Dual-AndroidTM on Nexus 10
2/11/2014 © Samsung Electronics 1
Samsung Research UK Presentation
for
FOSDEM 2014
2 © Samsung Electronics
Introduction
Feasibility: 2 copies of Android on Xen on ARM?
o Xen on mobile performance?
o Virtualized GPU required
Nexus 10 device used (SoC: Samsung Exynos 5250)
o CPU: ARM Cortex A15 (x2) : With virtualization extensions
o GPU: ARM Mali T604 (OpenGl ES2.0)
o Memory available: 2GB RAM, plenty of Flash
o Screen resolution: 2560x1504
3 © Samsung Electronics
Configuration
Software configuration – 2 VMs only
o DOM0 = 1st Android
o DOMU = 2nd Android
o Linux 3.4
o Android Jelly Bean 4.2
Xen 4.2 for ARM
o Virtualization extensions support
• vGIC2
• Two stage translation page tables, guest memory isolation by hardware.
• Generic timer for Hypervisor timer
• Neon SIMD support
• IOMMU (not fully supported yet so IPA=PA)
Parallel development in Samsung HQ to community
Xen DOM0 kernel DOMU kernel
Memory 1GB RAM 1GB RAM
SMP Dual-core Dual-core Single-core
I/O Pass through PV Drivers
Xen PVH Architecture
4 © Samsung Electronics
DOMU DOM0
Android
Jelly Bean 4.2
GPU
Mali T604
CPU 0
(Cortex A15)
Kernel
(PL1)
User
(PL0)
HYP
(PL2)
Android
Apps
Linux 3.4
HW CPU 1
(Cortex A15)
Android
Jelly Bean 4.2
Android
Apps
Linux 3.4
Xen on ARM
Rings Physical
Drivers
Back End
Drivers
Front End
Drivers
Display,
Touch
etc.
5 © Samsung Electronics
Mobile Virtualization
I/O Challenges – Mobiles have ~50 device drivers
o Sensors: Touch, gyro, proximity, ambient light
o Media: Display, GPU, Camera, Audio, Video
o Connectivity: Charger, USB, WiFi, Bluetooth
User Switching
o Xen scheduler runs as normal.
o “Foreground” VM – user devices require arbitration driver in DOM0
• Display
• Touch
Display
Switch
Foreground VM
6 © Samsung Electronics
Video
DOM0 – Blue Wallpaper DOMU – Orange Wallpaper
Switching icon
Demo video
o Switching between Android Icon or Volume key
o Angry Birds in DOMU Near-native performance of PV drivers
o Angry Birds in DOM0 and DOMU concurrently Two independent Android
o 3D Benchmark clip
Passthrough drivers PV Drivers
Android UI virtualization challenges
Android Jelly Bean
o Project Butter: Buttery smooth UI
o Triple buffering using ION memory allocated buffers, no FBdev
o New sync mechanism via fences.
o Hardware composition for the Surfaces
o So rendering to display is all closely integrated within the OS frameworks and
Kernel Subsystems (Surfaceflinger, Surfaceview, Gralloc , ION memory
allocator, Fence-sync, Display driver).
Para-virtualization of ION, Fence-Sync and Display using grant-memory and
eventchannels.
7 © Samsung Electronics
8 © Samsung Electronics
Near-Native Performance Challenges
60 frames per second = 16.6ms per frame
o GPU renders each surface GPU composes the surfaces frame
Virtualized graphics options
o API Remoting done above GPU driver for chipset portability
Android JB has “butter smooth” technology
o Triple buffering
o Needs reliable Vsync interrupt Xen event channel stressed
o Deferred waiting using sync points & fences
15 0 30 45 60 time (ms)
Composition frame buffers
0
1
2
0
1
2 App frame buffers
9 © Samsung Electronics
Results
0
20
40
60
80
100
120
140
160
0
10
20
30
40
50
60
70
Packets
/sec (
k)
FP
S
Dual-Android, GPU composition
DOM0 DOMU Packets/sec (k)
10 © Samsung Electronics
Event Channel Under Stress
DOMU Vsync arrival time delta
16.67
0
5
10
15
20
25
30
35
10 11 12 13 14 15 16 17 18 19 20
De
lta
Tim
e (
ms
)
Benchmark Time (sec)
Some
missed
events
11 © Samsung Electronics
Xen For Mobile
Multi-page ring
o Needed for throughput performance running benchmarks
o Ensure low-latency
Non-linear grant references
o Old grants are re-used. PV drivers assume linearity
RAM Allocation limit 512MB
o Buddy allocator is unable to allocate contiguous chunk of memory from the Domheap
memory
Per-VM interrupts unreliable when stressed
o Must ensure Vsync is received in DOMU with minimal latency
Contribution to community
o Samsung will work to share Xen changes with community
o Some code is proprietary
12 © Samsung Electronics
Conclusion
Two Android can run with near-native graphics performance
Xen runs well on mobile devices
Using PV drivers, no major changes to Xen architecture required
Android is a trademark of Google Inc.
The Android robot is reproduced or modified from work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License.
Linux® is the registered trademark of Linus Torvalds in the U.S. and other countries.
ARM is a registered trademark of ARM Limited. Mali is a trademark of ARM Limited.
STAR WARS and related properties are trademarks in the United States and/or in other countries of Lucasfilm Ltd. and/or its affiliates. © 2012 Lucasfilm Ltd. All rights reserved.
Angry Birds is a trademark of Rovio Entertainment Ltd.
13 © Samsung Electronics
Q&A