Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

61
KERNEL DEVELOPMENT: DRAWING LESSONS FROM "MISTAKES" Japan Linux Symposium 2009 October 23, 2009 Toshiharu Harada [email protected] NTT DATA CORPORATION

Transcript of Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

Page 1: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

KERNEL DEVELOPMENT: DRAWING LESSONS FROM

"MISTAKES"

Japan Linux Symposium 2009October 23, 2009Toshiharu Harada

[email protected] DATA CORPORATION

Page 2: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

ABSTRACTS

Every kernel developer knows that Linux comes with plenty of precious documentation as an integral part. From coding style to how to post patches, almost everything has been documented. However, history shows that error is human nature. Sometimes developers do not well know Don’ts, but there are also cases when they make mistakes despite being aware of such rules. Why this happen is unsolved, but a documentation, so far missing, of the consequences of this misbehavior could discourage it. The presenter is project manager of TOMOYO Linux, a security enhancement feature merged in version 2.6.30. Thinking open-minded, he decided to share the errors his project made, wishing it could be a helpful warning to other projects, especially newcomers. In this presentation, it will try to explain the mistake circumstances in TOMOYO Linux project, highlighting the thoughts of project members and the community reactions.

Page 3: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

“Experience is the name everyone gives to his mistakes” --- Oscar Wild

Page 4: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

WHAT’S THIS ALL ABOUT

• Linux comes with a set of great documentation

•DOs and DON’Ts are there already

• Yet we keep on making mistakes

• Finding a missing piece

Page 5: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

WHAT IS MISSING?

• In my humble opinion:

• Human nature (hard to fix)

•Most of us don’t really like readings (hard to fix)

• Real-life examples taken from TOMOYO Linux project

Page 6: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

WHO AM I?

• Project manager of TOMOYO Linux

Page 7: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

OUCH, IS THIS “SECURE LINUX” TALK?

•No! This talk has no “security”, no “Policy” or “MAC” (so, please remain seated)

• If you are interested in them, contact me personally

Page 8: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

COVERED TOPICS

• Chapter 1:

• Where to find DOs and DON’Ts

• Chapter 2:

• TOMOYO Linux posting history overview

• Chapter 3:

• Step by step introDOs and DON’Ts of the TOMOYO Linux

Page 9: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

CHAPTER 1Where to find DOs and DON’Ts

Page 10: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

Gentle Reminder

Documentation is a part of Linux Kernel

After checking out the kernel, cd to “Documentation”

Problem is “there are just too many files and directories” and people prefer coding than reading

Page 11: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

How Great is It?

$Documentation/ManagementStyle

“Most people are idiots, and being a manager means you'll have to deal with it, and perhaps more importantly, that _they_ have to deal with _you_.”

“Thing will go wrong, and people want somebody to blame. Tag you’re it.”

Page 12: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

Minimal Reading

Entire Scheme

$Documentation/HOWTO

Submitting Patches

$Documentation/SubmitChecklist

$Documentation/CodingStyle

Page 13: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

References

Note that the title is “How to Participate in the Linux Community”

Making your code upstream means your participation in the Linux Community

Page 14: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

My favorite one

http://www.linuxfoundation.jp/jp_uploads/seminar20070710/Jon-Dev-Process.pdf

����������������� �����������������������

��������������� ��

� �������������� ���� �������

Page 15: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

CHAPTER 2TOMOYO Linux by Numbers

Page 16: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

"All Happy Families Resemble Each Other, Each Unhappy Family Is Unhappy in Its Own Way." - Leo Tolstoy

Page 17: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

3

Page 18: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

We were 3

Page 19: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

3

Page 20: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

3rd LSM module

Page 21: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

15

Page 22: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

Posted 15 times

Page 23: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

716

Page 24: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

Merged since 716 days after the first

post

Page 25: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

162

Page 26: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

Received 162 comments from

LKML

Page 28: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

CHAPTER 3Drawing Lessons from the “Mistakes”

of TOMOYO Linux Project

Page 30: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

DON’TSend URL

Send patches

Page 31: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

WHAT HAPPENED?

• I got a personal message from Stephen Smalley, a maintainer of that famous SELinux

–“If you really want feedback or to get your code into the kernel, you need to do more than post a URL to the code - you need to break your code down into a number of patches and post them, just like the AppArmor folks have been doing. “

Page 32: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

SO WE RUSHED TO POSTED PATCHES NEXT DAY

• Pavel Machek gave a comment

• “Looks whitespace-damaged to me.”

Page 33: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

DON’TIgnore the Linux standard coding style

Always apply checkpatch.pl

Page 34: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

DO

• Read the $Document/CodingStyle

• Check your code with $scripts/checkpatch.pl

• Also use other $scripts/check*.pl

Page 35: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

• Jiri Kosina pointed us to make patches bisectable

• “Just a trivial minor nitpick - IMHO this breaks bisectability. It might be better to add the Kconfig/Makefile patch at the end of the whole series, so that bisect doesn't end up in the tree in which Makefile references non-existing files/directories.”

Page 36: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

DO

• Add the Kconfig/Makefile patch at the end of the whole series, so that bisect doesn't end up in the tree in which Makefile references non-existing files/directories.”

Page 37: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

IN THE 3RD PATCH

• James Morris taught us series of patches should form a thread

• “I'd also suggest making all of the patches a reply to the first email, so they can be threaded.”

Page 38: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

DO

• Send series of patches as children of the first message so that they can form a thread

Page 39: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

• James Morris said:

• “Please use standard kernel list handling, per include/linux/list.h”

• YOSHIFUJI Hideaki also mentioned:

• You're introducing a custom API, which is open-coded repeatedly throughout your module.

• All linked lists (at least, new ones) must use the standard kernel list API.

Page 40: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

DON’TPropose new data structure

Use existing one

Page 41: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

IN THE 5TH POSTING

• James Morris suggested to CC netdev mailing list

• “You should send anything which touches core networking to netdev, too, and get an ack from one of the core developers there.”

Page 42: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

DO

• Carefully choose CCs and get a review from them

Page 44: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

DON’TTry to invent a new API

Respect a standard and follow one

Page 45: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

• Tetsuo and I knew that posting such patches will never be accepted

• However, we had been stuck and we couldn’t find another way

•Our posting was thoughtless, but we were so serious to make our code upstream

Page 46: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

IN THE 7TH POSTING

I changed my mind and wrote:

We apologize for the confusion we caused in the last posting, but we don't want to give up returning our work to the mainline. We cordially request LSM changes to pass vfsmount parameters.

Page 47: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

DON’TCordially ask to merge your code ;-)

Make good patches and post them

Page 48: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

• Stephen Smalley kindly responded on the list

–“Don't cordially request it - submit patches to make it happen.  Or work with others who have been submitting such patches. “

Page 49: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

• Serge E. Hallyn wrote:

Page 50: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

CONCLUSION

Page 51: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

•Our mistakes, presented in this slides, are merely the tip of the iceberg

•We made many failures and we sometimes behaved very badly

•Nevertheless, this Linux community reacted and even merged our code

Page 52: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

• Feedbacks were not limited by mailing list replies

• There were people who sent off-list messages and left advices in face

Page 53: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

WITH ALL MY EXPERIENCESI CAN SAY

• Linux is not just free code

• Linux is great because people are great

• Sending your code is a conversation with people

• They might not appear friendly for the first time, but try to speak them first

Page 54: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

ACKNOWLEDGMENTS

Page 55: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)
Page 56: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

Al Viro, Albert Cahalan, Alexey Dobriyan, Andi Kleen, Andrew Morton, Bodo Eggert, Casey Schaufler, Chris Wright, Christoph Hellwig, Crispin Cowan, Daniel Walker, David Howells, David Lang, David P. Quigley, Greg KH, James Morris, Jamie Lokier, Jiri Kosina, Jonathan Corbet, Joshua Brindle, KaiGai Kohei, Kamezawa Hiroyuki, KOSAKI Motohiro, Kyle Moffett, Linus Torvalds, Matthew Wilcox, Miklos Szeredi, Paul E. McKenney, Paul Moore, Pavel Machek, Peter Dolding, Peter Zijlstra, Rik van Riel, Serge E. Hallyn, Seth Arnorld, Shaya Potter, Stephen Smalley, Tim Bird, Trond Myklebust, Valdis Kletnieks, William Leibzon, YOSHIFUJI Hideaki

Page 57: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

WE COULDN’T HAVE DONE IT WITHOUT YOUR HELP

Al Viro, Albert Cahalan, Alexey Dobriyan, Andi Kleen, Andrew Morton, Bodo Eggert, Casey Schaufler, Chris Wright, Christoph Hellwig, Crispin Cowan, Daniel Walker, David Howells, David Lang, David P. Quigley, Greg KH, James Morris, Jamie Lokier, Jiri Kosina, Jonathan Corbet, Joshua Brindle, KaiGai Kohei, Kamezawa Hiroyuki, KOSAKI Motohiro, Kyle Moffett, Linus Torvalds, Matthew Wilcox, Miklos Szeredi, Paul E. McKenney, Paul Moore, Pavel Machek, Peter Dolding, Peter Zijlstra, Rik van Riel, Serge E. Hallyn, Seth Arnorld, Shaya Potter, Stephen Smalley, Tim Bird, Trond Myklebust, Valdis Kletnieks, William Leibzon, YOSHIFUJI Hideaki

Page 58: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

AND OF COURSE•We thank NTT DATA CORPORATION for their support of

the project

Page 59: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

RELATED PRESENTATIONS

Realities of Mainlining- Case of the TOMOYO Linux Project -

Toshiharu Harada<[email protected]><[email protected]>

NTT DATA CORPORATION

July 9, 2008

Time to Glean!"#$%&'$()*+,-$.)/0&'1$2*3$0.4$%+0+'4

July 25, 2008

Toshiharu Harada<[email protected]>

Kentaro TakedaTetsuo Handa

NTT DATA CORPORATION

Page 60: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

What does it mean being an Open Source project manager

in Enterpriseenterprise edition

LinuxCon 2009 (Business)September 23, 2009Toshiharu Harada

<[email protected]>

NTT DATA CORPORATION

What does it mean being an Open Source project manager

in EnterpriseOpen Source Edition

LinuxCon2009 (Business)September 23, 2009Toshiharu Harada

<[email protected]>TOMOYO Linux Project

Page 61: Kernel Development: Drawing Lessons From "Mistakes" (Japan Linux Symposium 2009)

TRADEMARKS

• Linux is a registered trademark of Linus Torvalds in Japan and other countries

• TOMOYO is a registered trademark of NTT DATA CORPORATION in Japan