[acme@filo examples]$ pahole --reorganize --verbose --show_reorg_steps -C cheese swiss_cheese /* bitfield types were fixed */ 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) --- */ short unsigned int bitfield1:1; /* 64 2 */ short unsigned int bitfield2:1; /* 64 2 */ /* XXX 14 bits hole, try to pack */ 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 */ /* Demoting bitfield ('a' ... 'a') from 'int' to 'unsigned char' */ struct cheese { char id; /* 0 1 */ /* XXX 1 byte hole, try to pack */ short int number; /* 2 2 */ char name[52]; /* 4 52 */ unsigned char a:1; /* 56 1 */ /* XXX 7 bits hole, try to pack */ /* XXX 3 bytes hole, try to pack */ int b; /* 60 4 */ /* --- cacheline 1 boundary (64 bytes) --- */ short unsigned int bitfield1:1; /* 64 2 */ short unsigned int bitfield2:1; /* 64 2 */ /* XXX 14 bits hole, try to pack */ short int d; /* 66 2 */ short int e; /* 68 2 */ short int last:5; /* 70 2 */ }; /* size: 72, cachelines: 2 */ /* sum members: 68, holes: 2, sum holes: 4 */ /* bit holes: 2, sum bit holes: 21 bits */ /* bit_padding: 11 bits */ /* last cacheline: 8 bytes */ /* Demoting bitfield ('bitfield1' ... 'bitfield2') from 'short unsigned int' to 'unsigned char' */ struct cheese { char id; /* 0 1 */ /* XXX 1 byte hole, try to pack */ short int number; /* 2 2 */ char name[52]; /* 4 52 */ unsigned char a:1; /* 56 1 */ /* XXX 7 bits hole, try to pack */ /* XXX 3 bytes hole, try to pack */ int b; /* 60 4 */ /* --- cacheline 1 boundary (64 bytes) --- */ unsigned char bitfield1:1; /* 64 1 */ unsigned char bitfield2:1; /* 64 1 */ /* XXX 6 bits hole, try to pack */ /* XXX 1 byte hole, try to pack */ short int d; /* 66 2 */ short int e; /* 68 2 */ short int last:5; /* 70 2 */ }; /* size: 72, cachelines: 2 */ /* sum members: 67, holes: 3, sum holes: 5 */ /* bit holes: 2, sum bit holes: 13 bits */ /* bit_padding: 11 bits */ /* last cacheline: 8 bytes */ /* Demoting bitfield ('last') from 'short int' to 'unsigned char' */ struct cheese { char id; /* 0 1 */ /* XXX 1 byte hole, try to pack */ short int number; /* 2 2 */ char name[52]; /* 4 52 */ unsigned char a:1; /* 56 1 */ /* XXX 7 bits hole, try to pack */ /* XXX 3 bytes hole, try to pack */ int b; /* 60 4 */ /* --- cacheline 1 boundary (64 bytes) --- */ unsigned char bitfield1:1; /* 64 1 */ unsigned char bitfield2:1; /* 64 1 */ /* XXX 6 bits hole, try to pack */ /* XXX 1 byte hole, try to pack */ short int d; /* 66 2 */ short int e; /* 68 2 */ unsigned char last:5; /* 70 1 */ /* XXX 3 bits hole, try to pack */ }; /* size: 72, cachelines: 2 */ /* sum members: 66, holes: 3, sum holes: 5 */ /* bit holes: 2, sum bit holes: 16 bits */ /* padding: 1 */ /* last cacheline: 8 bytes */ /* Moving 'bitfield2:1' from after 'bitfield1' to after 'a:1' */ struct cheese { char id; /* 0 1 */ /* XXX 1 byte hole, try to pack */ short int number; /* 2 2 */ char name[52]; /* 4 52 */ unsigned char a:1; /* 56 1 */ unsigned char bitfield2:1; /* 56 1 */ /* XXX 6 bits hole, try to pack */ /* XXX 3 bytes hole, try to pack */ int b; /* 60 4 */ /* --- cacheline 1 boundary (64 bytes) --- */ unsigned char bitfield1:1; /* 64 1 */ /* XXX 7 bits hole, try to pack */ /* XXX 1 byte hole, try to pack */ short int d; /* 66 2 */ short int e; /* 68 2 */ unsigned char last:5; /* 70 1 */ /* XXX 3 bits hole, try to pack */ }; /* size: 72, cachelines: 2 */ /* sum members: 66, holes: 3, sum holes: 5 */ /* bit holes: 2, sum bit holes: 16 bits */ /* padding: 1 */ /* last cacheline: 8 bytes */ /* Moving 'bitfield1:1' from after 'b' to after 'bitfield2:1' */ struct cheese { char id; /* 0 1 */ /* XXX 1 byte hole, try to pack */ short int number; /* 2 2 */ char name[52]; /* 4 52 */ unsigned char a:1; /* 56 1 */ unsigned char bitfield2:1; /* 56 1 */ unsigned char bitfield1:1; /* 56 1 */ /* XXX 5 bits hole, try to pack */ /* XXX 3 bytes hole, try to pack */ int b; /* 60 4 */ /* XXX 2 bytes hole, try to pack */ /* --- cacheline 1 boundary (64 bytes) was 2 bytes ago --- */ short int d; /* 66 2 */ short int e; /* 68 2 */ unsigned char last:5; /* 70 1 */ /* XXX 3 bits hole, try to pack */ }; /* size: 72, cachelines: 2 */ /* sum members: 65, holes: 3, sum holes: 6 */ /* bit holes: 1, sum bit holes: 8 bits */ /* padding: 1 */ /* last cacheline: 8 bytes */ /* Moving 'last:5' from after 'e' to after 'bitfield1:1' */ struct cheese { char id; /* 0 1 */ /* XXX 1 byte hole, try to pack */ short int number; /* 2 2 */ char name[52]; /* 4 52 */ unsigned char a:1; /* 56 1 */ unsigned char bitfield2:1; /* 56 1 */ unsigned char bitfield1:1; /* 56 1 */ unsigned char last:5; /* 56 1 */ /* XXX 3 bytes hole, try to pack */ int b; /* 60 4 */ /* XXX 2 bytes hole, try to pack */ /* --- cacheline 1 boundary (64 bytes) was 2 bytes ago --- */ short int d; /* 66 2 */ short int e; /* 68 2 */ }; /* size: 72, cachelines: 2 */ /* sum members: 64, holes: 3, sum holes: 6 */ /* padding: 2 */ /* last cacheline: 8 bytes */ /* Moving bitfield('a' ... 'last') from after 'name' to after 'id' */ 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 */ /* XXX 2 bytes hole, try to pack */ short int d; /* 62 2 */ /* --- cacheline 1 boundary (64 bytes) --- */ short int e; /* 64 2 */ }; /* size: 68, cachelines: 2 */ /* sum members: 64, holes: 2, sum holes: 2 */ /* padding: 2 */ /* last cacheline: 4 bytes */ /* Moving 'e' from after 'd' to after 'b' */ 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 */ /* Final reorganized struct: */ /* <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! */