Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: libbpf/libbpf
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.4.6
Choose a base ref
...
head repository: libbpf/libbpf
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.4.7
Choose a head ref
  • 8 commits
  • 4 files changed
  • 5 contributors

Commits on Oct 29, 2024

  1. libbpf: Skip base btf sanity checks

    When upgrading to libbpf 1.3 we noticed a big performance hit while
    loading programs using CORE on non base-BTF symbols. This was tracked
    down to the new BTF sanity check logic. The issue is the base BTF
    definitions are checked first for the base BTF and then again for every
    module BTF.
    
    Loading 5 dummy programs (using libbpf-rs) that are using CORE on a
    non-base BTF symbol on my system:
    - Before this fix: 3s.
    - With this fix: 0.1s.
    
    Fix this by only checking the types starting at the BTF start id. This
    should ensure the base BTF is still checked as expected but only once
    (btf->start_id == 1 when creating the base BTF), and then only
    additional types are checked for each module BTF.
    
    Fixes: 3903802bb99a ("libbpf: Add basic BTF sanity validation")
    Signed-off-by: Antoine Tenart <atenart@kernel.org>
    Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
    Reviewed-by: Alan Maguire <alan.maguire@oracle.com>
    Link: https://lore.kernel.org/bpf/20240624090908.171231-1-atenart@kernel.org
    (cherry picked from commit 95c63a0)
    atenart authored and anakryiko committed Oct 29, 2024
    Configuration menu
    Copy the full SHA
    bf7da9e View commit details
    Browse the repository at this point in the history
  2. libbpf: move global data mmap()'ing into bpf_object__load()

    Since BPF skeleton inception libbpf has been doing mmap()'ing of global
    data ARRAY maps in bpf_object__load_skeleton() API, which is used by
    code generated .skel.h files (i.e., by BPF skeletons only).
    
    This is wrong because if BPF object is loaded through generic
    bpf_object__load() API, global data maps won't be re-mmap()'ed after
    load step, and memory pointers returned from bpf_map__initial_value()
    would be wrong and won't reflect the actual memory shared between BPF
    program and user space.
    
    bpf_map__initial_value() return result is rarely used after load, so
    this went unnoticed for a really long time, until bpftrace project
    attempted to load BPF object through generic bpf_object__load() API and
    then used BPF subskeleton instantiated from such bpf_object. It turned
    out that .data/.rodata/.bss data updates through such subskeleton was
    "blackholed", all because libbpf wouldn't re-mmap() those maps during
    bpf_object__load() phase.
    
    Long story short, this step should be done by libbpf regardless of BPF
    skeleton usage, right after BPF map is created in the kernel. This patch
    moves this functionality into bpf_object__populate_internal_map() to
    achieve this. And bpf_object__load_skeleton() is now simple and almost
    trivial, only propagating these mmap()'ed pointers into user-supplied
    skeleton structs.
    
    We also do trivial adjustments to error reporting inside
    bpf_object__populate_internal_map() for consistency with the rest of
    libbpf's map-handling code.
    
    Reported-by: Alastair Robertson <ajor@meta.com>
    Reported-by: Jonathan Wiepert <jwiepert@meta.com>
    Fixes: d66562fba1ce ("libbpf: Add BPF object skeleton support")
    Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
    Link: https://lore.kernel.org/r/20241023043908.3834423-3-andrii@kernel.org
    Signed-off-by: Alexei Starovoitov <ast@kernel.org>
    (cherry picked from commit 2dea4b8)
    anakryiko committed Oct 29, 2024
    Configuration menu
    Copy the full SHA
    995e413 View commit details
    Browse the repository at this point in the history
  3. libbpf: never interpret subprogs in .text as entry programs

    Libbpf pre-1.0 had a legacy logic of allowing singular non-annotated
    (i.e., not having explicit SEC() annotation) function to be treated as
    sole entry BPF program (unless there were other explicit entry
    programs).
    
    This behavior was dropped during libbpf 1.0 transition period (unless
    LIBBPF_STRICT_SEC_NAME flag was unset in libbpf_mode). When 1.0 was
    released and all the legacy behavior was removed, the bug slipped
    through leaving this legacy behavior around.
    
    Fix this for good, as it actually causes very confusing behavior if BPF
    object file only has subprograms, but no entry programs.
    
    Fixes: bd054102a8c7 ("libbpf: enforce strict libbpf 1.0 behaviors")
    Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
    Link: https://lore.kernel.org/r/20241010211731.4121837-1-andrii@kernel.org
    Signed-off-by: Alexei Starovoitov <ast@kernel.org>
    (cherry picked from commit ac9ced9)
    anakryiko committed Oct 29, 2024
    Configuration menu
    Copy the full SHA
    8eb345a View commit details
    Browse the repository at this point in the history
  4. libbpf: fix sym_is_subprog() logic for weak global subprogs

    sym_is_subprog() is incorrectly rejecting relocations against *weak*
    global subprogs. Fix that by realizing that STB_WEAK is also a global
    function.
    
    While it seems like verifier doesn't support taking an address of
    non-static subprog right now, it's still best to fix support for it on
    libbpf side, otherwise users will get a very confusing error during BPF
    skeleton generation or static linking due to misinterpreted relocation:
    
      libbpf: prog 'handle_tp': bad map relo against 'foo' in section '.text'
      Error: failed to open BPF object file: Relocation failed
    
    It's clearly not a map relocation, but is treated and reported as such
    without this fix.
    
    Fixes: 53eddb5e04ac ("libbpf: Support subprog address relocation")
    Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
    Link: https://lore.kernel.org/r/20241009011554.880168-1-andrii@kernel.org
    Signed-off-by: Alexei Starovoitov <ast@kernel.org>
    (cherry picked from commit 0e39713)
    anakryiko committed Oct 29, 2024
    Configuration menu
    Copy the full SHA
    54d02df View commit details
    Browse the repository at this point in the history
  5. libbpf: Do not resolve size on duplicate FUNCs

    FUNCs do not have sizes, thus currently btf__resolve_size will fail
    with -EINVAL. Add conditions so that we only update size when the BTF
    object is not function or function prototype.
    
    Signed-off-by: Eric Long <i@hack3r.moe>
    Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
    Link: https://lore.kernel.org/bpf/20241002-libbpf-dup-extern-funcs-v4-1-560eb460ff90@hack3r.moe
    (cherry picked from commit ecf998e)
    hack3ric authored and anakryiko committed Oct 29, 2024
    Configuration menu
    Copy the full SHA
    9d89f7b View commit details
    Browse the repository at this point in the history
  6. libbpf: Fix uretprobe.multi.s programs auto attachment

    As reported by Andrii we don't currently recognize uretprobe.multi.s
    programs as return probes due to using (wrong) strcmp function.
    
    Using str_has_pfx() instead to match uretprobe.multi prefix.
    
    Tests are passing, because the return program was executed
    as entry program and all counts were incremented properly.
    
    Reported-by: Andrii Nakryiko <andrii@kernel.org>
    Signed-off-by: Jiri Olsa <jolsa@kernel.org>
    Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
    Link: https://lore.kernel.org/bpf/20240910125336.3056271-1-jolsa@kernel.org
    (cherry picked from commit 6967130)
    olsajiri authored and anakryiko committed Oct 29, 2024
    Configuration menu
    Copy the full SHA
    a9f5978 View commit details
    Browse the repository at this point in the history
  7. libbpf: Fix expected_attach_type set handling in program load callback

    Referenced commit broke the logic of resetting expected_attach_type to
    zero for allowed program types if kernel doesn't yet support such field.
    We do need to overwrite and preserve expected_attach_type for
    multi-uprobe though, but that can be done explicitly in
    libbpf_prepare_prog_load().
    
    Fixes: 5902da6d8a52 ("libbpf: Add uprobe multi link support to bpf_program__attach_usdt")
    Suggested-by: Jiri Olsa <jolsa@kernel.org>
    Signed-off-by: Tao Chen <chen.dylane@gmail.com>
    Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
    Link: https://lore.kernel.org/bpf/20240925153012.212866-1-chen.dylane@gmail.com
    Signed-off-by: Alexei Starovoitov <ast@kernel.org>
    (cherry picked from commit ad633fb)
    chentao-kernel authored and anakryiko committed Oct 29, 2024
    Configuration menu
    Copy the full SHA
    bbe53cc View commit details
    Browse the repository at this point in the history
  8. libbpf: bump version to v1.4.7

    New patch version bump for v1.4.7.
    
    Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
    anakryiko committed Oct 29, 2024
    Configuration menu
    Copy the full SHA
    ca72d07 View commit details
    Browse the repository at this point in the history
Loading