BPF List
 help / color / mirror / Atom feed
From: Alan Maguire <alan.maguire@oracle.com>
To: Antoine Tenart <atenart@kernel.org>,
	andrii@kernel.org, eddyz87@gmail.com
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf] libbpf: skip base btf sanity checks
Date: Mon, 24 Jun 2024 14:30:42 +0100	[thread overview]
Message-ID: <e4ff46d8-c4d4-4c0b-bea1-c0ab9aa6517d@oracle.com> (raw)
In-Reply-To: <20240624090908.171231-1-atenart@kernel.org>

On 24/06/2024 10:09, Antoine Tenart wrote:
> 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>

This looks good to me.

Reviewed-by: Alan Maguire <alan.maguire@oracle.com>

> ---
>  tools/lib/bpf/btf.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
> index 2d0840ef599a..142060bbce0a 100644
> --- a/tools/lib/bpf/btf.c
> +++ b/tools/lib/bpf/btf.c
> @@ -598,7 +598,7 @@ static int btf_sanity_check(const struct btf *btf)
>  	__u32 i, n = btf__type_cnt(btf);
>  	int err;
>  
> -	for (i = 1; i < n; i++) {
> +	for (i = btf->start_id; i < n; i++) {
>  		t = btf_type_by_id(btf, i);
>  		err = btf_validate_type(btf, t, i);
>  		if (err)

  reply	other threads:[~2024-06-24 13:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-24  9:09 [PATCH bpf] libbpf: skip base btf sanity checks Antoine Tenart
2024-06-24 13:30 ` Alan Maguire [this message]
2024-06-24 16:18 ` Andrii Nakryiko
2024-06-24 20:10 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e4ff46d8-c4d4-4c0b-bea1-c0ab9aa6517d@oracle.com \
    --to=alan.maguire@oracle.com \
    --cc=andrii@kernel.org \
    --cc=atenart@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=eddyz87@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox