lkml.org 
[lkml]   [2006]   [Oct]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [ANNOUNCE] pahole and other DWARF2 utilities
    On Tue, Oct 31, 2006 at 02:22:37PM -0300, Arnaldo Carvalho de Melo wrote:
    > On Mon, Oct 30, 2006 at 08:33:34PM -0800, Andrew Morton wrote:
    > > On Mon, 30 Oct 2006 18:33:19 -0300
    > > Arnaldo Carvalho de Melo <acme@mandriva.com> wrote:
    > >
    > > > I've been working on some DWARF2 utilities and thought that it
    > > > is about time I announce it to the community, so that what is already
    > > > available can be used by people interested in reducing structure sizes
    > > > and otherwise taking advantage of the information available in the elf
    > > > sections of files compiled with 'gcc -g' or in the case of the kernel
    > > > with CONFIG_DEBUG_INFO enabled, so here it goes the description of said
    > > > tools:
    > > >
    > > > pahole: Poke-a-Hole is a tool to find out holes in structures, holes
    > > > being defined as the space between members of functions due to alignemnt
    > > > rules that could be used for new struct entries or to reorganize
    > > > existing structures to reduce its size, without more ado lets see what
    > > > that means:
    > > >
    > > > ...
    > > >
    > > > Further ideas on how to use the DWARF2 information include tools
    > > > that will show where inlines are being used, how much code is added by
    > > > inline functions,
    > >
    > > It would be quite useful to be able to identify inlined functions which are
    > > good candidates for uninlining.

    For now people can take a look at:

    http://oops.merseine.nu:81/acme/net.ipv4.tcp.o.pahole

    Where all the types in headers included from net/ipv4/tcp.c that have
    holes can be seen, for instance:

    /* /pub/scm/linux/kernel/git/acme/net-2.6/include/linux/dqblk_xfs.h:143
    * */
    struct fs_quota_stat {
    __s8 qs_version; /* 0 1 */

    /* XXX 1 bytes hole, try to pack */

    __u16 qs_flags; /* 2 2 */
    __s8 qs_pad; /* 4 1 */

    /* XXX 3 bytes hole, try to pack */

    fs_qfilestat_t qs_uquota; /* 8 20 */
    fs_qfilestat_t qs_gquota; /* 28 20 */
    __u32 qs_incoredqs; /* 48 4 */
    __s32 qs_btimelimit; /* 52 4 */
    __s32 qs_itimelimit; /* 56 4 */
    __s32 qs_rtbtimelimit; /* 60 4 */
    __u16 qs_bwarnlimit; /* 64 2 */
    __u16 qs_iwarnlimit; /* 66 2 */
    }; /* size: 68, sum members: 64, holes: 2, sum holes: 4 */


    See? two holes, that can be combined and reduce the size of this
    struct by 4 bytes, just moving qs_pad to be defined just before
    qs_flags, many more holes are there to harvest :-)

    Of course, mistakes from the past for structs that are exported
    to userspace have to be kept that way, and in other cases where grouping
    members for cacheline locality optimizations, etc.

    - Arnaldo
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2006-10-31 21:49    [W:0.026 / U:1.600 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site