简体   繁体   English

如何在Linux内核中添加代码?

[英]How to add code into the linux kernel?

I am studying how to analyse and evaluate the TCP/IP protocol stack of Linux. 我正在研究如何分析和评估Linux的TCP / IP协议栈。 My goal is to study the performance of the tcp/ip protocol stack as a whole, to study the time cost of each layer and interaction between the layers of tcp/p protocol and queuinf of the ip layer. 我的目标是研究整个tcp / ip协议栈的性能,研究每个层的时间成本以及tcp / p协议层与ip层队列之间的交互。

To do the above : I am using a probing node based schema to to study the internal behaviour of TCP/IP protocol of linux. 为此,请执行以下操作:我正在使用基于探测节点的架构来研究Linux的TCP / IP协议的内部行为。 probing node is a piece of code added into the kernel to record the information like timestamp, queuing length and size of packet. 探测节点是一段添加到内核中的代码,用于记录诸如时间戳,排队长度和数据包大小之类的信息。

my question : how to add the probing node into the kernel ? 我的问题:如何将探测节点添加到内核中?

You can use (for example) SystemTap , the main idea behind this tool is to put probing node somewhere: kernel or userspace program. 您可以使用(例如) SystemTap ,此工具背后的主要思想是将探测节点放在某个位置:内核或用户空间程序。

If you do not have time to learn SystemTap, you can just put some printk in the kernel and read them from dmesg . 如果您没有时间学习SystemTap,则可以在内核中放入一些printk并从dmesg读取它们。

In both cases, you are introducing a big delay in the network stack due to the prints. 在这两种情况下,由于打印,您都会在网络堆栈中引入很大的延迟。 In order to reduce the delay introduced by probing, I suggest you to use SystemTap, store all your time-sample somewhere and print only at the end of acquisition. 为了减少探测带来的延迟,建议您使用SystemTap,将所有时间样本存储在某个地方,并仅在采集结束时打印。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM