Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp416386pxu; Tue, 5 Jan 2021 15:03:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJxxhQp21580HncxJJuNOmOiYtJVuh4GHKMNdajeYRJwDunW7dlp0TIicq38/YDxjZfJtYrf X-Received: by 2002:a50:fc0d:: with SMTP id i13mr1935222edr.171.1609887779953; Tue, 05 Jan 2021 15:02:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609887779; cv=none; d=google.com; s=arc-20160816; b=GnzBty7rVKryID8qYvmKc/MT08BnUjEU29wRsq0ThiW0I64XWwmU4Rpuw9Jam/XVk3 MnPZFUttXll77SeUJDmAZnOsNxMXKU7PPV0SMQT04TN5tzxv7tcFQz74xCZJuQcXBDCx x/pCz8URly6CtjaRmMz18dYAWirAsl+YHE/bQNnt0iEUqwHpZPXlpsGxFew8vhSJT0zN YEfaKZ4KbyZA5BnTxXD1fkyHWmLQZCjXlPiOMruzgrMl7JMuUF10immjFkoTFRDVpnkY ZEKyPYgzEArlJFIwHb825Q718Wq5Pl+jNOLEbJrNE+Ur4EFN5344SxWQ2uLxlyrIP8P4 yPHg== 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=mVVOLK7TKY0xTO7tS1oO2XqfQArJqlcn9xJJIW/nDFI=; b=WalNNVMx8LUQYxhJaKFKh4zVm9UIM3ADREPXRcpJrVDLXnRM8f6M2EjDbl5mp9MQBc tlhJUmPnmxk4PotMk7rEAPr13gdqt0xB8WtbC1ScgZpQzbWVVX+TCq6Ds0y8CNh7Edha DJe2UAxj77DCC9JEXI34DH28yMcE1L5uTssQr1kChXTKAOiACYVv8715pwhBFLm2/UWn TdN6DF7AK17N5NdJ34wXzi0MXl3aLJ3lzbfCjbXvDmj8yctAndQ7jh0R6KKNQAnbontY afAzI+mwv4h95FfkFe+DDTxWSoKHSTPRTdj3siJ9GDqtQ43NsdHF37iX/KFdGD3HK1pI QngA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DACEnE1e; 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 b16si228546ejc.710.2021.01.05.15.02.36; Tue, 05 Jan 2021 15:02:59 -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=DACEnE1e; 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 S1728594AbhAEUs5 (ORCPT + 99 others); Tue, 5 Jan 2021 15:48:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727304AbhAEUs5 (ORCPT ); Tue, 5 Jan 2021 15:48:57 -0500 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 437A4C061793; Tue, 5 Jan 2021 12:48:17 -0800 (PST) Received: by mail-pf1-x429.google.com with SMTP id d2so434440pfq.5; Tue, 05 Jan 2021 12:48:17 -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=mVVOLK7TKY0xTO7tS1oO2XqfQArJqlcn9xJJIW/nDFI=; b=DACEnE1e98TLwGq6kCGUdA1072X7VMlx371yiC3cm3uDYt084dJE2K9jI8NSnaeGKb z2Ja2fRJVerXvWAbPZ2ewZGhRm0CT2LrYfsXLPqEYnfbhUxS4eYaPnuNg2SXh7hdUiG9 HaMisZFXViONKwecB5MedIicHqpii6N2duzn2mOU8qEieTlM2M1iK+5m++BbptctmhqN Who5usTiYqYKtIU4s4GmVBnnWgyLoFtOSFg1ZvsWZNDzlKzqN1WFc5QbHz11h9cP1ojW qOPS5xQJjB62hq/JoGLe2Cwaz+1u7pPXAhxVK+hZH48mhrJxIMkvSA/MwzCCG/gLRxUD Uxfg== 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=mVVOLK7TKY0xTO7tS1oO2XqfQArJqlcn9xJJIW/nDFI=; b=AUCZvj0EmV4EFfQReoBXqJOQOryPDKKCZdUh3aGN3MtGq2QffN1a3Wxk5dqE3n/omc Zy5sDe1aMCPMVaWgdxmqIiGgpCIjMxNlQR4OiktgQfASEPYO9NLltExuZmVebKyessUn 0BVbsmtl7ZX9v1ZGd32AUJEdlpnknw7Ykq218eD2hDcMISpwbjv+d3GY27qssq0vAehl g7pnkwsCghkMd3+RZOXx2JrkRxIv+/ONApW1n0++8S/qyGrmpZxffggz2XWyiFQ8IHsA x/uEmGPRbwo1MhIDKM34p63aRKKvXlIVFxeRAf6KOGRR/77nc/bd6yL7sjN0MUMOc3R4 cqww== X-Gm-Message-State: AOAM530vD1k3H4rz99OHMhhEoy5UBOBRh7AsVhWlSdmG32JmoM9qioIy AwuObpXZBulA6V1z+W93W3+M3W9ia6ret1PLaCE= X-Received: by 2002:a62:4d03:0:b029:1ac:6159:4572 with SMTP id a3-20020a624d030000b02901ac61594572mr816939pfb.10.1609879696812; Tue, 05 Jan 2021 12:48:16 -0800 (PST) MIME-Version: 1.0 References: <1609773991-10509-1-git-send-email-alan.maguire@oracle.com> In-Reply-To: <1609773991-10509-1-git-send-email-alan.maguire@oracle.com> From: Cong Wang Date: Tue, 5 Jan 2021 12:48:06 -0800 Message-ID: Subject: Re: [RFC PATCH bpf-next] ksnoop: kernel argument/return value tracing/display using BTF To: Alan Maguire Cc: Alexei Starovoitov , Daniel Borkmann , andrii@kernel.org, Martin KaFai Lau , Song Liu , yhs@fb.com, John Fastabend , kpsingh@kernel.org, Nathan Chancellor , Nick Desaulniers , =?UTF-8?B?VG9rZSBIw7hpbGFuZC1Kw7hyZ2Vuc2Vu?= , jean-philippe@linaro.org, bpf , Linux Kernel Network Developers , LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 4, 2021 at 7:29 AM Alan Maguire wrote: > > BPF Type Format (BTF) provides a description of kernel data structures > and of the types kernel functions utilize as arguments and return values. > > A helper was recently added - bpf_snprintf_btf() - that uses that > description to create a string representation of the data provided, > using the BTF id of its type. For example to create a string > representation of a "struct sk_buff", the pointer to the skb > is provided along with the type id of "struct sk_buff". > > Here that functionality is utilized to support tracing kernel > function entry and return using k[ret]probes. The "struct pt_regs" > context can be used to derive arguments and return values, and > when the user supplies a function name we > > - look it up in /proc/kallsyms to find its address/module > - look it up in the BTF kernel data to get types of arguments > and return value > - store a map representation of the trace information, keyed by > instruction pointer > - on function entry/return we look up the map to retrieve the BTF > ids of the arguments/return values and can call bpf_snprintf_btf() > with these argument/return values along with the type ids to store > a string representation in the map. > - this is then sent via perf event to userspace where it can be > displayed. > > ksnoop can be used to show function signatures; for example: This is definitely quite useful! Is it possible to integrate this with bpftrace? That would save people from learning yet another tool. ;) Thanks.