joining the herd of cats: how to work with the kernel ... · kernel developers have different...

72
Joining the herd of cats: how to work with the kernel development process Jonathan Corbet [email protected] Slides: http://lwn.net/talks/elc2007/

Upload: others

Post on 22-Jul-2020

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Joining the herd of cats:how to work with the 

kernel development process

Jonathan [email protected]

Slides: http://lwn.net/talks/elc2007/

Page 2: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

I:Introduction

Page 3: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Why?

“There are a number of very good Linux kernel developers, but they tend to get outshouted by a large crowd of arrogant fools. Trying to communicate user requirements to these people is a waste of time. They are much too 'intelligent' to listen to lesser mortals.”

-- Jack O'Quin, Linux audio developer

Page 4: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Why?

There is great value to working with the communityInfluence development directionsOffload code maintenanceBetter support for customersMore efficient developmentBenefit from community expertiseTake ownership of your platform – and make it better

Page 5: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Free software is different

Proprietary softwareProprietary software

Product driven

Free software

Process driven

Page 6: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Free software is different

Proprietary softwareProprietary software

Product driven

Top-down requirements

Free software

Process driven

Bottom-up requirements

Page 7: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Free software is different

Proprietary softwareProprietary software

Product driven

Top-down requirements

Short time horizon

Free software

Process driven

Bottom-up requirements

Long-term view

Page 8: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Free software is different

Proprietary softwareProprietary software

Product driven

Top-down requirements

Short time horizon

Internal QA

Free software

Process driven

Bottom-up requirements

Long-term view

External QA

Page 9: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Free software is different

Proprietary softwareProprietary software

Product driven

Top-down requirements

Short time horizon

Internal QA

Hierarchical decisions

Free software

Process driven

Bottom-up requirements

Long-term view

External QA

Consensus decisions

Page 10: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Free software is different

Proprietary softwareProprietary software

Product driven

Top-down requirements

Short time horizon

Internal QA

Hierarchical decisions

Private

Free software

Process driven

Bottom-up requirements

Long-term view

External QA

Consensus decisions

Public

Page 11: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Free software is different

Proprietary softwareProprietary software

Product driven

Top-down requirements

Short time horizon

Internal QA

Hierarchical decisions

Private

Complete control

Free software

Process driven

Bottom-up requirements

Long-term view

External QA

Consensus decisions

Public

Little control

Page 12: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

The kernel is even more different

Page 13: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

It's big

Over 2,000 contributors 3/2006 to 4/2007

Only 10 contributed over 1% of changes

Page 14: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

It's worldwide

Significant contributions fromNorth AmericaEuropeJapanSouth AmericaIndia...

Page 15: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

It's of great commercial interest

At least 2/3 of kernel work is by paid developers

Page 16: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

It's growing quickly

750,000 lines added 3/2006 to 3/2007

Page 17: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

It's the wild west

Page 18: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

It's the wild west

...but that is changing

Page 19: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

II:Processissues

Page 20: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Do: understand the patch lifecycle

Much developer pain results from a failure to understand how code gets into the kernel.

Page 21: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Patch lifecycle: the beginning

Page 22: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Patch Lifecycle: the RFC

Page 23: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Patch lifecycle: first code

Page 24: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Patch lifecycle: repairs

Page 25: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Patch lifecycle: wider testing

Page 26: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Finally: into the mainline

Page 27: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Patch lifecycle: repeat

Page 28: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Lifecycle: the corporate view

Page 29: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Do: communicate early

Let the community know what you are doing

Avoid duplication

Avoid mistakes

Page 30: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Do: release early

Big vendor mistake:“We'll release the code after it passes internal QA”

By then it is too late

Page 31: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Do: expect to make changes

No initial code submission is perfect

Kernel developers have different goals

Page 32: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

The kernel release cycle

Page 33: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

The kernel release cycle

Page 34: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Do: observe the merge window

“I'm really fed up with having to pull big changes after the merge window, because it just doesn't seem to let up. I'm going to go postal on the next maintainer who doesn't understand what 'merge window' and 'fixes only' means”

-- Linus Torvalds

Page 35: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

II:Patch

submission

Page 36: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Do: Send in your changes

Avoid having to carry changes out-of-tree

Draw attention to problems

Influence the direction of the kernel

Page 37: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Don't: send multipurpose patches

Patches should:Be small (if possible)Do exactly one thing

If you have a big change:Split it into independent pieces

Page 38: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Do: send bisectable patches

“git bisect” is a great tool for finding regressionsBinary search on the patch stream

To support bisect:Your patch series must work after every patch

Page 39: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Do: take care in submitting patches

Use diff -uNo MIME attachmentsDescribe them properly

A one-line summary at topLonger description below (if needed)Justify the patch

Include a Signed-off-by: lineAvoid word-wrapping

Thunderbird is especially bad here

See:Documentation/SubmittingPatches

Page 40: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Find the correct mailing list

linux-kernel is not the right place for all patches

Example: networking patches go to netdev

See:MAINTAINERSvger.kernel.org/vger-lists.html

Page 41: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Aside: the new linux­kernel subscriber

1) I want to be part of this, I'll subscribe

Page 42: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Aside: the new linux­kernel subscriber

1) I want to be part of this, I'll subscribe2) I have mail from Linus! Cool!

Page 43: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Aside: the new linux­kernel subscriber

1) I want to be part of this, I'll subscribe2) I have mail from Linus! Cool!

...I wish I understood it

Page 44: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Aside: the new linux­kernel subscriber

1) I want to be part of this, I'll subscribe2) I have mail from Linus! Cool!

...I wish I understood it3) Hmm...I have a lot of mail from Linus

Page 45: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Aside: the new linux­kernel subscriber

1) I want to be part of this, I'll subscribe2) I have mail from Linus! Cool!

...I wish I understood it3) Hmm...I have a lot of mail from Linus

...I thought he was a nicer guy than that.

Page 46: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Aside: the new linux­kernel subscriber

1) I want to be part of this, I'll subscribe2) I have mail from Linus! Cool!

...I wish I understood it3) Hmm...I have a lot of mail from Linus

...I thought he was a nicer guy than that.4) 350 new messages. Ouch!

...I was only gone for an hour...

Page 47: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Aside: the new linux­kernel subscriber

1) I want to be part of this, I'll subscribe2) I have mail from Linus! Cool!

...I wish I understood it3) Hmm...I have a lot of mail from Linus

...I thought he was a nicer guy than that.4) 350 new messages. Ouch!

...I was only gone for an hour...5) I'll post my great idea for using C++ in the kernel

Page 48: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Aside: the new linux­kernel subscriber

1) I want to be part of this, I'll subscribe2) I have mail from Linus! Cool!

...I wish I understood it3) Hmm...I have a lot of mail from Linus

...I thought he was a nicer guy than that.4) 350 new messages. Ouch!

...I was only gone for an hour...5) I'll post my great idea for using C++ in the kernel6) These people have no clue of how to program!

Page 49: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Aside: the new linux­kernel subscriber

1) I want to be part of this, I'll subscribe2) I have mail from Linus! Cool!

...I wish I understood it3) Hmm...I have a lot of mail from Linus

...I thought he was a nicer guy than that.4) 350 new messages. Ouch!

...I was only gone for an hour...5) I'll post my great idea for using C++ in the kernel6) These people have no clue of how to program!7) My full mailbox is making me miss those great

penny stock alerts.

Page 50: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Aside: the new linux­kernel subscriber

1) I want to be part of this, I'll subscribe2) I have mail from Linus! Cool!

...I wish I understood it3) Hmm...I have a lot of mail from Linus

...I thought he was a nicer guy than that.4) 350 new messages. Ouch!

...I was only gone for an hour...5) I'll post my great idea for using C++ in the kernel6) These people have no clue of how to program!7) My full mailbox is making me miss those great

penny stock alerts.8) Unsubscribe. I'll go run Windows now.

Page 51: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

On mailing lists

Ask whether you really need to read linux-kernelMany of us do

Consider a subsystem list instead

If so, read it sparinglyLook for interesting topics and contributors

Page 52: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Do: listen to reviewers

Reviewing patches is hard, thankless work

When a reviewer makes a commentSay “thanks”Respond politelyFix the problem (or justify the current code)

Page 53: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Don't: attack reviewers

...even if they are rude

Page 54: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Don't: take criticism personally

Patch reviewers do not hate you

They do not hate your company

They do not hate your employees

Page 55: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Requests for major changes

Reviewers may ask for big changesPush functionality into higher layersReimplement major functionalityClean up a longstanding mess

Their goals are different than yoursLong-term maintainability is key

Try to accommodate these requestsThey usually make sense in the long term

Page 56: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Do: Let go

Others will patch your codeAn Acked-by: for good changes is polite

They may replace it outright!Consider it the sincerest form of flattery

Once you release code under a free license...you no longer have controlIt gets better without work from you!

Page 57: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

III:Codingissues

Page 58: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Do: follow the coding style

Documentation/CodingStyle

Page 59: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Do: avoid unnecessary abstractions

Things to avoid:HAL layersUnused parameters “just in case”Single-line functions

Page 60: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

API stability

There is no stable internal kernel APIGet used to it

Ways to copeGet your code into the mainlinehttp://lwn.net/Articles/2.6-kernel-api

Page 61: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Don't: add multi­version code

Support the current mainline kernel...and no others

Page 62: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Do: clean up your messes

Breaking an internal API is OK...if there is a good reason for it

But: you have the responsibility to fix in-tree code

Page 63: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Don't add regressions

...even to fix something else

Page 64: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Don't: change the user­space API

Breaking applications is bad news

The API includesSystem call behavior/proc filesSysfs filesNetlink

Page 65: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Don't: assume all the world is a PC

Linux runs on all kinds of systemshandhelds to supercomputers32/64 bitSingle processor through thousands of processorsA few dozen architectures

Your code should build and work everywhere

In particular:Get your locking right from the beginning

Page 66: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Do: avoid silly mistakes

Use the tools:gcc -Wlockdepfault injection frameworkslab poisoningsparse...

Page 67: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Red flags

#ifdeftypedefsioctl()Silenceinline functionsHeavy stack usageUnnecessary abstractions

HAL layersSingle-line functionsUnused parameters

Page 68: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

IV:Finalnotes

Page 69: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Don't: submit tainted code

Read the Developer's Certification of OriginBe sure you mean it

Be very careful with reverse engineeringChinese wall approach should be used

Page 70: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Don't: ship binary­only modules

Legality of these modules is dubious

The benefit is even more dubious

Respect your customers: give them the source

Page 71: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Do: use the resources available

There is information and help out therekernelnewbies.orgKernel mentorsDocumentation/HOWTOLWN

Page 72: Joining the herd of cats: how to work with the kernel ... · Kernel developers have different goals. The kernel release cycle. The kernel release cycle ... Heavy stack usage Unnecessary

Do: join in and have fun

Questions....?