In July, Microsoft released a Linux driver to allow Linux to run better in a Hyper-V virtual machine: it was done in source code under the GPL. This was pretty big news at the time, and in September, more than 200 patches were committed by Greg Kroah-Hartman to introduce the driver into the staging tree.
The drivers required a "massive cleanup effort" to bring the code to a "semi-sane kernel coding style". This has elicited comments from the peanut gallery - and from some serious Linux kernel developers - about shoddy/crappy code from Microsoft.
My gut feeling was that this wasn't the case, so I dug in this weekend to all 212 patches to find out what this was about, and I did indeed satisfy myself that this wasn't any kind of shoddy effort, though it may have been a misjudgment on Microsoft's part.
The short version is that Microsoft wrote the driver in an obviously Window-y coding style, and though the code may be perfectly correct, the whole look and feel grates on anybody who does Linux kernel work all day. Most of Greg's changes were designed to transform the driver from a Windows coding style to a Linux coding style (this is about form, not substance).
Now most of you are probably thinking: "Duh. For a Linux driver you code to the Linux style. How hard could it be?", and this is a compelling argument that I believe will ultimately win the day.
But it's not a slam dunk: the Hyper-V driver is talking to Windows code on the other end of the hypervisor VMBUS, and that means at some level there is some shared code: put a message on the bus, take a message from the bus, define all the objects. There is a strong case to keep as much of the code the same as possible simply to avoid style-induced differences.
I don't know how VMWare is written, but it's not silly to suggest that both sides of the VMWare driver share common code. I bet the Xen driver does :-)
In any case, my point is not to argue that the Win32 coding style is appropriate for the Linux kernel — I don't think it is — but to note that the style used was perfectly consistent with the Windows programming style that's been in use for at least 20 years. I've written hundreds of thousands of lines to this style (though not on Linux).
This is in contrast to the whining on the Linux kernel mailing lists about how terrible the style was, obviously unaware that this is how it's done in the Win32 world, as if the Hyper-V driver people just made crap up out of thin air.
This is where having real cross-platform expertise can help understand things that Linux-only developers won't. Some will say it doesn't matter, but I believe that a broader perspective is better than a narrower one.
But don't believe me: look at the patches for yourself and make your own decision. To make it easier, I've created a new Tech Tip that links to every patch, includes the commit comment, and my own analysis, and I think it will show the driver in the proper light that thoughtful consideration requires.
This is an excellent article. I currently work for MS but previously was in the exclusive domain of linux. I felt very much how you described many of the people on those lists when I first arrived at MS. Everything was wrong and it made no sense. This was of course completely ignorant and in many ways I have found some great practices at MS that I think the linux community could learn from.
All that aside your analysis was done quite well and very even. I thank you for doing this and being so fair. I hope this driver is a step toward the two communities working toward the benefit of the science instead of the benefit of their own methods.
Posted by: Aaron | September 30, 2009 at 08:55 PM