From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,UNWANTED_LANGUAGE_BODY,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30B3EC433EB for ; Sat, 11 Jul 2020 21:53:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 039CF2077D for ; Sat, 11 Jul 2020 21:53:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594504433; bh=9BL0QiPJtO192y1EzUyuLOnGBESBvRk9qnS06CXwx0A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=D8cnXy95Cy/fg9EkOF7KzQ/Uiy+NVmdgIinpVpgPr+moNKUYc4jJ8+yAgaxoLQxW2 t/pfHSHZNgSdup6axTittcABE6gw4wPCLEI0vM9zd1s+EETdD9vuejl6o26gDNOp9Y s0DoSRXTQ1HpRlxhZk3GXaXlTIr8i0JOSNUbnJGI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728075AbgGKVxv convert rfc822-to-8bit (ORCPT ); Sat, 11 Jul 2020 17:53:51 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:40233 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728218AbgGKVxv (ORCPT ); Sat, 11 Jul 2020 17:53:51 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-194-U5kv5oCtPTq6uhN1zKzvOw-1; Sat, 11 Jul 2020 17:53:44 -0400 X-MC-Unique: U5kv5oCtPTq6uhN1zKzvOw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 72C951800D42; Sat, 11 Jul 2020 21:53:43 +0000 (UTC) Received: from krava.redhat.com (unknown [10.40.192.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id 07E4160BEC; Sat, 11 Jul 2020 21:53:41 +0000 (UTC) From: Jiri Olsa To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: netdev@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH v7 bpf-next 6/9] bpf: Use BTF_ID to resolve bpf_ctx_convert struct Date: Sat, 11 Jul 2020 23:53:26 +0200 Message-Id: <20200711215329.41165-7-jolsa@kernel.org> In-Reply-To: <20200711215329.41165-1-jolsa@kernel.org> References: <20200711215329.41165-1-jolsa@kernel.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kernel.org Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: 8BIT Sender: bpf-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org This way the ID is resolved during compile time, and we can remove the runtime name search. Acked-by: Andrii Nakryiko Tested-by: Andrii Nakryiko Signed-off-by: Jiri Olsa --- kernel/bpf/btf.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c index 71140b73ae3c..a710e3ee1f18 100644 --- a/kernel/bpf/btf.c +++ b/kernel/bpf/btf.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -3621,12 +3622,15 @@ static int btf_translate_to_vmlinux(struct bpf_verifier_log *log, return kern_ctx_type->type; } +BTF_ID_LIST(bpf_ctx_convert_btf_id) +BTF_ID(struct, bpf_ctx_convert) + struct btf *btf_parse_vmlinux(void) { struct btf_verifier_env *env = NULL; struct bpf_verifier_log *log; struct btf *btf = NULL; - int err, btf_id; + int err; env = kzalloc(sizeof(*env), GFP_KERNEL | __GFP_NOWARN); if (!env) @@ -3659,14 +3663,8 @@ struct btf *btf_parse_vmlinux(void) if (err) goto errout; - /* find struct bpf_ctx_convert for type checking later */ - btf_id = btf_find_by_name_kind(btf, "bpf_ctx_convert", BTF_KIND_STRUCT); - if (btf_id < 0) { - err = btf_id; - goto errout; - } /* btf_parse_vmlinux() runs under bpf_verifier_lock */ - bpf_ctx_convert.t = btf_type_by_id(btf, btf_id); + bpf_ctx_convert.t = btf_type_by_id(btf, bpf_ctx_convert_btf_id[0]); /* find bpf map structs for map_ptr access checking */ err = btf_vmlinux_map_ids_init(btf, log); -- 2.25.4