Go to file
Arnaldo Carvalho de Melo 743f2536d8 btf_encoder: Move libbtf.c to btf_encoder.c, the only user of its functions
All those functions now operate on a 'struct btf_encoder' object, there
is no need to make them visible outside the btf_encoder.c source file,
so move them all there and make them static.

This leads to some savings as the compiler is free to optimize further,
inlining stuff used in just one place, etc:

Before, for encoding then reading we have:

  ⬢[acme@toolbox pahole]$ rm -f vmlinux.btf ; perf stat -r5 pahole -j vmlinux.btf vmlinux && perf stat -r5 btfdiff vmlinux vmlinux.btf

   Performance counter stats for 'pahole -j vmlinux.btf vmlinux' (5 runs):

            8,546.56 msec task-clock:u              #    0.989 CPUs utilized            ( +-  0.71% )
                   0      context-switches:u        #    0.000 /sec
                   0      cpu-migrations:u          #    0.000 /sec
             775,699      page-faults:u             #   89.802 K/sec                    ( +-  0.00% )
      34,082,471,148      cycles:u                  #    3.946 GHz                      ( +-  0.22% )  (83.33%)
         636,039,662      stalled-cycles-frontend:u #    1.87% frontend cycles idle     ( +-  1.69% )  (83.33%)
       4,895,524,778      stalled-cycles-backend:u  #   14.38% backend cycles idle      ( +-  2.10% )  (83.33%)
      77,379,632,646      instructions:u            #    2.27  insn per cycle
                                                    #    0.07  stalled cycles per insn  ( +-  0.04% )  (83.33%)
      18,185,560,802      branches:u                #    2.105 G/sec                    ( +-  0.03% )  (83.34%)
         149,715,849      branch-misses:u           #    0.82% of all branches          ( +-  0.15% )  (83.34%)

              8.6412 +- 0.0612 seconds time elapsed  ( +-  0.71% )

   Performance counter stats for 'btfdiff vmlinux vmlinux.btf' (5 runs):

            7,168.97 msec task-clock:u              #    1.016 CPUs utilized            ( +-  0.50% )
                   0      context-switches:u        #    0.000 /sec
                   0      cpu-migrations:u          #    0.000 /sec
             727,965      page-faults:u             #  103.257 K/sec                    ( +-  0.00% )
      27,339,019,686      cycles:u                  #    3.878 GHz                      ( +-  0.17% )  (83.28%)
         511,689,773      stalled-cycles-frontend:u #    1.88% frontend cycles idle     ( +-  1.84% )  (83.34%)
       3,677,090,126      stalled-cycles-backend:u  #   13.53% backend cycles idle      ( +-  1.47% )  (83.35%)
      66,182,032,226      instructions:u            #    2.44  insn per cycle
                                                    #    0.06  stalled cycles per insn  ( +-  0.02% )  (83.35%)
      15,747,149,247      branches:u                #    2.234 G/sec                    ( +-  0.02% )  (83.36%)
          98,013,024      branch-misses:u           #    0.62% of all branches          ( +-  0.21% )  (83.33%)

              7.0554 +- 0.0357 seconds time elapsed  ( +-  0.51% )

  ⬢[acme@toolbox pahole]$

Then, with this patch:

  ⬢[acme@toolbox pahole]$ rm -f vmlinux.btf ; perf stat -r5 pahole -j vmlinux.btf vmlinux && perf stat -r5 btfdiff vmlinux vmlinux.btf

   Performance counter stats for 'pahole -j vmlinux.btf vmlinux' (5 runs):

            8,280.48 msec task-clock:u              #    0.975 CPUs utilized            ( +-  0.72% )
                   0      context-switches:u        #    0.000 /sec
                   0      cpu-migrations:u          #    0.000 /sec
             775,699      page-faults:u             #   91.481 K/sec                    ( +-  0.00% )
      33,265,078,702      cycles:u                  #    3.923 GHz                      ( +-  0.32% )  (83.32%)
         725,690,346      stalled-cycles-frontend:u #    2.16% frontend cycles idle     ( +-  1.76% )  (83.34%)
       4,803,211,469      stalled-cycles-backend:u  #   14.33% backend cycles idle      ( +-  2.43% )  (83.34%)
      77,162,277,929      instructions:u            #    2.30  insn per cycle
                                                    #    0.07  stalled cycles per insn  ( +-  0.06% )  (83.34%)
      18,139,715,894      branches:u                #    2.139 G/sec                    ( +-  0.03% )  (83.34%)
         149,609,552      branch-misses:u           #    0.82% of all branches          ( +-  0.16% )  (83.33%)

              8.4921 +- 0.0630 seconds time elapsed  ( +-  0.74% )

   Performance counter stats for 'btfdiff vmlinux vmlinux.btf' (5 runs):

            7,018.11 msec task-clock:u              #    1.013 CPUs utilized            ( +-  0.68% )
                   0      context-switches:u        #    0.000 /sec
                   0      cpu-migrations:u          #    0.000 /sec
             727,949      page-faults:u             #  105.207 K/sec                    ( +-  0.00% )
      26,632,191,985      cycles:u                  #    3.849 GHz                      ( +-  0.31% )  (83.35%)
         496,648,058      stalled-cycles-frontend:u #    1.87% frontend cycles idle     ( +-  2.02% )  (83.29%)
       3,437,243,040      stalled-cycles-backend:u  #   12.92% backend cycles idle      ( +-  0.90% )  (83.33%)
      66,192,034,237      instructions:u            #    2.49  insn per cycle
                                                    #    0.05  stalled cycles per insn  ( +-  0.03% )  (83.34%)
      15,750,883,004      branches:u                #    2.276 G/sec                    ( +-  0.03% )  (83.35%)
          97,544,298      branch-misses:u           #    0.62% of all branches          ( +-  0.12% )  (83.36%)

              6.9247 +- 0.0478 seconds time elapsed  ( +-  0.69% )

  ⬢[acme@toolbox pahole]$

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-09 13:34:15 -03:00
cmake/modules cmake: libebl was merged into libdw 2020-02-03 08:42:13 +01:00
lib btf: Add support for the floating-point types 2021-03-11 14:45:38 -03:00
man-pages pahole: Allow encoding BTF into a detached file 2021-06-04 17:28:54 -03:00
ostra ostra: Initial python3 conversion 2019-04-23 12:02:22 -03:00
rpm/SPECS pahole: Prep 1.21 2021-04-09 19:39:15 -03:00
.gitignore pahole: Add build dir, config.h to .gitignore 2019-02-11 12:55:46 -03:00
.gitmodules pahole: add libbpf as submodule under lib/bpf 2019-02-11 12:56:40 -03:00
CMakeLists.txt btf_encoder: Move libbtf.c to btf_encoder.c, the only user of its functions 2021-06-09 13:34:15 -03:00
COPYING [LICENSE]: Add COPYING file and add missing license info on some files 2007-12-17 14:15:42 -02:00
MANIFEST btf_encoder: Move libbtf.c to btf_encoder.c, the only user of its functions 2021-06-09 13:34:15 -03:00
NEWS pahole: Prep 1.21 2021-04-09 19:39:15 -03:00
README README: Mention how to specify another prefix 2021-05-10 21:32:13 -03:00
README.DEBUG README.DEBUG: Add an extra step to make the instructions cut'n'exec 2017-12-14 14:15:54 -03:00
README.btf v1.13: New release 2019-04-16 16:13:19 -03:00
README.cross README: Add instructions to do a cross build 2020-08-17 09:52:02 -03:00
README.ctracer ctracer: update README.ctracer, f9 has the dwarves 2008-10-29 08:54:53 -02:00
README.tarball docs: Add command line to generate tarball with a prefix 2020-03-12 16:55:15 -03:00
btf_encoder.c btf_encoder: Move libbtf.c to btf_encoder.c, the only user of its functions 2021-06-09 13:34:15 -03:00
btf_encoder.h btf_encoder: Move library global variable btf_gen_floats to btf_encoder class 2021-06-09 10:54:10 -03:00
btf_loader.c btf_loader: Stop using libbtf.h and the btf_elf class 2021-06-04 17:28:56 -03:00
btfdiff btfdiff: Support diffing DWARF vs detached BTF 2021-06-08 10:08:22 -03:00
changes-v1.13 v1.13: New release 2019-04-16 16:13:19 -03:00
changes-v1.16 dwarves: Prep v1.16 2019-12-16 11:43:53 -03:00
changes-v1.17 dwarves: Prep v1.17 2020-03-13 16:36:02 -03:00
changes-v1.18 dwarves: Prep v1.18 2020-10-02 17:29:59 -03:00
changes-v1.19 dwarves: Prep v1.19 2020-11-23 09:52:44 -03:00
changes-v1.20 pahole: Prep 1.20 2021-02-03 21:45:01 -03:00
changes-v1.21 pahole: Prep 1.21 2021-04-09 19:39:15 -03:00
codiff.c codiff: Use zfree() where applicable 2021-05-27 11:00:18 -03:00
config.h.cmake [DWARVES] Fixes a FIXME relating to a missing elf (libdw) symbol check. 2008-02-12 21:08:49 -02:00
ctf.h Adopt SPDX-License-Identifier 2019-01-18 15:41:48 -03:00
ctf_encoder.c strings: use BTF's string APIs for strings management 2020-10-20 17:17:51 -03:00
ctf_encoder.h Adopt SPDX-License-Identifier 2019-01-18 15:41:48 -03:00
ctf_loader.c dwarves: Move the common initialization of fields for 'struct type' 2020-08-05 15:16:19 -03:00
ctfdwdiff ctfdwdiff: Don't ask for variables and inline expansions in pfunct 2009-03-31 19:21:46 -03:00
ctracer.c ctracer: Initialize the 'parm_list' variable, detected by covscan 2021-05-27 11:00:18 -03:00
dtagnames.c dtagnames: Stop using the deprecated mallinfo() function 2021-02-02 09:38:46 -03:00
dutil.c dutil: Make handling of NULL by destructos consistent 2021-05-27 11:00:18 -03:00
dutil.h dutil: Adopt the zalloc()/zfree() from perf 2021-05-27 11:00:18 -03:00
dwarf_loader.c dwarf_loader: Add define for DW_OP_addrx 2021-05-28 13:23:29 -03:00
dwarves.c btf_loader: Stop using libbtf.h and the btf_elf class 2021-06-04 17:28:56 -03:00
dwarves.h core: Allow passing the base_btf object via 'struct conf_load' 2021-06-04 17:28:56 -03:00
dwarves_emit.c emit: Remove unused 'is_pointer' variable 2019-07-02 10:27:16 -03:00
dwarves_emit.h Adopt SPDX-License-Identifier 2019-01-18 15:41:48 -03:00
dwarves_fprintf.c codiff: Fix usage of negative errno values with strerror(), reported by covscan 2021-05-27 11:00:18 -03:00
dwarves_reorganize.c reorganize: Enclose bitfield routines under ifdef 2019-07-02 12:28:50 -03:00
dwarves_reorganize.h Adopt SPDX-License-Identifier 2019-01-18 15:41:48 -03:00
elf_symtab.c elf_symtab: Use zfree() where applicable 2021-05-27 11:00:18 -03:00
elf_symtab.h bpf_encoder: Translate SHN_XINDEX in symbol's st_shndx values 2021-01-26 22:36:36 -03:00
elfcreator.c elfcreator: Address initialization warning emitted by 'gcc -O6' 2019-12-16 11:19:47 -03:00
elfcreator.h Adopt SPDX-License-Identifier 2019-01-18 15:41:48 -03:00
fullcircle v1.13: New release 2019-04-16 16:13:19 -03:00
gobuffer.c gobuffer: Use zfree() and make delete accept NULL, like free() 2021-05-27 11:00:18 -03:00
gobuffer.h Adopt SPDX-License-Identifier 2019-01-18 15:41:48 -03:00
hash.h dwarf_loader: Use a better hashing function, from libbpf 2021-02-12 09:35:53 -03:00
libctf.c libctf: Use zfree() where applicable 2021-05-27 11:00:18 -03:00
libctf.h strings: use BTF's string APIs for strings management 2020-10-20 17:17:51 -03:00
list.h Adopt SPDX-License-Identifier 2019-01-18 15:41:48 -03:00
pahole.c btf_encoder: Move libbtf.c to btf_encoder.c, the only user of its functions 2021-06-09 13:34:15 -03:00
pahole_strings.h pahole: Add --kabi_prefix flag 2021-05-27 13:44:35 -03:00
pdwtags.c core: Allow the loaders to advertise features they have 2019-04-15 14:45:27 -03:00
pfunct.c pfunct: Use load stealer to speed up --class 2020-11-16 08:15:23 -03:00
pglobal.c pglobal: Allow passing the format path specifier, to use with BTF 2019-10-24 08:17:16 -03:00
prefcnt.c prefcnt: Avoid ambiguous else with for_each macro 2019-07-02 12:31:57 -03:00
rbtree.c Adopt SPDX-License-Identifier 2019-01-18 15:41:48 -03:00
rbtree.h Adopt SPDX-License-Identifier 2019-01-18 15:41:48 -03:00
regtest regtest: Accept --diff instad of plain 'diff' as long option 2012-05-14 19:36:58 -03:00
scncopy.c Adopt SPDX-License-Identifier 2019-01-18 15:41:48 -03:00
strings.c pahole: Add --kabi_prefix flag 2021-05-27 13:44:35 -03:00
syscse.c dwarves: Make function__for_each_parameter receive 'cu' arg 2020-01-09 14:16:52 -03:00

README

Build instructions:

1. install cmake
2. mkdir build
3. cd build
4. cmake -D__LIB=lib ..
5. make install

Default is to install to /usr/local, use -DCMAKE_INSTALL_PREFIX=
when invoking cmake to specify another install location.

Known to work scenarios:

Mandriva Cooker:

cmake 2.4.5-1mdv2007.1
libelfutils1-devel 0.123-1mdv2007.1

Debian Unstable:

cmake 2.4.5-1
libdw-dev 0.123-2

Fedora Core 6:

cmake 2.4.5-2.fc6
elfutils-devel 0.126-1.fc6