Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf bench: Remove reference to cmd_inject

Avoid `perf bench internals inject-build-id` referencing the
cmd_inject sub-command that requires perf-bench to backward reference
internals of builtins. Replace the reference to cmd_inject with a call
to main. To avoid python.c needing to link with something providing
main, drop the libperf-bench library from the python shared object.

Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Colin Ian King <colin.i.king@gmail.com>
Cc: Dapeng Mi <dapeng1.mi@linux.intel.com>
Cc: Howard Chu <howardchu95@gmail.com>
Cc: Ilya Leoshkevich <iii@linux.ibm.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Richter <tmricht@linux.ibm.com>
Cc: Veronika Molnarova <vmolnaro@redhat.com>
Cc: Weilin Wang <weilin.wang@intel.com>
Link: https://lore.kernel.org/r/20241119011644.971342-17-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ian Rogers and committed by
Arnaldo Carvalho de Melo
df487111 1a12ed09

+12 -14
+5 -2
tools/perf/Makefile.perf
··· 487 487 EXTLIBS := $(call filter-out,$(EXCLUDE_EXTLIBS),$(EXTLIBS)) 488 488 LIBS = -Wl,--whole-archive $(PERFLIBS) $(EXTRA_PERFLIBS) -Wl,--no-whole-archive -Wl,--start-group $(EXTLIBS) -Wl,--end-group 489 489 490 + PERFLIBS_PY := $(call filter-out,$(LIBPERF_BENCH),$(PERFLIBS)) 491 + LIBS_PY = -Wl,--whole-archive $(PERFLIBS_PY) $(EXTRA_PERFLIBS) -Wl,--no-whole-archive -Wl,--start-group $(EXTLIBS) -Wl,--end-group 492 + 490 493 export INSTALL SHELL_PATH 491 494 492 495 ### Build rules ··· 738 735 # Create python binding output directory if not already present 739 736 $(shell [ -d '$(OUTPUT)python' ] || mkdir -p '$(OUTPUT)python') 740 737 741 - $(OUTPUT)python/perf$(PYTHON_EXTENSION_SUFFIX): util/python.c util/setup.py $(PERFLIBS) 738 + $(OUTPUT)python/perf$(PYTHON_EXTENSION_SUFFIX): util/python.c util/setup.py $(PERFLIBS_PY) 742 739 $(QUIET_GEN)LDSHARED="$(CC) -pthread -shared" \ 743 - CFLAGS='$(CFLAGS)' LDFLAGS='$(LDFLAGS) $(LIBS)' \ 740 + CFLAGS='$(CFLAGS)' LDFLAGS='$(LDFLAGS) $(LIBS_PY)' \ 744 741 $(PYTHON_WORD) util/setup.py \ 745 742 --quiet build_ext; \ 746 743 cp $(PYTHON_EXTBUILD_LIB)perf*.so $(OUTPUT)python/
+7 -6
tools/perf/bench/inject-buildid.c
··· 52 52 static int nr_dsos; 53 53 static struct bench_dso *dsos; 54 54 55 - extern int cmd_inject(int argc, const char *argv[]); 55 + extern int main(int argc, const char **argv); 56 56 57 57 static const struct option options[] = { 58 58 OPT_UINTEGER('i', "iterations", &iterations, ··· 294 294 295 295 if (data->pid == 0) { 296 296 const char **inject_argv; 297 - int inject_argc = 2; 297 + int inject_argc = 3; 298 298 299 299 close(data->input_pipe[1]); 300 300 close(data->output_pipe[0]); ··· 318 318 if (inject_argv == NULL) 319 319 exit(1); 320 320 321 - inject_argv[0] = strdup("inject"); 322 - inject_argv[1] = strdup("-b"); 321 + inject_argv[0] = strdup("perf"); 322 + inject_argv[1] = strdup("inject"); 323 + inject_argv[2] = strdup("-b"); 323 324 if (build_id_all) 324 - inject_argv[2] = strdup("--buildid-all"); 325 + inject_argv[3] = strdup("--buildid-all"); 325 326 326 327 /* signal that we're ready to go */ 327 328 close(ready_pipe[1]); 328 329 329 - cmd_inject(inject_argc, inject_argv); 330 + main(inject_argc, inject_argv); 330 331 331 332 exit(0); 332 333 }
-6
tools/perf/util/python.c
··· 19 19 #include "util/kwork.h" 20 20 #include "util/sample.h" 21 21 #include <internal/lib.h> 22 - #include "../builtin.h" 23 22 24 23 #define _PyUnicode_FromString(arg) \ 25 24 PyUnicode_FromString(arg) ··· 1307 1308 struct kwork_work *key __maybe_unused) 1308 1309 { 1309 1310 return NULL; 1310 - } 1311 - 1312 - int cmd_inject(int argc __maybe_unused, const char *argv[] __maybe_unused) 1313 - { 1314 - return -1; 1315 1311 }