Message ID | 20221103045437.163510-1-irogers@google.com |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp321440wru; Wed, 2 Nov 2022 21:59:08 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5sfyjPTyN3M1aoY7KOTBVySYWYjHXdNS/yxHapRTZGv2u/dx9Iv65kJCI4v5hn0nUHa8bK X-Received: by 2002:a62:2703:0:b0:56d:60f2:97 with SMTP id n3-20020a622703000000b0056d60f20097mr20509714pfn.10.1667451548196; Wed, 02 Nov 2022 21:59:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667451548; cv=none; d=google.com; s=arc-20160816; b=lfwRNi8UL0T6KjKyYI2q+snCAf+ieTFEHtbgnOoTF5Zf7pO8eSXCuBv3Fvp/XNIHSp fL7GQVlzAVzmnTCW2fU4BmyASUd5X796Tlnl1yXgUiuXH62eAd5xaepPeAgtycJXQKX3 dvvEtoPsb26ZF6DZuqoWM72eWVvIa02vdSbDxf1OZl6vJjadI2tbVoxC6bdSIirpRgCy XYO+enJG5Xl7jUBoMZloxUdlU18jDMEiIt77Sz3csQf+CtXY6UmB62cyvCSQ1gL/Esmg UnM5/a/fsIAbxx+rLk69jm9gst7x0Ij+hmcQRn36CBziPdpd9fqh+W+DWZ2ASkkrPMGL KLcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:mime-version:message-id:date :dkim-signature; bh=jZXowGsurJE+s3+HfBZ6GT+6g7K96tSBIPyO+vNCcsA=; b=JP6xfWQnIL5uSWRheVjHkMlDJeL/FxIzU68XgcUGLPl6+a3ipnmEPicg7Y9HX2lUiM IVAJYp9SmtLQ9tpRh6UKjWgaQAyyc7vBwYzS+181HslwpVXt5YWpioz2at74CkxkuagM VyBBJcNUeAE4bRdupGZrj1teYgacWnNCfjIKu/uirQETBOn/2C5FXgA4NYDeDuxTZMKw 22nsM2cFojHDJeV+0/B+aJ8QyaISsSlzJ4K9sSm/bLwFoqhUQ2MNKN+xUPOvWUFT80c5 R1NOVCl1wfrKBQYIU23lxnLFSG74yFOoqZFWELpfwvpc4yNJOVCCaGsz/Aek5HISDNTu dVaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=NxXkPe3p; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pv5-20020a17090b3c8500b00212c3779154si4755906pjb.118.2022.11.02.21.58.54; Wed, 02 Nov 2022 21:59:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=NxXkPe3p; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230220AbiKCEyv (ORCPT <rfc822;yves.mi.zy@gmail.com> + 99 others); Thu, 3 Nov 2022 00:54:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229579AbiKCEys (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 3 Nov 2022 00:54:48 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00F7317AAA for <linux-kernel@vger.kernel.org>; Wed, 2 Nov 2022 21:54:47 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id h9-20020a25e209000000b006cbc4084f2eso1076005ybe.23 for <linux-kernel@vger.kernel.org>; Wed, 02 Nov 2022 21:54:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:mime-version:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=jZXowGsurJE+s3+HfBZ6GT+6g7K96tSBIPyO+vNCcsA=; b=NxXkPe3pHcYT8iN7ya3pJumFi+pQ0vkHaIriviOdmvPthV36Y5/415d2g41J5VldXl WQ8ILJP0mmK8scFWbpLeRf3cPnKM0ktYsPaaIPcBU/2yYdwFDwkAEtUVtU9FutGvJ81Z og9FRK7xk9I9WPZsv3H/fnCJNmGcbyN1oc+FREMP61iWQKUCdwJQ7Sz1/+1eXI+oKVSv OoclwxiwCBCXSv+1uJDQc/IzPL7kZBvAsodPlJwaHbAuBW63OeLXfFo3/GwP6qNh5D7M fpWFMFamJD/hFyEDZ8iRGyDIxLrMz4ysj5Q0WwN7pmWqcbb+IMC58wX1oVfkE+L4KRz1 po5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:mime-version:message-id:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=jZXowGsurJE+s3+HfBZ6GT+6g7K96tSBIPyO+vNCcsA=; b=HEYGZIEl1Wnl/NVDspADRw7eGX2Akrx28mSwADTi3SeZo9H1gwTOzHD+oSl4QQmKof 9yd3W3n18z/k6ZzP2qEZeD+nVaKykTAmDP+39HlfdzYjjTO9ToFqRcvdVZqHYfdSjwFT Igr0Sq+wrVJeNIXwbTyiPivCnoqOUyz5qMHUAOXd3wwwpXHXjOexP4uNZnDh2LWaDVZa IctLDrpyM1ot2p/6VlJzyLM2F+dAsrSZciqclvrrzDrARZPSWrSTbxzQuYlTCgsSs/QC miTR9dNqK0itALzR0pdK4NJWebchQV2RpxroScqv98LCMgpCRc2ypz5/LgzBePQb0Fog 7uIQ== X-Gm-Message-State: ACrzQf0gsSiErGmSqJfNXM/Zh3nm+ka1ya5PZaGYSN4IMlsWKROpFACh VH4OzZU5P6Q9uZVruZpWvIqsFfLgYbSq X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:8a9d:7f38:6465:2d7b]) (user=irogers job=sendgmr) by 2002:a25:6dc4:0:b0:6c1:822b:391f with SMTP id i187-20020a256dc4000000b006c1822b391fmr25547855ybc.586.1667451287286; Wed, 02 Nov 2022 21:54:47 -0700 (PDT) Date: Wed, 2 Nov 2022 21:54:30 -0700 Message-Id: <20221103045437.163510-1-irogers@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.38.1.273.g43a17bfeac-goog Subject: [PATCH v1 0/7] Fix perf trace libbpf 1.0+ compatibility From: Ian Rogers <irogers@google.com> To: Leo Yan <leo.yan@linaro.org>, Peter Zijlstra <peterz@infradead.org>, Ingo Molnar <mingo@redhat.com>, Arnaldo Carvalho de Melo <acme@kernel.org>, Mark Rutland <mark.rutland@arm.com>, Alexander Shishkin <alexander.shishkin@linux.intel.com>, Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Stephane Eranian <eranian@google.com>, Ian Rogers <irogers@google.com> Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748449674723289132?= X-GMAIL-MSGID: =?utf-8?q?1748449674723289132?= |
Series |
Fix perf trace libbpf 1.0+ compatibility
|
|
Message
Ian Rogers
Nov. 3, 2022, 4:54 a.m. UTC
Perf trace can augment system calls with a BPF program passed as an event. The BPF code for this lives in examples. This patch fixes the example code to not used deprecated/removed APIs in libbpf. As libbpf has similar header files to tools/perf/include/bpf the code is transitioned to use the more standard libbpf code and the perf BPF header files removed. Ian Rogers (7): perf trace: Raw augmented syscalls fix libbpf 1.0+ compatibility perf trace: Etcsnoop fix libbpf 1.0+ compatibility perf trace: Augmented syscalls fix libbpf 1.0+ compatibility perf trace: hello fix libbpf 1.0+ compatibility perf trace: empty fix libbpf 1.0+ compatibility perf trace: 5sec fix libbpf 1.0+ compatibility perf bpf: Remove now unused BPF headers tools/perf/Makefile.perf | 5 -- tools/perf/examples/bpf/5sec.c | 8 +- .../examples/bpf/augmented_raw_syscalls.c | 75 ++++++++++++++----- tools/perf/examples/bpf/augmented_syscalls.c | 58 +++++++++----- tools/perf/examples/bpf/empty.c | 13 +++- tools/perf/examples/bpf/etcsnoop.c | 41 ++++++++-- tools/perf/examples/bpf/hello.c | 24 +++++- tools/perf/include/bpf/bpf.h | 70 ----------------- tools/perf/include/bpf/linux/socket.h | 24 ------ tools/perf/include/bpf/pid_filter.h | 21 ------ tools/perf/include/bpf/stdio.h | 16 ---- tools/perf/include/bpf/unistd.h | 10 --- 12 files changed, 169 insertions(+), 196 deletions(-) delete mode 100644 tools/perf/include/bpf/bpf.h delete mode 100644 tools/perf/include/bpf/linux/socket.h delete mode 100644 tools/perf/include/bpf/pid_filter.h delete mode 100644 tools/perf/include/bpf/stdio.h delete mode 100644 tools/perf/include/bpf/unistd.h
Comments
Hi Ian, Arnaldo, On Wed, Nov 02, 2022 at 09:54:30PM -0700, Ian Rogers wrote: > Perf trace can augment system calls with a BPF program passed as an > event. The BPF code for this lives in examples. This patch fixes the > example code to not used deprecated/removed APIs in libbpf. As libbpf > has similar header files to tools/perf/include/bpf the code is > transitioned to use the more standard libbpf code and the perf BPF > header files removed. I think you missed to update the code examples/bpf/sys_enter_openat.c, either you could remove it (since it's duplicate with augmented_raw_syscalls.c), or we should apply below fixing: From f30af3b43060e482c54e113cbe90223173c69abd Mon Sep 17 00:00:00 2001 From: Leo Yan <leo.yan@linaro.org> Date: Fri, 11 Nov 2022 12:02:24 +0000 Subject: [PATCH] perf trace: sys_enter_openat.c fix libbpf 1.0+ compatibility Avoid use of tools/perf/include/bpf/bpf.h and use the more regular BPF headers. With fixing: # ./perf trace -e examples/bpf/sys_enter_openat.c 0.000 irqbalance/1025 syscalls:sys_enter_openat(AT_FDCWD, "", O_RDONLY) 1.596 irqbalance/1025 syscalls:sys_enter_openat(AT_FDCWD, "", O_RDONLY) 1.832 irqbalance/1025 syscalls:sys_enter_openat(AT_FDCWD, "", O_RDONLY) 1.864 irqbalance/1025 syscalls:sys_enter_openat(AT_FDCWD, "", O_RDONLY) Signed-off-by: Leo Yan <leo.yan@linaro.org> --- tools/perf/examples/bpf/sys_enter_openat.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/perf/examples/bpf/sys_enter_openat.c b/tools/perf/examples/bpf/sys_enter_openat.c index c4481c390d23..8edfa7c147d1 100644 --- a/tools/perf/examples/bpf/sys_enter_openat.c +++ b/tools/perf/examples/bpf/sys_enter_openat.c @@ -14,7 +14,9 @@ * the return value. */ -#include <bpf/bpf.h> +#include <linux/bpf.h> +#include <linux/limits.h> +#include <bpf/bpf_helpers.h> struct syscall_enter_openat_args { unsigned long long unused; @@ -25,9 +27,10 @@ struct syscall_enter_openat_args { long mode; }; -int syscall_enter(openat)(struct syscall_enter_openat_args *args) +SEC("syscalls:sys_enter_openat") +int syscall_enter_openat(struct syscall_enter_openat_args *args) { return 1; } -license(GPL); +char _license[] SEC("license") = "GPL";
On Fri, Nov 11, 2022 at 4:09 AM Leo Yan <leo.yan@linaro.org> wrote: > > Hi Ian, Arnaldo, > > On Wed, Nov 02, 2022 at 09:54:30PM -0700, Ian Rogers wrote: > > Perf trace can augment system calls with a BPF program passed as an > > event. The BPF code for this lives in examples. This patch fixes the > > example code to not used deprecated/removed APIs in libbpf. As libbpf > > has similar header files to tools/perf/include/bpf the code is > > transitioned to use the more standard libbpf code and the perf BPF > > header files removed. > > I think you missed to update the code examples/bpf/sys_enter_openat.c, > either you could remove it (since it's duplicate with > augmented_raw_syscalls.c), or we should apply below fixing: Arnaldo, what do you think? Thanks, Ian > From f30af3b43060e482c54e113cbe90223173c69abd Mon Sep 17 00:00:00 2001 > From: Leo Yan <leo.yan@linaro.org> > Date: Fri, 11 Nov 2022 12:02:24 +0000 > Subject: [PATCH] perf trace: sys_enter_openat.c fix libbpf 1.0+ compatibility > > Avoid use of tools/perf/include/bpf/bpf.h and use the more regular BPF > headers. > > With fixing: > > # ./perf trace -e examples/bpf/sys_enter_openat.c > 0.000 irqbalance/1025 syscalls:sys_enter_openat(AT_FDCWD, "", O_RDONLY) > 1.596 irqbalance/1025 syscalls:sys_enter_openat(AT_FDCWD, "", O_RDONLY) > 1.832 irqbalance/1025 syscalls:sys_enter_openat(AT_FDCWD, "", O_RDONLY) > 1.864 irqbalance/1025 syscalls:sys_enter_openat(AT_FDCWD, "", O_RDONLY) > > Signed-off-by: Leo Yan <leo.yan@linaro.org> > --- > tools/perf/examples/bpf/sys_enter_openat.c | 9 ++++++--- > 1 file changed, 6 insertions(+), 3 deletions(-) > > diff --git a/tools/perf/examples/bpf/sys_enter_openat.c b/tools/perf/examples/bpf/sys_enter_openat.c > index c4481c390d23..8edfa7c147d1 100644 > --- a/tools/perf/examples/bpf/sys_enter_openat.c > +++ b/tools/perf/examples/bpf/sys_enter_openat.c > @@ -14,7 +14,9 @@ > * the return value. > */ > > -#include <bpf/bpf.h> > +#include <linux/bpf.h> > +#include <linux/limits.h> > +#include <bpf/bpf_helpers.h> > > struct syscall_enter_openat_args { > unsigned long long unused; > @@ -25,9 +27,10 @@ struct syscall_enter_openat_args { > long mode; > }; > > -int syscall_enter(openat)(struct syscall_enter_openat_args *args) > +SEC("syscalls:sys_enter_openat") > +int syscall_enter_openat(struct syscall_enter_openat_args *args) > { > return 1; > } > > -license(GPL); > +char _license[] SEC("license") = "GPL";