Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove packed when possible #16

Closed
wants to merge 1 commit into from

Conversation

nmorey
Copy link
Contributor

@nmorey nmorey commented Apr 24, 2019

WIP on issue #15

This removes the packed attribute from all structs that do not need it.
All remaining structs are impacted either by a size change or hole inserted for alignment.

For a lot of the IBA structures, the packed attribute has no effect.

List of impacted struct and checks were done this way:

Before applying this patch
- Generate a single file with all the IBA structs
(echo -e "#include <iba/ib_types.h>\n#include <stdio.h>\n\n\n"; for struct in $(git grep '^} PACK_SUFFIX' -- include/iba/ib_types.h | awk '{ print $NF }' | sed -e 's/;//'); do echo -e "$struct a_$struct;"; done) > ib_sizes.c
- Compile for both 32 and 64b
gcc -o ib_sizes.64.o -g3 -c ib_sizes.c -I./include/
gcc -o ib_sizes.32.o -g3 -m32 -c ib_sizes.c -I./include/
- Generate structure data using pahole
pahole ib_sizes.64.o > sizes.64.org
pahole ib_sizes.32.o > sizes.32.org

After applying this patch:
- Compile for both 32 and 64b
gcc -o ib_sizes.64.o -g3 -c ib_sizes.c -I./include/
gcc -o ib_sizes.32.o -g3 -m32 -c ib_sizes.c -I./include/
- Generate structure data using pahole
pahole ib_sizes.64.o > sizes.64.new
pahole ib_sizes.32.o > sizes.32.new

Diff pahole results:
diff sizes.64.org sizes.64.new
diff sizes.32.org sizes.32.new

As the patch remove effect-less attribute, no diff shows up

Signed-off-by: Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com>
@hnrose
Copy link
Contributor

hnrose commented Apr 25, 2019

WIP on issue #15

This removes the packed attribute from all structs that do not need it.
All remaining structs are impacted either by a size change or hole inserted for alignment.

I visually inspected all struct changes where packing is removed and it looks fine to me. What is next step ? Should I test these changes out ? Are there more to come (and if so, would this patch be modified or would it be a subsequent patch to this) ?

@nmorey
Copy link
Contributor Author

nmorey commented Apr 26, 2019

These changes should be 100% safe. Pahole checked all the struct in 32 and 64 bits and sees no change.

There should probably be more changes but they are tricky. Not sure if they are worth doing

@hnrose
Copy link
Contributor

hnrose commented Apr 26, 2019

These changes should be 100% safe. Pahole checked all the struct in 32 and 64 bits and sees no change.

I did some initial testing with this patch and my simple tests worked. I'll merge patch and some regression tests will be run probably over the weekend.

There should probably be more changes but they are tricky. Not sure if they are worth doing

OK

@hnrose
Copy link
Contributor

hnrose commented Apr 26, 2019

Manually merged

@hnrose
Copy link
Contributor

hnrose commented Apr 29, 2019

Unfortunately some regressions are now failing. I started to investigate these failures. Not sure if this is an issue with the regressions or whether it's caused by this patch. Still investigating...

@hnrose
Copy link
Contributor

hnrose commented May 3, 2019

It is likely just a regression issue.

@hnrose
Copy link
Contributor

hnrose commented May 3, 2019

Closing

@hnrose hnrose closed this May 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants