Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2894762pxu; Mon, 7 Dec 2020 20:14:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJzEgUlK2MYvwYvlZi+PtQIYdoapuRYzxHGK8quQjNoLQJp5tIIpkrLhW3RvhLmfo3GYbKQh X-Received: by 2002:a17:906:2b95:: with SMTP id m21mr22181389ejg.134.1607400840057; Mon, 07 Dec 2020 20:14:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607400840; cv=none; d=google.com; s=arc-20160816; b=ymq9ZtyCRkueckWjopgblR2ej3SbCcPbWnKa12IUo6MeD7EDRRbAgT44YANVsH8ku3 pXvZW9oNpJjxYPLQzkVGUHd+orouDtiSFyx4cn+LaToDdCZmtlj0FbzhpxkC6Pb2GayR B5bMW7bHljhwZYJzyMeNowJ6y91FMOtasl7cedR0PlBiuMuWmAiljyG5mqUf6MefqBZD 74Ip3TFz2HkOKFZUxsIw89fisBlWq6Yl4hitZ3EVBFQL0M08xzmwNuaX5+YXESqe/OIp x3f6GDnsTshPVrgoiN+PsXyo0HWzilKCGSqpqlPrZQHsJwQkuUWMjhyEC/tRA9d7Xxkk 4TVQ== 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=rVF0ZTpG4KyKSrWlbeJiAw2aw7KsjahNGWMZr7fhkHk=; b=b126xsXNkz+IuEwepAAHkxtUJVjHv10HUOu9Qzjay6s/DDFWC9+x64PtC5VEOitUQY vbO57LPHqySsomnFyqy4Czj/NbfmYLfr5km137KKHAaUa7IZoAmXknlPOgpbvtD3z9re AazIQlarl4QnvnVZF7+wwJq2rkBSlzGKNofLsfIhJiY9A0TUxbF+h88pvuOaO0gfBw63 CD5/e520iMlasq8Tw9Gmd8oPE7cUsminwIAcT48hhhx5uik/91rBauUYHvDbwviDYC0x fMPW7pSO7DM/uVVS5j2ypWhFLPns6WkyBWskLfUqs4dhD18Sgfzp5i2ZQxyDTS0mC9bU 4wmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="BPa3/BjB"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a23si9652475edy.268.2020.12.07.20.13.35; Mon, 07 Dec 2020 20:14:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="BPa3/BjB"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726897AbgLHDnL (ORCPT + 99 others); Mon, 7 Dec 2020 22:43:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726689AbgLHDnL (ORCPT ); Mon, 7 Dec 2020 22:43:11 -0500 Received: from mail-yb1-xb42.google.com (mail-yb1-xb42.google.com [IPv6:2607:f8b0:4864:20::b42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39683C0613D6; Mon, 7 Dec 2020 19:42:31 -0800 (PST) Received: by mail-yb1-xb42.google.com with SMTP id w127so3412768ybw.8; Mon, 07 Dec 2020 19:42:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=rVF0ZTpG4KyKSrWlbeJiAw2aw7KsjahNGWMZr7fhkHk=; b=BPa3/BjB+L6D2YqA9dPlyXktUcodacMyngTKOJWFJk7ozjZiZ8WaFDP1g65futKeDn jFCXr3S+1EpOHmwW7kUhz/X19KmZZDq+Av+tWHU82lzEMKu30IeH8IVmLyvlAN5CvVT6 g8NYlRnHhHCun/UoIluyV+FpDWwZ5yUsvN3/qTpeuy8cSKXmyHGGTXFHs5M1SUAuwnrF jRhu0q6CUItI1S1axL2FuB1sF9IASYLF3SHJ8mEs7xSXJAmH11hkhp2mIBq9ERZWPMD7 UZszu2w+0ZW/F/ki25Of6Tp9I1+tT1wuHRNEsQAU6RaBVVYWsPTwRyaoyhYEPIg68iEA YWGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=rVF0ZTpG4KyKSrWlbeJiAw2aw7KsjahNGWMZr7fhkHk=; b=oXOCdL3P26HU2X96iOgKUEts8cGs5fUoq2MYCFgAQIBQOcVvAPbLadYYJGGspjMbS4 e3UR4iKzmKD0JjNGrUTeqsEEESkFguC3E73eZbaIUN0BrH7YyX5exGvMf4yXqBov8SQW qPi1YlgG8BJyELdW6+lwm+mGYAd9TQa8Sf6Zvq8ylvX2/XELHs+gkkQn+XaU+IHfg6It JEWmB6fzEzw7uhQ+348zOTfRRac4gjafOo+NQe2k9UK/5bnC5K+gBfz+h+8BmPnCz7g6 pA2CK2b/feWHOjYzIbDGFO9rtQZ22O6t0pgRJFLVvNozcQkql7MGB2PIdEFQ5jWQAWaq ymqA== X-Gm-Message-State: AOAM53202hSYdlt+ZF6qLDj6LF+uJDIXxbpRfBwR1YnVXPUFcJdRIOyu zvZvGv/ZKmK84BamWGIh256lsN1GBDi5WIMNo+8= X-Received: by 2002:a25:df8e:: with SMTP id w136mr26537481ybg.230.1607398950542; Mon, 07 Dec 2020 19:42:30 -0800 (PST) MIME-Version: 1.0 References: <1607107716-14135-1-git-send-email-alan.maguire@oracle.com> <3dce8546-60d4-bb94-2c7a-ed352882cd37@fb.com> In-Reply-To: From: Andrii Nakryiko Date: Mon, 7 Dec 2020 19:42:19 -0800 Message-ID: Subject: Re: [PATCH v2 bpf-next 0/3] bpf: support module BTF in BTF display helpers To: Alan Maguire Cc: Yonghong Song , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin Lau , Song Liu , john fastabend , KP Singh , Steven Rostedt , Ingo Molnar , Hao Luo , Jiri Olsa , Quentin Monnet , open list , Networking , bpf , Shuah Khan , Lorenz Bauer , "open list:KERNEL SELFTEST FRAMEWORK" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Dec 5, 2020 at 4:44 PM Alan Maguire wrote: > > > On Sat, 5 Dec 2020, Yonghong Song wrote: > > > > > > > __builtin_btf_type_id() is really only supported in llvm12 > > and 64bit return value support is pushed to llvm12 trunk > > a while back. The builtin is introduced in llvm11 but has a > > corner bug, so llvm12 is recommended. So if people use the builtin, > > you can assume 64bit return value. libbpf support is required > > here. So in my opinion, there is no need to do feature detection. > > > > Andrii has a patch to support 64bit return value for > > __builtin_btf_type_id() and I assume that one should > > be landed before or together with your patch. > > > > Just for your info. The following is an example you could > > use to determine whether __builtin_btf_type_id() > > supports btf object id at llvm level. > > > > -bash-4.4$ cat t.c > > int test(int arg) { > > return __builtin_btf_type_id(arg, 1); > > } > > > > Compile to generate assembly code with latest llvm12 trunk: > > clang -target bpf -O2 -S -g -mcpu=v3 t.c > > In the asm code, you should see one line with > > r0 = 1 ll > > > > Or you can generate obj code: > > clang -target bpf -O2 -c -g -mcpu=v3 t.c > > and then you disassemble the obj file > > llvm-objdump -d --no-show-raw-insn --no-leading-addr t.o > > You should see below in the output > > r0 = 1 ll > > > > Use earlier version of llvm12 trunk, the builtin has > > 32bit return value, you will see > > r0 = 1 > > which is a 32bit imm to r0, while "r0 = 1 ll" is > > 64bit imm to r0. > > > > Thanks for this Yonghong! I'm thinking the way I'll tackle it > is to simply verify that the upper 32 bits specifying the > veth module object id are non-zero; if they are zero, we'll skip Let's instead of the real veth module use selftests's bpf_testmod, which I added specifically to use for tests like these. We can define whatever types we need in there. > the test (I think a skip probably makes sense as not everyone will > have llvm12). Does that seem reasonable? > > With the additional few minor changes on top of Andrii's patch, > the use of __builtin_btf_type_id() worked perfectly. Thanks! > > Alan