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=-10.1 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 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 2DD1EC433EC for ; Fri, 10 Jul 2020 19:38:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F1D13207BB for ; Fri, 10 Jul 2020 19:38:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594409899; bh=lKrC43bRVgrt9v9sJnWa3299C00tHCML0ZmxNNExyoY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=KPz0UtmkYNUXLM1BP8boOHiU3qpBsdYYOpnb+fTM4GAKrJvT616FIY0zV+YNyVoHt JT8YS0em35G0ZSmAbUGI6ZysBJX3ZKsW9T7RpUqOHlYv4vxXks1vqToreFJKg8Sy8s ncd8tgxYI1wORfeIgrgHKSJeJiuKT9UFlHrc6Ko0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728422AbgGJTiR convert rfc822-to-8bit (ORCPT ); Fri, 10 Jul 2020 15:38:17 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:46501 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728406AbgGJTiO (ORCPT ); Fri, 10 Jul 2020 15:38:14 -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-451-LPs1ADbxM-mLuTA1WtJ0Dg-1; Fri, 10 Jul 2020 15:38:10 -0400 X-MC-Unique: LPs1ADbxM-mLuTA1WtJ0Dg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A843F100CCC8; Fri, 10 Jul 2020 19:38:08 +0000 (UTC) Received: from krava.redhat.com (unknown [10.40.192.98]) by smtp.corp.redhat.com (Postfix) with ESMTP id 403AA100EBA9; Fri, 10 Jul 2020 19:38:07 +0000 (UTC) From: Jiri Olsa To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: netdev@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH v6 bpf-next 6/9] bpf: Use BTF_ID to resolve bpf_ctx_convert struct Date: Fri, 10 Jul 2020 21:37:51 +0200 Message-Id: <20200710193754.3821104-7-jolsa@kernel.org> In-Reply-To: <20200710193754.3821104-1-jolsa@kernel.org> References: <20200710193754.3821104-1-jolsa@kernel.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kernel.org Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: 8BIT Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This way the ID is resolved during compile time, and we can remove the runtime name search. Acked-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