From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796178889; b=vyNVj1V3m9ci0T6OkF2YG4L2s0MMJQc+0ayWHImb1ghKNBXvYfSZ+yzhyzPJFAVxV+HF jOiZjaWpiMtt11W8cQH+CRfZ5a/vy0SbNPnXVnoAFaXuniGRXVzJJ9I8hg0wQXipH/2Cz Eh8CLQ711QVsDovWwA2lcttmDgbJgkHtJzPbZvt30nBHA4b0DEju+ik7PrimCgxBwIJzA fkPW303K/SsjmZB3ZrPD05PPRM63AAGL49mS5SykeYGc59V8ztrAIVRAwo6Bq6d2d7KAt lvKeJjQAOc76uIJ80jmpxXvuVDHU0EkEyQg0EfyxX02amxcSkLAbo64kGW0b0e6IQTg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796178889; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=cwuCckV3ouTcKpbVjKOZhflqlYNq0Uo6eR9GM4y1t6Q=; b=rvUz4y3dT3wz+ewpTEM0Unjtu9p3tj+ZWISm2qRMy8LU6IG+7WwtctXAQsqO00/f0IZA wK90ZSBp+iBNENsg7LbddSOCJDjOo6iTjXeUK8QGfBWwFO6Gx9lQxQUuOuGmTr6gIeUEu FHNse6RpdiNttQ27uOuDG1EYuCB1OWdJTy0ThwaUf0kaQrqXmEAPqD9JMvmv8IF7pm67S RM3Nt2+59R7g3lWFDVXI0fv6upjzZmPeeAYA80jP4PhTU/zISoMNB5C2mwx7ckd0GgvKk Ngu3jyTAMDJOPqseQ5t8eV/oCIsBv1ufNPQsD2+9Lz4BOxEjjVUvwas9yyv5yBqUFFA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="Y/anbPEh"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EB02A606A327 for ; Wed, 2 Dec 2026 02:34:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Y/anbPEh Received: by smtp.kernel.org (Postfix) with ESMTPSA id CCA4C1F000C1; Wed, 2 Dec 2026 02:34:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796178888; bh=cwuCckV3ouTcKpbVjKOZhflqlYNq0Uo6eR9GM4y1t6Q=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=Y/anbPEh3jMNzvhmKMpDTpFc1dT3fwPJFi4fstJzFcyvKBByhUqeY3IbjNfjiyVFK U1bupKfs0/Xyv6nzWTRZ1lZ++vdlEwwsQfc25xbDyI9lW9v8Gq8zvK2XMg3jOx+QoJ 9RpXc8KPn6RVgFnp3HfKWurZtlU4ku0D7w9MIq49CrVbKggGWq9vEtOuwqpKSZjBqW gWMVF/lkG+DzUk/wrUYfgm5u84FlT+/3QKtSk3fvUPqJekkt7CKE5Q0ICGYVpY0Puu vdoORdLlsC+ez/Ib5yoGfN6rTUPAzLFvY7hsPrDYUEa6b7ZXS8oBlLga1hpH4rsn47 mQ6VAzEY3xKkQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [RFC PATCH v2 09/43] bpf: Do not embed page-aligned members in struct bpf_ringbuf Reply-To: sashiko-reviews@lists.linux.dev To: "Eric Curtin" Cc: bpf@vger.kernel.org In-Reply-To: <20261201015240.1017259-10-ericcurtin17@gmail.com> References: <20261201015240.1017259-1-ericcurtin17@gmail.com> <20261201015240.1017259-10-ericcurtin17@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 02:34:47 +0000 X-Mailing-List: bpf@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] bpf: unreferenced enum page_size_enum omitted from vmlinux BTF - [Medium] bpf: pointer conversion in struct bpf_ringbuf breaks check_ringbuf() selftest -- commit 459a31118167667b9c22651aaa45f157fe2327bb Author: Ryan Roberts bpf: Do not embed page-aligned members in struct bpf_ringbuf This commit replaces page-aligned embedded fields in struct bpf_ringbuf with pointers to the position and data pages, and updates enum page_size_enum in kernel/bpf/core.c for boot-time page size selection. > diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c > index 6742f5be86586..dc3d62671a9dc 100644 > --- a/kernel/bpf/core.c > +++ b/kernel/bpf/core.c > @@ -97,9 +97,16 @@ void *bpf_internal_load_pointer_neg_helper(const struc= t sk_buff *skb, int k, uns > return NULL; > } > =20 > -/* tell bpf programs that include vmlinux.h kernel's PAGE_SIZE */ > +/* > + * tell bpf programs that include vmlinux.h kernel's PAGE_SIZE. __PAGE_S= IZE is > + * only known for compile-time PAGE_SIZE builds, the limits are always k= nown. > + */ > enum page_size_enum { > + __PAGE_SIZE_MIN =3D PAGE_SIZE_MIN, > + __PAGE_SIZE_MAX =3D PAGE_SIZE_MAX, > +#if PAGE_SIZE_MIN =3D=3D PAGE_SIZE_MAX > __PAGE_SIZE =3D PAGE_SIZE > +#endif > }; > =20 > struct bpf_prog *bpf_prog_alloc_no_stats(unsigned int size, gfp_t gfp_ex= tra_flags) > @@ -108,7 +115,7 @@ struct bpf_prog *bpf_prog_alloc_no_stats(unsigned int= size, gfp_t gfp_extra_flag > struct bpf_prog_aux *aux; > struct bpf_prog *fp; > =20 > - size =3D round_up(size, __PAGE_SIZE); > + size =3D round_up(size, PAGE_SIZE); > fp =3D __vmalloc(size, gfp_flags); > if (fp =3D=3D NULL) > return NULL; [Severity: Medium] Does replacing __PAGE_SIZE with PAGE_SIZE here cause enum page_size_enum to be omitted from vmlinux BTF? fe5064158c56 ("bpf: Tell bpf programs kernel's PAGE_SIZE") used __PAGE_SIZE in bpf_prog_alloc_no_stats() to keep the enum referenced so the compiler emits it into DWARF debug info. With no remaining reference to enum page_size_enum or its enumerators in kernel/bpf/core.c, the compiler strips the unused enum and pahole does not emit __PAGE_SIZE_MIN, __PAGE_SIZE_MAX or __PAGE_SIZE into vmlinux BTF or vmlinux.h, breaking in-tree BPF programs and selftests that rely on __PAGE_SIZE. Adding BTF_TYPE_EMIT(enum page_size_enum) in bpf_prog_alloc_no_stats() would preserve the BTF type emission. > diff --git a/kernel/bpf/ringbuf.c b/kernel/bpf/ringbuf.c > index 447863ece26a3..9f9fab60e0c90 100644 > --- a/kernel/bpf/ringbuf.c > +++ b/kernel/bpf/ringbuf.c [ ... ] > @@ -72,11 +72,11 @@ struct bpf_ringbuf { > * validate each sample to ensure that they're correctly formatted, and > * fully contained within the ring buffer. > */ > - unsigned long consumer_pos __aligned(PAGE_SIZE); > - unsigned long producer_pos __aligned(PAGE_SIZE); > - unsigned long pending_pos; > - unsigned long overwrite_pos; /* position after the last overwritten rec= ord */ > - char data[] __aligned(PAGE_SIZE); > + unsigned long *consumer_pos; > + unsigned long *producer_pos; > + unsigned long *pending_pos; > + unsigned long *overwrite_pos; /* position after the last overwritten re= cord */ > + char *data; > }; [Severity: Medium] Does changing consumer_pos and producer_pos to pointers break the map_ptr BPF selftest? tools/testing/selftests/bpf/progs/map_ptr_kern.c still declares them as unsigned long scalars and compares them directly: tools/testing/selftests/bpf/progs/map_ptr_kern.c:check_ringbuf() { ... rb =3D ringbuf->rb; VERIFY(rb); VERIFY(rb->consumer_pos =3D=3D 0); VERIFY(rb->producer_pos =3D=3D 128 + BPF_RINGBUF_HDR_SZ); ... } Because the kernel BTF types of consumer_pos and producer_pos are now BTF_KIND_PTR rather than BTF_KIND_INT, CO-RE field relocation fails when loading map_ptr_kern.c, and check_ringbuf() needs to dereference the pointers via bpf_core_read() or bpf_probe_read_kernel(). --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261201015240.1017= 259-1-ericcurtin17@gmail.com?part=3D9