Commit Graph

448 Commits

Author SHA1 Message Date
Arnaldo Carvalho de Melo cd07fdbaf0 [PFUNCT]: Use cus__loadfl, aka libdwfl
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-03-30 13:45:57 -03:00
Arnaldo Carvalho de Melo 61609b4364 [PAHOLE]: Use cus__loadfl, i.e. libdwfl
Now we have:

[acme@filo pahole]$ pahole --help
Usage: pahole [OPTION...] [FILE] {[CLASS]}

  -a, --anon_include         include anonymous classes
  -A, --nested_anon_include  include nested (inside other structs) anonymous
                             classes
  -B, --bit_holes=NR_HOLES   Show only structs at least NR_HOLES bit holes
  -c, --cacheline_size=SIZE  set cacheline size to SIZE
  -D, --decl_exclude=PREFIX  exclude classes declared in files with PREFIX
  -E, --expand_types         expand class members
  -H, --holes=NR_HOLES       show only structs at least NR_HOLES holes
  -m, --nr_methods           show number of methods
  -n, --nr_members           show number of members
  -N, --class_name_len       show size of classes
  -P, --packable             show only structs that has holes that can be
                             packed
  -R, --reorganize           reorg struct trying to kill holes
  -s, --sizes                show size of classes
  -S, --show_reorg_steps     show the struct layout at each reorganization step

  -t, --nr_definitions       show how many times struct was defined
  -V, --verbose              be verbose
  -x, --exclude=PREFIX       exclude PREFIXed classes
  -X, --cu_exclude=PREFIX    exclude PREFIXed compilation units

 Input Selection:
      --debuginfo-path=PATH  Search path for separate debuginfo files
  -e, --executable=FILE      Find addresses in FILE
  -k, --kernel               Find addresses in the running kernel
  -K, --offline-kernel[=RELEASE]   Kernel with all modules
  -M, --linux-process-map=FILE   Find addresses in files mapped as read from
                             FILE in Linux /proc/PID/maps format
  -p, --pid=PID              Find addresses in files mapped into process PID

  -?, --help                 Give this help list
      --usage                Give a short usage message

Mandatory or optional arguments to long options are also mandatory or optional
for any corresponding short options.

Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-03-30 13:25:51 -03:00
Arnaldo Carvalho de Melo 26ea852c17 [LIB]: Moving to libdwfl
Now there is a cus__loadfl function that receives the tool argp tables and uses
libdwfl to process the DWARF info, with this RELA objects such as .o and .ko
files in a Linux kernel build are supported, and all the other goodies that
come from using libdwfl, such as separate debuginfo files, etc come as a bonus.

Now to convert the tools, pahole being the first, that already works well using
cus__loadfl().

Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-03-30 13:22:28 -03:00
Arnaldo Carvalho de Melo 950fbc7110 [PGLOBAL]: Convert to argp
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-03-30 11:33:17 -03:00
Arnaldo Carvalho de Melo 0004a8ea7a [DTAGNAMES]: Fix cus__print_error_msg prog name
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-03-30 11:33:00 -03:00
Arnaldo Carvalho de Melo 4b733527ed [PREFCNT]: No need to use getopt
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-03-30 11:25:25 -03:00
Arnaldo Carvalho de Melo b7cd0b6fdf [CTRACER]: Convert to argp
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-03-30 11:16:50 -03:00
Arnaldo Carvalho de Melo 0f8e3423b5 [CODIFF]: Fix bug in diff_struct
We weren't initializing new_structure when a struct was removed.

Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-03-30 10:59:04 -03:00
Arnaldo Carvalho de Melo 6bcf3751df [CODIFF]: Convert codiff to argp
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-03-30 10:37:37 -03:00
Arnaldo Carvalho de Melo 78beb03ca1 [PFUNCT]: Convert to argp
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-03-30 10:24:13 -03:00
Arnaldo Carvalho de Melo 5f1ba48d5e [PAHOLE]: Convert to argp
Paving the way to move from libdw to libdwfl.

Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-03-30 10:07:01 -03:00
Arnaldo Carvalho de Melo 0dcc856a7f [LIB]: Emit a warning when the compiler gets the byte_offset (seemingly) wrong
[acme@filo examples]$ pahole -a mpg_audio_frame_t
/* <14f> /home/acme/git/pahole/examples/mpg_audio_frame_t.c:4 */
typedef struct {
        uint16_t     frame_sync;           /*     0     2 */
        uint8_t      layer;                /*     2     1 */

        /* WARNING: DWARF offset=0, real offset=3 */

        uint32_t     mpeg25_bit:1;         /*     0     4 */
        uint32_t     lsf_bit:1;            /*     0     4 */
        uint32_t     bitrate_idx:4;        /*     0     4 */
<SNIP>

So gcc combined a uint16_t + a uint8_t + the first entries in the uint32_t
bitfield that could fit in the 8 bits after the first two fields but haven't
updated the size of the bitfield (4) and wrote 0 as the offset, warn about such
inconsistencies.

Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-03-29 11:25:02 -03:00
Arnaldo Carvalho de Melo 27ac8cec6c [LIB]: Only check if it is a cacheline boundary when the offset changes
So that we print the boundary after the last member in a bitfield.

Spotted by Matthew Wilcox.

Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-03-28 13:21:27 -03:00
Arnaldo Carvalho de Melo c87d8d831a [ALL]: Emit better diagnostic messages
[acme@mica pahole]$ pahole lala
pahole: Permission denied
[acme@mica pahole]$ pahole foo
pahole: No such file or directory
[acme@mica pahole]$ pahole ctracer.c
pahole: couldn't load DWARF info from ctracer.c
[acme@mica pahole]$

Thanks to Matthew Wilcox for noticing how lame it was :-)

Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-03-28 12:54:46 -03:00
Arnaldo Carvalho de Melo 7bd8fb3c43 [LIB]: Fix compiler warnings on 64bits
Mostly related to size_t, Dwarf_Off -> (unsigned long long), etc.

Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-03-28 11:38:32 -03:00
Diego "Flameeyes" Pettenò c8054ae5e8 [CMAKE]: Link libdwarves only to libdw
And let the final binaries get it from that. Fixes building with
-Wl,--as-needed

Signed-off-by: Diego "Flameeyes" Pettenò <flameeyes@gmail.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-03-28 10:18:57 -03:00
Arnaldo Carvalho de Melo 3005b6b7e1 [LIB]: Reorganize struct tag
Erm, eating my dog food now that I have access to a 64bit machine here at home:

[acme@mica pahole]$ pahole build/libdwarves.so.1.0.0 tag
/* <b7e> /home/acme/git/pahole/dwarves.h:48 */
struct tag {
        struct list_head      node;          /*     0    16 */
        Dwarf_Off             type;          /*    16     8 */
        Dwarf_Off             id;            /*    24     8 */
        uint16_t              tag;           /*    32     2 */
        uint16_t              decl_line;     /*    34     2 */

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

        const char  *         decl_file;     /*    40     8 */
        uint32_t              refcnt;        /*    48     4 */
}; /* size: 56, cachelines: 1 */
   /* sum members: 48, holes: 1, sum holes: 4 */
   /* padding: 4 */
   /* last cacheline: 56 bytes */
[acme@mica pahole]$

[acme@mica pahole]$ pahole --reorganize build/libdwarves.so.1.0.0 tag
/* <b7e> /home/acme/git/pahole/dwarves.h:48 */
struct tag {
        struct list_head      node;          /*     0    16 */
        Dwarf_Off             type;          /*    16     8 */
        Dwarf_Off             id;            /*    24     8 */
        uint16_t              tag;           /*    32     2 */
        uint16_t              decl_line;     /*    34     2 */
        uint32_t              refcnt;        /*    36     4 */
        const char  *         decl_file;     /*    40     8 */
}; /* size: 48, cachelines: 1 */
   /* last cacheline: 48 bytes */
   /* saved 8 bytes! */
[acme@mica pahole]$

[acme@mica pahole]$ codiff build/libdwarves.so.1.0.0.before build/libdwarves.so.1.0.0
/home/acme/git/pahole/dwarves.c:
  struct tag              |   -8
  struct type             |   -8
  struct class            |   -8
  struct base_type        |   -8
  struct array_type       |   -8
  struct class_member     |   -8
  struct lexblock         |   -8
  struct ftype            |   -8
  struct function         |  -16
  struct parameter        |   -8
  struct variable         |   -8
  struct inline_expansion |   -8
  struct label            |   -8
  struct enumerator       |   -8
 14 structs changed
  class_member__clone     |   -8
  class__clone            |   -8
 2 functions changed, 16 bytes removed
[acme@mica pahole]$

Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-03-07 12:10:56 -03:00
Arnaldo Carvalho de Melo 0895c23b46 [LIB]: Be a bit more paranoid about types not found in type__fprintf
Instead of just segfaulting on these extreme cases.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2007-02-26 23:00:56 -03:00
Arnaldo Carvalho de Melo 723c27b3e0 [LIB]: Expand typedefs in the expand_types mode
[acme@filo pahole]$ cat examples/expand_typedefs.c
<SNIP>
typedef struct {
	int a, b, c;
} inner;

static struct outer {
        int q, b;
        inner m;
} foo;
<SNIP>
[acme@filo pahole]$ pahole --expand_types examples/expand_typedefs
/* <158> /home/acme/git/pahole/examples/expand_typedefs.c:7 */
struct outer {
	int          q;                 /*     0     4 */
	int          b;                 /*     4     4 */
	/* typedef inner */ struct {
		int  a;                 /*     0     4 */
		int  b;                 /*     4     4 */
		int  c;                 /*     8     4 */
	} m;                            /*     8    12 */
}; /* size: 20, cachelines: 1 */
   /* last cacheline: 20 bytes */
   /* definitions: 1 */
[acme@filo pahole]$

For now it does all typedef expansions, which in at least the base types may be
a bit too much, e.g. u32 -> unsigned long int, lets see if somebody complains,
perhaps even myself 8) If that is the case we can add yet another command line
option to specify that such base type expansions should be filtered out, making
the expand_types parameter be flag mask, not just a boolean as it is today.

To see a more complete output look at:

http://oops.ghostprotocols.net:81/acme/dwarves/vmlinux-pahole-expand_types-typedef_unfolding.txt

Suggested by Jeff Muizelaar.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2007-02-26 22:57:38 -03:00
Arnaldo Carvalho de Melo 75d0eb048e [RPM]: 15th release
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2007-02-26 13:45:45 -03:00
Arnaldo Carvalho de Melo 3c148cd84b [CMAKE] FindDWARF.cmake: use the "include_directories" command
To tell where to find the elfutils/libdw.h, etc if they are not in the standard
system include dirs, i.e. its no use to find the paths if we don't tell the
cmake system to use the paths found 8)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2007-02-25 17:21:29 -03:00
Arnaldo Carvalho de Melo 104a418109 [CMAKE] FindDWARF.cmake: check for elfutils/libdw.h, not plain libdw.h
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2007-02-25 17:08:28 -03:00
Arnaldo Carvalho de Melo accbd016e9 [CMAKE] FindDWARF.cmake: lowercase the commands and reindent
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2007-02-25 17:03:28 -03:00
Arnaldo Carvalho de Melo 8cbec769ba [CMAKE]: Test if all the previous path checks were sucessful
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2007-02-25 16:52:08 -03:00
Arnaldo Carvalho de Melo 0a65e24cae [CMAKE]: Just convert the commands to lowercase
Its case insensitive, so why have it screaming? :)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2007-02-25 16:43:59 -03:00
Arnaldo Carvalho de Melo a2b4f4fd6f [CODIFF]: Look for diffs in the number and total size of inline expansions:
Example

/home/acme/git/net-2.6/net/ipv4/tcp_input.c:
  tcp_prune_queue |  +24 : 683 -> 707, size inlines: 389 -> 417

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2007-02-24 23:12:34 -02:00
Arnaldo Carvalho de Melo d415382909 [LIB]: Rename all the variables used to account the number of bytes printed in __fprintf routines
For consistency

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2007-02-15 12:28:02 -02:00
Arnaldo Carvalho de Melo 5a420cc24e [LIB]: Make tag__fprintf return the number of bytes printed
For consistency with all the other __fprintf routines.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2007-02-15 12:03:47 -02:00
Arnaldo Carvalho de Melo c3103abfef [LIB]: Rename function__print_stats to function__fprintf_stats, for consistency
Also make it return the number of bytes printed.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2007-02-15 12:01:01 -02:00
Arnaldo Carvalho de Melo 640d1d5e53 [LIB]: Rename function__print to function__fprintf, for consistency
Also make it return the number of bytes printed.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2007-02-15 11:58:28 -02:00
Arnaldo Carvalho de Melo d5a0c78a4c [LIB]: Rename lexblock__print to lexblock__fprintf, for consistency
Also make it return the number of bytes printed.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2007-02-15 11:56:16 -02:00
Arnaldo Carvalho de Melo 6b1f439074 [LIB]: Rename typedef__print to typedef__fprintf, for consistency
And also make it return the number of bytes printed.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2007-02-15 11:46:49 -02:00
Arnaldo Carvalho de Melo 02d70cca53 [LIB]: Rename tag__print_decl_info to tag__fprintf_decl_info
Also for consistency

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2007-02-15 11:42:33 -02:00
Arnaldo Carvalho de Melo 70f9135467 [LIB]: Rename tag__print to tag__fprintf, for consistency
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2007-02-15 11:40:51 -02:00
Arnaldo Carvalho de Melo f411354f05 [LIB]: Convert the __snprintf routines to __fprintf semantics
So that we get rid of all the buffer limits, if we need to format into strings
we can use string streams, like we're doing now in just one case, tag__name for
DW_TAG_subroutine_type, that is bogus as it is, as we need to have the name of
the type inside the type declaration (void (*type_name)(parameters)) and not
after (void (*)(parameters) type_name)), but leave this for an upcoming cset.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2007-02-15 11:36:49 -02:00
Arnaldo Carvalho de Melo dabcb982df [LIB]: Bigger name_spacing when expanding types
To better align the comments with the offset and member size on the right.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2007-02-11 21:58:05 -02:00
Arnaldo Carvalho de Melo f6888f029a [PAHOLE]: Honor --expand_types when the class is specified too
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2007-02-11 00:55:54 -02:00
Arnaldo Carvalho de Melo ce9d7e11fe [CTRACER]: Lots of improvements
1. We now use relayfs
2. ostra-cg is shipped and used in the Makefile
3. README.ctracer has all the details

I followed README.ctracer and the result, in my workstation, was this one:
http://oops.ghostprotocols.net:81/acme/dwarves/callgraphs/acme_eating_his_dog_food/6.html

I've started on the 6th page as it is more interesting, having tcp and netlink
callchains, don't be disappointed by some pages having just one level of
nesting, that is just the lack of containers and aliases (to follow tcp_sock,
skb->sk, etc) from the OSTRA days, but it's getting there! :-)

Ah, it is collecting all the base types in the specified struct by doing a
struct "view", i.e. trimming the struct to have just members that are
"reducible" to basic types (int, long, char, signed and unsigned), then
reorganizing it with the code introduced in pahole --reorganize to get it to
the best layout possible, reducing the size of the entry probe points trace
entries.

Updated rpms are available at the usual place:

http://oops.ghostprotocols.net:81/acme/dwarves/rpm/

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2007-02-02 15:15:27 -02:00
Arnaldo Carvalho de Melo d37f41df58 [LIB]: Pass a FILE pointer to the cus__emit routines
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2007-02-02 12:52:46 -02:00
Arnaldo Carvalho de Melo b7cad1782d [RPM]: Release 13
Adding pglobal and the latest advancements in pahole --reorganize.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2007-02-02 12:30:56 -02:00
Davi Arnaut 4ab3403e3b [LIB]: Add initial support for DW_AT_location, in variables
And use it in a new tool, pglobal, that shows global variables and functions.

Signed-off-by: Davi Arnaut <davi@haxent.com.br>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2007-02-02 11:56:53 -02:00
Arnaldo Carvalho de Melo dfccef66dd [LIB]: Use list_for_each_entry_safe in class__delete
As we're deleting the members.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2007-02-01 15:54:42 -02:00
Arnaldo Carvalho de Melo e4ad9bb2e8 [LIB]: Optionally pass a new name for the class in class__clone
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2007-02-01 14:09:48 -02:00
Arnaldo Carvalho de Melo aab506fdcc [LIB]: Pass a FILE pointer to the __print routines
So that in tools like ctracer we can print to a file, most of the tools just
pass stdout, keeping the previous behaviour.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2007-02-01 13:50:28 -02:00
Arnaldo Carvalho de Melo 67119ea1a3 [LIB]: Move class__reorganize and friends from pahole to libdwarves
Will be used in ctracer to create a struct subset with just the types for which
we have "collectors", i.e. functions that reduce complex types to base types
that will be put in the mini-struct, that will be as tightly packed as it can
be.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2007-02-01 13:17:41 -02:00
Arnaldo Carvalho de Melo f221465b68 [PAHOLE]: Introduce --show_reorg_steps
To show how the struct looks like after each member reorganization, should help
with debugging when something looks like a bad decision.

An example is provided at:

http://oops.ghostprotocols.net:81/acme/dwarves/pahole--reorganize--verbose--show_reorg_steps_example.txt

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2007-02-01 12:27:43 -02:00
Arnaldo Carvalho de Melo 5d300c135e [LIB]: Export class__print
Will be used by pahole --show_reorg_steps

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2007-02-01 11:51:38 -02:00
Arnaldo Carvalho de Melo d105a5eb6c [PAHOLE]: Reorganize bitfields
This cset also does a fixup for cases where the compiler keeps the type
specified by the programmer for a bitfield but uses less space to combine with
the next, non-bitfield member, these cases can be caught using plain pahole and
will appear with this comment:

        /* --- cacheline 1 boundary (64 bytes) --- */
        int          bitfield1:1;   /* 64 4 */
        int          bitfield2:1;   /* 64 4 */

        /* XXX 14 bits hole, try to pack */
        /* Bitfield WARNING: DWARF size=4, real size=2 */

        short int    d;             /* 66 2 */

The fixup is done prior to reorganizing the fields.

Now an example of this code in action:

[acme@filo examples]$ cat swiss_cheese.c
<SNIP>
struct cheese {
        char  id;
        short number;
        char  name[52];
        int   a:1;
        int   b;
        int   bitfield1:1;
        int   bitfield2:1;
        short d;
        short e;
        short last:5;
};
<SNIP>
[acme@filo examples]$

Lets look at the layout:

[acme@filo examples]$ pahole swiss_cheese cheese
/* <11b> /home/acme/git/pahole/examples/swiss_cheese.c:3 */
struct cheese {
        char        id;             /*  0  1 */

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

        short int   number;         /*  2  2 */
        char        name[52];       /*  4 52 */
        int         a:1;            /* 56  4 */

        /* XXX 31 bits hole, try to pack */

        int         b;              /* 60  4 */
        /* --- cacheline 1 boundary (64 bytes) --- */
        int         bitfield1:1;    /* 64  4 */
        int         bitfield2:1;    /* 64  4 */

        /* XXX 14 bits hole, try to pack */
        /* Bitfield WARNING: DWARF size=4, real size=2 */

        short int   d;              /* 66  2 */
        short int   e;              /* 68  2 */
        short int   last:5;         /* 70  2 */
}; /* size: 72, cachelines: 2 */
   /* sum members: 71, holes: 1, sum holes: 1 */
   /* bit holes: 2, sum bit holes: 45 bits */
   /* bit_padding: 11 bits */
   /* last cacheline: 8 bytes */
[acme@filo examples]$

Full of holes, has bit padding and uses more than one 64 bytes cacheline.

Now lets ask pahole to reorganize it:

[acme@filo examples]$ pahole --reorganize --verbose swiss_cheese cheese
/* Demoting bitfield ('a' ... 'a') from 'int' to 'unsigned char' */
/* Demoting bitfield ('bitfield1' ... 'bitfield2') from 'short unsigned int' to 'unsigned char' */
/* Demoting bitfield ('last') from 'short int' to 'unsigned char' */
/* Moving 'bitfield2:1' from after 'bitfield1' to after 'a:1' */
/* Moving 'bitfield1:1' from after 'b' to after 'bitfield2:1' */
/* Moving 'last:5' from after 'e' to after 'bitfield1:1' */
/* Moving bitfield('a' ... 'last') from after 'name' to after 'id' */
/* Moving 'e' from after 'd' to after 'b' */

/* <11b> /home/acme/git/pahole/examples/swiss_cheese.c:3 */
struct cheese {
        char                       id;                   /*     0     1 */
        unsigned char              a:1;                  /*     1     1 */
        unsigned char              bitfield2:1;          /*     1     1 */
        unsigned char              bitfield1:1;          /*     1     1 */
        unsigned char              last:5;               /*     1     1 */
        short int                  number;               /*     2     2 */
        char                       name[52];             /*     4    52 */
        int                        b;                    /*    56     4 */
        short int                  e;                    /*    60     2 */
        short int                  d;                    /*    62     2 */
        /* --- cacheline 1 boundary (64 bytes) --- */
}; /* size: 64, cachelines: 1 */
   /* saved 8 bytes and 1 cacheline! */
[acme@filo examples]$

Instant karma, it gets completely packed, and look ma, no
__attribute__((packed)) :-)

With this struct task_struct in the linux kernel is shrunk by 12 bytes, there
is more 4 bytes to save with another technique that involves not combining
holes, but using the last single hole to fill it with members at the tail of
the struct.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2007-02-01 10:51:16 -02:00
Arnaldo Carvalho de Melo 26c1474b61 [CMAKE/RPM]: Fix build for x86-64
RPMS for FC6 x86-64 are available at:

http://oops.ghostprotocols.net:81/acme/dwarves/rpm/x86-64/

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2007-01-30 19:07:28 -02:00
Arnaldo Carvalho de Melo 8e236f4ca3 [PAHOLE]: Combine bitfields and demote the ones that have more bits than needed
This allows us to save 4 more bytes in struct task_struct, for instance, now we
need to combine whole bitfields with other fields if some bitfield has a size
less than sizeof(void *) and there is a suitable hole.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2007-01-30 16:55:19 -02:00