1. 17 Apr, 2023 8 commits
    • Masahiro Yamada's avatar
      scripts/kallsyms: decrease expand_symbol() / cleanup_symbol_name() calls · dd1553b8
      Masahiro Yamada authored
      Currently, expand_symbol() is called many times to get the uncompressed
      symbol names for sorting, and also for adding comments.
      
      With the output order shuffled in the previous commit, the symbol data
      are now written in the following order:
      
       (1) kallsyms_num_syms
       (2) kallsyms_names                         <-- need compressed names
       (3) kallsyms_markers
       (4) kallsyms_token_table
       (5) kallsyms_token_index
       (6) kallsyms_addressed / kallsyms_offsets  <-- need uncompressed names (for commenting)
       (7) kallsyms_relative_base
       (8) kallsyms_seq_of_names                  <-- need uncompressed names (for sorting)
      
      The compressed names are only needed by (2).
      
      Call expand_symbol() between (2) and (3) to restore the original symbol
      names. This requires just one expand_symbol() call for each symbol.
      
      Call cleanup_symbol_name() between (7) and (8) instead of during sorting.
      It is allowed to overwrite the ->sym field because (8) just outputs the
      index instead of the name of each symbol. Again, this requires just one
      cleanup_symbol_name() call for each symbol.
      
      This refactoring makes it ~30% faster.
      
      [Before]
      
        $ time scripts/kallsyms --all-symbols --absolute-percpu --base-relative \
          .tmp_vmlinux.kallsyms2.syms >/dev/null
      
        real    0m1.027s
        user    0m1.010s
        sys     0m0.016s
      
      [After]
      
        $ time scripts/kallsyms --all-symbols --absolute-percpu --base-relative \
          .tmp_vmlinux.kallsyms2.syms >/dev/null
      
        real    0m0.717s
        user    0m0.717s
        sys     0m0.000s
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      dd1553b8
    • Masahiro Yamada's avatar
      scripts/kallsyms: change the output order · 404bad70
      Masahiro Yamada authored
      Currently, this tool outputs symbol data in the following order.
      
       (1) kallsyms_addressed / kallsyms_offsets
       (2) kallsyms_relative_base
       (3) kallsyms_num_syms
       (4) kallsyms_names
       (5) kallsyms_markers
       (6) kallsyms_seq_of_names
       (7) kallsyms_token_table
       (8) kallsyms_token_index
      
      This commit changes the order as follows:
      
       (1) kallsyms_num_syms
       (2) kallsyms_names
       (3) kallsyms_markers
       (4) kallsyms_token_table
       (5) kallsyms_token_index
       (6) kallsyms_addressed / kallsyms_offsets
       (7) kallsyms_relative_base
       (8) kallsyms_seq_of_names
      
      The motivation is to decrease the number of function calls to
      expand_symbol() and cleanup_symbol_name().
      
      The compressed names are only required for writing 'kallsyms_names'.
      If you do this first, we can restore the original symbol names.
      You do not need to repeat the same operation over again.
      
      The actual refactoring will happen in the next commit.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      404bad70
    • Masahiro Yamada's avatar
      scripts/kallsyms: move compiler-generated symbol patterns to mksysmap · 320e7c9d
      Masahiro Yamada authored
      scripts/kallsyms.c maintains compiler-generated symbols, but we end up
      with something similar in scripts/mksysmap to avoid the "Inconsistent
      kallsyms data" error. For example, commit c17a2538 ("mksysmap: Fix
      the mismatch of 'L0' symbols in System.map").
      
      They were separately maintained prior to commit 94ff2f63 ("kbuild:
      reuse mksysmap output for kallsyms").
      
      Now that scripts/kallsyms.c parses the output of scripts/mksysmap,
      it makes more sense to collect all the ignored patterns to mksysmap.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      320e7c9d
    • Masahiro Yamada's avatar
      scripts/kallsyms: exclude symbols generated by itself dynamically · ca09bf48
      Masahiro Yamada authored
      Drop the symbols generated by scripts/kallsyms itself automatically
      instead of maintaining the symbol list manually.
      
      Pass the kallsyms object from the previous kallsyms step (if it exists)
      as the third parameter of scripts/mksysmap, which will weed out the
      generated symbols from the input to the next kallsyms step.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      ca09bf48
    • Masahiro Yamada's avatar
      scripts/mksysmap: use sed with in-line comments · c4802044
      Masahiro Yamada authored
      It is not feasible to insert comments in a multi-line shell command.
      Use sed, and move comments close to the code.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      c4802044
    • Masahiro Yamada's avatar
      scripts/mksysmap: remove comments described in nm(1) · e9f76363
      Masahiro Yamada authored
      I do not think we need to repeat what is written in 'man nm'.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      e9f76363
    • Masahiro Yamada's avatar
      scripts/kallsyms: remove redundant code for omitting U and N · a7b00a18
      Masahiro Yamada authored
      The symbol types 'U' and 'N' are already filtered out by the following
      line in scripts/mksysmap:
      
          -e ' [aNUw] '
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      a7b00a18
    • Arnd Bergmann's avatar
      kallsyms: expand symbol name into comment for debugging · bea5b745
      Arnd Bergmann authored
      The assembler output of kallsyms.c is not meant for people to understand,
      and is generally not helpful when debugging "Inconsistent kallsyms data"
      warnings. I have previously struggled with these, but found it helpful
      to list which symbols changed between the first and second pass in the
      .tmp_vmlinux.kallsyms*.S files.
      
      As this file is preprocessed, it's possible to add a C-style multiline
      comment with the full type/name tuple.
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      bea5b745
  2. 16 Apr, 2023 12 commits
  3. 15 Apr, 2023 6 commits
  4. 14 Apr, 2023 14 commits