From patchwork Sat Apr 6 04:09:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13619652 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2BFE317C8B for ; Sat, 6 Apr 2024 04:09:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712376561; cv=none; b=FbLG6BMDNb1MXlioRD3l0GrcQgASCY+WinK5325uDgENf/SB9tggcreGDMwDlb55h9ss9sHX1c5VgCLKwkXkEe0b5DeaHKaP/wgj7X/Y+7YR4AFV/bLoL6HP7K0nh4yX9nCfAxlqyiUZnWQaO3SVcarjIn7LJIs1QbPBqymJ464= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712376561; c=relaxed/simple; bh=ryhaCjT8y83e6nm9rSvWXbKLjBmeKFK9uS2+aXyQEW0=; h=Date:Message-Id:Mime-Version:Subject:From:To:Content-Type; b=AsVaHit6hpfOQ2jo+UMreore3LPeOYdDripXU2B2sNXLw9gSF3nC/IwcUkH+0Zb3XNOaKHNz7Za+K6CuK1D7uZOgxNv3yUDJXqv/ThsnaxKyFltB2QIxWKsh51Q1wyJMK1S3DeY0X+oR9Gjvl/PWDraqnTI5O5dtL/rfBUAHR1g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=3zBk0Xr7; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="3zBk0Xr7" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-60a2386e932so52655767b3.1 for ; Fri, 05 Apr 2024 21:09:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1712376558; x=1712981358; darn=vger.kernel.org; h=to:from:subject:mime-version:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=sNu7c9amoaI33ZXVqjycoBCCoj/nNGvrPWP0zIU3JJE=; b=3zBk0Xr7z/O6DQ7wPX07f9FomFCdMKYk+5o37Ytw0tYuIrpnIAtC3TjJcAycYEYmK4 8rjVaH7lXIa6Xel7D2it7fad1mWR2UbUMNUlrlnkDSKMdqSYcBd4L526I1caImigrENJ wokRdsmVG2KuNTgb2kCSu8BM8XixsY9/VFaRf3muRRqr7Vh4XfurriIDhyHh1o3zXQOC NSQoUYtzDiPlA34Dzn4WXbxpQET1AuD/caeXMd+cXp1s2hv07GrVSUjIGWmeHo0afjDw Ew0c1EaU0addIEkgbwFjvlTBsaGUs2LRloTptPy1TIrjT6Ta/hTKYvmWOk2UBNu3B5lD smFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712376558; x=1712981358; h=to:from:subject:mime-version:message-id:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=sNu7c9amoaI33ZXVqjycoBCCoj/nNGvrPWP0zIU3JJE=; b=IsHI7NiPadGeP9hyBDEpAWEvhyyhE1gERyDhSarw2o5nLp0B0Tm+mXOKoKD51f0mtr XW/EvvsqaHD84Ldu7XtB80wzxl1Z37o7O/17KX5MBLxiUHWkpKlj7n/TgKWc2Nsk/6LH xTCWhMl/wxYpTDPz4Elq+VuKOVtXQ8NzG9mc5CITGSF6k4++o3Rytw1yWuvsjCnMi0di wFDt+aACFqxNX2JdEiUpZNaAHVclApMbSoFeA8TILG6Q4upQnztWVJNCtK1LvuAy9jgu XJRQVJxd+Je81X+5DSKPCKkTPRRjUM5gOz2BEo6NTto59wOYPzI/3KFHt4koDU+9eabX rqjg== X-Forwarded-Encrypted: i=1; AJvYcCXRe7fqT0kuWdETHKI4CLtduECpyaulep6jr0ISmwKMxx2tbl/MW7fFaw9hNYxIulcWHc1J+0h833C65eCCLqEc0R1+ X-Gm-Message-State: AOJu0Yzli/IFcDUOYONRPMpt4tr1sGF+ZPuOY36Yb9GqQXYDbVJ2cTfH y50wnLXKZWwKxIvv8CQNA/oLOYedTEhgHf4j2tOo2J/dzjianXPZqE5a3cMVcmapOKxpdnjGO3W JeQHFvA== X-Google-Smtp-Source: AGHT+IH7IGd2BpRVCyTAOvsnf3SjaXVdsGIlIFz5FXVc55i7Tlr9PCarJ5xLRb9aFCQWhPs6faG7upJWWRWK X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:51c1:e2b:9198:3cdc]) (user=irogers job=sendgmr) by 2002:a0d:ca88:0:b0:614:ff0d:2c7b with SMTP id m130-20020a0dca88000000b00614ff0d2c7bmr806437ywd.10.1712376558227; Fri, 05 Apr 2024 21:09:18 -0700 (PDT) Date: Fri, 5 Apr 2024 21:09:10 -0700 Message-Id: <20240406040911.1603801-1-irogers@google.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.44.0.478.gd926399ef9-goog Subject: [PATCH v1 1/2] perf bench uprobe: Remove lib64 from libc.so.6 binary path From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , Kees Cook , Andrei Vagin , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org bpf_program__attach_uprobe_opts will search LD_LIBRARY_PATH and so specifying `/lib64` is unnecessary and causes failures for libc.so.6 paths like `/lib/x86_64-linux-gnu/libc.so.6`. Fixes: 7b47623b8cae ("perf bench uprobe trace_printk: Add entry attaching an BPF program that does a trace_printk") Signed-off-by: Ian Rogers Acked-by: Jiri Olsa --- tools/perf/bench/uprobe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/bench/uprobe.c b/tools/perf/bench/uprobe.c index 5c71fdc419dd..b722ff88fe7d 100644 --- a/tools/perf/bench/uprobe.c +++ b/tools/perf/bench/uprobe.c @@ -47,7 +47,7 @@ static const char * const bench_uprobe_usage[] = { #define bench_uprobe__attach_uprobe(prog) \ skel->links.prog = bpf_program__attach_uprobe_opts(/*prog=*/skel->progs.prog, \ /*pid=*/-1, \ - /*binary_path=*/"/lib64/libc.so.6", \ + /*binary_path=*/"libc.so.6", \ /*func_offset=*/0, \ /*opts=*/&uprobe_opts); \ if (!skel->links.prog) { \ From patchwork Sat Apr 6 04:09:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13619653 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 91F641B7FD for ; Sat, 6 Apr 2024 04:09:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712376563; cv=none; b=oxMBryoHlYgL/mCuKtgOjhBGF5CXASilI5zOHiFHMR9T5N3a8hsxa+NjGIUr0YyYJTd++BgidCK9NXlUPiM2JiPZhBLRU0uCJB+f+lwkuqBtb84VmeNM1g4J1TVkpHejImUQAPJG4xJP2c/kPhkUksSI/JF+8ioVVcKLGA8gFRY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712376563; c=relaxed/simple; bh=juPnXzP618xWObDkf1iUj+LsRWuVKPa2Y4ItrduMxq0=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=H2uYO83FGyVbP6PM+NbRbn0Ejf5ffqsRM9i464KJptltz6Jyf0z5UZqhKe8NrQvTfKiJwq8MeRsxBlIhdvVK0qXdnzu8R45tiTd7J3binWR/M/PIONSd9/YLmXEceHAFsDsuhnQXs31LMyKSbFwu90vy9+36CmkeULmDYSd51Sg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=U8QItgEn; arc=none smtp.client-ip=209.85.128.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="U8QItgEn" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-61506d6d667so48160257b3.1 for ; Fri, 05 Apr 2024 21:09:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1712376561; x=1712981361; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=G6CfeKOKugD2wHzsxUq+tzYMTN2fGH3EGK3TX/G0kaY=; b=U8QItgEneV0nrbeFlyb00Ii1SS5i04UN6IZrhpWjLgjAQF1z56K1sudQSWhH6THENP XkBQNQD9uWjB88HJ2d6HqTF+tBvpvAvJx9rJSXwnXfIiXf/CQrjAd4AU5iDiARLKsvEp Yrlfz7RNwLtLL4+EtvKbPfcphSNEN9Z9/N432sSrJVExqNbLMbGAPGNWizbayqaCVdIv jBo3P1ubEx15MFTqphEWoKpQOl8hy5qTDOobtxG/WNSmG56EHqA5iD+eJUBo1pIGKtuv y3G+iqmrdB4gRhZdyN/BKe5VsomhdLfb6xqPsZjk6Ziko0C3zW8iaabJlyxGWNCs49Na VVPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712376561; x=1712981361; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=G6CfeKOKugD2wHzsxUq+tzYMTN2fGH3EGK3TX/G0kaY=; b=fPdMCj3lYzL/GuA/DaAsf8LEzoTeNRf6aODbeOJudlOTGQ6K5H3sZ92SKYVwCD8zKe WwA4fFw+TQ+p3N6Kkm71ReqPRcD3J3pGyWK7gbBUaEcvo/fx4syoMlzPc11Gse+XQPWE hUJ/i8TKMpq1JbT9rbcej/EIo60uXt2MSyLrEy2cGdZQ2caoyYgSMMhG8hwNB1hBVfPG oVSnxuecDWv8vLAQ9ziMWHiHG43L9IhtKoX0tGkEKlYAl4NWXIFk1CjDeRh2yK3cYzZx cHINNUlL39/Ig2TDmKC0KdK4Hwf8rSlyXeaU8gj6sxriBVf0Fr/C/JH2107ZTHPLw2jB iOgg== X-Forwarded-Encrypted: i=1; AJvYcCU7yY+q1UrU7iwrtwPj2gGRVFCsft/+oFZdfHUhmObz4CDKXgmHhCv+dQHOjCMotNb4ZteqyBhpWXFb8DdfEQXclJGA X-Gm-Message-State: AOJu0Yz2W99w0dulHOJ4QdJzJpMU9Q55/ooHwRX9+aZKlv1T5sYs7ag1 kZZxz7ltVw8VQf4OmxOpfG8ZZ+BV4b7gNi0lkEHTihLmyL+wMpYgjJI1D9R5Jv98Wh732sBOFlL +conR9Q== X-Google-Smtp-Source: AGHT+IGKdPN5hUTbwKOwQZ1f9rtbG1LHGY0ZdYTo9IZKVqZ2bXxgEHgJCHIFKCtc+jY7dFopC7vL4/p0oAeC X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:51c1:e2b:9198:3cdc]) (user=irogers job=sendgmr) by 2002:a05:690c:4509:b0:615:19db:8ee0 with SMTP id gt9-20020a05690c450900b0061519db8ee0mr767763ywb.1.1712376560891; Fri, 05 Apr 2024 21:09:20 -0700 (PDT) Date: Fri, 5 Apr 2024 21:09:11 -0700 In-Reply-To: <20240406040911.1603801-1-irogers@google.com> Message-Id: <20240406040911.1603801-2-irogers@google.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240406040911.1603801-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.478.gd926399ef9-goog Subject: [PATCH v1 2/2] perf bench uprobe: Add uretprobe variant of uprobe benchmarks From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , Kees Cook , Andrei Vagin , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org Name benchmarks with _ret at the end to avoid creating a new set of benchmarks. Signed-off-by: Ian Rogers --- tools/perf/bench/bench.h | 2 ++ tools/perf/bench/uprobe.c | 20 +++++++++++++++++--- tools/perf/builtin-bench.c | 2 ++ tools/perf/util/bpf_skel/bench_uprobe.bpf.c | 16 ++++++++++++++++ 4 files changed, 37 insertions(+), 3 deletions(-) diff --git a/tools/perf/bench/bench.h b/tools/perf/bench/bench.h index faa18e6d2467..9f736423af53 100644 --- a/tools/perf/bench/bench.h +++ b/tools/perf/bench/bench.h @@ -46,6 +46,8 @@ int bench_breakpoint_enable(int argc, const char **argv); int bench_uprobe_baseline(int argc, const char **argv); int bench_uprobe_empty(int argc, const char **argv); int bench_uprobe_trace_printk(int argc, const char **argv); +int bench_uprobe_empty_ret(int argc, const char **argv); +int bench_uprobe_trace_printk_ret(int argc, const char **argv); int bench_pmu_scan(int argc, const char **argv); #define BENCH_FORMAT_DEFAULT_STR "default" diff --git a/tools/perf/bench/uprobe.c b/tools/perf/bench/uprobe.c index b722ff88fe7d..0b90275862e1 100644 --- a/tools/perf/bench/uprobe.c +++ b/tools/perf/bench/uprobe.c @@ -26,9 +26,11 @@ static int loops = LOOPS_DEFAULT; enum bench_uprobe { - BENCH_UPROBE__BASELINE, - BENCH_UPROBE__EMPTY, - BENCH_UPROBE__TRACE_PRINTK, + BENCH_UPROBE__BASELINE, + BENCH_UPROBE__EMPTY, + BENCH_UPROBE__TRACE_PRINTK, + BENCH_UPROBE__EMPTY_RET, + BENCH_UPROBE__TRACE_PRINTK_RET, }; static const struct option options[] = { @@ -81,6 +83,8 @@ static int bench_uprobe__setup_bpf_skel(enum bench_uprobe bench) case BENCH_UPROBE__BASELINE: break; case BENCH_UPROBE__EMPTY: bench_uprobe__attach_uprobe(empty); break; case BENCH_UPROBE__TRACE_PRINTK: bench_uprobe__attach_uprobe(trace_printk); break; + case BENCH_UPROBE__EMPTY_RET: bench_uprobe__attach_uprobe(empty_ret); break; + case BENCH_UPROBE__TRACE_PRINTK_RET: bench_uprobe__attach_uprobe(trace_printk_ret); break; default: fprintf(stderr, "Invalid bench: %d\n", bench); goto cleanup; @@ -197,3 +201,13 @@ int bench_uprobe_trace_printk(int argc, const char **argv) { return bench_uprobe(argc, argv, BENCH_UPROBE__TRACE_PRINTK); } + +int bench_uprobe_empty_ret(int argc, const char **argv) +{ + return bench_uprobe(argc, argv, BENCH_UPROBE__EMPTY_RET); +} + +int bench_uprobe_trace_printk_ret(int argc, const char **argv) +{ + return bench_uprobe(argc, argv, BENCH_UPROBE__TRACE_PRINTK_RET); +} diff --git a/tools/perf/builtin-bench.c b/tools/perf/builtin-bench.c index 1a8898d5b560..2c1a9f3d847a 100644 --- a/tools/perf/builtin-bench.c +++ b/tools/perf/builtin-bench.c @@ -109,6 +109,8 @@ static struct bench uprobe_benchmarks[] = { { "baseline", "Baseline libc usleep(1000) call", bench_uprobe_baseline, }, { "empty", "Attach empty BPF prog to uprobe on usleep, system wide", bench_uprobe_empty, }, { "trace_printk", "Attach trace_printk BPF prog to uprobe on usleep syswide", bench_uprobe_trace_printk, }, + { "empty_ret", "Attach empty BPF prog to uretprobe on usleep, system wide", bench_uprobe_empty_ret, }, + { "trace_printk_ret", "Attach trace_printk BPF prog to uretprobe on usleep syswide", bench_uprobe_trace_printk_ret,}, { NULL, NULL, NULL }, }; diff --git a/tools/perf/util/bpf_skel/bench_uprobe.bpf.c b/tools/perf/util/bpf_skel/bench_uprobe.bpf.c index 2c55896bb33c..a01c7f791fcd 100644 --- a/tools/perf/util/bpf_skel/bench_uprobe.bpf.c +++ b/tools/perf/util/bpf_skel/bench_uprobe.bpf.c @@ -4,6 +4,7 @@ #include unsigned int nr_uprobes; +unsigned int nr_uretprobes; SEC("uprobe") int BPF_UPROBE(empty) @@ -20,4 +21,19 @@ int BPF_UPROBE(trace_printk) return 0; } +SEC("uretprobe") +int BPF_URETPROBE(empty_ret) +{ + return 0; +} + +SEC("uretprobe") +int BPF_URETPROBE(trace_printk_ret) +{ + char fmt[] = "perf bench uretprobe %u"; + + bpf_trace_printk(fmt, sizeof(fmt), ++nr_uretprobes); + return 0; +} + char LICENSE[] SEC("license") = "Dual BSD/GPL";