mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: bot+bpf-ci@kernel.org
To: leon.hwang@linux.dev,bpf@vger.kernel.org
Cc: qmo@kernel.org,ast@kernel.org,daniel@iogearbox.net,andrii@kernel.org,eddyz87@gmail.com,memxor@gmail.com,martin.lau@linux.dev,song@kernel.org,yonghong.song@linux.dev,jolsa@kernel.org,emil@etsalapatis.com,ihor.solodrai@linux.dev,linux-kernel@vger.kernel.org,leon.hwang@linux.dev,ast@kernel.org,andrii@kernel.org,daniel@iogearbox.net,martin.lau@kernel.org,eddyz87@gmail.com,yonghong.song@linux.dev,mason@kernel.org,ihor.solodrai@linux.dev
Subject: Re: [PATCH bpf-next v3] bpftool: Compute map size of light skeletons at runtime
Date: Tue, 15 Sep 2026 16:53:46 +0000 (UTC)	[thread overview]
Message-ID: <10b12a0016e965f98f6789b11c4eaa5afbce2d623d6ddd80bd92105830ec2c13@mail.kernel.org> (raw)
In-Reply-To: <20260915161450.96249-1-leon.hwang@linux.dev>

[-- Attachment #1: Type: text/plain, Size: 4169 bytes --]

> diff --git a/tools/bpf/bpftool/gen.c b/tools/bpf/bpftool/gen.c
> index a50540ef6521..ee680f7c2116 100644
> --- a/tools/bpf/bpftool/gen.c
> +++ b/tools/bpf/bpftool/gen.c

[ ... ]

> diff --git a/tools/lib/bpf/skel_internal.h b/tools/lib/bpf/skel_internal.h
> index 1f3f332dffbe..9e16b8e8cb7c 100644
> --- a/tools/lib/bpf/skel_internal.h
> +++ b/tools/lib/bpf/skel_internal.h
> @@ -11,6 +11,7 @@
>  #include <linux/bpf.h>
>  #else
>  #include <unistd.h>
> +#include <sys/param.h>
>  #include <sys/syscall.h>
>  #include <sys/mman.h>
>  #include <linux/keyctl.h>
> @@ -127,7 +128,7 @@ static inline void skel_free(const void *p)
>   * either bpf_probe_read_kernel() or bpf_copy_from_user() from initial_value
>   * depending on bpf_loader_ctx->flags.
>   */
> -static inline void skel_free_map_data(void *p, __u64 addr, size_t sz)
> +static inline void skel_free_map_data(void *p, __u64 addr, size_t val_sz, __u32 max_entries)
>  {
>  	if (addr != ~0ULL)
>  		kvfree(p);
> @@ -138,18 +139,20 @@ static inline void skel_free_map_data(void *p, __u64 addr, size_t sz)
>  	 */
>  }
>
> -static inline void *skel_prep_map_data(const void *val, size_t mmap_sz, size_t val_sz)
> +static inline void *skel_prep_map_data(const void *val, size_t val_sz, __u32 max_entries,
> +				       size_t data_sz)
>  {
>  	void *addr;
>
> -	addr = kvmalloc(val_sz, GFP_KERNEL);
> +	addr = kvmalloc(data_sz, GFP_KERNEL);
>  	if (!addr)
>  		return NULL;
> -	memcpy(addr, val, val_sz);
> +	memcpy(addr, val, data_sz);
>  	return addr;
>  }

This isn't a bug, but would naming these something like value_sz and
init_sz make it harder to mix up the map value size and the embedded
blob length? The two names differ by three characters and describe
different quantities, and in the __KERNEL__ variant above val_sz is not
referenced at all while data_sz drives both the kvmalloc() and the
memcpy(). A future edit that reaches for the wrong one would size an
allocation or a copy incorrectly.

>
> -static inline void *skel_finalize_map_data(__u64 *init_val, size_t mmap_sz, int flags, int fd)
> +static inline void *skel_finalize_map_data(__u64 *init_val, size_t val_sz, __u32 max_entries,
> +					   int flags, int fd)

[ ... ]

> @@ -193,25 +197,39 @@ static inline void skel_free(void *p)
>  	free(p);
>  }

[ ... ]

>
> -static inline void *skel_prep_map_data(const void *val, size_t mmap_sz, size_t val_sz)
> +static inline void *skel_prep_map_data(const void *val, size_t val_sz, __u32 max_entries,
> +				       size_t data_sz)
>  {
> +	size_t mmap_sz = skel_map_mmap_sz(val_sz, max_entries);
>  	void *addr;
>
>  	addr = mmap(NULL, mmap_sz, PROT_READ | PROT_WRITE,
>  		    MAP_SHARED | MAP_ANONYMOUS, -1, 0);
>  	if (addr == (void *) -1)
>  		return NULL;
> -	memcpy(addr, val, val_sz);
> +	memcpy(addr, val, data_sz);
>  	return addr;
>  }

[ ... ]

commit 417792b69014155cfa0ecc10cdffc4c2e54b9e60
Author: Leon Hwang <leon.hwang@linux.dev>

>     bpftool: Compute map size of light skeletons at runtime
>
>     bpftool rounds memory-mapped data map sizes to the host page size when
>     generating a light skeleton. The generated code therefore uses a 64K
>     mapping size when bpftool runs on a 64K-page host, even if the skeleton
>     runs on a 4K-page target. The target rejects the oversized map mmap(),
>     causing failure of loading the light skeleton.
>
>     When try to run 64K-page selftests on 4K-page VM, the error message does
>     not provide the reason about page size.
>
>      test_atomics:PASS:atomics skeleton open 0 nsec
>      test_atomics:FAIL:atomics skeleton load unexpected error: -12 (errno 22)
>      #15      atomics:FAIL

This isn't a bug, but could this sentence be reworded ("When running
64K-page selftests on a 4K-page VM ...") or dropped, since the patch
does not change the error message itself? The sentence is missing a
subject and describes a diagnostics shortcoming that this patch does not
address.


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/34994524877

  reply	other threads:[~2026-09-15 16:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-15 16:14 Leon Hwang
2026-09-15 16:53 ` bot+bpf-ci [this message]
2026-09-17 11:24 ` Quentin Monnet
2026-09-21 21:20 ` 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=10b12a0016e965f98f6789b11c4eaa5afbce2d623d6ddd80bd92105830ec2c13@mail.kernel.org \
    --to=bot+bpf-ci@kernel.org \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=emil@etsalapatis.com \
    --cc=ihor.solodrai@linux.dev \
    --cc=jolsa@kernel.org \
    --cc=leon.hwang@linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.lau@kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=mason@kernel.org \
    --cc=memxor@gmail.com \
    --cc=qmo@kernel.org \
    --cc=song@kernel.org \
    --cc=yonghong.song@linux.dev \
    /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

all inboxes | Powered by JetHome®