When should I write a Linux kernel module?

后端 未结 10 1031
礼貌的吻别
礼貌的吻别 2021-02-02 08:05

Some people want to move code from user space to kernel space in Linux for some reason. A lot of times the reason seems to be that the code should have particularly high priorit

10条回答
  •  不要未来只要你来
    2021-02-02 08:27

    If you just need lower latency, higher throughput, etc., it is probably cheaper to buy a faster computer than to develop kernel code.

    Kernel modules may be faster (due to less context switches, less system call overhead, and less interruptions), and certainly do run at very high priority. If you want to export a small amount of fairly simple code into kernel space, this might be OK. That is, if a small piece of code is found to be crucial to performance, and is the sort of code that would benefit from being placed in kernel mode, then it may be justified to place it there.

    But moving large parts of your program into kernel space should be avoided unless all other options are completely exhausted. Aside from the difficulty of doing so, the performance benefit is not likely to be very large.

提交回复
热议问题