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>
1 file changed