-
Notifications
You must be signed in to change notification settings - Fork 286
/
skblife.bt
executable file
·45 lines (41 loc) · 1019 Bytes
/
skblife.bt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/local/bin/bpftrace
/*
* skblife - Lifespan of sk_buff as inter-stack latency.
*
* See BPF Performance Tools, Chapter 10, for an explanation of this tool.
*
* Copyright (c) 2019 Brendan Gregg.
* Licensed under the Apache License, Version 2.0 (the "License").
* This was originally created for the BPF Performance Tools book
* published by Addison Wesley. ISBN-13: 9780136554820
* When copying or porting, include this comment.
*
* 04-Apr-2019 Brendan Gregg Created this.
*/
kprobe:kmem_cache_alloc,
kprobe:kmem_cache_alloc_node
{
$cache = arg0;
if ($cache == *kaddr("skbuff_fclone_cache") ||
$cache == *kaddr("skbuff_head_cache")) {
@is_skb_alloc[tid] = 1;
}
}
kretprobe:kmem_cache_alloc,
kretprobe:kmem_cache_alloc_node
/@is_skb_alloc[tid]/
{
delete(@is_skb_alloc[tid]);
@skb_birth[retval] = nsecs;
}
kprobe:kmem_cache_free
/@skb_birth[arg1]/
{
@skb_residency_nsecs = hist(nsecs - @skb_birth[arg1]);
delete(@skb_birth[arg1]);
}
END
{
clear(@is_skb_alloc);
clear(@skb_birth);
}