学习9-runqlat有一些问题求教
请问在handle_switch函数里对hist进行更新后是eBPF程序是如何把数据传输给用户空间命令行显示的呢?而且我也没有看到把hist进行存储,以供下一次更新。 有大佬知道怎么回事吗?
handle_switchupdated data stored in maphist- userspace program can access the same map as kernel program does, so it can also access
hist histdoesn't need to be stored by your program, its handled by kernel, and only a fd is provided to your program so you can operate on it
Thanks for your answer!
I have run the program by bash
The command is ./ecli package.json without any parameters.
I view the code, the information about nums of process among different durations is stored in the maps hists
Because I ran the program without any parameters, the hists has only one elem(hist) whose key is -1.
All of information to user space is stored in slots in the hist struct.
There is no user space code. So I am wondering how the bash print the result like this:
Tracing run queue latency... Hit Ctrl-C to end.
usecs : count distribution
0 -> 1 : 233 |*********** |
2 -> 3 : 742 |************************************ |
4 -> 7 : 203 |********** |
8 -> 15 : 173 |******** |
16 -> 31 : 24 |* |
32 -> 63 : 0 | |
64 -> 127 : 30 |* |
128 -> 255 : 6 | |
256 -> 511 : 3 | |
512 -> 1023 : 5 | |
1024 -> 2047 : 27 |* |
2048 -> 4095 : 30 |* |
4096 -> 8191 : 20 | |
8192 -> 16383 : 29 |* |
16384 -> 32767 : 809 |****************************************|
32768 -> 65535 : 64 |*** |
I konw the workflow about the kernel space, but I haven't seen any code about output in user space. Looking forward to your answer! @Officeyutong
Thanks for your answer! I have run the program by
bashThe command is./ecli package.jsonwithout any parameters. I view the code, the information about nums of process among different durations is stored in the mapshistsBecause I ran the program without any parameters, thehistshas only one elem(hist) whose key is -1. All of information to user space is stored inslotsin the hist struct.There is no user space code. So I am wondering how the bash print the result like this:
Tracing run queue latency... Hit Ctrl-C to end. usecs : count distribution 0 -> 1 : 233 |*********** | 2 -> 3 : 742 |************************************ | 4 -> 7 : 203 |********** | 8 -> 15 : 173 |******** | 16 -> 31 : 24 |* | 32 -> 63 : 0 | | 64 -> 127 : 30 |* | 128 -> 255 : 6 | | 256 -> 511 : 3 | | 512 -> 1023 : 5 | | 1024 -> 2047 : 27 |* | 2048 -> 4095 : 30 |* | 4096 -> 8191 : 20 | | 8192 -> 16383 : 29 |* | 16384 -> 32767 : 809 |****************************************| 32768 -> 65535 : 64 |*** |I konw the workflow about the kernel space, but I haven't seen any code about output in user space. Looking forward to your answer! @Officeyutong
eunomia-bpf automatically detects map types and decides how to show that. Related logic is in https://github.com/eunomia-bpf/eunomia-bpf/blob/291304bf415817d2f5b46a3655d9f9594b8672a6/bpf-loader-rs/bpf-loader-lib/src/export_event/event_handlers/sample_map.rs#L118
For runqlat, there is a special mark in its header file (See https://github.com/eunomia-bpf/bpf-developer-tutorial/blob/5e6225549b156670e3157bba36e3c5a47f57a838/src/9-runqlat/runqlat.bpf.c#L38), eunomia-bpf will parse this header to retrive these special marked maps, and use the corresponding way to show the data in it