From patchwork Wed Jun 12 18:32:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13695443 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.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 60DCF823CA for ; Wed, 12 Jun 2024 18:33:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718217220; cv=none; b=ew1ZO0e9SCHTbdjBLQH10BAvupSPIAbS/FVHam1K0xiPCg7kk6V6C2keG1JZYAuYgRzDVT+dKkNEvzICg1HH9QdSIrRP/JIsoHmPai9ihmnaTjmRs/VH3KrEVydhaaii0o6IZAxIKGNh2D2E1C72ZPB7EHagoTaG0g/ahQb2bas= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718217220; c=relaxed/simple; bh=GW3F5bRDidIfzFfzx2XH9TZgHygHBWW2YgjI9x1i9kA=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=stpJkg0vAk80CV7KzdeChmWk9TdgioYShhS1fGbYGz4zHhrHYOQB/24GV/QXMWhiAAVyCSC8X4j6rZjjrEup+vl4khD0FxRIlYXMvzoszFIjsi+IgvJ+EsWGqvUPMCsXmT9yUUucLE9yVMWf6mUxLu4a9rf8aB1emzK7S2hURCs= 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=wBAfei2k; arc=none smtp.client-ip=209.85.219.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="wBAfei2k" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dfdddb9b425so244675276.2 for ; Wed, 12 Jun 2024 11:33:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1718217216; x=1718822016; 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=hxFca2akLEi/c6aeiWryG3twAj/x8mJ+5CcLXE4nJMw=; b=wBAfei2kL1ZcoeHo2BHZAsPPT1zDP5xxnU6YYpceSEzBFi7SBKeExgVLw0n+LAhgqL ekC+59Nvwt5+iMo05pAagN5j5k+BkZQqUiH1hUcfyLxpi8QTPTSTuzemGfa4/8kdV/2D /21CWctfBEE1zX6ZTbrg/p9pSmGE7LozNvRQg7Kr0WMCep7AWEsnYk6vwwubXp2ft1CF ORBSVxUQIo0qYo9tLnVDk2NMJuksDau5vpMvBmbh08RNRId1YVUbmaW2rLdlTeJEUhpB 8DXegtwm1hB2qCQXlbjiwdIANggpt0Fx0YrTb8X660HCXQvz6W2k/j3yHoqEI8bE8nCt /6vA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718217216; x=1718822016; 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=hxFca2akLEi/c6aeiWryG3twAj/x8mJ+5CcLXE4nJMw=; b=MMtYkRuSHwQSAQjgbSit1DvwJqqsHwV+Yeh4rf3fxYoSe/kkj6M8mqEgDQGkHzXabF CSd+ZiaGDjzgtCb9yLuTTsKT4ffCygAhgJPayFWUSZUPgM8BWwM9A0tEl55w56YBUo3Q TkDO68mIjNq8UK2yzD5l0qX/e0z5GbhKedCtmSEHSZNwgeO5xUVvM5o+7UuCf2PdFpZi op8YkXUxJ0y+JiZTlOBhr8ruto/jzIyM4XSDk575V1obvNAKubqYFwHnVBUM5St1e5On /kgahyqVQIiTrb8elfcxZZzwVnF+Tf3TOzt3fE90oiZV0YMohhN0p8sYfFlieH3wkzis fITQ== X-Forwarded-Encrypted: i=1; AJvYcCWq56UVIPDDwspHxxC56JN04iVfQ2gANjR9v+5ogbJLAUkJBhlxOoZ6PQXIN+Cx6QB08bE3tDEMOC33lpCAuaQrmQ4N X-Gm-Message-State: AOJu0YzmtlQ8iWfjpZR7ohDT2ai3b5dn7XAFnvTEU8qeevswUGIEDr4R tGyJaw8c498ygO2nQoI9Ein4p0Xmfw8KwgKvS9Ov2zouhrZcGSlQUoyhC3MX9VbKTVVmsUgxr+L vo8UKiQ== X-Google-Smtp-Source: AGHT+IHHEhm3YqNyXbkwlJqf7zAbA10K5YtztZ12tlPf+OX1TpaElO1uBuwFIrHE76zPeVUQ691ENdAPSP7k X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:959d:4302:db0e:d12a]) (user=irogers job=sendgmr) by 2002:a05:6902:2b03:b0:dda:c57c:b69b with SMTP id 3f1490d57ef6-dfe62f13456mr822488276.0.1718217216102; Wed, 12 Jun 2024 11:33:36 -0700 (PDT) Date: Wed, 12 Jun 2024 11:32:02 -0700 In-Reply-To: <20240612183205.3120248-1-irogers@google.com> Message-Id: <20240612183205.3120248-5-irogers@google.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240612183205.3120248-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.505.gda0bf45e8d-goog Subject: [PATCH v1 4/7] 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 --- 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 ecf0586e9061..f9709718cb83 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