From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.5 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8D00C43381 for ; Fri, 8 Mar 2019 18:45:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6AAAF20857 for ; Fri, 8 Mar 2019 18:45:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BMON71PL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726947AbfCHSpY (ORCPT ); Fri, 8 Mar 2019 13:45:24 -0500 Received: from mail-qt1-f194.google.com ([209.85.160.194]:46741 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726930AbfCHSpX (ORCPT ); Fri, 8 Mar 2019 13:45:23 -0500 Received: by mail-qt1-f194.google.com with SMTP id z25so22321052qti.13; Fri, 08 Mar 2019 10:45:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=kjMJJ8GDF8FR8NsYgfMsFywn04rGBOdLrtB2PNvHObk=; b=BMON71PLcKmLpjAXlxqQqbBKg7U1GY2Kcq7zropKr7KcJYE8sOOGmWsg5QtNYBUDH7 6eOitwodiqy/+a0XoZt+JTHQGcemGHjGgoQZoUsYdj5AG88JZxpp/WoPoabLQW5ARplW lOvRFkB2DJh1f+ILA/1LI7KhZqhF3t+R9AnWqFmLi+D9wDWgMPCu3o42aP93Qo/4DxOJ FbtWHAm+S2xXcYbo5LO3rSNP6jeGhHKzg+d9Z32WztHtr83rhic6iRfOFEL7dx9DMWav et1kykCzCgUOr9e4tT8YKOFuXkjQ4CmCxnGXZ8nov1A+YxhmA6s4k5buQA5l/SH5Uzsa RlnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=kjMJJ8GDF8FR8NsYgfMsFywn04rGBOdLrtB2PNvHObk=; b=q1NsyOq63o50yv4H4wYeBqZf/ZYxOGN6+9NKOVGtCbVFf2HCmXNvtEb5JJmbzw4Mlk E8aYlksi/nybLyWEFJt1ScQdAYyRietMhcXyXkXuF2A9V6O/QBektZPo2YARYhY8y07F fm/13DPfVtdiGRwnZBYjzC2hpNPKU31ljtExks6wnyOo2Ngv3+NpOGYT9EMPW6oL4TYj qCa+yx3xSCQNEHWNYSaP2L6DnMo0uadETNYngpq5KOYlFmS9IBVIyELu5sm6lwEmTdMJ I2lrmWmQQe+IdnY0rWF0vdGCHbMJMuCLgzjA5ewsUHeg5Qe5/6BuywL+VqbhLbwVlspz 6fBA== X-Gm-Message-State: APjAAAWhimX8/P/a0AFUH+pC7u2A7toywPgJGvBm+bfmZOim6m5ERS5/ 9fIWUekZDjpxLqMkK8tcd7Q= X-Google-Smtp-Source: APXvYqyKUK26kj2zF4Ooya8bHCDWcaAZ7RKLunH3HvATQpoIjd4T9LlySWhxmwlgwr+ypO259GiH4A== X-Received: by 2002:ac8:22b6:: with SMTP id f51mr15644376qta.182.1552070721904; Fri, 08 Mar 2019 10:45:21 -0800 (PST) Received: from quaco.ghostprotocols.net ([190.15.121.82]) by smtp.gmail.com with ESMTPSA id t49sm1864311qte.86.2019.03.08.10.45.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Mar 2019 10:45:21 -0800 (PST) From: Arnaldo Carvalho de Melo X-Google-Original-From: Arnaldo Carvalho de Melo Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id CABED4039C; Fri, 8 Mar 2019 15:45:17 -0300 (-03) Date: Fri, 8 Mar 2019 15:45:17 -0300 To: Andrii Nakryiko Cc: Andrii Nakryiko , Alexei Starovoitov , Yonghong Song , Song Liu , Martin Lau , Jiri Olsa , Namhyung Kim , dwarves@vger.kernel.org, bpf@vger.kernel.org Subject: Re: [PATCH pahole] pahole: use 32-bit integers for iterations within CU Message-ID: <20190308184517.GI10690@kernel.org> References: <20190307002321.4071708-1-andriin@fb.com> <20190307140247.GV13100@kernel.org> <20190308002637.GF32240@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190308002637.GF32240@kernel.org> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.10.1 (2018-07-13) Sender: bpf-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org Em Thu, Mar 07, 2019 at 09:26:37PM -0300, Arnaldo Carvalho de Melo escreveu: > Several looks similar and the low hanging fruit to investigate, seems to > be enum bitfields, and the others may as well end up being the same, in > miscalculated stats for structs embedded in other structs: I had little time to further look into this, but from what I've seen the good news is that it seems the problem is with the DWARF loader, the BTF one producing the right results 8-) I'll take a look at a fix you made for packed enums and probably use the same thing on the DWARF loader. - Arnaldo > $ btfdiff examples/vmlinux-aarch64 > --- /tmp/btfdiff.dwarf.81KCPb 2019-03-07 18:20:13.153319625 -0300 > +++ /tmp/btfdiff.btf.g1QkcZ 2019-03-07 18:20:13.928328675 -0300 > @@ -306626,18 +306626,15 @@ struct myrb_enquiry2 { > MYRB_RAM_TYPE_EDO = 1, > MYRB_RAM_TYPE_SDRAM = 2, > MYRB_RAM_TYPE_Last = 7, > - } ram:3; /* 40 4 */ > + } ram:3; /* 40 1 */ > enum { > MYRB_ERR_CORR_None = 0, > MYRB_ERR_CORR_Parity = 1, > MYRB_ERR_CORR_ECC = 2, > MYRB_ERR_CORR_Last = 7, > - } ec:3; /* 40 4 */ > + } ec:3; /* 40 1 */ > unsigned char fast_page:1; /* 40: 6 1 */ > unsigned char low_power:1; /* 40: 7 1 */ > - > - /* Bitfield combined with next fields */ > - > unsigned char rsvd4; /* 41 1 */ > } mem_type; /* 40 2 */ > short unsigned int clock_speed; /* 42 2 */ > @@ -306668,18 +306665,15 @@ struct myrb_enquiry2 { > MYRB_WIDTH_NARROW_8BIT = 0, > MYRB_WIDTH_WIDE_16BIT = 1, > MYRB_WIDTH_WIDE_32BIT = 2, > - } bus_width:2; /* 106 4 */ > + } bus_width:2; /* 106 1 */ > enum { > MYRB_SCSI_SPEED_FAST = 0, > MYRB_SCSI_SPEED_ULTRA = 1, > MYRB_SCSI_SPEED_ULTRA2 = 2, > - } bus_speed:2; /* 106 4 */ > + } bus_speed:2; /* 106 1 */ > unsigned char differential:1; /* 106: 4 1 */ > unsigned char rsvd10:3; /* 106: 5 1 */ > } scsi_cap; /* 106 1 */ > - > - /* XXX last struct has 65533 bytes of padding */ > - > unsigned char rsvd11[5]; /* 107 5 */ > short unsigned int fw_build; /* 112 2 */ > enum { > @@ -306701,7 +306695,6 @@ struct myrb_enquiry2 { > unsigned char rsvd14[8]; /* 120 8 */ > > /* size: 128, cachelines: 2, members: 46 */ > - /* paddings: 1, sum paddings: 65533 */ > }; > struct myrb_ldev_info { > unsigned int size; /* 0 4 */ > @@ -306741,7 +306734,7 @@ struct myrb_pdev_state { > MYRB_TYPE_DISK = 1, > MYRB_TYPE_TAPE = 2, > MYRB_TYPE_CDROM_OR_WORM = 3, > - } devtype:2; /* 1 4 */ > + } devtype:2; /* 1 1 */ > > /* Bitfield combined with previous fields */ > > @@ -306868,7 +306861,7 @@ struct myrb_config2 { > MYRB_SPEED_SYNC_8MHz = 1, > MYRB_SPEED_SYNC_5MHz = 2, > MYRB_SPEED_SYNC_10_OR_20MHz = 3, > - } speed:2; /* 12 4 */ > + } speed:2; /* 12 1 */ > unsigned int force_8bit:1; /* 12: 2 4 */ > unsigned int disable_fast20:1; /* 12: 3 4 */ > unsigned int rsvd8:3; /* 12: 4 4 */ > @@ -306891,7 +306884,7 @@ struct myrb_config2 { > MYRB_GEOM_255_63 = 1, > MYRB_GEOM_RESERVED1 = 2, > MYRB_GEOM_RESERVED2 = 3, > - } drive_geometry:2; /* 52 4 */ > + } drive_geometry:2; /* 52 1 */ > unsigned int rsvd12:1; /* 52: 7 4 */ > > /* Bitfield combined with next fields */ > @@ -306913,7 +306906,7 @@ struct myrb_dcdb { > MYRB_DCDB_XFER_DEVICE_TO_SYSTEM = 1, > MYRB_DCDB_XFER_SYSTEM_TO_DEVICE = 2, > MYRB_DCDB_XFER_ILLEGAL = 3, > - } data_xfer:2; /* 1 4 */ > + } data_xfer:2; /* 1 1 */ > > /* Bitfield combined with previous fields */ > > @@ -306928,7 +306921,7 @@ struct myrb_dcdb { > MYRB_DCDB_TMO_10_SECS = 1, > MYRB_DCDB_TMO_60_SECS = 2, > MYRB_DCDB_TMO_10_MINS = 3, > - } timeout:2; /* 1 4 */ > + } timeout:2; /* 1 1 */ > > /* Bitfield combined with previous fields */ > > @@ -307053,7 +307046,7 @@ union myrb_cmd_mbox { > MYRB_SGL_ADDR32_COUNT16 = 1, > MYRB_SGL_COUNT32_ADDR32 = 2, > MYRB_SGL_COUNT16_ADDR32 = 3, > - } sg_type:2; /* 12 4 */ > + } sg_type:2; /* 12 1 */ > unsigned char rsvd[3]; /* 13 3 */ > } type5; /* 0 16 */ > struct { > @@ -453415,15 +453408,10 @@ struct ieee80211_tx_rate { > /* Bitfield combined with previous fields */ > > u16 count:5; /* 0: 8 2 */ > - > - /* XXX 3 bits hole, try to pack */ > - /* Bitfield combined with next fields */ > - > - u16 flags:11; /* 1: 5 2 */ > + u16 flags:11; /* 0:13 2 */ > > /* size: 3, cachelines: 1, members: 3 */ > - /* bit holes: 1, sum bit holes: 3 bits */ > - /* bit_padding: 5 bits */ > + /* padding: 1 */ > /* last cacheline: 3 bytes */ > }; > struct ieee80211_key_conf { > @@ -488743,6 +488731,9 @@ struct ieee80211_tx_rate_control { > struct ieee80211_bss_conf * bss_conf; /* 16 8 */ > struct sk_buff * skb; /* 24 8 */ > struct ieee80211_tx_rate reported_rate; /* 32 3 */ > + > + /* XXX last struct has 1 byte of padding */ > + > bool rts; /* 35 1 */ > bool short_preamble; /* 36 1 */ > > @@ -488758,6 +488749,7 @@ struct ieee80211_tx_rate_control { > /* size: 64, cachelines: 1, members: 10 */ > /* sum members: 50, holes: 2, sum holes: 7 */ > /* padding: 7 */ > + /* paddings: 1, sum paddings: 1 */ > }; > struct rate_control_ops { > long unsigned int capa; /* 0 8 */ > @@ -528758,7 +528750,7 @@ struct skb_pool { > }; > struct vc_map { > volatile unsigned int tx:1; /* 0: 0 4 */ > - volatile unsigned int rx:1; /* 0: 1 4 */ > + volatile unsigned int rx:1; /* 0: 0 4 */ > > /* XXX 30 bits hole, try to pack */ > /* XXX 4 bytes hole, try to pack */ > @@ -675819,7 +675811,10 @@ union zip_zres_s { > u64 exbits:7; /* 16:41 8 */ > u64 reserved_137_143:7; /* 16:48 8 */ > u64 ef:1; /* 16:55 8 */ > - volatile u64 compcode:8; /* 16:56 8 */ > + > + /* Bitfield combined with next fields */ > + > + volatile u64 compcode:8; /* 23: 0 8 */ > } s; /* 0 24 */ > }; > struct sg_info { > @@ -784966,12 +784961,14 @@ struct ieee80211_tx_data { > struct ieee80211_key * key; /* 128 8 */ > struct ieee80211_tx_rate rate; /* 136 3 */ > > + /* XXX last struct has 1 byte of padding */ > /* XXX 1 byte hole, try to pack */ > > unsigned int flags; /* 140 4 */ > > /* size: 144, cachelines: 3, members: 8 */ > /* sum members: 143, holes: 1, sum holes: 1 */ > + /* paddings: 1, sum paddings: 1 */ > /* last cacheline: 16 bytes */ > }; > struct ieee80211_rx_data { > > > For a more usual vmlinux, with a .config similar to the one in a fedora > distro, we get everything seemingly ok: > > [acme@quaco pahole]$ btfdiff vmlinux > [acme@quaco pahole]$ file vmlinux > vmlinux: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, BuildID[sha1]=e7b4562926e9f69b2f478a3b4a7dd33136f42f5d, with debug_info, not stripped > [acme@quaco pahole]$ size vmlinux > text data bss dec hex filename > 17124425 7038546 5378112 29541083 1c2c2db vmlinux > [acme@quaco pahole]$ ls -lah vmlinux > -rwxrwxr-x. 1 acme acme 621M Mar 7 15:40 vmlinux > [acme@quaco pahole]$ pahole -F btf --sizes vmlinux | wc -l > 7472 > [acme@quaco pahole]$ pahole -F dwarf --sizes vmlinux | wc -l > 7445 > [acme@quaco pahole]$ pahole -F dwarf --show_private_classes --sizes vmlinux | wc -l > 7472 > [acme@quaco pahole]$ > [acme@quaco pahole]$ pahole -F btf -C perf_event_attr vmlinux > struct perf_event_attr { > __u32 type; /* 0 4 */ > __u32 size; /* 4 4 */ > __u64 config; /* 8 8 */ > union { > __u64 sample_period; /* 16 8 */ > __u64 sample_freq; /* 16 8 */ > }; /* 16 8 */ > __u64 sample_type; /* 24 8 */ > __u64 read_format; /* 32 8 */ > __u64 disabled:1; /* 40:63 8 */ > __u64 inherit:1; /* 40:62 8 */ > __u64 pinned:1; /* 40:61 8 */ > __u64 exclusive:1; /* 40:60 8 */ > __u64 exclude_user:1; /* 40:59 8 */ > __u64 exclude_kernel:1; /* 40:58 8 */ > __u64 exclude_hv:1; /* 40:57 8 */ > __u64 exclude_idle:1; /* 40:56 8 */ > __u64 mmap:1; /* 40:55 8 */ > __u64 comm:1; /* 40:54 8 */ > __u64 freq:1; /* 40:53 8 */ > __u64 inherit_stat:1; /* 40:52 8 */ > __u64 enable_on_exec:1; /* 40:51 8 */ > __u64 task:1; /* 40:50 8 */ > __u64 watermark:1; /* 40:49 8 */ > __u64 precise_ip:2; /* 40:47 8 */ > __u64 mmap_data:1; /* 40:46 8 */ > __u64 sample_id_all:1; /* 40:45 8 */ > __u64 exclude_host:1; /* 40:44 8 */ > __u64 exclude_guest:1; /* 40:43 8 */ > __u64 exclude_callchain_kernel:1; /* 40:42 8 */ > __u64 exclude_callchain_user:1; /* 40:41 8 */ > __u64 mmap2:1; /* 40:40 8 */ > __u64 comm_exec:1; /* 40:39 8 */ > __u64 use_clockid:1; /* 40:38 8 */ > __u64 context_switch:1; /* 40:37 8 */ > __u64 write_backward:1; /* 40:36 8 */ > __u64 namespaces:1; /* 40:35 8 */ > __u64 ksymbol:1; /* 40:34 8 */ > __u64 bpf_event:1; /* 40:33 8 */ > __u64 __reserved_1:33; /* 40: 0 8 */ > union { > __u32 wakeup_events; /* 48 4 */ > __u32 wakeup_watermark; /* 48 4 */ > }; /* 48 4 */ > __u32 bp_type; /* 52 4 */ > union { > __u64 bp_addr; /* 56 8 */ > __u64 kprobe_func; /* 56 8 */ > __u64 uprobe_path; /* 56 8 */ > __u64 config1; /* 56 8 */ > }; /* 56 8 */ > /* --- cacheline 1 boundary (64 bytes) --- */ > union { > __u64 bp_len; /* 64 8 */ > __u64 kprobe_addr; /* 64 8 */ > __u64 probe_offset; /* 64 8 */ > __u64 config2; /* 64 8 */ > }; /* 64 8 */ > __u64 branch_sample_type; /* 72 8 */ > __u64 sample_regs_user; /* 80 8 */ > __u32 sample_stack_user; /* 88 4 */ > __s32 clockid; /* 92 4 */ > __u64 sample_regs_intr; /* 96 8 */ > __u32 aux_watermark; /* 104 4 */ > __u16 sample_max_stack; /* 108 2 */ > __u16 __reserved_2; /* 110 2 */ > > /* size: 112, cachelines: 2, members: 49 */ > /* last cacheline: 48 bytes */ > }; > [acme@quaco pahole]$ -- - Arnaldo