Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

support kernel annotations for versioned vmlinux and kernel modules in collapse-perf #182

Merged
merged 3 commits into from
Jun 26, 2020

Conversation

AnderEnder
Copy link
Contributor

Support kernel annotations for versioned vmlinux and kernel modules

Backport of brendangregg/FlameGraph#232

Example of stack trace:

swapper     0 [012] 2281339.604067:   20834821 cycles:
        ffffffffc09ace93 bpf_prog_2b956549c660136a_uni_l4lb+0xb80 (bpf_prog_2b956549c660136a_uni_l4lb)
        ffffffffc087cbc9 mlx5e_xdp_handle+0xa9 (/lib/modules/5.4.14-cloudflare-2020.1.11/kernel/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.ko)
        ffffffffc0878d87 mlx5e_skb_from_cqe_linear+0xc7 (/lib/modules/5.4.14-cloudflare-2020.1.11/kernel/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.ko)
        ffffffffc087a254 mlx5e_handle_rx_cqe+0x64 (/lib/modules/5.4.14-cloudflare-2020.1.11/kernel/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.ko)
        ffffffffc087bb48 mlx5e_poll_rx_cq+0x808 (/lib/modules/5.4.14-cloudflare-2020.1.11/kernel/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.ko)
        ffffffffc087beee mlx5e_napi_poll+0xde (/lib/modules/5.4.14-cloudflare-2020.1.11/kernel/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.ko)
        ffffffffb8f03eaa net_rx_action+0x13a (/usr/lib/debug/boot/vmlinux-5.4.14-cloudflare-2020.1.11)
        ffffffffb94000e0 __softirqentry_text_start+0xe0 (/usr/lib/debug/boot/vmlinux-5.4.14-cloudflare-2020.1.11)
        ffffffffb886c8c0 irq_exit+0xa0 (/usr/lib/debug/boot/vmlinux-5.4.14-cloudflare-2020.1.11)
        ffffffffb9201908 do_IRQ+0x58 (/usr/lib/debug/boot/vmlinux-5.4.14-cloudflare-2020.1.11)
        ffffffffb9200a0f common_interrupt+0xf (/usr/lib/debug/boot/vmlinux-5.4.14-cloudflare-2020.1.11)
        ffffffffb8ebc022 cpuidle_enter_state+0xb2 (/usr/lib/debug/boot/vmlinux-5.4.14-cloudflare-2020.1.11)
        ffffffffb8ebc3c9 cpuidle_enter+0x29 (/usr/lib/debug/boot/vmlinux-5.4.14-cloudflare-2020.1.11)
        ffffffffb88960f8 do_idle+0x1b8 (/usr/lib/debug/boot/vmlinux-5.4.14-cloudflare-2020.1.11)
        ffffffffb88962c9 cpu_startup_entry+0x19 (/usr/lib/debug/boot/vmlinux-5.4.14-cloudflare-2020.1.11)
        ffffffffb8841383 start_secondary+0x143 (/usr/lib/debug/boot/vmlinux-5.4.14-cloudflare-2020.1.11)
        ffffffffb88000d4 [unknown] (/usr/lib/debug/boot/vmlinux-5.4.14-cloudflare-2020.1.11)

src/collapse/perf.rs Outdated Show resolved Hide resolved
@jonhoo
Copy link
Owner

jonhoo commented Jun 20, 2020

It'd be great to include the examples from the upstream PR as tests!
Also, you may want to rebase on the master I just pushed 😅

@codecov
Copy link

codecov bot commented Jun 20, 2020

Codecov Report

Merging #182 into master will increase coverage by 0.27%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #182      +/-   ##
==========================================
+ Coverage   90.25%   90.53%   +0.27%     
==========================================
  Files          16       17       +1     
  Lines        2238     2293      +55     
==========================================
+ Hits         2020     2076      +56     
+ Misses        218      217       -1     
Impacted Files Coverage Δ
src/collapse/mod.rs 66.66% <ø> (ø)
src/collapse/matcher.rs 100.00% <100.00%> (ø)
src/collapse/perf.rs 97.34% <100.00%> (-0.02%) ⬇️
src/collapse/common.rs 62.87% <0.00%> (+0.33%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e1bcecb...6570849. Read the comment docs.

@AnderEnder
Copy link
Contributor Author

AnderEnder commented Jun 20, 2020

@jonhoo, can we add regex lib? The draft implementation uses contains, while the proper one should check something like vmlinux[\d\w\-]*$

@jonhoo
Copy link
Owner

jonhoo commented Jun 20, 2020

I'd still prefer not to bring in regex, since I think these are pretty easy parsing cases:

fn is_vmlinux(s: &str) -> bool {
  if let Some(vm) = s.rfind("vmlinux") {
    s[vm..].chars().all(|c| c.is_ascii_alphanumeric() || c == '-')
  } else {
    false
  }
}

@AnderEnder
Copy link
Contributor Author

AnderEnder commented Jun 21, 2020

@jonhoo, I put the functions into separate module matcher. Can you confirm this implementation?

jonhoo
jonhoo previously approved these changes Jun 22, 2020
@jonhoo
Copy link
Owner

jonhoo commented Jun 22, 2020

Yes, that looks great, thanks!

@AnderEnder AnderEnder marked this pull request as ready for review June 22, 2020 22:28
@AnderEnder AnderEnder changed the title support kernel annotations for versioned vmlinux and kernel modules support kernel annotations for versioned vmlinux and kernel modules in collapse-perf Jun 22, 2020
@jonhoo
Copy link
Owner

jonhoo commented Jun 22, 2020

I'm surprised that this doesn't affect any of the tests.. We don't have any with versioned kernel symbols I suppose? Maybe it'd be good to add a short one? Not sure if you feel like it might be worth it?

@AnderEnder
Copy link
Contributor Author

@jonhoo, It would be good to add this case to test. Unfortunately I was not able to get the example and I do not want to create an artificial one instead.

@jonhoo
Copy link
Owner

jonhoo commented Jun 26, 2020

@AnderEnder Can't we use the ones in the original issue? Namely

        ffffffffb8f6abf0 nf_hook_slow+0x40 (/usr/lib/debug/boot/vmlinux-5.4.14-cloudflare-2020.1.11)
        ffffffffb8f74051 ip_local_deliver+0xd1 (/usr/lib/debug/boot/vmlinux-5.4.14-cloudflare-2020.1.11)
        ffffffffb8f7412c ip_rcv+0xbc (/usr/lib/debug/boot/vmlinux-5.4.14-cloudflare-2020.1.11)

and

swapper     0 [012] 2281339.604067:   20834821 cycles:
        ffffffffc09ace93 bpf_prog_2b956549c660136a_uni_l4lb+0xb80 (bpf_prog_2b956549c660136a_uni_l4lb)
        ffffffffc087cbc9 mlx5e_xdp_handle+0xa9 (/lib/modules/5.4.14-cloudflare-2020.1.11/kernel/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.ko)
        ffffffffc0878d87 mlx5e_skb_from_cqe_linear+0xc7 (/lib/modules/5.4.14-cloudflare-2020.1.11/kernel/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.ko)
        ffffffffc087a254 mlx5e_handle_rx_cqe+0x64 (/lib/modules/5.4.14-cloudflare-2020.1.11/kernel/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.ko)
        ffffffffc087bb48 mlx5e_poll_rx_cq+0x808 (/lib/modules/5.4.14-cloudflare-2020.1.11/kernel/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.ko)
        ffffffffc087beee mlx5e_napi_poll+0xde (/lib/modules/5.4.14-cloudflare-2020.1.11/kernel/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.ko)
        ffffffffb8f03eaa net_rx_action+0x13a (/usr/lib/debug/boot/vmlinux-5.4.14-cloudflare-2020.1.11)
        ffffffffb94000e0 __softirqentry_text_start+0xe0 (/usr/lib/debug/boot/vmlinux-5.4.14-cloudflare-2020.1.11)
        ffffffffb886c8c0 irq_exit+0xa0 (/usr/lib/debug/boot/vmlinux-5.4.14-cloudflare-2020.1.11)
        ffffffffb9201908 do_IRQ+0x58 (/usr/lib/debug/boot/vmlinux-5.4.14-cloudflare-2020.1.11)
        ffffffffb9200a0f common_interrupt+0xf (/usr/lib/debug/boot/vmlinux-5.4.14-cloudflare-2020.1.11)
        ffffffffb8ebc022 cpuidle_enter_state+0xb2 (/usr/lib/debug/boot/vmlinux-5.4.14-cloudflare-2020.1.11)
        ffffffffb8ebc3c9 cpuidle_enter+0x29 (/usr/lib/debug/boot/vmlinux-5.4.14-cloudflare-2020.1.11)
        ffffffffb88960f8 do_idle+0x1b8 (/usr/lib/debug/boot/vmlinux-5.4.14-cloudflare-2020.1.11)
        ffffffffb88962c9 cpu_startup_entry+0x19 (/usr/lib/debug/boot/vmlinux-5.4.14-cloudflare-2020.1.11)
        ffffffffb8841383 start_secondary+0x143 (/usr/lib/debug/boot/vmlinux-5.4.14-cloudflare-2020.1.11)
        ffffffffb88000d4 [unknown] (/usr/lib/debug/boot/vmlinux-5.4.14-cloudflare-2020.1.11)

@jonhoo jonhoo merged commit 1aa64a2 into jonhoo:master Jun 26, 2020
@jonhoo
Copy link
Owner

jonhoo commented Oct 6, 2020

Released in 0.10.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants