-
Notifications
You must be signed in to change notification settings - Fork 38
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
Avoid copying elf symbol names, cache elf_get_section_info results #210
Conversation
cdde356
to
030cf3f
Compare
Grabbed a random 3.10 kernel and it rarely hits the fallback path, in contrary to my 5.15 one... Should probably check if we can swap the order, although my gut feeling is that it'll cause breakage. The generated index files do vary across the two kernels. At a glance an extra |
Signed-off-by: Emil Velikov <[email protected]>
Since the caller already copies the strings as needed, we can just point to the elf data directly. Signed-off-by: Emil Velikov <[email protected]>
As per the documentation (man 5 elf) the section must be null terminated. Move the check further up and remove the no longer needed code trying to workaround non-compliant instances. Note: drop the erroneous +1 in the overflow (malloc size) calculation Signed-off-by: Emil Velikov <[email protected]>
Since the caller already copies the strings as needed, we can just point to the elf data directly. Signed-off-by: Emil Velikov <[email protected]>
Since the caller already copies the strings as needed, we can just point to the elf data directly. Signed-off-by: Emil Velikov <[email protected]>
030cf3f
to
56cd05d
Compare
Codecov ReportAttention: Patch coverage is
|
Since the caller already copies the strings as needed, we can just point to the elf data directly. Signed-off-by: Emil Velikov <[email protected]>
Rename kmod_elf_get_strings() to kmod_elf_get_modinfo_strings() and fold the section name within, instead of passing it as an argument. This aligns better with the other kmod_elf function names and will allow us to tweak the kmod_elf_get_section() handling with later commit. Signed-off-by: Emil Velikov <[email protected]>
56cd05d
to
ff7a904
Compare
v2: quit looping when found, ELFDBG print missing sections Seemingly only ~20% of modules have |
Currently, we repeatedly loop over the elf headers looking for five well known sections. Just do it once in kmod_elf_new() and reuse the data as needed. Note that not all sections are guaranteed to be available, so check and ELFDBG print the ones which are missing. v2: quit looping when found, ELFDBG print missing sections v3: match the first section name, use a loop Signed-off-by: Emil Velikov <[email protected]>
ff7a904
to
4a3d7dd
Compare
Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Tobias Stoeckmann <[email protected]> Link: #210 Signed-off-by: Lucas De Marchi <[email protected]>
Since the caller already copies the strings as needed, we can just point to the elf data directly. Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Tobias Stoeckmann <[email protected]> Link: #210 Signed-off-by: Lucas De Marchi <[email protected]>
As per the documentation (man 5 elf) the section must be null terminated. Move the check further up and remove the no longer needed code trying to workaround non-compliant instances. Note: drop the erroneous +1 in the overflow (malloc size) calculation Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Tobias Stoeckmann <[email protected]> Link: #210 Signed-off-by: Lucas De Marchi <[email protected]>
Since the caller already copies the strings as needed, we can just point to the elf data directly. Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Tobias Stoeckmann <[email protected]> Link: #210 Signed-off-by: Lucas De Marchi <[email protected]>
Since the caller already copies the strings as needed, we can just point to the elf data directly. Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Tobias Stoeckmann <[email protected]> Link: #210 Signed-off-by: Lucas De Marchi <[email protected]>
Since the caller already copies the strings as needed, we can just point to the elf data directly. Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Tobias Stoeckmann <[email protected]> Link: #210 Signed-off-by: Lucas De Marchi <[email protected]>
Rename kmod_elf_get_strings() to kmod_elf_get_modinfo_strings() and fold the section name within, instead of passing it as an argument. This aligns better with the other kmod_elf function names and will allow us to tweak the kmod_elf_get_section() handling with later commit. Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Tobias Stoeckmann <[email protected]> Link: #210 Signed-off-by: Lucas De Marchi <[email protected]>
Currently, we repeatedly loop over the elf headers looking for five well known sections. Just do it once in kmod_elf_new() and reuse the data as needed. Note that not all sections are guaranteed to be available, so check and ELFDBG print the ones which are missing. v2: quit looping when found, ELFDBG print missing sections v3: match the first section name, use a loop Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Tobias Stoeckmann <[email protected]> Link: #210 Signed-off-by: Lucas De Marchi <[email protected]>
Applied, thanks |
Couple of tiny tweaks, which shave a ~4MB of memory and ~5% CPU cycles off a depmod run, although the actual perf difference is within the noise margin.
Grab whichever commit make sense.
OOC: any ideas when all
.strtab
started getting only__crc_
symbols? Going back to ~2011 and it seems to have always been the case.