Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D42A51C3D for ; Fri, 11 Aug 2023 07:19:22 +0000 (UTC) Received: from out-120.mta1.migadu.com (out-120.mta1.migadu.com [IPv6:2001:41d0:203:375::78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9DD92D43 for ; Fri, 11 Aug 2023 00:19:20 -0700 (PDT) Message-ID: <25d08207-43e6-36a8-5e0f-47a913d4cda5@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1691738358; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Hd2S8ZGX6o389ipkrUYWXiz5xXIto0fBL2Sfn+aGdGs=; b=RGMX0qCXMTnlRRuTZoV+lWay/zCpo+6UYDEtG0W0I2BCVe8VhQ4j5Je5uPi8dbng01w3QE h2jzHjU6ZmqTTDqzEBvEZjf8RD7fYCYQOOz2/U/Zfs+FXFZ+JUI1wscYpg6xKETVUJ8baE LsG/hbMEYmMHz0bX4ASxPSKEFpHHS4w= Date: Fri, 11 Aug 2023 00:19:12 -0700 Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Reply-To: yonghong.song@linux.dev Subject: Re: [PATCH bpf-next 1/3] bpf: Explicitly emit BTF for struct bpf_iter_num, not btf_iter_num Content-Language: en-US To: Dave Marchevsky , bpf@vger.kernel.org Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Kernel Team References: <20230810183513.684836-1-davemarchevsky@fb.com> <20230810183513.684836-2-davemarchevsky@fb.com> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Yonghong Song In-Reply-To: <20230810183513.684836-2-davemarchevsky@fb.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net On 8/10/23 11:35 AM, Dave Marchevsky wrote: > Commit 6018e1f407cc ("bpf: implement numbers iterator") added the > BTF_TYPE_EMIT line that this patch is modifying. The struct btf_iter_num > doesn't exist, so only a forward declaration is emitted in BTF: > > FWD 'btf_iter_num' fwd_kind=struct > > Since that commit was probably hoping to ensure that struct bpf_iter_num > is emitted in vmlinux BTF, this patch changes it to the correct type. > > This isn't marked "Fixes" because the extraneous btf_iter_num FWD wasn't > causing any issues that I noticed, aside from mild confusion when I > looked through the code. > > Signed-off-by: Dave Marchevsky > --- > kernel/bpf/bpf_iter.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/bpf/bpf_iter.c b/kernel/bpf/bpf_iter.c > index 96856f130cbf..20ef64445754 100644 > --- a/kernel/bpf/bpf_iter.c > +++ b/kernel/bpf/bpf_iter.c > @@ -793,7 +793,7 @@ __bpf_kfunc int bpf_iter_num_new(struct bpf_iter_num *it, int start, int end) > BUILD_BUG_ON(sizeof(struct bpf_iter_num_kern) != sizeof(struct bpf_iter_num)); > BUILD_BUG_ON(__alignof__(struct bpf_iter_num_kern) != __alignof__(struct bpf_iter_num)); > > - BTF_TYPE_EMIT(struct btf_iter_num); > + BTF_TYPE_EMIT(struct bpf_iter_num); I think this can be removed instead. In kernel/bpf/bpf_iter.c, we have __bpf_kfunc int bpf_iter_num_new(struct bpf_iter_num *it, int start, int end) __bpf_kfunc int *bpf_iter_num_next(struct bpf_iter_num* it) __bpf_kfunc void bpf_iter_num_destroy(struct bpf_iter_num *it) This will ensure that bpf_iter_num btf type will be generated by the compiler. > > /* start == end is legit, it's an empty range and we'll just get NULL > * on first (and any subsequent) bpf_iter_num_next() call