microdrivers a new architecture for device drivers vinod ganapathyarini balakrishnan michael...

33
Microdrivers A New Architecture for Device Drivers Vinod Ganapathy Arini Balakrishnan Michael Swift Somesh Jha HotOS XI, 8 th May 2007 Computer Sciences Department University of Wisconsin-Madison

Upload: mitchell-kay

Post on 28-Mar-2015

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Microdrivers A New Architecture for Device Drivers Vinod GanapathyArini Balakrishnan Michael SwiftSomesh Jha HotOS XI, 8 th May 2007 Computer Sciences

MicrodriversA New Architecture for Device Drivers

Vinod Ganapathy Arini Balakrishnan

Michael Swift Somesh Jha

HotOS XI, 8th May 2007

Computer Sciences DepartmentUniversity of Wisconsin-Madison

Page 2: Microdrivers A New Architecture for Device Drivers Vinod GanapathyArini Balakrishnan Michael SwiftSomesh Jha HotOS XI, 8 th May 2007 Computer Sciences

HotOS XI Microdrivers: A New Architecture for Device Drivers 2

Introduction Device drivers account for a large fraction

of kernel code• Over 70% in Linux [Chou et al., 2001]

Buggy device drivers are a major source of reliability problems• Account for over 85% of Windows XP crashes

[Orgovan and Tricker, 2003]

Page 3: Microdrivers A New Architecture for Device Drivers Vinod GanapathyArini Balakrishnan Michael SwiftSomesh Jha HotOS XI, 8 th May 2007 Computer Sciences

HotOS XI Microdrivers: A New Architecture for Device Drivers 3

Challenging to write and debug

Writing a device driver• Must handle asynchronous events• Must obey kernel programming rules

Debugging a device driver• Non-reproducible failures• Fewer advanced development tools

Many drivers written by non-kernel experts

Device drivers are hard to get right

Page 4: Microdrivers A New Architecture for Device Drivers Vinod GanapathyArini Balakrishnan Michael SwiftSomesh Jha HotOS XI, 8 th May 2007 Computer Sciences

HotOS XI Microdrivers: A New Architecture for Device Drivers 4

Macrokernels

Kernel Driver Device

Driver Device

Applications

Poor fault isolation

Page 5: Microdrivers A New Architecture for Device Drivers Vinod GanapathyArini Balakrishnan Michael SwiftSomesh Jha HotOS XI, 8 th May 2007 Computer Sciences

HotOS XI Microdrivers: A New Architecture for Device Drivers 5

Kernel

User-space device drivers

Driver

Device

Driver

Runtime

Device

Applications

Page 6: Microdrivers A New Architecture for Device Drivers Vinod GanapathyArini Balakrishnan Michael SwiftSomesh Jha HotOS XI, 8 th May 2007 Computer Sciences

HotOS XI Microdrivers: A New Architecture for Device Drivers 6

But…

Limited by existing kernel/driver interface [Van Maren, 1999]

• Written expecting local procedure calls

New interfaces (e.g., new system calls) New device drivers [Chubb 2004, Leslie et al., 2005]

Poor performance

Incompatible with commodity OS

Page 7: Microdrivers A New Architecture for Device Drivers Vinod GanapathyArini Balakrishnan Michael SwiftSomesh Jha HotOS XI, 8 th May 2007 Computer Sciences

HotOS XI Microdrivers: A New Architecture for Device Drivers 7

Kernel

Best of both worlds: Microdrivers

Applications

KerndriverDevice

Userdriver

Runtime

Runtime

Split device driver functionality

Microdriver

Performance-criticalfunctionality

Startup, shutdown,device configuration

Common caseRare case

Page 8: Microdrivers A New Architecture for Device Drivers Vinod GanapathyArini Balakrishnan Michael SwiftSomesh Jha HotOS XI, 8 th May 2007 Computer Sciences

HotOS XI Microdrivers: A New Architecture for Device Drivers 8

How to produce a microdriver?

Userdriver

Runtime

Use program analysis & transformation

Traditionaldevice driver

Splitter andCode generator

KerndriverRuntime

Page 9: Microdrivers A New Architecture for Device Drivers Vinod GanapathyArini Balakrishnan Michael SwiftSomesh Jha HotOS XI, 8 th May 2007 Computer Sciences

HotOS XI Microdrivers: A New Architecture for Device Drivers 9

How big is the kernel driver? Studied 455 drivers from Linux-2.6.18 Identified critical functions

• Interrupt handlers• Tasklets, bottom-halves• Supply/receive data to/from the device• Plus the functions that they transitively call

Analysis is automatic• Uses the call-graph of the device driver

Page 10: Microdrivers A New Architecture for Device Drivers Vinod GanapathyArini Balakrishnan Michael SwiftSomesh Jha HotOS XI, 8 th May 2007 Computer Sciences

HotOS XI Microdrivers: A New Architecture for Device Drivers 10

e100_xmit_frame

e100_exec_cmd

Page 11: Microdrivers A New Architecture for Device Drivers Vinod GanapathyArini Balakrishnan Michael SwiftSomesh Jha HotOS XI, 8 th May 2007 Computer Sciences

HotOS XI Microdrivers: A New Architecture for Device Drivers 11

e100_xmit_frame

e100_exec_cmd

Page 12: Microdrivers A New Architecture for Device Drivers Vinod GanapathyArini Balakrishnan Michael SwiftSomesh Jha HotOS XI, 8 th May 2007 Computer Sciences

HotOS XI Microdrivers: A New Architecture for Device Drivers 12

e100_xmit_frame

e100_exec_cmd

Page 13: Microdrivers A New Architecture for Device Drivers Vinod GanapathyArini Balakrishnan Michael SwiftSomesh Jha HotOS XI, 8 th May 2007 Computer Sciences

HotOS XI Microdrivers: A New Architecture for Device Drivers 13

26.1 20.6

72.2 73.992.2

79.4

7.827.8

0%

10%

20%

30%

40%

50%

60%

70%

80%

90%

100%

Network (134) SCSI (49) Sound (272) Average

Non-critical

Critical

In-kernel driver code is reduced

Page 14: Microdrivers A New Architecture for Device Drivers Vinod GanapathyArini Balakrishnan Michael SwiftSomesh Jha HotOS XI, 8 th May 2007 Computer Sciences

HotOS XI Microdrivers: A New Architecture for Device Drivers 14

Mechanics

Page 15: Microdrivers A New Architecture for Device Drivers Vinod GanapathyArini Balakrishnan Michael SwiftSomesh Jha HotOS XI, 8 th May 2007 Computer Sciences

HotOS XI Microdrivers: A New Architecture for Device Drivers 15

Kernel

Architecture of a microdriver

Applications

Device

Userdriver

Runtime Responsibilities• Communication• Object tracking• Recovery

KerndriverRuntime

Page 16: Microdrivers A New Architecture for Device Drivers Vinod GanapathyArini Balakrishnan Michael SwiftSomesh Jha HotOS XI, 8 th May 2007 Computer Sciences

HotOS XI Microdrivers: A New Architecture for Device Drivers 16

Communication Mechanisms for control and data transfer Control transfer:

• LRPC [Bershad et al., 1990], Nooks XPC [Swift et al., 2003]

• Stubs in kerndriver for userdriver functions• Upcall and downcall mechanism

Data transfer:• Copy function arguments• Copy shared data structures

Synchronization done by object tracker

Page 17: Microdrivers A New Architecture for Device Drivers Vinod GanapathyArini Balakrishnan Michael SwiftSomesh Jha HotOS XI, 8 th May 2007 Computer Sciences

HotOS XI Microdrivers: A New Architecture for Device Drivers 17

UserdriverKerndriver

Object tracking

0x128 0x512

0x196 0x248

0x128 0x196 0x202

Upcall

0x512 0x248 0x296

0x202 0x296

Synchronize shared data structures

Page 18: Microdrivers A New Architecture for Device Drivers Vinod GanapathyArini Balakrishnan Michael SwiftSomesh Jha HotOS XI, 8 th May 2007 Computer Sciences

HotOS XI Microdrivers: A New Architecture for Device Drivers 18

Object tracking: Key challenges

Challenging cases• Locks• Device memory and registers• DMA memory

Solution• Userdriver must synchronize and update

version seen by the kerndriver

Memory objects with special semantics

Page 19: Microdrivers A New Architecture for Device Drivers Vinod GanapathyArini Balakrishnan Michael SwiftSomesh Jha HotOS XI, 8 th May 2007 Computer Sciences

HotOS XI Microdrivers: A New Architecture for Device Drivers 19

Recovery Detect and recover from failed userdriver

• Ideally transparent to applications

Detection done at interface • Parameter checks and timeouts

Recovery – compatible with prior work• Shadow driver mechanism [Swift et al., 2004]

• SafeDrive recovery mechanism [Zhou et al., 2006]

Page 20: Microdrivers A New Architecture for Device Drivers Vinod GanapathyArini Balakrishnan Michael SwiftSomesh Jha HotOS XI, 8 th May 2007 Computer Sciences

HotOS XI Microdrivers: A New Architecture for Device Drivers 20

Benefits

Page 21: Microdrivers A New Architecture for Device Drivers Vinod GanapathyArini Balakrishnan Michael SwiftSomesh Jha HotOS XI, 8 th May 2007 Computer Sciences

HotOS XI Microdrivers: A New Architecture for Device Drivers 21

Kernel

Improved fault isolation

Applications

Device

Userdriver

Runtime

Fewer lines of in-kernel driver code

KerndriverRuntime

Page 22: Microdrivers A New Architecture for Device Drivers Vinod GanapathyArini Balakrishnan Michael SwiftSomesh Jha HotOS XI, 8 th May 2007 Computer Sciences

HotOS XI Microdrivers: A New Architecture for Device Drivers 22

Kernel

Good common-case performance

Applications

Device

Userdriver

Runtime

User/kernel crosses are infrequent

Performance-criticalfunctionality

KerndriverRuntime

Page 23: Microdrivers A New Architecture for Device Drivers Vinod GanapathyArini Balakrishnan Michael SwiftSomesh Jha HotOS XI, 8 th May 2007 Computer Sciences

HotOS XI Microdrivers: A New Architecture for Device Drivers 23

Kernel

Compatibility with commodity OS

Applications

Device

Userdriver

Runtime

Kernel/driver interface is unchanged

KerndriverRuntime

Page 24: Microdrivers A New Architecture for Device Drivers Vinod GanapathyArini Balakrishnan Michael SwiftSomesh Jha HotOS XI, 8 th May 2007 Computer Sciences

HotOS XI Microdrivers: A New Architecture for Device Drivers 24

Kernel

Compatibility with commodity OS

Applications

Device

Userdriver

Runtime

Can coexist with traditional drivers

DeviceDriver

KerndriverRuntime

Page 25: Microdrivers A New Architecture for Device Drivers Vinod GanapathyArini Balakrishnan Michael SwiftSomesh Jha HotOS XI, 8 th May 2007 Computer Sciences

HotOS XI Microdrivers: A New Architecture for Device Drivers 25

Kernel

Ease of driver development

Applications

Device

Userdriver

Runtime

More tools available for driver development

gdb,gprof,valgrind,…

KerndriverRuntime

Page 26: Microdrivers A New Architecture for Device Drivers Vinod GanapathyArini Balakrishnan Michael SwiftSomesh Jha HotOS XI, 8 th May 2007 Computer Sciences

HotOS XI Microdrivers: A New Architecture for Device Drivers 26

Pragmatics

Page 27: Microdrivers A New Architecture for Device Drivers Vinod GanapathyArini Balakrishnan Michael SwiftSomesh Jha HotOS XI, 8 th May 2007 Computer Sciences

HotOS XI Microdrivers: A New Architecture for Device Drivers 27

Generating a microdriver

Userdriver

Runtime

Traditional device driver

Splitter

Traditional device driver

Code generator

Marshalingannotations

KernUser

KerndriverRuntime

Page 28: Microdrivers A New Architecture for Device Drivers Vinod GanapathyArini Balakrishnan Michael SwiftSomesh Jha HotOS XI, 8 th May 2007 Computer Sciences

HotOS XI Microdrivers: A New Architecture for Device Drivers 28

Marshaling annotations

char *nullterm string; struct net_device *list next; struct pcnet32_rx_head *array(“rx_ringsize”)

rx_ring;

Program analysis algorithms to infer need for annotations

Need to serialize complex data structures

Page 29: Microdrivers A New Architecture for Device Drivers Vinod GanapathyArini Balakrishnan Michael SwiftSomesh Jha HotOS XI, 8 th May 2007 Computer Sciences

HotOS XI Microdrivers: A New Architecture for Device Drivers 29

Performance of a microdriver e1000 device driver from Linux-2.6.18

• Intel PRO/1000 gigabit network adapter

Methodology• Split into kerndriver and userdriver• Ran both halves in the kernel• Used delays to simulate user/kernel crosses• Infrastructure is still in construction!

Testbed• Dual-core 3Ghz Pentium-D machine.

Page 30: Microdrivers A New Architecture for Device Drivers Vinod GanapathyArini Balakrishnan Michael SwiftSomesh Jha HotOS XI, 8 th May 2007 Computer Sciences

HotOS XI Microdrivers: A New Architecture for Device Drivers 30

TCP-send performance

0

20

40

60

80

100

120

140

1 10 100 1000 10000 20000

ThroughputCPU

60 million machine cycles

26% rise

6.8% drop

Relativeperformance

Delay to simulate cost of user/kernel crossing (in microseconds)

Page 31: Microdrivers A New Architecture for Device Drivers Vinod GanapathyArini Balakrishnan Michael SwiftSomesh Jha HotOS XI, 8 th May 2007 Computer Sciences

HotOS XI Microdrivers: A New Architecture for Device Drivers 31

Open questions Will microdrivers improve system reliability

in practice?• Where are most of the bugs – in the kerndriver

or in the userdriver?

Will the transition to microdrivers expose otherwise latent bugs in device drivers?

Page 32: Microdrivers A New Architecture for Device Drivers Vinod GanapathyArini Balakrishnan Michael SwiftSomesh Jha HotOS XI, 8 th May 2007 Computer Sciences

HotOS XI Microdrivers: A New Architecture for Device Drivers 32

Microdrivers …

… improve fault isolation

… have good common-case performance

… are compatible with commodity OSes

… reduce the amount of code in the kernel

… permit the use of user-mode tools for driver development

… can be generated largely automatically from existing drivers

Page 33: Microdrivers A New Architecture for Device Drivers Vinod GanapathyArini Balakrishnan Michael SwiftSomesh Jha HotOS XI, 8 th May 2007 Computer Sciences

Vinod Ganapathy [email protected]

Arini Balakrishnan [email protected]

Michael Swift [email protected]

Somesh Jha [email protected]

MicrodriversA New Architecture for Device Drivers

Computer Sciences DepartmentUniversity of Wisconsin-Madison