From patchwork Thu Jun 13 18:32:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13697286 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 9A04D15572F for ; Thu, 13 Jun 2024 18:32:44 +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=1718303566; cv=none; b=t7m3KQgxd+GExLZ9RN6wS5PtNl5HrUOhj/sQA3oYbJqx10wI7oE3ExN1APfxxRXF3bfml8+T9jcYlS4pyealjygwgsG4SFMk6c2CWIVCnOQo01+8g+7Ol1PrrY1bRu2OxheMIdV3IYsg+CblKiP6amsK3WkoQAmcigw0VzFYkF8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718303566; c=relaxed/simple; bh=YCtNNA8v+ohwBpi9Rus0CYVSC7ZO/eTuaCLvVJt5XpM=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=sycNC8L6nsk7ncEMTTpFQ89QdlUv452HvVxpurvvE8gQYBdSp3rVUSIjikxxv8/YiZV1Ri3T5b0l6Xt/+REtnZVnJ97N0jDXhg+khVQQ/1zPK7QEmw83wh1Wxem+hRDKwcNy0M5Ee8icb9cXwAi2GsLtCJpYZ+Wk2W4Lnh6tVQU= 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=sIGemxPJ; 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="sIGemxPJ" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-62fd1655e12so27177437b3.1 for ; Thu, 13 Jun 2024 11:32:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1718303564; x=1718908364; 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=VsC80hpqUOVrh72YOJDioHn4WeJ5/uS/HucL7CDuoyM=; b=sIGemxPJmbf2lKUHiAspy5SuPSh6XniGN2354rlm69qOLzNIs39f+llazou1DeLuA+ PzLym+q31Sg0jZucPHTB4Dc0zq3UepFYf0k0Xdrf8fhs4pPnZjjpGn1usibd9PCpeGZb LQT/tSC7FIk+AU3swi8rvawYxXoxBFI+Q3shT2nW1fpf5ZNiT/AbcQgan8prj2cNwwjo vjThl9WMfPjsyorhwDOeVZ3GGFvinWp68lb/4QTUpEZiNMAvcvxLYFFg31b/WgToldIb KEkoWWdrkQfrEKtbK6SK57psm3+DLGzx1Y3wMyqocozQg8D37ujRj1Hw7cVtjQorcUjv epCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718303564; x=1718908364; 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=VsC80hpqUOVrh72YOJDioHn4WeJ5/uS/HucL7CDuoyM=; b=l5WfCYQT3RYI9TbtB1lt7bYL944rCfH0QYJO3PfbuH+TSTKMkEw7rzJ13prYy0XZ2X V61LmCTGeCsrcN/hyUkDIInIqusy2FePrD2OSYCo4voZs/UX/Ehx0VD7CcaYNrnyDpI4 2Hb7W1zDyy36v9FD9xi7Pxz1O2JJSJH4kI67/+i1gxhGJw2EuVUe505pe+ibWLCf1y/f FWF0e9RySGzqXiRXvI3JFbiGtK1sVjxBUdB8GRZy1m9cr66DUWwBY1gLdaFA6HK40hGi 4yUKj+QHuV4fHcPkmhFluZCAPUP++lgqXoeTo8rRQwH3RncWhDrWZnZPQWEs8ad30RJs QC2Q== X-Forwarded-Encrypted: i=1; AJvYcCX0ByI9HpZoHTW0WoihB4tTjQeMRYZVFxNibFYMYCJ0fdWKNtwc+hulBCHdOsMwhvnmbfuelmLdlZKtrYn9OBxSGNSH X-Gm-Message-State: AOJu0YwmIR4gWsNYns3taUjNiITtgasUmeV6xn1tLjg3rpMluBiX8Z7s lcjH7pbDFwbpFfX/Qza5rMxVD0F5DYKbpbI0wZSRqxgAU70XPPn6bU75aO06+NOvaHS6p7MExZd nuWyXLg== X-Google-Smtp-Source: AGHT+IEdqa6Cq2DjAQ1hydcxNB6Fk+xXGdzWy6Gy93AqEv1pt5Ye/DroFSzoO6amfQnl0ylP95kficGysIqg X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:96dd:26a6:1493:53c8]) (user=irogers job=sendgmr) by 2002:a05:690c:6ac8:b0:622:d1d3:124 with SMTP id 00721157ae682-632248126c8mr799617b3.10.1718303563655; Thu, 13 Jun 2024 11:32:43 -0700 (PDT) Date: Thu, 13 Jun 2024 11:32:21 -0700 In-Reply-To: <20240613183224.3399628-1-irogers@google.com> Message-Id: <20240613183224.3399628-6-irogers@google.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240613183224.3399628-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.627.g7a2c4fd464-goog Subject: [PATCH v2 5/8] perf bench: Make bench its own library 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 , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Guo Ren , Paul Walmsley , Palmer Dabbelt , Albert Ou , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , " =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= " , Benno Lossin , Andreas Hindborg , Alice Ryhl , Nick Terrell , Ravi Bangoria , Kees Cook , Andrei Vagin , Athira Jajeev , Oliver Upton , Ze Gao , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-csky@vger.kernel.org, linux-riscv@lists.infradead.org, coresight@lists.linaro.org, rust-for-linux@vger.kernel.org, bpf@vger.kernel.org Make the benchmark code into a library so it may be linked against things like the python module to avoid compiling code twice. Signed-off-by: Ian Rogers Reviewed-by: James Clark --- tools/perf/Build | 4 ++-- tools/perf/Makefile.perf | 11 +++++++++- tools/perf/bench/Build | 46 ++++++++++++++++++++-------------------- 3 files changed, 35 insertions(+), 26 deletions(-) diff --git a/tools/perf/Build b/tools/perf/Build index fddd45ab35b4..2787f5630ff7 100644 --- a/tools/perf/Build +++ b/tools/perf/Build @@ -1,4 +1,4 @@ -perf-y += builtin-bench.o +perf-bench-y += builtin-bench.o perf-y += builtin-annotate.o perf-y += builtin-config.o perf-y += builtin-diff.o @@ -35,7 +35,7 @@ endif perf-$(CONFIG_LIBELF) += builtin-probe.o -perf-y += bench/ +perf-bench-y += bench/ perf-test-y += tests/ perf-y += perf.o diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index 9fa69dd0b472..4a3c000b9845 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -425,6 +425,9 @@ endif export PERL_PATH +LIBPERF_BENCH_IN := $(OUTPUT)perf-bench-in.o +LIBPERF_BENCH := $(OUTPUT)libperf-bench.a + LIBPERF_TEST_IN := $(OUTPUT)perf-test-in.o LIBPERF_TEST := $(OUTPUT)libperf-test.a @@ -438,7 +441,7 @@ PERFLIBS = $(LIBAPI) $(LIBPERF) $(LIBSUBCMD) $(LIBSYMBOL) ifdef LIBBPF_STATIC PERFLIBS += $(LIBBPF) endif -PERFLIBS += $(LIBPERF_TEST) $(LIBPERF_UI) $(LIBPMU_EVENTS) +PERFLIBS += $(LIBPERF_BENCH) $(LIBPERF_TEST) $(LIBPERF_UI) $(LIBPMU_EVENTS) # We choose to avoid "if .. else if .. else .. endif endif" # because maintaining the nesting to match is a pain. If @@ -740,6 +743,12 @@ $(LIBPMU_EVENTS_IN): FORCE prepare $(LIBPMU_EVENTS): $(LIBPMU_EVENTS_IN) $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $< +$(LIBPERF_BENCH_IN): FORCE prepare + $(Q)$(MAKE) $(build)=perf-bench + +$(LIBPERF_BENCH): $(LIBPERF_BENCH_IN) + $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $< + $(LIBPERF_TEST_IN): FORCE prepare $(Q)$(MAKE) $(build)=perf-test diff --git a/tools/perf/bench/Build b/tools/perf/bench/Build index c2ab30907ae7..279ab2ab4abe 100644 --- a/tools/perf/bench/Build +++ b/tools/perf/bench/Build @@ -1,25 +1,25 @@ -perf-y += sched-messaging.o -perf-y += sched-pipe.o -perf-y += sched-seccomp-notify.o -perf-y += syscall.o -perf-y += mem-functions.o -perf-y += futex-hash.o -perf-y += futex-wake.o -perf-y += futex-wake-parallel.o -perf-y += futex-requeue.o -perf-y += futex-lock-pi.o -perf-y += epoll-wait.o -perf-y += epoll-ctl.o -perf-y += synthesize.o -perf-y += kallsyms-parse.o -perf-y += find-bit-bench.o -perf-y += inject-buildid.o -perf-y += evlist-open-close.o -perf-y += breakpoint.o -perf-y += pmu-scan.o -perf-y += uprobe.o +perf-bench-y += sched-messaging.o +perf-bench-y += sched-pipe.o +perf-bench-y += sched-seccomp-notify.o +perf-bench-y += syscall.o +perf-bench-y += mem-functions.o +perf-bench-y += futex-hash.o +perf-bench-y += futex-wake.o +perf-bench-y += futex-wake-parallel.o +perf-bench-y += futex-requeue.o +perf-bench-y += futex-lock-pi.o +perf-bench-y += epoll-wait.o +perf-bench-y += epoll-ctl.o +perf-bench-y += synthesize.o +perf-bench-y += kallsyms-parse.o +perf-bench-y += find-bit-bench.o +perf-bench-y += inject-buildid.o +perf-bench-y += evlist-open-close.o +perf-bench-y += breakpoint.o +perf-bench-y += pmu-scan.o +perf-bench-y += uprobe.o -perf-$(CONFIG_X86_64) += mem-memcpy-x86-64-asm.o -perf-$(CONFIG_X86_64) += mem-memset-x86-64-asm.o +perf-bench-$(CONFIG_X86_64) += mem-memcpy-x86-64-asm.o +perf-bench-$(CONFIG_X86_64) += mem-memset-x86-64-asm.o -perf-$(CONFIG_NUMA) += numa.o +perf-bench-$(CONFIG_NUMA) += numa.o