grafana / pyroscope

Continuous Profiling Platform. Debug performance issues down to a single line of code
https://grafana.com/oss/pyroscope/
GNU Affero General Public License v3.0
10.13k stars 614 forks source link

Fix issues when porting alloy/pyroscope to android #3582

Closed zmj64351508 closed 2 months ago

zmj64351508 commented 2 months ago

I'm porting alloy/pyroscope to the mobile phone running Android 14. And I found some issues:

  1. The config CONFIG_PID_NS is not set in standard Android kernel, which means /proc/self/ns/pid is not exist and alloy will exit with failure. The first commit fixed this issue by ignoring error when /proc/self/ns/pid doesn't exist.

  2. When kernel modules or bpf programs are dynamic loaded from userspace after kernel boot, the address in /proc/kallsyms may be unordered, which causes the origin code find wrong symbol. The second commit fixed this issue by sorting the symbol by address. Here's an example for such /proc/kallsyms:

    # cat /proc/kallsyms
    ...
    ffffffd6b60e2140 t cleanup_module       [bootprof]
    ffffffd6b60e53c0 d __this_module        [bootprof]  
    ffffffc0145a52cc t bpf_prog_98e4c662c49a1bca_xdp_drop_ipv4_u    [bpf]
    ffffffc0145ad4a8 t bpf_prog_a06399a1ec0a769e_schedcls_tether    [bpf]
    ffffffc012b4b218 t bpf_prog_e814348da2c722a4_schedcls_tether    [bpf]
    ...
CLAassistant commented 2 months ago

CLA assistant check
All committers have signed the CLA.

CLAassistant commented 2 months ago

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


mingjun.zhou seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

korniltsev commented 2 months ago

Thank you for the contribution. I left some comments.

korniltsev commented 2 months ago

Thank you for the contribution! I've created an issue to add an integration tests for these cases. Feel free to submit a PR if you want to https://github.com/grafana/pyroscope/issues/3588