Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3633309pxv; Mon, 19 Jul 2021 05:13:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzmTi5AzA/n8CgWRXRrHrcK3E+rCdskJi29THawi4a2sB5JMDdspN1LJPibSV9b/oRKGw68 X-Received: by 2002:a02:3845:: with SMTP id v5mr21628757jae.119.1626696793332; Mon, 19 Jul 2021 05:13:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626696793; cv=none; d=google.com; s=arc-20160816; b=Ov6e2xePlK1LpBQ14dLS0jF3acCVjoWxWpBrsyi7lKNRwSUHGVjvjvohVwISgkHioJ zeRQ/OvjpU7T2nhVgbTGYEYyirbRPtDy0luTUBqezfUmsTKZS1jKKL1/spxyurlRlZTj p/XOafJvVMYMfYaskOLGPi/PIY4EEHN0hKtgZ3hdBdwVUnhR5tgqxEdfgemqZReKB9WQ Sh8vQRSDIImFTOa4nvPhSraLA+YWRNXJJY5htTtevNjTBqb2qE7oH0CQwuwR+xvNIq/J lvJeUVnxOYxSbnGNtPxPyZRMF1PtsWDSONBGPjVaNcyVv/0K8oHoOe0TKTr4ursSgKzn u8xA== 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=/UU/c96xB2XnsKcImXrMAG0NX8G+S47OMuRsfPPQPuI=; b=AQQqNjsO6CvWrNj1F/92UF1/+wifJ5L4olyR2R/HvGz7RgXStmmZGqJafabJ1BXGah IPdqeY3gAKHzd5l39Ncz04HCRLEu1wyupD9xX+3u1QpVmwITqYeMT0n7qmphVuyqYp2i qd4DEXqGi/pc5gmdkc9NUhEmLzcxJWma3jOjBSeEFjEgZtzHtsrbVRKJ4iEw1vFDPnSy IVwZyr9zcb2h7utCMEOfZTT2VppfEjA9eBvv5v4xGcLOChpbIh3Kn7rrtjhKn5+35BDS 8+QejjNpPRZav3OzlXw/rTMTYgdHYyHp00Li0lo3QGNcektMKwr4OFHpPe/nk5jyL3OU ILCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CK1gkwph; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r17si21205449iov.104.2021.07.19.05.13.01; Mon, 19 Jul 2021 05:13:13 -0700 (PDT) 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=@linaro.org header.s=google header.b=CK1gkwph; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236866AbhGSLb2 (ORCPT + 99 others); Mon, 19 Jul 2021 07:31:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236865AbhGSLb1 (ORCPT ); Mon, 19 Jul 2021 07:31:27 -0400 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BDDCC061766 for ; Mon, 19 Jul 2021 04:27:03 -0700 (PDT) Received: by mail-ed1-x52f.google.com with SMTP id dj21so23727968edb.0 for ; Mon, 19 Jul 2021 05:12:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/UU/c96xB2XnsKcImXrMAG0NX8G+S47OMuRsfPPQPuI=; b=CK1gkwphNUpnV7qz0pEiNQPARKls7lgV4k0YhHtRviZNNNf9pduPYAm6rasO2Z4JYq yCfq8C7eKnhN+sLicDffhTPpp6ANXP4DqCoi59AQthWxFpsbTPcmXNQxiSf4zkbTW0pW K3aY/qy6QxN6TUQ+ylVmRuiz2j60u5w0PKO//4WhJzkw8/BP/YMkgXaltIlAxAr5v94A fKQ0wT14If3pjD//EisFpRLYUCGqpzt6ZOREOCfMTFpNyAAbyVqgTwrKeuMjTSC4anJJ Vb2nRPBLSF9PjEe+M0s5mDp+DlyqqAgbMhs3l4NUalgsijVHBhCBnMXqQ6NfFE39Zzyf K6dQ== 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=/UU/c96xB2XnsKcImXrMAG0NX8G+S47OMuRsfPPQPuI=; b=raejg82S3BG85l8mMrf2q980yK+G/7kNtUQcL61jA6u4TWpZ9sk0b1S4k03KgFMFSq zJFlcTgUIKl9O8NfNy9Y3EMAfWtZMO2qRH37xZEmhV17HBnwX8WJCHM/ayTi0XrvMD0f FJVtI71cblLt2b5iWQbR3zQs5u/5u4GOYdxnTbfdWpdAd1/KwbFWk8WUl2aL9giDHLOD liino1V0Sgw5BvJwrKopg3sjIbOyvaP1e5uTr7QJc6/t1DMDdvplpZz4A7vUBu467+kw f2e9TBuTiyeU5QM112gJIYKXsio+rAkrqF1SpNQXeLvBoz8W21W9+7h0eDyeOcp9guV+ O3Kg== X-Gm-Message-State: AOAM5306V0m9V3h6EMbi7LDfYt1z9S5NhlEY4bEgmFoxN6QvHu09ujDP HT48GImkCia1GsUlmLufph0vgQYazy4FTrEyH/j7Sw== X-Received: by 2002:a05:6402:152:: with SMTP id s18mr33808453edu.221.1626696725478; Mon, 19 Jul 2021 05:12:05 -0700 (PDT) MIME-Version: 1.0 References: <1626362126-27775-1-git-send-email-alan.maguire@oracle.com> <1626362126-27775-2-git-send-email-alan.maguire@oracle.com> In-Reply-To: <1626362126-27775-2-git-send-email-alan.maguire@oracle.com> From: Naresh Kamboju Date: Mon, 19 Jul 2021 17:41:53 +0530 Message-ID: Subject: Re: [PATCH v6 bpf-next 1/3] libbpf: BTF dumper support for typed data To: Alan Maguire , Linux-Next Mailing List Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , john.fastabend@gmail.com, kpsingh@kernel.org, morbo@google.com, Shuah Khan , bpf , Netdev , "open list:KERNEL SELFTEST FRAMEWORK" , open list , Stephen Rothwell , lkft-triage@lists.linaro.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 15 Jul 2021 at 20:46, Alan Maguire wrote: > > Add a BTF dumper for typed data, so that the user can dump a typed > version of the data provided. > > The API is > > int btf_dump__dump_type_data(struct btf_dump *d, __u32 id, > void *data, size_t data_sz, > const struct btf_dump_type_data_opts *opts); > > ...where the id is the BTF id of the data pointed to by the "void *" > argument; for example the BTF id of "struct sk_buff" for a > "struct skb *" data pointer. Options supported are > > - a starting indent level (indent_lvl) > - a user-specified indent string which will be printed once per > indent level; if NULL, tab is chosen but any string <= 32 chars > can be provided. > - a set of boolean options to control dump display, similar to those > used for BPF helper bpf_snprintf_btf(). Options are > - compact : omit newlines and other indentation > - skip_names: omit member names > - emit_zeroes: show zero-value members > > Default output format is identical to that dumped by bpf_snprintf_btf(), > for example a "struct sk_buff" representation would look like this: > > struct sk_buff){ > (union){ > (struct){ > .next = (struct sk_buff *)0xffffffffffffffff, > .prev = (struct sk_buff *)0xffffffffffffffff, > (union){ > .dev = (struct net_device *)0xffffffffffffffff, > .dev_scratch = (long unsigned int)18446744073709551615, > }, > }, > ... > > If the data structure is larger than the *data_sz* > number of bytes that are available in *data*, as much > of the data as possible will be dumped and -E2BIG will > be returned. This is useful as tracers will sometimes > not be able to capture all of the data associated with > a type; for example a "struct task_struct" is ~16k. > Being able to specify that only a subset is available is > important for such cases. On success, the amount of data > dumped is returned. > > Signed-off-by: Alan Maguire > --- > tools/lib/bpf/btf.h | 19 ++ > tools/lib/bpf/btf_dump.c | 819 ++++++++++++++++++++++++++++++++++++++++++++++- > tools/lib/bpf/libbpf.map | 1 + > 3 files changed, 834 insertions(+), 5 deletions(-) > diff --git a/tools/lib/bpf/btf_dump.c b/tools/lib/bpf/btf_dump.c > index 5dc6b517..929cf93 100644 > --- a/tools/lib/bpf/btf_dump.c > +++ b/tools/lib/bpf/btf_dump.c Following perf build errors noticed on i386 and arm 32-bit architectures on linux next 20210719 tag with gcc-11. metadata: -------------- git_repo: https://gitlab.com/Linaro/lkft/mirrors/next/linux-next git_short_log: 08076eab6fef ( Add linux-next specific files for 20210719 ) toolchain: gcc-11 target_arch: arm and i386 > +static void btf_dump_int128(struct btf_dump *d, > + const struct btf_type *t, > + const void *data) > +{ > + __int128 num = *(__int128 *)data; btf_dump.c: In function 'btf_dump_int128': btf_dump.c:1559:9: error: expected expression before '__int128' 1559 | __int128 num = *(__int128 *)data; | ^~~~~~~~ btf_dump.c:1561:14: error: 'num' undeclared (first use in this function) 1561 | if ((num >> 64) == 0) | ^~~ btf_dump.c:1561:14: note: each undeclared identifier is reported only once for each function it appears in btf_dump.c: At top level: btf_dump.c:1568:17: error: '__int128' is not supported on this target 1568 | static unsigned __int128 btf_dump_bitfield_get_data(struct btf_dump *d, | ^~~~~~~~ btf_dump.c: In function 'btf_dump_bitfield_get_data': btf_dump.c:1576:18: error: '__int128' is not supported on this target 1576 | unsigned __int128 num = 0, ret; | ^~~~~~~~ btf_dump.c: In function 'btf_dump_bitfield_check_zero': btf_dump.c:1608:9: error: expected expression before '__int128' 1608 | __int128 check_num; | ^~~~~~~~ btf_dump.c:1610:9: error: 'check_num' undeclared (first use in this function) 1610 | check_num = btf_dump_bitfield_get_data(d, t, data, bits_offset, bit_sz); | ^~~~~~~~~ btf_dump.c: In function 'btf_dump_bitfield_data': btf_dump.c:1622:18: error: '__int128' is not supported on this target 1622 | unsigned __int128 print_num; | ^~~~~~~~ btf_dump.c: In function 'btf_dump_dump_type_data': btf_dump.c:2212:34: error: '__int128' is not supported on this target 2212 | unsigned __int128 print_num; | ^~~~~~~~ Reported-by: Linux Kernel Functional Testing reference build link, build: https://builds.tuxbuild.com/1vWeCpIox9EoV35c80bwOvU9nbb/ config: https://builds.tuxbuild.com/1vWeCpIox9EoV35c80bwOvU9nbb/config steps to reproduce: --------------------- # TuxMake is a command line tool and Python library that provides # portable and repeatable Linux kernel builds across a variety of # architectures, toolchains, kernel configurations, and make targets. # # TuxMake supports the concept of runtimes. # See https://docs.tuxmake.org/runtimes/, for that to work it requires # that you install podman or docker on your system. # # To install tuxmake on your system globally: # sudo pip3 install -U tuxmake # # See https://docs.tuxmake.org/ for complete documentation. tuxmake --runtime podman --target-arch arm --toolchain gcc-11 --kconfig defconfig --kconfig-add https://builds.tuxbuild.com/1vWeCpIox9EoV35c80bwOvU9nbb/config -- Linaro LKFT https://lkft.linaro.org