From: M. R. B. <mr...@0x...> - 2001-08-01 01:02:33
|
Introduction ============ I've been working with the LinuxSH code for about 10 months now, and in that time I've come up with a few gripes and ideas concerning the core code base and the methods developers use to structure and write drivers. This RFC attempts to address some of the challenges I've faced writing code for LinuxSH, and it hopefully provides some constructive ideas that we can all use to better the code. To a lesser extent, it asks about the future of LinuxSH, in regards to the imminent release of 2.5.x. This RFC doesn't cover the specific APIs that would allow for a total code rewrite across all SH boards/platforms (I'm still working on those :), but it does talk about driver placement, arch/sh file organization, code reuse, and developers not being lazy when writing their code. Some of these ideas are taken from the Linux/MIPS port. The MIPS port has thus far been a good model for writing embedded systems code under Linux, most embedded platforms have homes under this tree. With the formation of the linux-mips tree (http://sf.net/projects/linux-mips), their focus is now on getting additions and patches tested and in the tree in a timely fashion. I believe it's beneficial to share concepts and code with MIPS rather than architectures that aren't traditionally suited for embedded boards, such as the i386. Current Situation ================= Inconsistency ------------- Looking over the arch/sh subdirectory, I find a number of things disturbing about the lack of consistency when targetting new boards. There are two toplevel board directories, overdrive and stboards. overdrive appears to contain code for the support of a single board, as does stboards. The remaining boards supported by LinuxSH are in various files in the kernel directory. Now, the new-machine.txt document in Documentation/sh does provide a starting point for adding a new SH board, but it doesn't talk about where to place other support code for the board, and it fails to mention the setup_<board>.c convention that the majority of boards follow. The result of placing board definition and support code in the kernel directory is that the directory appears cluttered, and this will only worsen as more boards are added. This also makes maintenence combersome, and discourages new developers from hacking on code (I say this because it's discouraged me a bit :). Another point of inconsistency was in the addition of the Maple Dreamcast drivers. Originally, they were placed in drivers/dreamcast, which completely goes against standard kernel semantics of driver placement. The Maple Bus is an input bus within the Dreamcast, with a variety of character-style input drivers, such as a mouse, keyboard, or joystick. Normally, system buses go into a drivers/<bus> subdirectory, and bus devices go under the respective driver interfaces they support, e.g. the Maple joystick device driver would live under drivers/char/joystick. All of the other device drivers that I've seen contributed by LinuxSH developers have followed the normal convention, so that was probably an isolated incident. The misplaced Maple drivers have since been fixed. Code Cleanliness ---------------- I don't want to take the time to site specific examples, because it would take a while :). But overall (just me manually viewing each file) the source files in arch/sh leave a lot to be desired. It looks like a lot of source come from developers who come from embedded backrounds, not bothering (or not knowing) about the kernel development guidelines. Of course, I could be wrong, and it's just laziness. I'm guilty of it too. Proposal for Change =================== Review ------ All code that is submitted to go into LinuxSH should be reviewed by all developers, where it's assumed that all interested LinuxSH developers are subscribed to the linuxsh-dev mailing list. If, after a 1-2 day period no one objects to the inclusion of the patch, and the submitting developer has write priveledges, she should feel free to apply the patch. If someone does object to the patch, however, then those two developers need to find a solution, and if that still fails, the group should arbitrate or NIIBE should step in and make the final call. The important thing is that *all* code, no matter how trivial, should be reviewed by the entire community. Drop-in Tree ------------ While talking to a linux-mips developer while updating the latest revision of LinuxSH, I came to a realization. NIIBE spends a significant time merging changes from upstream back into LinuxSH. Also, hosting the entire kernel and updating it is a substantial drain of space and bandwidth, especially since LinuxSH affects such a small portion of the kernel. Besides a few device drivers underneath the drivers/ tree, all LinuxSH code lives under arch/sh and include/asm-sh. The linux-mips project and ruby project (just two projects I've encountered that do this) use "drop-in trees". A drop-in tree only contains the code relevant to the project, so for LinuxSH, its drop-in tree would look like: linux/Documentation/sh/... linux/arch/sh/... linux/include/asm-sh/... linux/drivers/char/sh-sci.[hc] linux/drivers/char/ec3104_keyb.c linux/drivers/char/maple* linux/drivers/char/joystick/maplecontrol.c linux/drivers/maple/... So a developer would download the latest kernel and relevant patches, then download the LinuxSH drop-in tree. She runs a script called treelink.sh that symlinks the files from the drop-in tree on top of the upstream kernel. She can then build the kernel for her platform. This should also make NIIBE's job a lot easier, since he no longer would have to do branch merges with upstream, but only worry about the overall "sync" of the LinuxSH tree with the upstream tree. If there isn't a kernel-wide change that breaks LinuxSH functionality, then the tree remains synced. Drop-in trees also have the benefit of being small (a lot easier to shuffle than a 136M tree, IMO), and helps developers to be more focused. No Divergence ------------- Haven given it minimal thought, it makes no sense for the LinuxDC project to maintain another divergent tree, especially since the DC is just another embedded SH board, and SH development is centralized around LinuxSH. So all DC drivers will be added directly to the LinuxSH tree. LinuxDC would still remain to provide user support, but there's now a central place to grab and maintain the source. All SH boards and their drivers should live within LinuxSH. Another point about divergence: I've seen/made some changes to the drivers/net/8139too.c driver so that it can support the Dreamcast's Broadband Adapter. If we need to make changes to code that we don't maintain, we should make the effort to contact the maintainer to ensure that the code makes it upstream. If we don't do this, upstream will end up with shoddy support for our boards, i.e. as it stands the 2.4.7 8139too driver won't work properly with the DC BBA. Consistency ----------- We need to come up with the Standard way of adding new boards to the tree, while cleaning up the existing mess. The format that linux-mips finalized on (and I think it fits just as well with LinuxSH) is this: - Only processor, kernel, and processor module code should go into arch/sh/kernel. This directory should be "holy ground" - no board-specific hacks belong here. - System controllers, like the hd64465 and hd64461 (please help me out with others) that share common code between multiple boards should live in an arch/sh/<system controller> directory. Only boards that share a common system controller (does the 7750S fall into this category? Or is that processor-specific code?) should have a system controller placed there. - Each individual board that LinuxSH runs on should live in arch/sh/boards/<board>. The actual "reference" name of the board should be used, not the marketing name. So, a quick example of the new layout (a lot of files/boards ommitted): arch/sh/kernel/ arch/sh/hd64465/ arch/sh/hd64461/ arch/sh/solutionengine/ arch/sh/boards/hp620/ arch/sh/boards/hp680/ arch/sh/boards/hp690/ arch/sh/boards/dreamcast/ arch/sh/boards/cqreek/ ... arch/sh/mm/ arch/sh/lib/ arch/sh/boot/ I also think we need to split off PCI support into a seperate subdirectory, i.e. pci/, but I'm still working on that proposal so that can wait. Cleanliness ----------- C'mon folks, it's not that difficult to follow the guidelines set forth in CodingStyle and other documents that describe kernel development semantics. I have also been guilty of not doing this, and we need to make a concerted effort to make sure our code is clean. I know that most of us are embedded systems developers, who may not be as familiar with kernel development, but it's important that we strive to write high-quality code, especially since this all goes upstream, and once that happens, your support base gets much, much larger. Garbage In, Garbage Out - Just because a piece of code is "functional" doesn't mean it belongs in the tree, especially if it suffers from critical design flaws or doesn't follow kernel guidelines. We should be able to police ourselves, and we should never settle for shoddy code. A good place to look for kernel guidelines is, uh, in the kernel Documentation directory itself. CodingStyle, kbuild/, DocBook/, and the files of the subsystems of any drivers we develop should be consulted before we do *any* code or design. I've always looked at kernel sub-ports like LinuxSH as "role models" for young developers like myself who are looking for a fit in a smaller kernel project with a close-knit community of developers. We should set the right example for these developers by making sure we do the right thing from the start. The Future ---------- 2.5.x is almost upon us. Are we prepared for it yet? Besides that, what are some of our ideas in regards to providing better documentation and tool support? I think we should revisit the "roadmap" or "tasklist" and (if you have the time to be able to) start writing down deadlines for the things we want done. I didn't touch documentation at all in this RFC (or the lack thereof :), or some of the problems with using GNU tools with LinuxSH, hopefully we can see people getting more proactive around this. Conclusion ========== Besides the issues I've raised, I've always been impressed with the rapid progress of LinuxSH. The fact that NIIBE was able to quintiple the speed of his board within 3 kernel revisions is just amazing :). I think that if we start making the effort to write better code and establish a consistent interface, we can make even better progress. New SH developers looking to port LinuxSH to their favorite board will have a much easier time doing so. Patch review will allow us to ensure that the best code goes in, and will help minimize conflicts. Overall, we'll have a much better port. Comments? Marcus |
From: NIIBE Y. <gn...@m1...> - 2001-08-01 01:44:02
|
Thanks a lot. Well written. I think that change of structure and the move towards only maintaining SuperH portion are good idea. If possible, it's good we can adopt such a new way of development for 2.5. I'd like to add some. (1) "Patch Manager" We have "Patch Manager", but it's almost non-functional (no one care it). I think that the future direction is remove using "Patch Manager" and require people to send all the changes to review. (2) Changes done in mainline Occasionally, the changes will be done in the mainline source. We need to include the changes to our repository. This'd be a kind of special work. Does it require to send the changes to review? Who will do it, and how? Sometimes we can't identify who does the change and don't understand the intention why we need the change. (3) Testing It would be good if we can maintain some sort of success/failure table with version and/or date. It is good for tracking bug introduced. Performance test is also good. -- |
From: M. R. B. <mr...@0x...> - 2001-08-01 02:40:49
|
* NIIBE Yutaka <gn...@m1...> on Wed, Aug 01, 2001: > Thanks a lot. Well written. I think that change of structure and the > move towards only maintaining SuperH portion are good idea. If > possible, it's good we can adopt such a new way of development for > 2.5. > Well, I'm willing to be a bit more ambitious and commit to getting the current tree restructured, not waiting for 2.5. Sure it will take a lot of effort, but I think it will be beneficial in the long run. For August I have basically unlimited free time to commit to working on this. I can come up with a strategy for restructuring, when I get that finished I'll send it to the list for approval, is that ok? I can do my work on restructuring the tree in parallel with current LinuxSH development. The current LinuxSH code is based in the kernel/ CVS directory, I can start the restructuring work in a directory called linux/ at the same time. > > (1) "Patch Manager" > We have "Patch Manager", but it's almost non-functional (no one care > it). I think that the future direction is remove using "Patch > Manager" and require people to send all the changes to review. > I think that's a good idea. One more thing I wanted to point out but I forgot: in the mailing list section on the LinuxSH SF website, it mentions the linux-sh and linux-sh-ja mailing lists, but neglects to mention the linuxsh-dev and linuxsh-cvs lists. When I first looked at LinuxSH, I didn't realize that those lists existed, and I missed a good deal of discussion that only took place on the linuxsh-dev list. Could someone update that section to add those lists? > (2) Changes done in mainline > Occasionally, the changes will be done in the mainline source. > We need to include the changes to our repository. This'd be a kind > of special work. Does it require to send the changes to review? > Who will do it, and how? Sometimes we can't identify who does the > change and don't understand the intention why we need the change. > Well, by using a drop-in tree, we only have to worry about mainline changes to code that falls under the LinuxSH. From my understanding, anyone who attempted to patch LinuxSH from outside the community would have to consult with you as the LinuxSH maintainer. That's the advantage of using a drop-in tree as opposed to including the entire kernel source in CVS - if there is a "global" mainline change that somehow breaks LinuxSH functionality, all you have to do is fix that relevant portion in the drop-in tree - you don't have to patch everything. It should be easy to pick out individual patches that target LinuxSH code if that code comes from external sources. I believe the package named 'patchutils' (in Debian) allows you to pick out individual patches within a patchset. > (3) Testing > It would be good if we can maintain some sort of success/failure table > with version and/or date. It is good for tracking bug introduced. > Performance test is also good. That's a great idea :). Based on what you wrote earlier regarding the xengine performance, I'm eager to build the latest kernel for my Dreamcast to see how much better it runs compared to 2.4.3 :). Marcus |
From: Greg B. <gb...@po...> - 2001-08-01 09:28:43
|
"M. R. Brown" wrote: > > Well, I'm willing to be a bit more ambitious and commit to getting the > current tree restructured, not waiting for 2.5. Sure it will take a lot of > effort, but I think it will be beneficial in the long run. For August I > have basically unlimited free time to commit to working on this. I can > come up with a strategy for restructuring, when I get that finished I'll > send it to the list for approval, is that ok? I'm looking forward to it. > I can do my work on restructuring the tree in parallel with current LinuxSH > development. The current LinuxSH code is based in the kernel/ CVS > directory, I can start the restructuring work in a directory called linux/ > at the same time. > > > > > (1) "Patch Manager" > > We have "Patch Manager", but it's almost non-functional (no one care > > it). I think that the future direction is remove using "Patch > > Manager" and require people to send all the changes to review. Yes, sf's Patch Manager appears pretty much superfluous. We can't turn it off AFAIK, so we need to make sure people know not to use it. > I think that's a good idea. One more thing I wanted to point out but I > forgot: in the mailing list section on the LinuxSH SF website, it mentions > the linux-sh and linux-sh-ja mailing lists, but neglects to mention the > linuxsh-dev and linuxsh-cvs lists. When I first looked at LinuxSH, I > didn't realize that those lists existed, and I missed a good deal of > discussion that only took place on the linuxsh-dev list. Could someone > update that section to add those lists? Actually, I deliberately left lin...@sf... out because I was under the impression (apparently false) that it was nearly unused. Also it seems to me that it offers little advantage over or differentiation from the m17n.org list which it was meant to replace but which hasn't died. Frankly I think it should be killed off. As for linuxsh-cvs, it's there already. Perhaps you need to scroll down. > [...] That's the advantage of using a > drop-in tree as opposed to including the entire kernel source in CVS - if > there is a "global" mainline change that somehow breaks LinuxSH > functionality, all you have to do is fix that relevant portion in the > drop-in tree - you don't have to patch everything. Hah, if only it were so easy. A drop-in tree is a good idea but this is not a good reason for it. > It should be easy to pick out individual patches that target LinuxSH code > if that code comes from external sources. I believe the package named > 'patchutils' (in Debian) allows you to pick out individual patches within a > patchset. The problems arise when subtle things change in the mainline which are apparently unrelated to LinuxSH code but break it. For example, subtle behaviours of remap_page_range() changed between 2.4.0-test10 and 2.4.0, breaking my PCMCIA code. > > > (3) Testing > > It would be good if we can maintain some sort of success/failure table > > with version and/or date. It is good for tracking bug introduced. > > Performance test is also good. > > That's a great idea :). DGI (Damn Good Idea). Actually this was idea we had back in Mar 2000 but never got around to implementing. The dream was to have some kind of database attached to the SF website which people could update. Perhaps a less hi-tech approach would succeed ;-) Greg. -- If it's a choice between being a paranoid, hyper-suspicious global village idiot, or a gullible, mega-trusting sheep, I don't look good in mint sauce. - jd, slashdot, 11Feb2000. |
From: Masahiro A. <m-...@aa...> - 2001-08-01 02:00:37
|
I don't know if I'm eligible/qualified to comment, but want to add some noise(?) on this issue 8-) I've just read it, and at first glance, basically I'm with your opinion. I may find some place which I dislike sometime later, but I haven't for now. I'm embedded developer, and added code to support for our custom board. When I did that, I found the file placement in MIPS, and thought about following that. But as I was lazy, I didn't do what you have done with this document and just dropped code in existing directories. I believe your proposal on directory reorganization will benefit many, if not all. I like the idea of "drop-in tree" approach, but not sure if it works well in current situation. I've seen several files in kernel/ or mm/ modified for a while, and later that changes go into mainline. With "Cleanliness", I must admit I'm split-minded. I mean, I'm not with firm opinion on this yet. I can understand your point, but at the same time, "functional but ugly" code may benefit some others who need that feature early. I don't want to debate on this now, but just hope you may understand my uncertain feeling. I'm not a kernel hacker (at least yet, I think) but am an engineer who must release the outcome of my effort at my boss's request 8-< Well, no more personal complaints. As a final words, I think your document is constructive, worth considering for everyone, and can be a good starting point for the discussion. I hope this discussion will lead us to the new and higher ground at some time. ================================= Masahiro ABE, A&D Co., Ltd. Japan |
From: M. R. B. <mr...@0x...> - 2001-08-01 02:54:18
|
* Masahiro Abe <m-...@aa...> on Wed, Aug 01, 2001: > I don't know if I'm eligible/qualified to comment, but want to add some > noise(?) on this issue 8-) > Well, it was addressed to all LinuxSH developers, so that everyone could voice their opinions. Please, if you've got an opinion, let's hear it :). > > I like the idea of "drop-in tree" approach, but not sure if it works > well in current situation. I've seen several files in kernel/ or mm/ > modified for a while, and later that changes go into mainline. > Ah, ok. I'm sorry NIIBE I think I misunderstood what you wrote in your reply to the RFC. As far as these changes to mainline, it's just the issue of making sure they're synced for every kernel patchlevel, just like you would the full tree. If it's a mainline file, like something in kernel/ or mm/, then it should still be included in the drop-in tree. As far as any other special procedures and who will be responsible for doing that, well, I know yet :). For example in the ruby tree, there are files that ruby modifies that sit in other people trees, etc. Ruby even has an arch/sh/kernel/setup.c :). The ruby maintainer syncs the ruby drop-in tree with mainline on every major kernel release, so I would assume we'd do the same thing (or do it frequently). > With "Cleanliness", I must admit I'm split-minded. I mean, I'm not with > firm opinion on this yet. I can understand your point, but at the same > time, "functional but ugly" code may benefit some others who need that > feature early. I don't want to debate on this now, but just hope you may > understand my uncertain feeling. I'm not a kernel hacker (at least yet, > I think) but am an engineer who must release the outcome of my effort at > my boss's request 8-< Well, no more personal complaints. > Heh, I'm not a kernel hacker yet (I don't think I know enough about kernel development yet) either. But I do want to strive for quality code, and I believe that others should at least try to follow the guidelines set forth when developing new code. I do understand the sentiment of getting working code out there for everyone to use, but why not spend the extra day or week working on the code so that it's better quality? And while doing that you teach yourself more about how the underlying kernel works. Marcus |
From: M. R. B. <mr...@0x...> - 2001-08-01 03:06:41
|
* M. R. Brown <mr...@0x...> on Tue, Jul 31, 2001: > > As far as any other special procedures and who will be responsible for > doing that, well, I know yet :). > Erm, I meant I don't know yet :). Marcus |
From: Masahiro A. <m-...@aa...> - 2001-08-01 04:03:27
|
Hello, On Tue, 31 Jul 2001 21:46:36 -0500 "M. R. Brown" <mr...@0x...> wrote: > * Masahiro Abe <m-...@aa...> on Wed, Aug 01, 2001: > > > With "Cleanliness", I must admit I'm split-minded. I mean, I'm not with > > firm opinion on this yet. I can understand your point, but at the same > > time, "functional but ugly" code may benefit some others who need that > > feature early. I don't want to debate on this now, but just hope you may > > understand my uncertain feeling. I'm not a kernel hacker (at least yet, > > I think) but am an engineer who must release the outcome of my effort at > > my boss's request 8-< Well, no more personal complaints. > > > > Heh, I'm not a kernel hacker yet (I don't think I know enough about kernel > development yet) either. But I do want to strive for quality code, and I > believe that others should at least try to follow the guidelines set forth > when developing new code. I do understand the sentiment of getting working > code out there for everyone to use, but why not spend the extra day or week > working on the code so that it's better quality? And while doing that you > teach yourself more about how the underlying kernel works. It may not always be possible to spend the extra day, depending on the situation. I don't say that code quality can be neglected. It should be high. I may be thinking about the special case... In some case, bad code can be a starting point of polishment. Oh, this can be done with "published patch" approach also... Just my random thoughts, maybe not in a quality for the post ^^;) ================================= Masahiro ABE, A&D Co., Ltd. Japan |