-
-
Save kingluo/9c7feb606a1348cfb8c942ecb35bddf6 to your computer and use it in GitHub Desktop.
skb stats
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
#include <linux/module.h> | |
#include <linux/kernel.h> | |
#include <linux/skbuff.h> | |
int init_module(void) | |
{ | |
printk(KERN_INFO "skb_count=%ld\n", __get_skb_count()); | |
return 0; | |
} | |
void cleanup_module(void) | |
{ | |
printk(KERN_INFO "quit.\n"); | |
} | |
MODULE_LICENSE("GPL"); |
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
obj-m += hello.o | |
all: | |
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules | |
clean: | |
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean |
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
#!/usr/bin/env stap | |
global skb_cnt = 0 | |
probe begin | |
{ | |
warn("Hit Ctrl-C to end.\n") | |
} | |
probe end | |
{ | |
printf("\nskb count: %d\n", skb_cnt) | |
} | |
// skbs[$skb] = backtrace() | |
// skbs[$skb] = execname() | |
probe kernel.statement("*@net/core/skbuff.c:1743"), | |
kernel.statement("*@net/core/skbuff.c:499"), | |
kernel.function("__build_skb_around@net/core/skbuff.c") | |
{ | |
skb_cnt++ | |
} | |
probe kernel.statement("*@net/core/skbuff.c:911"), | |
kernel.statement("*@net/core/skbuff.c:1134"), | |
kernel.statement("*@net/core/skbuff.c:1154"), | |
kernel.statement("*@net/core/skbuff.c:1173"), | |
kernel.statement("*@net/core/skbuff.c:883") | |
{ | |
skb_cnt-- | |
} | |
probe kernel.function("napi_skb_free_stolen_head") | |
{ | |
print_stack(backtrace()) | |
skb_cnt-- | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment