-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: support versioned vmlinux and kernel modules (#182)
- Loading branch information
1 parent
e1bcecb
commit 1aa64a2
Showing
7 changed files
with
127 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
// Detects vmlinux in stack, with version or without. | ||
// | ||
// Examples: | ||
// | ||
// ffffffffb94000e0 __softirqentry_text_start+0xe0 (/usr/lib/debug/boot/vmlinux-5.4.14-cloudflare-2020.1.11) | ||
// 8c3453 tcp_sendmsg (/lib/modules/4.3.0-rc1-virtual/build/vmlinux) | ||
// 7d8 ipv4_conntrack_local+0x7f8f80b8 ([nf_conntrack_ipv4]) | ||
// | ||
#[inline] | ||
pub fn is_vmlinux(s: &str) -> bool { | ||
if let Some(vm) = s.rfind("vmlinux") { | ||
s[vm..].chars().all(|c| { | ||
c.is_ascii_alphanumeric() | ||
|| match c { | ||
'-' | '.' | '_' => true, | ||
_ => false, | ||
} | ||
}) | ||
} else { | ||
false | ||
} | ||
} | ||
|
||
// Detect kernel from module name, module file or from vmlinux | ||
#[inline] | ||
pub fn is_kernel(s: &str) -> bool { | ||
(s.starts_with('[') || s.ends_with(".ko") || is_vmlinux(s)) && s != "[unknown]" | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn is_vmlinux_true() { | ||
assert!(is_vmlinux("vmlinux")); | ||
assert!(is_vmlinux("vmlinux-5")); | ||
assert!(is_vmlinux("vmlinux-54")); | ||
assert!(is_vmlinux("vmlinux_54")); | ||
assert!(is_vmlinux("vmlinux-vmlinux")); | ||
assert!(is_vmlinux("vmlinux-5.4.14")); | ||
assert!(is_vmlinux("vmlinux-54-2020")); | ||
assert!(is_vmlinux("vmlinux-cloudflare")); | ||
assert!(is_vmlinux("vmlinux_cloudflare")); | ||
assert!(is_vmlinux("vmlinux-cloudflare-2020.1.11")); | ||
assert!(is_vmlinux("vmlinux-5.4.14-cloudflare-2020.1.11")); | ||
assert!(is_vmlinux("/usr/lib/debug/boot/vmlinux")); | ||
assert!(is_vmlinux( | ||
"/usr/lib/debug/boot/vmlinux-5.4.14-cloudflare-2020.1.11" | ||
)); | ||
} | ||
|
||
#[test] | ||
fn is_vmlinux_false() { | ||
assert!(!is_vmlinux("vmlinux/")); | ||
assert!(!is_vmlinux("vmlinux ")); | ||
assert!(!is_vmlinux("vmlinux+5")); | ||
assert!(!is_vmlinux("vmlinux,54")); | ||
assert!(!is_vmlinux("vmlinux\\5.4.14")); | ||
assert!(!is_vmlinux("vmlinux-Тест")); | ||
assert!(!is_vmlinux("vmlinux-cloudflare ")); | ||
assert!(!is_vmlinux("vmlinux-5.4.14-cloudflare-2020.1.11)")); | ||
assert!(!is_vmlinux("/usr/lib/debug/boot/vmlinu")); | ||
assert!(!is_vmlinux( | ||
"/usr/lib/debug/boot/vmlinu-5.4.14-cloudflare-2020.1.11" | ||
)); | ||
} | ||
|
||
#[test] | ||
fn is_kernel_true() { | ||
assert!(is_kernel("[")); | ||
assert!(is_kernel("[vmlinux")); | ||
assert!(is_kernel("[test")); | ||
assert!(is_kernel("[test]")); | ||
assert!(is_kernel(".ko")); | ||
assert!(is_kernel("module.ko")); | ||
assert!(is_kernel("vmlinux.ko")); | ||
assert!(is_kernel("vmlinux")); | ||
assert!(is_kernel(" [vmlinux")); | ||
assert!(is_kernel("vmlinux-5.4.14-cloudflare-2020.1.11")); | ||
assert!(is_kernel("vmlinux-5.4.14-cloudflare-2020.1.11")); | ||
assert!(is_kernel( | ||
"/usr/lib/debug/boot/vmlinux-5.4.14-cloudflare-2020.1.11" | ||
)); | ||
} | ||
|
||
#[test] | ||
fn is_kernel_false() { | ||
assert!(!is_kernel("[unknown]")); | ||
assert!(!is_kernel(" [")); | ||
assert!(!is_kernel(".ko ")); | ||
assert!(!is_kernel(" [.ko ")); | ||
assert!(!is_kernel("vmlinux-cloudflare ")); | ||
assert!(!is_kernel("vmlinux-5.4.14-cloudflare-2020.1.11)")); | ||
assert!(!is_kernel("/usr/lib/debug/boot/vmlinu")); | ||
assert!(!is_kernel( | ||
"/usr/lib/debug/boot/vmlinu-5.4.14-cloudflare-2020.1.11" | ||
)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
tests/data/collapse-perf/results/versioned-vmlinux-collapsed-kernel.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
swapper;[vmlinux-5.4.14-cloudflare-2020.1.11]_[k];start_secondary_[k];cpu_startup_entry_[k];do_idle_[k];cpuidle_enter_[k];cpuidle_enter_state_[k];common_interrupt_[k];do_IRQ_[k];irq_exit_[k];__softirqentry_text_start_[k];net_rx_action_[k];mlx5e_napi_poll_[k];mlx5e_poll_rx_cq_[k];mlx5e_handle_rx_cqe_[k];mlx5e_skb_from_cqe_linear_[k];mlx5e_xdp_handle_[k];bpf_prog_2b956549c660136a_uni_l4lb 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
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) |