Live data from Hacker News

Linux Kernel Module Programming Guide

sysprog21.github.io

21–30 of 44 posts

Re: Linux Kernel Module Programming Guide

#21
post #12

I’ve always been fascinated by kernel development. Realistically though, what are some examples of useful modules someone could write without several years of practice?

Probably nothing that will get added to the upstream source but you could make infinite file system modules for things. Userspace FUSE would probably make more sense but this would be a good way to get started. The general vibe I got when looking in to this is that the Linux kernel has more than enough contributors right now so they make no effort to make it beginner friendly or offer an easy on ramp. IIRC Linus said…

And testing, I believe the Linux community needs more testers.

Re: Linux Kernel Module Programming Guide

#22

This looks really good. :) Pity it's on GitHub Pages though, so people using IPv6 only can't access it. :(

See if your router supports DNS64 (DNS server maps IPv4 addresses in responses to IPv6 addresses under a chosen prefix) and NAT64 (firewall translates IPv6 LAN packets with addresses under that prefix to the original IPv4 packets, and back). I don't know about consumer routers, but it's relatively straightforward to do on pfSense / OPNsense.

It doesn't work for protocols that embed IP addresses, like BitTorrent, since you'd need a protocol-aware proxy for that rather than just an IP firewall, but for something like HTTP there won't be any problem.

Re: Linux Kernel Module Programming Guide

#24
post #12

I’ve always been fascinated by kernel development. Realistically though, what are some examples of useful modules someone could write without several years of practice?

It's not so much that kernel development is all that difficult, but 99% of the things you could make that would be useful would be device drivers. And device driver development requires an understanding of digital logic and the domain-specific "hardware APIs" (registers and stuff) exposed by various types of hardware.

Re: Linux Kernel Module Programming Guide

#25
post #5

This looks really good. :) Pity it's on GitHub Pages though, so people using IPv6 only can't access it. :(

So offer to mirror it then. The D in git’s DVCS stands for “decentralised”. I’ve heard some dumb complaints in my time but the real beauty of this one is you made it on another site that’s IPv4 only (HN doesn’t yet support IPv6 either).

If it were something I was likely to be using a bunch, then I probably would.

Saying that it's a "dumb complaint" to point out that large parts of the world can't access the content is kind of taking the piss though. :(

Re: Linux Kernel Module Programming Guide

#26
post #6

This looks really good. :) Pity it's on GitHub Pages though, so people using IPv6 only can't access it. :(

Not the world's biggest fan of GitHub myself but to be fair they're about to support ipv6. They've started putting up AAAA records around other parts of the site if memory serves.

Cool, that's really good news. :)

Re: Linux Kernel Module Programming Guide

#27
post #7

This looks really good. :) Pity it's on GitHub Pages though, so people using IPv6 only can't access it. :(

Do you have real examples of people that actually have zero access to IPv4 sites, or is this just a theoretical concern?

Quite a few of our (sqlitebrowser.org) users weren't able to access our download server, nor nightly build server, until we made it available over IPv6 in addition to just IPv4.

Seems to be mainly people located in South East Asian countries, though I'd have to go trawling back through log history to get the exact details.

Re: Linux Kernel Module Programming Guide

#28
post #12

I’ve always been fascinated by kernel development. Realistically though, what are some examples of useful modules someone could write without several years of practice?

Probably nothing that will get added to the upstream source but you could make infinite file system modules for things. Userspace FUSE would probably make more sense but this would be a good way to get started. The general vibe I got when looking in to this is that the Linux kernel has more than enough contributors right now so they make no effort to make it beginner friendly or offer an easy on ramp. IIRC Linus said…

It really depends what you mean by making it "beginner friendly".

A lot of work goes into refactoring and cleaning up code, making things cleaner, adding documentation, adding static and dynamic checkers for locks, memory errors, and various other things, making useful common data structures and code into libraries, inspection and debugging tools, reimplementing as much hand-coded assembly as reasonably possible in C, adding a staging area in the tree and moving to a distributed vcs, there are automated CI tests that get kicked off when you post a patch to a mailing list.

In my opinion it is far nicer to develop for, and a lot of code is far nicer to read than it was 20 or even 10 years ago. It's simpler to write some basic hello world filesystem or device driver module because APIs have become a lot cleaner and there are a lot more checks. It is also now far easier let's say to develop a high performance multi-queue block IO subsystem that is mostly lock free and can steer interrupts to specific CPUs based on context and have all the platform specific PCI and interrupt issues and the different memory ordering behaviors of different CPUs all just work. Linux already has one of those though.

Outside of device drivers and new hardware enablement for really simple device types or minor updates to an existing device type, what the kernel is doing now is vastly more complicated. So it is a lot of work to make a significant useful change. This isn't because there is no interest in making it beginner friendly, it's because a lot more of the "easy" things are done.

Re: Linux Kernel Module Programming Guide

#29
post #12

I’ve always been fascinated by kernel development. Realistically though, what are some examples of useful modules someone could write without several years of practice?

Another way to learn how the kernel module work is by tracing the kernel code..

    Learn about FTRACE - https://jvns.ca/blog/2017/03/19/getting-started-with-ftrace/

    Use ftrace to trace your favor .ko
       - simple one such as serial port driver. 
       - usb driver
       - usb to serial port driver, 
       - usb camera driver
       - gpu driver (opensource intel/amd)

Re: Linux Kernel Module Programming Guide

#30

Earlier quoted context omitted.

Probably nothing that will get added to the upstream source but you could make infinite file system modules for things. Userspace FUSE would probably make more sense but this would be a good way to get started. The general vibe I got when looking in to this is that the Linux kernel has more than enough contributors right now so they make no effort to make it beginner friendly or offer an easy on ramp. IIRC Linus said…

It really depends what you mean by making it "beginner friendly". A lot of work goes into refactoring and cleaning up code, making things cleaner, adding documentation, adding static and dynamic checkers for locks, memory errors, and various other things, making useful common data structures and code into libraries, inspection and debugging tools, reimplementing as much hand-coded assembly as reasonably possible in C…

My source for this comment is the Linux Device Drivers Development book from about 2004 still being the primary source of information on linux development and when asked about an updated version the response was something like "Back when it was written we needed more developers on linux but not anymore". As well as the comment from linus which I can't find anymore where he says other OSS projects need help more than linux.
Post reply on HN