5 ms·
Hi HN, this was my first attempt at writing any sort of kernel code. I would love to hear your thoughts on this experience and on the fixes I applied, especiall
by ksml 6y ago
Hi HN, this was my first attempt at writing any sort of kernel code. I would love to hear your thoughts on this experience and on the fixes I applied, especially from anyone with more Linux experience than me :)
- warybeary 6y agoHave you looked into using eBPF instead of writing a kernel module? http://ebpf.io http://ebpf.io for some more insights. At the very least, it'll provide some useful tooling for you to debug problems in kernel-space.
- ksml 6y agoI hadn't considered this! Can eBPF be used to access arbitrary kernel data structures, though?
- warybeary 6y agoYes (to a degree) :) Check out https://github.com/iovisor/bpftrace https://github.com/iovisor/bpftrace and the example tools/ for a taste. You'll likely want to play with kprobes/kretprobes.
- ksml 6y agoThis is really interesting; I hadn't realized it was so capable/general. I'll look into this. Thanks for the references!
- deleted 6y ago[deleted]
- lathiat 6y agoYou should also check out bpftrace which is a specific DSL to write both the kernel and userspace part in one language - rather than the mixed python/C approach people mostly took before that. And you can output things potentially as text or json for parsing. https://github.com/iovisor/bpftrace https://github.com/iovisor/bpftrace I would also strongly recommend Brendan Greggs book: http://www.brendangregg.com/bpf-performance-tools-book.html http://www.brendangregg.com/bpf-performance-tools-book.html
- ylyn 6y agoSeems like someone did try to get those functions exported, but the maintainer rejected it, saying that no driver should be poking so deep into fd internals. Makes sense. Your use case is kind of niche. https://lore.kernel.org/lkml/20180730163256.GC27761@infradead.org/ https://lore.kernel.org/lkml/20180730163256.GC27761@infradea... By the way, C Playground is really helpful for teaching an OS course!
- ksml 6y agoThat is really interesting and good to know -- thanks for that! I hope C Playground is helpful, and I'm building it with teaching in mind. If you teach anywhere and could find it useful, let me know!
- waiseristy 6y agoThat entire email chain was unpleasant. Are Linux maintainers typically that combative?
- Thorrez 6y ago> ... and there's a perfectly sane solution to that - it's called git rm. > The fundamental problem here (besides "who the hell thought that this Fine Piece Of Software belongs anywhere other than in /dev/null?") [...] Lol, is this a group of people trying to write software, or a group of people having a dissing contest?
- tinus_hn 6y agoIt’s the result of someone (appearing to be) trying to play politics to get their way, while their way is not the way the kernel works. Sounds harsh. Now for comparison try standing next to an electrician and suggest alternate ways of doing things that are dangerous and wrong.
- Thorrez 6y ago> It’s the result It could be handled differently. The kernel author could simply say "this isn't how the kernel works, so we cannot accept this". There isn't a need to come up with wacky insults, as humorous as they may be. > Sounds harsh. Now for comparison try standing next to an electrician and suggest alternate ways of doing things that are dangerous and wrong. To become an electrician you take classes and become certified. How does someone become a kernel developer? I would assume by interacting with other kernel developers, suggesting ideas, getting feedback on those ideas, etc. An electrician wiring a house is a single person job. An open source project is a team job, and there's a reason development takes place out in the open: so that others can contribute. If outside contributions to the project isn't allowed, why not make it a source available project instead of open source?
- ylyn 6y agoHere's a hack you could use to get around the functions not being exported: https://github.com/anbox/anbox-modules/blob/master/binder/deps.c https://github.com/anbox/anbox-modules/blob/master/binder/de...
- ksml 6y agoOh, that's clever! I might try that. I really don't feel comfortable building my own kernel
- loeg 6y agoDefinitely try to get comfortable with building a kernel eventually. You don't have to run it on your bare metal machine; you can boot test kernels in a VM. The actual test / development process is not especially different between kernel and modules.
- Soft 6y agoThis will stop working since kallsyms_lookup_name is no longer exported by recent kernels. See [1]. [1]: https://lwn.net/Articles/813350/ https://lwn.net/Articles/813350/