L4/Darwin: Evolving UNIX Charles Gray Research Engineer, National ICT Australia charles.gray@nicta.com.au
Outline 1. Project Overview 2. BSD on the Mach microkernel 3. Porting Darwin to the L4 microkernel 4. Project Status 2
Darbat Overview • Para-virtualised Darwin kernel • L4 μ -kernel hypervisor • Isolated kernel and device drivers • Standard virtualisation benefits 3
Why? • Virtualisation • Flexibility • Robustness • Code size 4
Linux Kernel Size (LoC) 7,000,000 6,000,000 5,000,000 4,000,000 3,000,000 2,000,000 1,000,000 0 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 5
Mach • Once a hot research topic Application Application • Many attempts at BSD Process Mgr Disk on Mach File System Network • Darwin is a monolithic User Mach kernel Kernel Mach • Gave microkernels a Hardware bad name 6
What’s in a kernel? • XML parser • Decompression algorithms • Linker • Network routing • Device drivers • Strings 7
Mac OS X Architecture OS X App Darwin launchd UNIX App Aqua GUI User Kernel xnu Hardware 8
Darwin • Unique kernel design UNIX App OS X App ‣ Mach 3.0 μ -kernel User ‣ 4.4 BSD derivative Kernel ‣ I/O Kit device drivers BSD • Mac OS X applications • Full FreeBSD 5 UNIX Mach I/O Kit environment Hardware 9
BSD Layer listen() User fork() mmap() Kernel BSD HFS+ TCP UFS Threads Process UBC Scheduler Disk Network VM PCI Bus Mach I/O Kit interrupt 10
The I/O Kit User mach_msg() Kernel BSD HFS+ User Partition0 Partition1 Client paging Disk0 Disk1 Keyboard ATA NIC UHCI interrupt PCI Bus Mach I/O Kit 11
BSD and I/O Kit read() ioctl() User Kernel BSD HFS+ bdevsw Partition0 Partition1 Disk0 Disk1 SCSI ATA I/O Kit 12
L4 • 2nd generation u-kernel • Learn from mistakes of Mach • Pay attention to cache, TLB, complexity • Make microkernels work • 10-20x performance improvement over Mach 13
L4 μ -kernel Application OS Kernel Application Application User Kernel IPC Threads Address Spaces Scheduler L4 Hardware interrupt page-fault / exception ★ not to scale 14
Darbat • Decompose Darwin kernel • Tackle complexity problem • Add flexibility • Maintain (or improve) performance • All with binary compatibility 15
Darbat Model UNIX App OS X App BSD stub BSD stub BSD BSD Drv. Stub Drv. Stub I/O Kit I/O Kit Mach xnuglue Mach xnuglue User Kernel L4 timer interrupt Hardware 16
XNU on L4 page faults syscalls timer int. mask I/O Kit exception ISR Thread Work-loop Thread Mach 17
Server Consolidation xnu xnu • Multiple OS instances • Kernel support I/O Kit • Simplified driver model User Kernel L4 Hardware 18
Crashable Drivers • Drivers crash xnu ‣ Holding locks ‣ Hogging resources Network • Can isolate drivers Disk Stack Stack ‣ and keep performance User Kernel • Some devices still L4 critical Hardware 19
VM Aware Scheduling Application Application Application Application priority Application xnu xnu xnu User Kernel L4 Hardware 20
Reliable Servers • Microkernel is very xnu Key Mgr. resilient • Protect data from 3rd party modules I/O Kit Watchdog • Ensure reliable User execution of code Kernel • Cheaper software L4 solutions Hardware 21
Heterogeneous Systems xnu • L4 is OS (everything?) Wombat agnostic Linux ‣ Linux I/O Kit ‣ *BSD • Share devices User Kernel • Share file systems L4 Hardware 22
System Call Performance Mac OS X 10.4.7 Darbat 0.2 UNIX App UNIX App ~2500 cycles ~2400 cycles xnu User Kernel User xnu Kernel L4 Hardware Hardware mach_msg null operation 23
In-task Synchronisation Mac OS X 10.4.7 Darbat UNIX App UNIX App ~17,000 cycles ~6,500 cycles User User Kernel Kernel xnu L4 Hardware Hardware pthreads synchronisation 24
IPC Optimisation OS X OS X App App • L4 IPC is a subset of Mach IPC xnu • Applications rely on Mach semantics User Kernel • Optimisation for some L4 messages Hardware 25
Kernel Scripting • Sometimes you just xnu need a hack • In-kernel scripts get Python messy I/O Kit • Scheduling and locks User are a pain Kernel • Don’t compromise the L4 whole system Hardware 26
Lessons So Far • Darwin modularity • Binary compatibility • Mac OS X has bugs • Performance • Debugging 27
Future Work? • Further decomposition • Improved xnu and I/O Kit bindings • Usable system! • Experiment with features • System benchmarks 28
Summary • UNIX kernels are feature-packed • L4 is one option to address this problem • Extend UNIX kernel to meet modern usage Questions? 29
Recommend
More recommend