aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2020-01-08 11:52:37 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2020-01-08 11:52:37 -0300
commit252b0fcc91ccc3e4f6ed2121a11901c3026ab0e8 (patch)
tree64535407c4f8a027ce784191c9c0e01ecbd7a642
parent202c8d5f5bd58af29826a61cb039dfc178457912 (diff)
downloadpahole-252b0fcc91ccc3e4f6ed2121a11901c3026ab0e8.tar.gz
pahole: Fix -m/--nr_methods - Number of functions operating on a type pointer
We had to use the same hack as in pfunct, as implemented in ccf3eebfcd9c ("btf_loader: Add support for BTF_KIND_FUNC"), will hide that 'struct ftype' (aka function prototype) indirection behind the parameter iterator (function__for_each_parameter). For now, here is the top 10 Linux kernel data structures in terms of number of functions receiving as one of its parameters a pointer to it, using /sys/kernel/btf/vmlinux to look at all the vmlinux types and functions (the ones visible in kallsyms, but with the parameters and its types): $ pahole -m | sort -k2 -nr | head device 955 sock 568 sk_buff 541 task_struct 437 inode 421 pci_dev 390 page 351 net_device 347 file 315 net 312 $ $ pahole --help |& grep -- -m -m, --nr_methods show number of methods $ Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--pahole.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/pahole.c b/pahole.c
index cd58772..d7019e5 100644
--- a/pahole.c
+++ b/pahole.c
@@ -623,8 +623,10 @@ static void cu__account_nr_methods(struct cu *cu)
uint32_t id;
cu__for_each_function(cu, id, pos_function) {
+ struct ftype *proto = pos_function->btf ? tag__ftype(cu__type(cu, pos_function->proto.tag.type)) : &pos_function->proto;
struct class_member *pos;
- list_for_each_entry(pos, &pos_function->proto.parms, tag.node) {
+
+ ftype__for_each_parameter(proto, pos) {
struct tag *type = cu__type(cu, pos->tag.type);
if (type == NULL || !tag__is_pointer(type))