From nobody Sun Nov 24 11:46:21 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AD81E1D2716; Tue, 5 Nov 2024 14:26:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730816796; cv=none; b=uHivL9KFIQLkthTC2d/6uPnam+kvLzGxWxGpdDcUNZqt61hl6X0Bs60E91dS4klBliWvAzVOAvnIGgS8L6sKaxvtQq2zCiBccAIgMaccX6k+n31XBtk3iR0aY5VcpPwtGkmQypmQfb8zHQ70kxLehEUQPw6ylz1sCz64nWkhYvE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730816796; c=relaxed/simple; bh=9Qx32ibOQahsytcxZpIWtr7v9jYW23YEBF9AKP4Z5Ck=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pV08Hvz7L0fBbK56wFNGHdj7Cr14Wf0ejMHwWZTvNCFmm5+9NEoX3RFpveoCR1+cwe6JpFr1isb8oUOuV3maVebyBqS9hVNGx9egWtr5qdxLp7kp3g+Lu/uEei8bBpsk3qWMroaWlWoIU4DPgirC815i4Ybqy2ZD+2S31MqMH+c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oY429oE8; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oY429oE8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7ACE2C4CED0; Tue, 5 Nov 2024 14:26:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730816796; bh=9Qx32ibOQahsytcxZpIWtr7v9jYW23YEBF9AKP4Z5Ck=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oY429oE8SG/SzY+hMqjar89Z2Vma/ZAEZfVGQU4aTOLDomZ/+Qa6a1Ya/MqOCcG8x qiIrIn/dCh2XlfP+gYAxv27ZlWpPSrz38cr9yoLCd0eDJyW+ZK2uv88zWZn6Dg+e9y CMggM6wabGt9xkg3Kl579HyJ+dMRI5DPX9/ETkBONQoMp+oU2SJZxn4qr6pEpliDEL QBWH3+taEWv7TPj7oycMVTDF2A3QeIc5a8jcPrXQxObG+gwEOcU7qhsv7uJsQEpRav ygVkDQ8fJ3dbhgFN+PyiB1U2LUhNrbwknzwWk7XDX6LUwO1sDGLMxVTXuK0Zzx4xDR BJm44mg9dQurg== From: Arnaldo Carvalho de Melo To: Namhyung Kim Cc: Ingo Molnar , Thomas Gleixner , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Arnaldo Carvalho de Melo , Athira Rajeev , Howard Chu , James Clark , Leo Yan , Thomas Richter , Veronika Molnarova Subject: [PATCH v2 1/4] perf test python: Robustify the 'perf test python' test case Date: Tue, 5 Nov 2024 11:26:13 -0300 Message-ID: <20241105142616.761042-2-acme@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241105142616.761042-1-acme@kernel.org> References: <20241105142616.761042-1-acme@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Arnaldo Carvalho de Melo Even without any python binding or support for loading it present in perf, the 'import perf' 'perf test' says that testing that feature somehow "passes": $ strace -s1024 -f -e execve perf test 17 execve("/home/acme/bin/perf", ["perf", "test", "17"], 0x7ffe99ae5d50 /* 3= 8 vars */) =3D 0 strace: Process 519319 attached 17: 'import perf' in python : Ru= nning (1 active) strace: Process 519320 attached [pid 519320] execve("/bin/sh", ["sh", "-c", "--", "echo \"import sys ; sy= s.path.insert(0, '/tmp/build/perf-tools-next/python'); import perf\" | 2> = /dev/null"], 0x377ba9a0 /* 40 vars */) =3D 0 strace: Process 519321 attached strace: Process 519322 attached 17: 'import perf' in python : Ok +++ exited with 0 +++ $ It doesn't matter if we fork a new perf process to run just that test entry or if we don't (using -F). The system() call (that execve) will return zero even with that echo being piped into nothing: # sh -c -- echo \"import sys ; sys.path.insert(0, '/tmp/build/perf-tools-= next/python'); import perf\" | 2> /dev/null -bash: syntax error near unexpected token `0,' # echo $? 2 # If we instead avoid the echo and use 'python -c' to pass that simple python script just trying to load the non-existent perf binding we get less processes and a more consistent result even in this pathological case where PYTHON=3D"": $ perf test 17 17: 'import perf' in python : FA= ILED! $ perf test -F 17 17: 'import perf' in python : FA= ILED! $ $ perf test -vv 17 Couldn't bump rlimit(MEMLOCK), failures may take place when creating BPF = maps, etc 17: 'import perf' in python: --- start --- test child forked, pid 522859 python usage test: " -c "import sys ; sys.path.insert(0, '/tmp/build/perf= -tools-next/python'); import perf" " sh: line 1: -c: command not found ---- end(-1) ---- 17: 'import perf' in python : FA= ILED! $ The next patch will sidestep all this by plain not building the python binding test when the binding isn't built, i.e. with NO_LIBPYTHON=3D1. Cc: Adrian Hunter Cc: Athira Rajeev Cc: Howard Chu Cc: Ian Rogers Cc: James Clark Cc: Jiri Olsa Cc: Kan Liang Cc: Leo Yan Cc: Namhyung Kim Cc: Thomas Richter Cc: Veronika Molnarova Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/tests/python-use.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/perf/tests/python-use.c b/tools/perf/tests/python-use.c index 0ebc22ac8d5b47ed..b7325caad22bab10 100644 --- a/tools/perf/tests/python-use.c +++ b/tools/perf/tests/python-use.c @@ -14,8 +14,8 @@ static int test__python_use(struct test_suite *test __may= be_unused, int subtest char *cmd; int ret; =20 - if (asprintf(&cmd, "echo \"import sys ; sys.path.insert(0, '%s'); import = perf\" | %s %s", - PYTHONPATH, PYTHON, verbose > 0 ? "" : "2> /dev/null") < 0) + if (asprintf(&cmd, "%s -c \"import sys ; sys.path.insert(0, '%s'); import= perf\" %s", + PYTHON, PYTHONPATH, verbose > 0 ? "" : "2> /dev/null") < 0) return -1; =20 pr_debug("python usage test: \"%s\"\n", cmd); --=20 2.47.0 From nobody Sun Nov 24 11:46:21 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9659E1D88D5; Tue, 5 Nov 2024 14:26:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730816804; cv=none; b=EMOWtdHcg9Ks+6kjg29dHnZ+Q5JBkumyi1MNnn3pHHQCa79jv2ZElgMxLkkr78aY7mW08zws24DbOaYzD2HycYgXiEFxNXKfhc+cUBO9Kodd0ZM84EB3WLh5klrpT4STMnrvPLe0dMMwrqpbPaAf8/J4HVbpBc0XIrUYbF/FzRE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730816804; c=relaxed/simple; bh=R62QBY8iaqvnHYn++qgnd8iZQwcx8VBpLT5T01W6EKc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=f3xY1hP/uk2GayFj4zrsO8QYcNaJibiFvVY3U7CSk8aiiBS3AxEIR2msR/tw9kOQaY8u3V3S7fhbzTzQBAizB7Y7h70hC6RKu3dvtxfhcjWMSouoTjRhbBkMJfHIIky7tby8HfoclJ/0yGkU57eB0m6L0YebLJzfJ/nllBRIn3w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=I7DUYGym; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="I7DUYGym" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DC7B3C4CECF; Tue, 5 Nov 2024 14:26:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730816804; bh=R62QBY8iaqvnHYn++qgnd8iZQwcx8VBpLT5T01W6EKc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I7DUYGymNMFL0v8uK0qpAg7iqoAnBvS8C211WO/PSYi4WmhOS17VQsrT/+Ntgj2v9 f5pqQm3j72j4wbvM9V/Z2glYsXScu5dBOaYYGQcFVjS+QIXzEi4AO/iHnVwIfpN7oU ZIOHbJP4TxCBYTYSbmIxyw8o6qLYIi4lzk4/agku58FpHeGsJOpQzwBE+7g2/YGGSd 6nA8nXgdAh+FPBN4WZz2pr6mKehVcfV4uLUUpepkZ9hzZ8U3lg/S5lw4xRi3D6Kkjn GAUZVWoV8vMFAb31zuGuf/bXF2fMrBnNE4BxXF0OyX09legCxKugh5EfB5LpoSwrEd CT0AgRHsBYgKg== From: Arnaldo Carvalho de Melo To: Namhyung Kim Cc: Ingo Molnar , Thomas Gleixner , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Arnaldo Carvalho de Melo , Athira Rajeev , Howard Chu , James Clark , Leo Yan , Thomas Richter , Veronika Molnarova Subject: [PATCH v2 2/4] perf test: Skip the python binding builtin test case with NO_LIBPYTHON=1 Date: Tue, 5 Nov 2024 11:26:14 -0300 Message-ID: <20241105142616.761042-3-acme@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241105142616.761042-1-acme@kernel.org> References: <20241105142616.761042-1-acme@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Arnaldo Carvalho de Melo The python_use test suite was being built and tested even when the python binding that it is designed to test is not being built, fix it by making it skip the test with an informative message. Testing this patch: When building with NO_LIBPYTHON=3D1, i.e. explicitely disabling linking against libpython and thus not building the python binding: $ perf test 17 17: 'import perf' in python : Skip (No python binding, enable by not = using NO_LIBPYTHON=3D1.) $ Not disabling linking with libpython, the default, that results in the python binding being built: $ perf test 17 17: 'import perf' in python : Ok $ Cc: Adrian Hunter Cc: Athira Rajeev Cc: Howard Chu Cc: Ian Rogers Cc: James Clark Cc: Jiri Olsa Cc: Kan Liang Cc: Leo Yan Cc: Namhyung Kim Cc: Thomas Richter Cc: Veronika Molnarova Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/tests/python-use.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/tools/perf/tests/python-use.c b/tools/perf/tests/python-use.c index b7325caad22bab10..7a86e59ebb27fa75 100644 --- a/tools/perf/tests/python-use.c +++ b/tools/perf/tests/python-use.c @@ -11,6 +11,7 @@ =20 static int test__python_use(struct test_suite *test __maybe_unused, int su= btest __maybe_unused) { +#ifdef HAVE_LIBPYTHON_SUPPORT char *cmd; int ret; =20 @@ -22,6 +23,23 @@ static int test__python_use(struct test_suite *test __ma= ybe_unused, int subtest ret =3D system(cmd) ? -1 : 0; free(cmd); return ret; +#else + return TEST_SKIP; +#endif // HAVE_LIBPYTHON_SUPPORT } =20 -DEFINE_SUITE("'import perf' in python", python_use); +static struct test_case tests__python_use[] =3D { + { + .name =3D "python_use", + .desc =3D "'import perf' in python", + .run_case =3D test__python_use, +#ifndef HAVE_LIBPYTHON_SUPPORT + .skip_reason =3D "No python binding, enable by not using NO_LIBPYTHON=3D= 1", +#endif + }, +}; + +struct test_suite suite__python_use =3D { + .desc =3D "'import perf' in python", + .test_cases =3D tests__python_use, +}; --=20 2.47.0 From nobody Sun Nov 24 11:46:21 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C86391D90B4; Tue, 5 Nov 2024 14:26:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730816811; cv=none; b=XOs5yYJ5XrDTHB6en46L3WzWehQPIhaV9Us9qBx9F6YIj5u0JzthTV35bHQwuEFYXo8Aib9i4MaSfVur8F4A5c2qDjsg5YmtzapZp1YLo7GQ9KdExDK5yfrJ6n0V4hpgUajOiM4mSoNDj7t1F9ac8DDdNP31cA2TwwuxhA2nyCc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730816811; c=relaxed/simple; bh=t7tZ5xBlWu62Qz3UH4jn6kCrdLSxP4bR6+eXyr6u5uQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Evtu53D7BENc8NLBV3k0XBSbuPG61JD9dhL1miJivN5WIHEehGP0GfG1AqyFXGSyqsCAroUTVpeYA2ii9mXSLkqCgpAKI3Mb14Mhtfq2VaV6ekARAm1IqUASh96iBWLLkcEYSE9ZwRQjwD9GmILp12OQLYRk85locWRGo6i97BU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=t4vKGFU2; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="t4vKGFU2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B5969C4CED0; Tue, 5 Nov 2024 14:26:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730816811; bh=t7tZ5xBlWu62Qz3UH4jn6kCrdLSxP4bR6+eXyr6u5uQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t4vKGFU2M9ft9aeSsaZyjR25YKE65QgFMHL75J3Tta0gq2TwR4rIo9gSrEfJZ37Jl 5/cc1oXR7Cdlta4xDDXKPCXmJwPyEPXxifZczq56Wp9Z2ficxUDljeX8a05EzIGHJT Jy27hVkyAWyxAdLWeMXmMljzmcdQ0ePR+WyhidKluTwmEXPP+Knz7+HUBTWu0uCIdE n+imNWTqGFPTRKvOItfK+6xb/NbbenF2RV9NuBNqKpdj1VMPxry0r8R9essID8hIOz AQC0Lh9QduaWPnk/3Anx5Vd/Fy0jVVeqrrUbtfvVgVfskYGWhFJyojbfcAbjqIEIrg xaN/6rseM3gsw== From: Arnaldo Carvalho de Melo To: Namhyung Kim Cc: Ingo Molnar , Thomas Gleixner , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Arnaldo Carvalho de Melo , Athira Rajeev , Howard Chu , James Clark , Leo Yan , Thomas Richter , Veronika Molnarova Subject: [PATCH v2 3/4] perf test: Don't suppress the libtraceevent tests, skip them Date: Tue, 5 Nov 2024 11:26:15 -0300 Message-ID: <20241105142616.761042-4-acme@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241105142616.761042-1-acme@kernel.org> References: <20241105142616.761042-1-acme@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Arnaldo Carvalho de Melo As suggested by Namhyung for the "import perf" python binding test, skip the tests that require perf being linked with libtraceevent, telling the reason: $ make -C tools/perf NO_LIBTRACEEVENT=3D1 # perf check feature libtraceevent libtraceevent: [ OFF ] # HAVE_LIBTRACEEVENT # ldd ~/bin/perf | grep traceevent # # perf test 1: vmlinux symtab matches kallsyms : Ok 2: Detect openat syscall event : Skip (not linked w= ith libtraceevent) 3: Detect openat syscall event on all cpus : Skip (not linked w= ith libtraceevent) 4: mmap interface tests : 4.1: Read samples using the mmap interface : Skip (not linked w= ith libtraceevent) 4.2: User space counter reading of instructions : Skip (not linked w= ith libtraceevent) 4.3: User space counter reading of cycles : Skip (not linked w= ith libtraceevent) 14: Parse sched tracepoints fields : Skip (not linked w= ith libtraceevent) 15: syscalls:sys_enter_openat event fields : Skip (not linked w= ith libtraceevent) 32: Track with sched_switch : Skip (not linked w= ith libtraceevent) Cc: Adrian Hunter Cc: Athira Rajeev Cc: Howard Chu Cc: Ian Rogers Cc: James Clark Cc: Jiri Olsa Cc: Kan Liang Cc: Leo Yan Cc: Namhyung Kim Cc: Thomas Richter Cc: Veronika Molnarova Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/tests/Build | 12 +++++----- tools/perf/tests/builtin-test.c | 6 ----- tools/perf/tests/evsel-tp-sched.c | 16 +++++++++++-- tools/perf/tests/mmap-basic.c | 26 +++++++++++++++++++-- tools/perf/tests/openat-syscall-all-cpus.c | 11 ++++++++- tools/perf/tests/openat-syscall-tp-fields.c | 11 ++++++++- tools/perf/tests/openat-syscall.c | 11 ++++++++- tools/perf/tests/switch-tracking.c | 23 +++++++++++++++++- 8 files changed, 96 insertions(+), 20 deletions(-) diff --git a/tools/perf/tests/Build b/tools/perf/tests/Build index 01ed9335db4dba4e..c57ac14e7114e291 100644 --- a/tools/perf/tests/Build +++ b/tools/perf/tests/Build @@ -5,13 +5,13 @@ perf-test-y +=3D tests-scripts.o perf-test-y +=3D parse-events.o perf-test-y +=3D dso-data.o perf-test-y +=3D vmlinux-kallsyms.o -perf-test-$(CONFIG_LIBTRACEEVENT) +=3D openat-syscall.o -perf-test-$(CONFIG_LIBTRACEEVENT) +=3D openat-syscall-all-cpus.o -perf-test-$(CONFIG_LIBTRACEEVENT) +=3D openat-syscall-tp-fields.o -perf-test-$(CONFIG_LIBTRACEEVENT) +=3D mmap-basic.o +perf-test-y +=3D openat-syscall.o +perf-test-y +=3D openat-syscall-all-cpus.o +perf-test-y +=3D openat-syscall-tp-fields.o +perf-test-y +=3D mmap-basic.o perf-test-y +=3D perf-record.o perf-test-y +=3D evsel-roundtrip-name.o -perf-test-$(CONFIG_LIBTRACEEVENT) +=3D evsel-tp-sched.o +perf-test-y +=3D evsel-tp-sched.o perf-test-y +=3D fdarray.o perf-test-y +=3D pmu.o perf-test-y +=3D pmu-events.o @@ -29,7 +29,7 @@ perf-test-y +=3D task-exit.o perf-test-y +=3D sw-clock.o perf-test-y +=3D mmap-thread-lookup.o perf-test-y +=3D thread-maps-share.o -perf-test-$(CONFIG_LIBTRACEEVENT) +=3D switch-tracking.o +perf-test-y +=3D switch-tracking.o perf-test-y +=3D keep-tracking.o perf-test-y +=3D code-reading.o perf-test-y +=3D sample-parsing.o diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-tes= t.c index d2cabaa8ad922d68..5ebeaf3d7b69a8d0 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -60,11 +60,9 @@ static struct test_suite *arch_tests[] =3D { =20 static struct test_suite *generic_tests[] =3D { &suite__vmlinux_matches_kallsyms, -#ifdef HAVE_LIBTRACEEVENT &suite__openat_syscall_event, &suite__openat_syscall_event_on_all_cpus, &suite__basic_mmap, -#endif &suite__mem, &suite__parse_events, &suite__expr, @@ -74,10 +72,8 @@ static struct test_suite *generic_tests[] =3D { &suite__tool_pmu, &suite__dso_data, &suite__perf_evsel__roundtrip_name_test, -#ifdef HAVE_LIBTRACEEVENT &suite__perf_evsel__tp_sched_test, &suite__syscall_openat_tp_fields, -#endif &suite__hists_link, &suite__python_use, &suite__bp_signal, @@ -95,9 +91,7 @@ static struct test_suite *generic_tests[] =3D { &suite__thread_maps_share, &suite__hists_output, &suite__hists_cumulate, -#ifdef HAVE_LIBTRACEEVENT &suite__switch_tracking, -#endif &suite__fdarray__filter, &suite__fdarray__add, &suite__kmod_path__parse, diff --git a/tools/perf/tests/evsel-tp-sched.c b/tools/perf/tests/evsel-tp-= sched.c index 3da6a76eac3856d1..a7d3a59f01217280 100644 --- a/tools/perf/tests/evsel-tp-sched.c +++ b/tools/perf/tests/evsel-tp-sched.c @@ -1,10 +1,12 @@ // SPDX-License-Identifier: GPL-2.0 #include -#include #include "evsel.h" #include "tests.h" #include "debug.h" =20 +#ifdef HAVE_LIBTRACEEVENT +#include + static int evsel__test_field(struct evsel *evsel, const char *name, int si= ze, bool should_be_signed) { struct tep_format_field *field =3D evsel__field(evsel, name); @@ -31,10 +33,12 @@ static int evsel__test_field(struct evsel *evsel, const= char *name, int size, bo =20 return ret; } +#endif // HAVE_LIBTRACEEVENT =20 static int test__perf_evsel__tp_sched_test(struct test_suite *test __maybe= _unused, int subtest __maybe_unused) { +#ifdef HAVE_LIBTRACEEVENT struct evsel *evsel =3D evsel__newtp("sched", "sched_switch"); int ret =3D TEST_OK; =20 @@ -87,12 +91,20 @@ static int test__perf_evsel__tp_sched_test(struct test_= suite *test __maybe_unuse =20 evsel__delete(evsel); return ret; +#else + return TEST_SKIP; +#endif // HAVE_LIBTRACEEVENT } =20 static struct test_case tests__perf_evsel__tp_sched_test[] =3D { TEST_CASE_REASON("Parse sched tracepoints fields", perf_evsel__tp_sched_test, - "permissions"), +#ifdef HAVE_LIBTRACEEVENT + "permissions" +#else + "not linked with libtraceevent" +#endif + ), { .name =3D NULL, } }; =20 diff --git a/tools/perf/tests/mmap-basic.c b/tools/perf/tests/mmap-basic.c index 012c8ae439fdcf56..f87ec3c40e091d5d 100644 --- a/tools/perf/tests/mmap-basic.c +++ b/tools/perf/tests/mmap-basic.c @@ -10,6 +10,7 @@ #include "evsel.h" #include "thread_map.h" #include "tests.h" +#include "tests/tests.h" #include "util/mmap.h" #include "util/sample.h" #include @@ -31,6 +32,7 @@ */ static int test__basic_mmap(struct test_suite *test __maybe_unused, int su= btest __maybe_unused) { +#ifdef HAVE_LIBTRACEEVENT int err =3D TEST_FAIL; union perf_event *event; struct perf_thread_map *threads; @@ -167,10 +169,14 @@ static int test__basic_mmap(struct test_suite *test _= _maybe_unused, int subtest out_free_threads: perf_thread_map__put(threads); return err; +#else + return TEST_SKIP; +#endif // HAVE_LIBTRACEEVENT } =20 -static int test_stat_user_read(int event) +static int test_stat_user_read(int event __maybe_unused) { +#ifdef HAVE_LIBTRACEEVENT struct perf_counts_values counts =3D { .val =3D 0 }; struct perf_thread_map *threads; struct perf_evsel *evsel; @@ -264,6 +270,9 @@ static int test_stat_user_read(int event) =20 perf_thread_map__put(threads); return ret; +#else + return TEST_SKIP; +#endif // HAVE_LIBTRACEEVENT } =20 static int test__mmap_user_read_instr(struct test_suite *test __maybe_unus= ed, @@ -281,23 +290,36 @@ static int test__mmap_user_read_cycles(struct test_su= ite *test __maybe_unused, static struct test_case tests__basic_mmap[] =3D { TEST_CASE_REASON("Read samples using the mmap interface", basic_mmap, - "permissions"), +#ifdef HAVE_LIBTRACEEVENT + "permissions" +#else + "not linked with libtraceevent" +#endif + ), TEST_CASE_REASON("User space counter reading of instructions", mmap_user_read_instr, +#ifdef HAVE_LIBTRACEEVENT #if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__) || \ (defined(__riscv) && __riscv_xlen =3D=3D 64) "permissions" #else "unsupported" +#endif +#else + "not linked with libtraceevent" #endif ), TEST_CASE_REASON("User space counter reading of cycles", mmap_user_read_cycles, +#ifdef HAVE_LIBTRACEEVENT #if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__) || \ (defined(__riscv) && __riscv_xlen =3D=3D 64) "permissions" #else "unsupported" +#endif +#else + "not linked with libtraceevent" #endif ), { .name =3D NULL, } diff --git a/tools/perf/tests/openat-syscall-all-cpus.c b/tools/perf/tests/= openat-syscall-all-cpus.c index fb114118c87640b8..72dc22bef917f17d 100644 --- a/tools/perf/tests/openat-syscall-all-cpus.c +++ b/tools/perf/tests/openat-syscall-all-cpus.c @@ -22,6 +22,7 @@ static int test__openat_syscall_event_on_all_cpus(struct test_suite *test = __maybe_unused, int subtest __maybe_unused) { +#ifdef HAVE_LIBTRACEEVENT int err =3D TEST_FAIL, fd, idx; struct perf_cpu cpu; struct perf_cpu_map *cpus; @@ -122,13 +123,21 @@ static int test__openat_syscall_event_on_all_cpus(str= uct test_suite *test __mayb out_thread_map_delete: perf_thread_map__put(threads); return err; +#else + return TEST_SKIP; +#endif // HAVE_LIBTRACEEVENT } =20 =20 static struct test_case tests__openat_syscall_event_on_all_cpus[] =3D { TEST_CASE_REASON("Detect openat syscall event on all cpus", openat_syscall_event_on_all_cpus, - "permissions"), +#ifdef HAVE_LIBTRACEEVENT + "permissions" +#else + "not linked with libtraceevent" +#endif + ), { .name =3D NULL, } }; =20 diff --git a/tools/perf/tests/openat-syscall-tp-fields.c b/tools/perf/tests= /openat-syscall-tp-fields.c index 3943da441979c0fc..cc0e31958646e88c 100644 --- a/tools/perf/tests/openat-syscall-tp-fields.c +++ b/tools/perf/tests/openat-syscall-tp-fields.c @@ -26,6 +26,7 @@ static int test__syscall_openat_tp_fields(struct test_suite *test __maybe_= unused, int subtest __maybe_unused) { +#ifdef HAVE_LIBTRACEEVENT struct record_opts opts =3D { .target =3D { .uid =3D UINT_MAX, @@ -144,12 +145,20 @@ static int test__syscall_openat_tp_fields(struct test= _suite *test __maybe_unused evlist__delete(evlist); out: return ret; +#else + return TEST_SKIP; +#endif // HAVE_LIBTRACEEVENT } =20 static struct test_case tests__syscall_openat_tp_fields[] =3D { TEST_CASE_REASON("syscalls:sys_enter_openat event fields", syscall_openat_tp_fields, - "permissions"), +#ifdef HAVE_LIBTRACEEVENT + "permissions" +#else + "not linked with libtraceevent" +#endif + ), { .name =3D NULL, } }; =20 diff --git a/tools/perf/tests/openat-syscall.c b/tools/perf/tests/openat-sy= scall.c index 131b62271bfa270b..2ca0b7d2cca7672e 100644 --- a/tools/perf/tests/openat-syscall.c +++ b/tools/perf/tests/openat-syscall.c @@ -17,6 +17,7 @@ static int test__openat_syscall_event(struct test_suite *test __maybe_unus= ed, int subtest __maybe_unused) { +#ifdef HAVE_LIBTRACEEVENT int err =3D TEST_FAIL, fd; struct evsel *evsel; unsigned int nr_openat_calls =3D 111, i; @@ -69,12 +70,20 @@ static int test__openat_syscall_event(struct test_suite= *test __maybe_unused, out_thread_map_delete: perf_thread_map__put(threads); return err; +#else + return TEST_SKIP; +#endif // HAVE_LIBTRACEEVENT } =20 static struct test_case tests__openat_syscall_event[] =3D { TEST_CASE_REASON("Detect openat syscall event", openat_syscall_event, - "permissions"), +#ifdef HAVE_LIBTRACEEVENT + "permissions" +#else + "not linked with libtraceevent" +#endif + ), { .name =3D NULL, } }; =20 diff --git a/tools/perf/tests/switch-tracking.c b/tools/perf/tests/switch-t= racking.c index 5cab17a1942e67d7..591ae74b663af3c1 100644 --- a/tools/perf/tests/switch-tracking.c +++ b/tools/perf/tests/switch-tracking.c @@ -22,6 +22,7 @@ #include "util/sample.h" #include "pmus.h" =20 +#ifdef HAVE_LIBTRACEEVENT static int spin_sleep(void) { struct timeval start, now, diff, maxtime; @@ -314,6 +315,7 @@ static int process_events(struct evlist *evlist, free_event_nodes(&events); return ret; } +#endif // HAVE_LIBTRACEEVENT =20 /** * test__switch_tracking - test using sched_switch and tracking events. @@ -325,6 +327,7 @@ static int process_events(struct evlist *evlist, */ static int test__switch_tracking(struct test_suite *test __maybe_unused, i= nt subtest __maybe_unused) { +#ifdef HAVE_LIBTRACEEVENT const char *sched_switch =3D "sched:sched_switch"; const char *cycles =3D "cycles:u"; struct switch_tracking switch_tracking =3D { .tids =3D NULL, }; @@ -581,6 +584,24 @@ static int test__switch_tracking(struct test_suite *te= st __maybe_unused, int sub out_err: err =3D -1; goto out; +#else + return TEST_SKIP; +#endif // HAVE_LIBTRACEEVENT } =20 -DEFINE_SUITE("Track with sched_switch", switch_tracking); +static struct test_case tests__switch_tracking[] =3D { + { + .name =3D "switch_tracking", + .desc =3D "Track with sched_switch", + .run_case =3D test__switch_tracking, +#ifndef HAVE_LIBTRACEEVENT + .skip_reason =3D "not linked with libtraceevent", +#endif + }, + { .name =3D NULL, } +}; + +struct test_suite suite__switch_tracking =3D { + .desc =3D "Track with sched_switch", + .test_cases =3D tests__switch_tracking, +}; --=20 2.47.0 From nobody Sun Nov 24 11:46:21 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D0BD41D2716; Tue, 5 Nov 2024 14:26:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730816818; cv=none; b=rYI5Lhx4o7fjn07d5e9TY+YzzutARW8aC/dk5IyzSQ9z5uEyg0IbQ82wy7kHvnG/ve6RBH937zKkD2RKbKgEuG/DSuCSOGXV0pKPHc/4jnVHRX0tjo2psXIl76IszjuF750iCZYRg8cUsiGwhXnEuqcCPflfkBdPFJb1tVHNEug= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730816818; c=relaxed/simple; bh=yHQaz97JADPxJTedTrQRaGlex8yfX/PiBJY+uGEeX6s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=roGpSIzN/QUMOeoDAALW5WHHl18YvgMbs/fseetpv7J0jF9ULeowKjyDbs70YPj3c8orO++N20nSJEMwz6qFi8uSRmS3vqVOVhiebzc0bzK6tcG2putNkttzBQg0vtftSgtcmiNFJaI7mSdnxT51ShzWNQsG2TAO4EXrR2c/u+E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=P5Bfbdzm; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="P5Bfbdzm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DC572C4CED3; Tue, 5 Nov 2024 14:26:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730816818; bh=yHQaz97JADPxJTedTrQRaGlex8yfX/PiBJY+uGEeX6s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P5BfbdzmvwYmwRtSR2ZASX5lLt+yQXWta33tCNL22UCiWKxP1DKJoxUy8GiqHcHbI R4/jHNO6MQiACaKXTiax19b7QYDfbcmYi4GsVfLYxtay1x/1ArYcqAOPXnfsaCLSQi Xq5RSjdPdA2xFHu925ShsCNEsxvL/TUCkPvHVhQ2LRcA8LA692pQVm0Kojsx/uXjma pSQWIj/d9qC/0FKb7mMqKHjFuO+H6xY59f9U65aDUGZjSxLlS7HIReU85s1I9BcNSO gPwD/D4IgTV44n+oAeC4pxDnh3wO9pNoThkbS/KSEhVntIRDLQTS6noNdODMfHgJVg 18RliGXHa+PBQ== From: Arnaldo Carvalho de Melo To: Namhyung Kim Cc: Ingo Molnar , Thomas Gleixner , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Arnaldo Carvalho de Melo , Athira Rajeev , Howard Chu , James Clark , Leo Yan , Thomas Richter , Veronika Molnarova Subject: [PATCH v2 4/4] perf build: Emit a warning when libtraceevent is explicitely disabled Date: Tue, 5 Nov 2024 11:26:16 -0300 Message-ID: <20241105142616.761042-5-acme@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241105142616.761042-1-acme@kernel.org> References: <20241105142616.761042-1-acme@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Arnaldo Carvalho de Melo Since not having the libtraceevent devel package installed prevents the build from proceeding unless NO_LIBTRACEEVENT=3D1 is passed: $ make O=3D/tmp/build/perf-tools-next/ -C tools/perf install-bin Makefile.config:1195: *** ERROR: libtraceevent is missing. Please install= libtraceevent-dev/libtraceevent-devel and/or set LIBTRACEEVENT_DIR or buil= d with NO_LIBTRACEEVENT=3D1. Stop. make[1]: *** [Makefile.perf:292: sub-make] Error 2 make: *** [Makefile:119: install-bin] Error 2 make: Leaving directory '/home/acme/git/perf-tools-next/tools/perf' $ Behave just like with the NO_LIBPYTHON case: $ make NO_LIBPYTHON=3D1 NO_LIBTRACEEVENT=3D1 O=3D/tmp/build/perf-tools-ne= xt/ -C tools/perf install-bin Makefile.config:874: Python support disabled by user Makefile.config:1180: libtraceevent support disabled by user Auto-detecting system features: Cc: Adrian Hunter Cc: Athira Rajeev Cc: Howard Chu Cc: Ian Rogers Cc: James Clark Cc: Jiri Olsa Cc: Kan Liang Cc: Leo Yan Cc: Namhyung Kim Cc: Thomas Richter Cc: Veronika Molnarova Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/Makefile.config | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config index 80bf06e828f0ebc8..3ae3449ccf684b42 100644 --- a/tools/perf/Makefile.config +++ b/tools/perf/Makefile.config @@ -1180,7 +1180,9 @@ ifndef NO_LIBPFM4 endif =20 # libtraceevent is a recommended dependency picked up from the system. -ifneq ($(NO_LIBTRACEEVENT),1) +ifeq ($(NO_LIBTRACEEVENT),1) + msg :=3D $(warning libtraceevent support disabled by user); +else $(call feature_check,libtraceevent) ifeq ($(feature-libtraceevent), 1) CFLAGS +=3D -DHAVE_LIBTRACEEVENT $(shell $(PKG_CONFIG) --cflags libtra= ceevent) --=20 2.47.0