Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4417159ioa; Wed, 27 Apr 2022 03:29:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzbiZLDndhWbrDe9PvlSn2iVgicx3J4tPu9J3QwymEh0p/Dr/vhXnz3XR7qxDlp1N2iR/Fx X-Received: by 2002:a17:90b:1b42:b0:1d9:73b4:4433 with SMTP id nv2-20020a17090b1b4200b001d973b44433mr17173807pjb.69.1651055357825; Wed, 27 Apr 2022 03:29:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651055357; cv=none; d=google.com; s=arc-20160816; b=JPZWJLf2lj3bdDYLgvsB297Dsbl4BuLGL34/iN7x7BylhxMaz8suRN+qOJBn4iLiPc H2TTWpCOoSgPrDNucOf1g8mjPznXnhguVbKmlGJDN7C01zLiTZV6f29HWKNBF2u3CKlJ UFUUDCjFwHYljctVOAVhFjPJKH/urNFchJY0/ZtlZjGA95vSXeDBeNhfQ0dCPl88qnIk pXQAJdgoKn4WUg00gCOBsMek/rahpPTDrbu2NKTV40i6Q41+4EPNhjMlOKx2Dwd/FIbL C95olo756CAqvfggxN+9I7Quebx0gxFwCSILvn/R1Nu0M9/0Dia/rj0gj1PiEaEvpkog 66qQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=/OKcS6E5AHopfe6TSQqeBBsA+saXO4yiGsN11OQPGJ8=; b=L/BCncaE6cMen50e85ADfzquOA4s5m7b3hXVtoc7W0GNGhwEq3Vpcgp+hvOIknxN5T YUio90wxf1BuzDLT+5vYSS5wQe+nXk8Fuq87Z2vWLJamIqgTnOXCyOtvb+esBIS+DfRh f35cL4nAjJdPhDZ3CKwA47mQo2oJvVBHR1/b3ia9fC57St2P9OdI7Esxt1c1Z03kvICT axkNaCLS5/J1493ncAmF2i/pecfoLuPnjBWzzqfMWKFDWbjwOaOj6yfJu80BtphklP7C zeYP6XBuYW7ctCynDIXiPnf2TI4DhCcwGpeUDxYwpFkSg5h5Cl7vYA44df6cNV9aYnWQ 6OgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=fLzncqcj; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id i16-20020a17090a7e1000b001d26e95f5f5si1200475pjl.182.2022.04.27.03.29.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 03:29:17 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=fLzncqcj; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 18F702820BB; Wed, 27 Apr 2022 02:44:46 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351666AbiDZSeB (ORCPT + 99 others); Tue, 26 Apr 2022 14:34:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351613AbiDZSd7 (ORCPT ); Tue, 26 Apr 2022 14:33:59 -0400 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B89761CB0D; Tue, 26 Apr 2022 11:30:51 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id k4so19446512plk.7; Tue, 26 Apr 2022 11:30:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/OKcS6E5AHopfe6TSQqeBBsA+saXO4yiGsN11OQPGJ8=; b=fLzncqcj0dXP5hQrUX0xFv5GFAYa+Swj7LLrKFTa4snWvd/S4QrdcP5YjXMWmQ1+es xY85buGrIJWvIjLkVKPB9qzFbL7CqWqUjPMUhsb9512+Ri1BaScFpieW5mWW+F+jcKdm fQzUTjRaHAizZbQr1Dh7HZ6DdIFruqmwCaxWDtMMGc9GKDvkyDAX6i5blV7wA/OmbnWU fj18nAGTVQChr/G0wrGDqbL0MsAogzN+mj4xCD8IdtXoLFDWv9OZ8UIk2JXq2VX5RH0V oYdnODOI2PMuPoYSzuwMnbGPA8mpqwbMwnQX5h4706OVsAELAxTj+7i78zzPaZoraqEi tsqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/OKcS6E5AHopfe6TSQqeBBsA+saXO4yiGsN11OQPGJ8=; b=WNuHT29N+dW9VFzZj/UTWzSpbpceUW9H62wBott3+5oJd/fV1I1tyQfmW1AFBLhBA4 HuLmj1pDsF21JhdcuJvavJrbgru9nNY6vMYhxlgeBEvN8sL7q1ElP3PDw4evbFOM2xo2 n0koFXvITNkcQRuibqb6YjY7VwQoHp45l/vYifyqmgE9I4KHyHycl5wF8PHbshNbG+AB RTsyoVZIPi7F/7BDHIwtfwarYlvck6Y4tbs2voSyNSfB7Q9WRFVE8sioZtQ8V99GuX9x 4f8SGSTOUm5JjbKXR6H+r+iJIURE0V5215gTaLdTMC5JwVJloWilvL1NixG9CCKtGD0S SS+Q== X-Gm-Message-State: AOAM5308kvPCdK7bKZJIcHEaxd2eyh2133DFEB8dG29gwjHhKQE6Gv8w RoPx0eFuEzYnzy8uJDTUdHUUxH6CvJ/ngSRSko8= X-Received: by 2002:a17:90a:8591:b0:1b9:da10:2127 with SMTP id m17-20020a17090a859100b001b9da102127mr39272157pjn.13.1650997851279; Tue, 26 Apr 2022 11:30:51 -0700 (PDT) MIME-Version: 1.0 References: <20220424092613.863290-1-imagedong@tencent.com> <20220426182621.kgut2bpateytcxaj@MacBook-Pro.local> In-Reply-To: <20220426182621.kgut2bpateytcxaj@MacBook-Pro.local> From: Alexei Starovoitov Date: Tue, 26 Apr 2022 11:30:40 -0700 Message-ID: Subject: Re: [PATCH] bpf: init map_btf_id during compiling To: Menglong Dong Cc: Alexei Starovoitov , Steven Rostedt , Ingo Molnar , "David S. Miller" , Hideaki YOSHIFUJI , David Ahern , Jakub Kicinski , Paolo Abeni , benbjiang@tencent.com, Hao Peng , Menglong Dong , Eric Dumazet , Martin KaFai Lau , Talal Ahmad , Kees Cook , Mengen Sun , dongli.zhang@oracle.com, LKML , Network Development Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 26, 2022 at 11:26 AM Alexei Starovoitov wrote: > > On Sun, Apr 24, 2022 at 05:26:13PM +0800, menglong8.dong@gmail.com wrote: > > diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c > > index 0918a39279f6..588a001cc767 100644 > > --- a/kernel/bpf/btf.c > > +++ b/kernel/bpf/btf.c > > @@ -4727,30 +4727,6 @@ static const struct bpf_map_ops * const btf_vmlinux_map_ops[] = { > > #undef BPF_MAP_TYPE > > }; > > > > -static int btf_vmlinux_map_ids_init(const struct btf *btf, > > - struct bpf_verifier_log *log) > > -{ > > - const struct bpf_map_ops *ops; > > - int i, btf_id; > > - > > - for (i = 0; i < ARRAY_SIZE(btf_vmlinux_map_ops); ++i) { > > - ops = btf_vmlinux_map_ops[i]; > > - if (!ops || (!ops->map_btf_name && !ops->map_btf_id)) > > - continue; > > - if (!ops->map_btf_name || !ops->map_btf_id) { > > - bpf_log(log, "map type %d is misconfigured\n", i); > > - return -EINVAL; > > - } > > - btf_id = btf_find_by_name_kind(btf, ops->map_btf_name, > > - BTF_KIND_STRUCT); > > - if (btf_id < 0) > > - return btf_id; > > - *ops->map_btf_id = btf_id; > > - } > > - > > - return 0; > > -} > > - > > static int btf_translate_to_vmlinux(struct bpf_verifier_log *log, > > struct btf *btf, > > const struct btf_type *t, > > @@ -4812,11 +4788,6 @@ struct btf *btf_parse_vmlinux(void) > > /* btf_parse_vmlinux() runs under bpf_verifier_lock */ > > 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); > > - if (err < 0) > > - goto errout; > > - > > Looks nice. Please address build warn and resubmit. Just noticed v2. Ignore the above.