diff options
| author | 2020-01-15 13:46:33 -0300 | |
|---|---|---|
| committer | 2020-01-15 13:47:49 -0300 | |
| commit | 3c1a9a3329d9fb3111865ecedf0472a48b0f55ee (patch) | |
| tree | 3e4ca03bb68728a490fca45c1e238b37d79cfed9 | |
| parent | ded5d36f9cf50fdfbeb73301b2fdf4f707c5ce3a (diff) | |
| download | pahole-3c1a9a3329d9fb3111865ecedf0472a48b0f55ee.tar.gz | |
pahole: Make --contains look for more than just unions, structs
Look for typedefs, enums and types that descend from 'struct type', that
is:
static inline int tag__is_type(const struct tag *tag)
{
return tag__is_union(tag) ||
tag__is_struct(tag) ||
tag__is_typedef(tag) ||
tag__is_rvalue_reference_type(tag) ||
tag__is_enumeration(tag);
}
So now we can do more interesting queries, lets see, what are the data
structures that embed a raw spinlock in the linux kernel?
$ pahole --contains raw_spinlock_t
task_struct
rw_semaphore
hrtimer_cpu_base
prev_cputime
percpu_counter
ratelimit_state
perf_event_context
task_delay_info
perf_cpu_context
perf_addr_filters_head
fprop_local_percpu
ld_semaphore
er_account
intel_excl_cntrs
perf_amd_iommu
irq_desc
irq_chip_generic
nmi_desc
ssb_state
semaphore
uv_hub_nmi_s
kretprobe
swait_queue_head
kvm_task_sleep_head
kthread_worker
root_domain
cpudl
rt_bandwidth
dl_bandwidth
dl_bw
cfs_bandwidth
rq
rt_rq
sugov_policy
rt_mutex
rcu_node
rcu_data
rcu_state
timer_base
cpu_stopper
trace_array
ring_buffer_per_cpu
pcpu_freelist_head
bpf_lru_list
bpf_lru_locallist
bucket
lpm_trie
bpf_queue_stack
$
This is using the /sys/kernel/btf/vmlinux file, so it is really fast:
$ time pahole --contains raw_spinlock_t > /dev/null
real 0m0.034s
user 0m0.023s
sys 0m0.011s
$
Look at one of those, say:
$ pahole bpf_queue_stack
struct bpf_queue_stack {
struct bpf_map map; /* 0 256 */
/* XXX last struct has 40 bytes of padding */
/* --- cacheline 4 boundary (256 bytes) --- */
raw_spinlock_t lock; /* 256 4 */
u32 head; /* 260 4 */
u32 tail; /* 264 4 */
u32 size; /* 268 4 */
char elements[]; /* 272 0 */
/* size: 320, cachelines: 5, members: 6 */
/* padding: 48 */
/* paddings: 1, sum paddings: 40 */
};
$
But you may be intested only in RCU stuff, so...
$ pahole --contains raw_spinlock_t --prefix rcu
rcu_node
rcu_data
rcu_state
$ pahole rcu_node,rcu_data,rcu_state | egrep '(^struct|raw_spinlock_t)'
struct rcu_data {
raw_spinlock_t nocb_lock; /* 288 4 */
raw_spinlock_t nocb_bypass_lock; /* 384 4 */
raw_spinlock_t nocb_gp_lock; /* 448 4 */
struct rcu_node {
raw_spinlock_t lock; /* 0 4 */
raw_spinlock_t fqslock; /* 320 4 */
struct rcu_state {
raw_spinlock_t ofl_lock; /* 3328 4 */
$
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
| -rw-r--r-- | pahole.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -1223,7 +1223,7 @@ static enum load_steal_kind pahole_stealer(struct cu *cu, static type_id_t class_id; bool include_decls = find_pointers_in_structs != 0 || stats_formatter == nr_methods_formatter; - struct tag *class = cu__find_struct_or_union_by_name(cu, pos->s, include_decls, &class_id); + struct tag *class = cu__find_type_by_name(cu, pos->s, include_decls, &class_id); if (class == NULL) continue; |
