Linux Kernel Introduction

Post on 12-Jul-2015

1,380 views 6 download

transcript

Linux Device Drivers

Sarah SharpDec 6, 2014

Sarah Sharp

● USB 3.0 host controller driver author● Linux kernel developer for 9 years● Worked in Intel's Open Source

Technology Center (OTC) for 7 years● Driver maintainer for 5 years

How did I get intoopen source?

● Didn't program until college● Portland State University● My boyfriend introduced me to

– open source, Linux, rockets

Portland State Aerospace Society

Rockets and Open Source

How did I get intoLinux kernel development?

● Professor Bart Masseyintroduced me to– The local Linux kernel community

– Greg Kroah-Hartman

● Greg suggested usbfs2 project● Bart helped me get:

– College credit for kernel project

– Intel undergraduate research grant

How did I get ajob in open source?

● Bart encouraged me to present at OSCON on usbfs2

● Kristin Accardi was onOSCON paper selection committee

● Through network(Bart → Greg → Kristen)I got a job

Sarah Sharp: Linux kernelUSB 3.0 driver developer

● Hired by Intel in July 2007● USB 3.0 specification draft● FPGA prototypes● Driver merged in April 2009

What is it like to be aLinux kernel developer?

● very tight-knit group, very slow turn over● 80% of kernel developers are paid● 20% are volunteers and students● all work done through mailing lists● a few IRC channels● rarely get together in person

Linux kernel subsystems

● Many different parts of the kernel● Broken into subsystems● Each has a maintainer● Most have a mailing list● MAINTAINERS file● scripts/get_maintainer.pl

What DoSubsystem Maintainers Do?

● Experts in their particular field● Usually 5-20 years of experience● Approve changes to their area● Often have 1-4 sub-maintainers● This is how Linux scales trust

IntelLinux Kernel Maintainers

● ACPI - Rafael Wysocki, Zhang Rui● Bluetooth - Marcel Holtmann● NFC - Samuel Ortiz● USB 3.0 - Mathias Nyman● Intel graphics - Daniel Vetter● EFI - Matt Fleming● x86 - H. Peter Anvin, Peter Z● RAS, machine check - Tony Luck● Code ellision - Andi Kleen● NVMe - Matthew Wilcox

● IOMMU - Dave Woodhouse● Temperature - Fenghua Yu● DMA offload - Vinod Koul● Wimax - Inaky Perez-Gonzalez● Intel wifi - Johannes Berg● Intel idle - Len Brown● Intel ethernet - Jeff Kirsher, Jesse

Brandeburg, Carolyn Wyborny● Intel C600 SAS, IOAT - Dan

Williams● Serial, GMA500/600/3600, misc -

Alan Cox

What is Being aLinux Kernel Maintainer Like?

● Hundreds of emails a day● 1:Many relationship with

contributors● Rapid development cycle● Looking at long-term health

of the project● Maintains code for 3 - 20 years● Reputation is on the line for

each patch

“Meritocracy”

● Maintainers are vested● Developers will come and go● Long-standing contributors gain trust● Easier for them to do complex things● Harder for newcomers

Community Trust andSocial Engineering

● Build a trust relationship with maintainers– Review patches

– Ask intelligent questions

– Submit small bug fixes

● Learn community norms– Email format

– Coding style

– Testing

Tips forAsking Intelligent Questions

● Always Cc the maintainer● Do your research● Document where you looked● Be concise and precise● Ask a question you know the

answer to, then one you don't

Tips forBug Reporting

● Always Cc the maintainer● System information is crucial

– What hardware?

– What kernel, what distro

– 32-bit vs 64-bit

– lspci, lsusb, acpidump

● Reproducibility thinking● Be responsive● Hold onto hardware

Linux KernelQuality Assurance

● Regressions are not tolerated● Buggy new code is fixed or reverted● Shifting towards static analysis tools

– sparse, smatch, Coccinelle

● 0-day testing infrastructure● kselftest

Getting into Linux kernel development

● Read the code, review other people's patches● Participate and ask questions on the mailing list● First patch tutorial

– http://kernelnewbies.org/FirstKernelPatch

● Staging cleanup patches– http://kernelnewbies.org/CheckpatchTips

● Linux kernel exercises– http://eudyptula-challenge.org/

Leveling Up inLinux Kernel Development

● Larger patchsets● Use complex tools (sparse, Coccinelle)● Find an area you're passionate about● Look for todos, bugzilla entries● Before starting a large task:

– Always ask the maintainer

– build trust with the maintainer

Tips for Code Review

● Keep a list of the feedback● Address ALL feedback in revisions● Track changes in your cover letter● If you disagree with a maintainer,

back yourself up with facts● Maintainers don't care about your deadline● Code must be complete and clean● Duplicate code or drivers won't be accepted

More Linux Kernel Resources

● Linux Device Drivers book:http://lwn.net/Kernel/LDD3

● Linux Device Driver tutorial:https://github.com/gregkh/kernel-tutorial

● FOSS Outreach Program for Women (OPW)(paid open source and Linux kernel internships)http://gnome.org/opw

Photo Attribution

● Tux: http://upload.wikimedia.org/wikipedia/commons/thumb/b/b0/NewTux.svg/400px-NewTux.svg.png

● Jamey and Sarah Sharp: https://www.flickr.com/photos/igalko/7570033604

● Sarah Sharp and PSAS photos CC BY-SA-NC Sarah Sharp

● Bart Massey: https://www.flickr.com/photos/reidab/9326868060

● OSCON sign: https://www.flickr.com/photos/kubina/912778997

● USB 3.0 host PCI card: https://www.flickr.com/photos/hades2k/9069181710

● Logitech webcam: https://www.flickr.com/photos/bshunrichs/162199777

● Greg Kroah-Hartman: https://www.flickr.com/photos/tian2992/6208491794

● David Brownell: https://www.flickr.com/photos/13825348@N03/sets/72157608741347102/detail/

Photo Attribution

● Computer guts: https://www.flickr.com/photos/orijinal/4832982682

● Kernel Summit: https://www.flickr.com/photos/linuxfoundation/2987611750

● Mail: https://www.flickr.com/photos/donebythehandsofabrokenartist/15027178189

● Nerd merit badge: https://www.flickr.com/photos/momentum/4203541703

● Trust: https://www.flickr.com/photos/dobs/10726756606

● Question: https://www.flickr.com/photos/marcobellucci/3534516458

● Bug: https://www.flickr.com/photos/103499652@N04/14232715868

● Quality: https://www.flickr.com/photos/dieselbug2007/414348333

● Editing: https://www.flickr.com/photos/nics_events/2349631515