dwarves/btfdiff

44 lines
1.2 KiB
Plaintext
Raw Normal View History

#!/bin/bash
# SPDX-License-Identifier: GPL-2.0-only
# Copyright © 2019 Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
# Use pahole to produce output from BTF and from DWARF, then do a diff
# Use --flat_arrays with DWARF as BTF, like CTF, flattens arrays.
# Use --show_private_classes as BTF shows all structs, while pahole knows
# if some struct is defined only inside another struct/class or in a function,
# this information is not available when loading from BTF.
if [ $# -eq 0 ] ; then
echo "Usage: btfdiff <filename_with_DWARF_and_maybe_BTF_info> [<filename_with_BTF_info>]"
exit 1
fi
dwarf_input=$1
btf_input=$dwarf_input
if [ $# -eq 2 ] ; then
btf_input=$2
fi
btf_output=$(mktemp /tmp/btfdiff.btf.XXXXXX)
dwarf_output=$(mktemp /tmp/btfdiff.dwarf.XXXXXX)
pahole_bin=${PAHOLE-"pahole"}
${pahole_bin} -F dwarf \
--flat_arrays \
--sort \
btfdiff: Use multithreaded DWARF loading Quite a few cases of types with the same name, will add a --exclude-types option to filter those, and study BTF dedup to see what it does in this case. $ btfdiff vmlinux --- /tmp/btfdiff.dwarf.BgsYYn 2021-07-06 17:03:07.471814114 -0300 +++ /tmp/btfdiff.btf.Ene2Ug 2021-07-06 17:03:07.714819609 -0300 @@ -23627,12 +23627,15 @@ struct deadline_data { }; struct debug_buffer { ssize_t (*fill_func)(struct debug_buffer *); /* 0 8 */ - struct ohci_hcd * ohci; /* 8 8 */ + struct usb_bus * bus; /* 8 8 */ struct mutex mutex; /* 16 32 */ size_t count; /* 48 8 */ - char * page; /* 56 8 */ + char * output_buf; /* 56 8 */ + /* --- cacheline 1 boundary (64 bytes) --- */ + size_t alloc_size; /* 64 8 */ - /* size: 64, cachelines: 1, members: 5 */ + /* size: 72, cachelines: 2, members: 6 */ + /* last cacheline: 8 bytes */ }; struct debug_reply_data { struct ethnl_reply_data base; /* 0 8 */ @@ -47930,11 +47933,12 @@ struct intel_community { /* last cacheline: 32 bytes */ }; struct intel_community_context { - u32 * intmask; /* 0 8 */ - u32 * hostown; /* 8 8 */ + unsigned int intr_lines[16]; /* 0 64 */ + /* --- cacheline 1 boundary (64 bytes) --- */ + u32 saved_intmask; /* 64 4 */ - /* size: 16, cachelines: 1, members: 2 */ - /* last cacheline: 16 bytes */ + /* size: 68, cachelines: 2, members: 2 */ + /* last cacheline: 4 bytes */ }; struct intel_early_ops { resource_size_t (*stolen_size)(int, int, int); /* 0 8 */ @@ -52600,64 +52604,19 @@ struct irqtime { /* size: 24, cachelines: 1, members: 4 */ /* last cacheline: 24 bytes */ }; -struct irte { - union { - struct { - __u64 present:1; /* 0: 0 8 */ - __u64 fpd:1; /* 0: 1 8 */ - __u64 __res0:6; /* 0: 2 8 */ - __u64 avail:4; /* 0: 8 8 */ - __u64 __res1:3; /* 0:12 8 */ - __u64 pst:1; /* 0:15 8 */ - __u64 vector:8; /* 0:16 8 */ - __u64 __res2:40; /* 0:24 8 */ - }; /* 0 8 */ - struct { - __u64 r_present:1; /* 0: 0 8 */ - __u64 r_fpd:1; /* 0: 1 8 */ - __u64 dst_mode:1; /* 0: 2 8 */ - __u64 redir_hint:1; /* 0: 3 8 */ - __u64 trigger_mode:1; /* 0: 4 8 */ - __u64 dlvry_mode:3; /* 0: 5 8 */ - __u64 r_avail:4; /* 0: 8 8 */ - __u64 r_res0:4; /* 0:12 8 */ - __u64 r_vector:8; /* 0:16 8 */ - __u64 r_res1:8; /* 0:24 8 */ - __u64 dest_id:32; /* 0:32 8 */ - }; /* 0 8 */ - struct { - __u64 p_present:1; /* 0: 0 8 */ - __u64 p_fpd:1; /* 0: 1 8 */ - __u64 p_res0:6; /* 0: 2 8 */ - __u64 p_avail:4; /* 0: 8 8 */ - __u64 p_res1:2; /* 0:12 8 */ - __u64 p_urgent:1; /* 0:14 8 */ - __u64 p_pst:1; /* 0:15 8 */ - __u64 p_vector:8; /* 0:16 8 */ - __u64 p_res2:14; /* 0:24 8 */ - __u64 pda_l:26; /* 0:38 8 */ - }; /* 0 8 */ - __u64 low; /* 0 8 */ - }; /* 0 8 */ - union { - struct { - __u64 sid:16; /* 8: 0 8 */ - __u64 sq:2; /* 8:16 8 */ - __u64 svt:2; /* 8:18 8 */ - __u64 __res3:44; /* 8:20 8 */ - }; /* 8 8 */ - struct { - __u64 p_sid:16; /* 8: 0 8 */ - __u64 p_sq:2; /* 8:16 8 */ - __u64 p_svt:2; /* 8:18 8 */ - __u64 p_res3:12; /* 8:20 8 */ - __u64 pda_h:32; /* 8:32 8 */ - }; /* 8 8 */ - __u64 high; /* 8 8 */ - }; /* 8 8 */ - - /* size: 16, cachelines: 1, members: 2 */ - /* last cacheline: 16 bytes */ +union irte { + u32 val; /* 0 4 */ + struct { + u32 valid:1; /* 0: 0 4 */ + u32 no_fault:1; /* 0: 1 4 */ + u32 int_type:3; /* 0: 2 4 */ + u32 rq_eoi:1; /* 0: 5 4 */ + u32 dm:1; /* 0: 6 4 */ + u32 rsvd_1:1; /* 0: 7 4 */ + u32 destination:8; /* 0: 8 4 */ + u32 vector:8; /* 0:16 4 */ + u32 rsvd_2:8; /* 0:24 4 */ + } fields; /* 0 4 */ }; struct irte_ga { union irte_ga_lo lo; /* 0 8 */ @@ -66862,12 +66821,13 @@ struct netlbl_domhsh_tbl { /* last cacheline: 16 bytes */ }; struct netlbl_domhsh_walk_arg { - struct netlbl_audit * audit_info; /* 0 8 */ - u32 doi; /* 8 4 */ + struct netlink_callback * nl_cb; /* 0 8 */ + struct sk_buff * skb; /* 8 8 */ + u32 seq; /* 16 4 */ - /* size: 16, cachelines: 1, members: 2 */ + /* size: 24, cachelines: 1, members: 3 */ /* padding: 4 */ - /* last cacheline: 16 bytes */ + /* last cacheline: 24 bytes */ }; struct netlbl_dommap_def { u32 type; /* 0 4 */ @@ -72907,20 +72867,16 @@ struct pci_raw_ops { /* last cacheline: 16 bytes */ }; struct pci_root_info { - struct list_head list; /* 0 16 */ - char name[12]; /* 16 12 */ - - /* XXX 4 bytes hole, try to pack */ - - struct list_head resources; /* 32 16 */ - struct resource busn; /* 48 64 */ - /* --- cacheline 1 boundary (64 bytes) was 48 bytes ago --- */ - int node; /* 112 4 */ - int link; /* 116 4 */ + struct acpi_pci_root_info common; /* 0 56 */ + struct pci_sysdata sd; /* 56 40 */ + /* --- cacheline 1 boundary (64 bytes) was 32 bytes ago --- */ + bool mcfg_added; /* 96 1 */ + u8 start_bus; /* 97 1 */ + u8 end_bus; /* 98 1 */ - /* size: 120, cachelines: 2, members: 6 */ - /* sum members: 116, holes: 1, sum holes: 4 */ - /* last cacheline: 56 bytes */ + /* size: 104, cachelines: 2, members: 5 */ + /* padding: 5 */ + /* last cacheline: 40 bytes */ }; struct pci_root_res { struct list_head list; /* 0 16 */ @@ -76415,25 +76371,66 @@ struct pmc_dev { /* XXX 4 bytes hole, try to pack */ - void * regmap; /* 8 8 */ + void * regbase; /* 8 8 */ const struct pmc_reg_map * map; /* 16 8 */ struct dentry * dbgfs_dir; /* 24 8 */ - bool init; /* 32 1 */ + int pmc_xram_read_bit; /* 32 4 */ - /* size: 40, cachelines: 1, members: 5 */ - /* sum members: 29, holes: 1, sum holes: 4 */ - /* padding: 7 */ - /* last cacheline: 40 bytes */ + /* XXX 4 bytes hole, try to pack */ + + struct mutex lock; /* 40 32 */ + /* --- cacheline 1 boundary (64 bytes) was 8 bytes ago --- */ + bool check_counters; /* 72 1 */ + + /* XXX 7 bytes hole, try to pack */ + + u64 pc10_counter; /* 80 8 */ + u64 s0ix_counter; /* 88 8 */ + int num_lpm_modes; /* 96 4 */ + int lpm_en_modes[8]; /* 100 32 */ + + /* XXX 4 bytes hole, try to pack */ + + /* --- cacheline 2 boundary (128 bytes) was 8 bytes ago --- */ + u32 * lpm_req_regs; /* 136 8 */ + + /* size: 144, cachelines: 3, members: 12 */ + /* sum members: 125, holes: 4, sum holes: 19 */ + /* last cacheline: 16 bytes */ }; struct pmc_reg_map { - const struct pmc_bit_map * d3_sts_0; /* 0 8 */ - const struct pmc_bit_map * d3_sts_1; /* 8 8 */ - const struct pmc_bit_map * func_dis; /* 16 8 */ - const struct pmc_bit_map * func_dis_2; /* 24 8 */ - const struct pmc_bit_map * pss; /* 32 8 */ + const struct pmc_bit_map * * pfear_sts; /* 0 8 */ + const struct pmc_bit_map * mphy_sts; /* 8 8 */ + const struct pmc_bit_map * pll_sts; /* 16 8 */ + const struct pmc_bit_map * * slps0_dbg_maps; /* 24 8 */ + const struct pmc_bit_map * ltr_show_sts; /* 32 8 */ + const struct pmc_bit_map * msr_sts; /* 40 8 */ + const struct pmc_bit_map * * lpm_sts; /* 48 8 */ + const u32 slp_s0_offset; /* 56 4 */ + const int slp_s0_res_counter_step; /* 60 4 */ + /* --- cacheline 1 boundary (64 bytes) --- */ + const u32 ltr_ignore_offset; /* 64 4 */ + const int regmap_length; /* 68 4 */ + const u32 ppfear0_offset; /* 72 4 */ + const int ppfear_buckets; /* 76 4 */ + const u32 pm_cfg_offset; /* 80 4 */ + const int pm_read_disable_bit; /* 84 4 */ + const u32 slps0_dbg_offset; /* 88 4 */ + const u32 ltr_ignore_max; /* 92 4 */ + const u32 pm_vric1_offset; /* 96 4 */ + const int lpm_num_maps; /* 100 4 */ + const int lpm_res_counter_step_x2; /* 104 4 */ + const u32 lpm_sts_latch_en_offset; /* 108 4 */ + const u32 lpm_en_offset; /* 112 4 */ + const u32 lpm_priority_offset; /* 116 4 */ + const u32 lpm_residency_offset; /* 120 4 */ + const u32 lpm_status_offset; /* 124 4 */ + /* --- cacheline 2 boundary (128 bytes) --- */ + const u32 lpm_live_status_offset; /* 128 4 */ + const u32 etr3_offset; /* 132 4 */ - /* size: 40, cachelines: 1, members: 5 */ - /* last cacheline: 40 bytes */ + /* size: 136, cachelines: 3, members: 27 */ + /* last cacheline: 8 bytes */ }; struct pmic_table { int address; /* 0 4 */ @@ -114574,12 +114571,18 @@ struct urb { /* last cacheline: 56 bytes */ }; struct urb_priv { - int num_tds; /* 0 4 */ - int num_tds_done; /* 4 4 */ - struct xhci_td td[]; /* 8 0 */ + struct ed * ed; /* 0 8 */ + u16 length; /* 8 2 */ + u16 td_cnt; /* 10 2 */ - /* size: 8, cachelines: 1, members: 3 */ - /* last cacheline: 8 bytes */ + /* XXX 4 bytes hole, try to pack */ + + struct list_head pending; /* 16 16 */ + struct td * td[]; /* 32 0 */ + + /* size: 32, cachelines: 1, members: 5 */ + /* sum members: 28, holes: 1, sum holes: 4 */ + /* last cacheline: 32 bytes */ }; struct usb2_lpm_parameters { unsigned int besl; /* 0 4 */ $ Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-07-06 22:07:39 +02:00
--jobs \
--suppress_aligned_attribute \
--suppress_force_paddings \
--suppress_packed \
--show_private_classes $dwarf_input > $dwarf_output
${pahole_bin} -F btf \
--sort \
--suppress_aligned_attribute \
--suppress_packed \
$btf_input > $btf_output
diff -up $dwarf_output $btf_output
rm -f $btf_output $dwarf_output
exit 0