Skip to content

Speed up the symbols' resolution process V3

Alessio Igor Bogani linux-embedded lkml 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest4 patches 0 repliesNew

Changes since V2 from the cover letter

*) Fix a bug in each_symbol() semantics by Anders Kaseorg *) Split the work in three patches as requested by Rusty Russell *) Add a generic binary search implementation made by Tim Abbott *) Remove CONFIG_SYMBOLS_BSEARCH kernel option

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4module: Split the find_symbol_in_section functioninclude/linux/module.h kernel/module.c+20 -120 replies
2/4module: Sort exported symbolsinclude/asm-generic/vmlinux.lds.h include/linux/module.h scripts/module-common.lds+23 -120 replies
3/4lib: Add generic binary search function to the kernel.include/linux/bsearch.h lib/Makefile lib/bsearch.c+64 -10 replies
4/4module: Use the binary search for symbols resolutionkernel/module.c+8 -40 replies

Reviews trailers per patch

None of the 4 patches has a Reviewed-by or Acked-by.

PatchAlan JenkinsAndré Goddard RosaRusty Russell
1/4
2/4
3/4Extra-bikeshedding-by Extra-bikeshedding-by Extra-bikeshedding-by
4/4

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v1 thread

Cover letter [PATCH 0/4] Speed up the symbols' resolution process V3

The intent of this patch is to speed up the symbols resolution process.

This objective is achieved by sorting all ksymtab* and kcrctab* symbols (those which reside both in the kernel and in the modules) and thus use the fast binary search.

To avoid adding lots of code for symbols sorting I rely on the linker which can easily do the job thanks to a little trick. The trick isn't really beautiful to see but permits minimal changes to the code and build process. Indeed the patch is very simple and short.

In the first place I changed the code for place every symbol in a different section (for example: "___ksymtab" sec "__" #sym) at compile time (this the above mentioned trick!). Thus I request to the linker to sort and merge all these sections into the appropriate ones (for example: "__ksymtab") at link time using the linker scripts. Once all symbols are sorted we can use binary search instead of the linear one.

I'm fairly sure that this is a good speed improvement even though I haven't made any comprehensive benchmarking (but follow a simple one). In any case I would be very happy to receive suggestions about how made it. Collaterally, the boot time should be reduced also (proportionally to the number of modules and symbols nvolved at boot stage).

I hope that you find that interesting!

This work was supported by a hardware donation from the CE Linux Forum.

Thanks to Ian Lance Taylor for help about how the linker works.

Changes since V2:
*) Fix a bug in each_symbol() semantics by Anders Kaseorg *) Split the work in three patches as requested by Rusty Russell *) Add a generic binary search implementation made by Tim Abbott *) Remove CONFIG_SYMBOLS_BSEARCH kernel option

Changes since V1:
*) Merge all patches into only one
*) Remove few useless things
*) Introduce CONFIG_SYMBOLS_BSEARCH kernel option

Alessio Igor Bogani (3):
module: Split the find_symbol_in_section function
module: Sort exported symbols
module: Use the binary search for symbols resolution

Tim Abbott (1):
lib: Add generic binary search function to the kernel.

 include/asm-generic/vmlinux.lds.h |   20 +++++++-------
 include/linux/bsearch.h           |    9 ++++++
 include/linux/module.h            |    7 +++--
 kernel/module.c                   |   37 ++++++++++++++++---------
 lib/Makefile                      |    3 +-
 lib/bsearch.c                     |   53 +++++++++++++++++++++++++++++++++++++
 scripts/module-common.lds         |   11 +++++++
 7 files changed, 113 insertions(+), 27 deletions(-)
 create mode 100644 include/linux/bsearch.h
 create mode 100644 lib/bsearch.c