Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

libbpf-tools/cpudist: Allow cpudist to run on old kernels #4338

Merged
merged 1 commit into from
Nov 26, 2022

Conversation

woodpenker
Copy link
Contributor

According to #4231

Test OK on Ubuntu 20.04 with 5.4.0-97-generic kernel like this:

$ sudo ./cpudist  
libbpf: sched_switch is not found in vmlinux BTF
Tracing on-CPU time... Hit Ctrl-C to end.
^C
     usecs               : count    distribution
         0 -> 1          : 5        |**                                      |
         2 -> 3          : 6        |**                                      |
         4 -> 7          : 14       |*****                                   |
         8 -> 15         : 22       |*********                               |
        16 -> 31         : 29       |************                            |
        32 -> 63         : 28       |***********                             |
        64 -> 127        : 51       |*********************                   |
       128 -> 255        : 15       |******                                  |
       256 -> 511        : 17       |*******                                 |
       512 -> 1023       : 29       |************                            |
      1024 -> 2047       : 67       |****************************            |
      2048 -> 4095       : 89       |*************************************   |
      4096 -> 8191       : 90       |*************************************   |
      8192 -> 16383      : 95       |****************************************|

@@ -71,8 +71,7 @@ static __always_inline void update_hist(struct task_struct *task,
histp = bpf_map_lookup_elem(&hists, &id);
if (!histp)
return;
bpf_probe_read_kernel_str(&histp->comm, sizeof(task->comm),
task->comm);
BPF_CORE_READ_STR_INTO(&histp->comm, task, comm);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this and below BPF_CORE_READ will actually call kernel helpers instead of direct memory access. But I understand this is necessary for raw_tp. I think it is okay for portability perspective. We have quite a few tools still using kprobe which uses BPF_CORE_READ as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review, do you mean this will have a latency cost to use BPF_CORE_READ instead of direct mem access? Maybe another way is to separate each other with independent functions containing the same logic?

@yonghong-song yonghong-song merged commit 957569f into iovisor:master Nov 26, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants