linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/2] perf machine: Factor creating a "live" machine out of dwarf-unwind
@ 2025-03-13  5:29 Ian Rogers
  2025-03-13  5:29 ` [PATCH v1 2/2] perf debug: Add function symbols to dump_stack Ian Rogers
  2025-03-14 17:18 ` [PATCH v1 1/2] perf machine: Factor creating a "live" machine out of dwarf-unwind Arnaldo Carvalho de Melo
  0 siblings, 2 replies; 8+ messages in thread
From: Ian Rogers @ 2025-03-13  5:29 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Ian Rogers, Adrian Hunter, Kan Liang, James Clark, Yicong Yang,
	Howard Chu, Andi Kleen, Michael Petlan, Anne Macedo,
	Dr. David Alan Gilbert, Dmitry Vyukov, linux-perf-users,
	linux-kernel

Factor out for use in places other than the dwarf unwinding tests for
libunwind.

Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/tests/dwarf-unwind.c | 35 ++++------------------
 tools/perf/util/machine.c       | 53 +++++++++++++++++++++++++++------
 tools/perf/util/machine.h       |  1 +
 3 files changed, 51 insertions(+), 38 deletions(-)

diff --git a/tools/perf/tests/dwarf-unwind.c b/tools/perf/tests/dwarf-unwind.c
index 4803ab2d97ba..525c46b7971a 100644
--- a/tools/perf/tests/dwarf-unwind.c
+++ b/tools/perf/tests/dwarf-unwind.c
@@ -15,7 +15,6 @@
 #include "symbol.h"
 #include "thread.h"
 #include "callchain.h"
-#include "util/synthetic-events.h"
 
 /* For bsearch. We try to unwind functions in shared object. */
 #include <stdlib.h>
@@ -37,24 +36,6 @@
 #define NO_TAIL_CALL_BARRIER __asm__ __volatile__("" : : : "memory");
 #endif
 
-static int mmap_handler(const struct perf_tool *tool __maybe_unused,
-			union perf_event *event,
-			struct perf_sample *sample,
-			struct machine *machine)
-{
-	return machine__process_mmap2_event(machine, event, sample);
-}
-
-static int init_live_machine(struct machine *machine)
-{
-	union perf_event event;
-	pid_t pid = getpid();
-
-	memset(&event, 0, sizeof(event));
-	return perf_event__synthesize_mmap_events(NULL, &event, pid, pid,
-						  mmap_handler, machine, true);
-}
-
 /*
  * We need to keep these functions global, despite the
  * fact that they are used only locally in this object,
@@ -202,8 +183,12 @@ noinline int test__dwarf_unwind(struct test_suite *test __maybe_unused,
 	struct machine *machine;
 	struct thread *thread;
 	int err = -1;
+	pid_t pid = getpid();
 
-	machine = machine__new_host();
+	callchain_param.record_mode = CALLCHAIN_DWARF;
+	dwarf_callchain_users = true;
+
+	machine = machine__new_live(/*kernel_maps=*/true, pid);
 	if (!machine) {
 		pr_err("Could not get machine\n");
 		return -1;
@@ -214,18 +199,10 @@ noinline int test__dwarf_unwind(struct test_suite *test __maybe_unused,
 		return -1;
 	}
 
-	callchain_param.record_mode = CALLCHAIN_DWARF;
-	dwarf_callchain_users = true;
-
-	if (init_live_machine(machine)) {
-		pr_err("Could not init machine\n");
-		goto out;
-	}
-
 	if (verbose > 1)
 		machine__fprintf(machine, stderr);
 
-	thread = machine__find_thread(machine, getpid(), getpid());
+	thread = machine__find_thread(machine, pid, pid);
 	if (!thread) {
 		pr_err("Could not get thread\n");
 		goto out;
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 2531b373f2cf..c5e28d15323f 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -20,6 +20,7 @@
 #include "path.h"
 #include "srcline.h"
 #include "symbol.h"
+#include "synthetic-events.h"
 #include "sort.h"
 #include "strlist.h"
 #include "target.h"
@@ -128,23 +129,57 @@ int machine__init(struct machine *machine, const char *root_dir, pid_t pid)
 	return 0;
 }
 
-struct machine *machine__new_host(void)
+static struct machine *__machine__new_host(bool kernel_maps)
 {
 	struct machine *machine = malloc(sizeof(*machine));
 
-	if (machine != NULL) {
-		machine__init(machine, "", HOST_KERNEL_ID);
+	if (!machine)
+		return NULL;
 
-		if (machine__create_kernel_maps(machine) < 0)
-			goto out_delete;
+	machine__init(machine, "", HOST_KERNEL_ID);
 
-		machine->env = &perf_env;
+	if (kernel_maps && machine__create_kernel_maps(machine) < 0) {
+		free(machine);
+		return NULL;
 	}
+	machine->env = &perf_env;
+	return machine;
+}
+
+struct machine *machine__new_host(void)
+{
+	return __machine__new_host(/*kernel_maps=*/true);
+}
+
+static int mmap_handler(const struct perf_tool *tool __maybe_unused,
+			union perf_event *event,
+			struct perf_sample *sample,
+			struct machine *machine)
+{
+	return machine__process_mmap2_event(machine, event, sample);
+}
 
+static int machine__init_live(struct machine *machine, pid_t pid)
+{
+	union perf_event event;
+
+	memset(&event, 0, sizeof(event));
+	return perf_event__synthesize_mmap_events(NULL, &event, pid, pid,
+						  mmap_handler, machine, true);
+}
+
+struct machine *machine__new_live(bool kernel_maps, pid_t pid)
+{
+	struct machine *machine = __machine__new_host(kernel_maps);
+
+	if (!machine)
+		return NULL;
+
+	if (machine__init_live(machine, pid)) {
+		machine__delete(machine);
+		return NULL;
+	}
 	return machine;
-out_delete:
-	free(machine);
-	return NULL;
 }
 
 struct machine *machine__new_kallsyms(void)
diff --git a/tools/perf/util/machine.h b/tools/perf/util/machine.h
index b56abec84fed..180b369c366c 100644
--- a/tools/perf/util/machine.h
+++ b/tools/perf/util/machine.h
@@ -171,6 +171,7 @@ void machines__set_comm_exec(struct machines *machines, bool comm_exec);
 
 struct machine *machine__new_host(void);
 struct machine *machine__new_kallsyms(void);
+struct machine *machine__new_live(bool kernel_maps, pid_t pid);
 int machine__init(struct machine *machine, const char *root_dir, pid_t pid);
 void machine__exit(struct machine *machine);
 void machine__delete_threads(struct machine *machine);
-- 
2.49.0.rc0.332.g42c0ae87b1-goog


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v1 2/2] perf debug: Add function symbols to dump_stack
  2025-03-13  5:29 [PATCH v1 1/2] perf machine: Factor creating a "live" machine out of dwarf-unwind Ian Rogers
@ 2025-03-13  5:29 ` Ian Rogers
  2025-03-14 17:18 ` [PATCH v1 1/2] perf machine: Factor creating a "live" machine out of dwarf-unwind Arnaldo Carvalho de Melo
  1 sibling, 0 replies; 8+ messages in thread
From: Ian Rogers @ 2025-03-13  5:29 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Ian Rogers, Adrian Hunter, Kan Liang, James Clark, Yicong Yang,
	Howard Chu, Andi Kleen, Michael Petlan, Anne Macedo,
	Dr. David Alan Gilbert, Dmitry Vyukov, linux-perf-users,
	linux-kernel

Symbolize stack traces by creating a live machine. Add this
functionality to dump_stack and switch dump_stack users to use
it. Switch TUI to use it. Add stack traces to the child test function
which can be useful to diagnose blocked code.

Example output:
```
  8: PERF_RECORD_* events & perf_sample fields                       : Running (1 active)
^C
Signal (2) while running tests.
Terminating tests with the same signal
Internal test harness failure. Completing any started tests:
:  8: PERF_RECORD_* events & perf_sample fields:

---- unexpected signal (2) ----
    #0 0x5590fb6209b6 in child_test_sig_handler builtin-test.c:243
    #1 0x7f4a91e49e20 in __restore_rt libc_sigaction.c:0
    #2 0x7f4a91ee4f33 in clock_nanosleep@GLIBC_2.2.5 clock_nanosleep.c:71
    #3 0x7f4a91ef0333 in __nanosleep nanosleep.c:26
    #4 0x7f4a91f01f68 in __sleep sleep.c:55
    #5 0x5590fb638c63 in test__PERF_RECORD perf-record.c:295
    #6 0x5590fb620b43 in run_test_child builtin-test.c:269
    #7 0x5590fb5b83ab in start_command run-command.c:127
    #8 0x5590fb621572 in start_test builtin-test.c:467
    #9 0x5590fb621a47 in __cmd_test builtin-test.c:573
    #10 0x5590fb6225ea in cmd_test builtin-test.c:775
    #11 0x5590fb5a9099 in run_builtin perf.c:351
    #12 0x5590fb5a9340 in handle_internal_command perf.c:404
    #13 0x5590fb5a9499 in run_argv perf.c:451
    #14 0x5590fb5a97e2 in main perf.c:558
    #15 0x7f4a91e33d68 in __libc_start_call_main libc_start_call_main.h:74
    #16 0x7f4a91e33e25 in __libc_start_main@@GLIBC_2.34 libc-start.c:128
    #17 0x5590fb4fd6d1 in _start perf[436d1]
```

Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/tests/builtin-test.c | 15 +++++++-
 tools/perf/ui/tui/setup.c       |  2 +-
 tools/perf/util/debug.c         | 64 +++++++++++++++++++++++++++------
 tools/perf/util/debug.h         |  1 +
 4 files changed, 69 insertions(+), 13 deletions(-)

diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 14d30a5053be..358bccc75d40 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -6,6 +6,9 @@
  */
 #include <fcntl.h>
 #include <errno.h>
+#ifdef HAVE_BACKTRACE_SUPPORT
+#include <execinfo.h>
+#endif
 #include <poll.h>
 #include <unistd.h>
 #include <setjmp.h>
@@ -230,6 +233,16 @@ static jmp_buf run_test_jmp_buf;
 
 static void child_test_sig_handler(int sig)
 {
+#ifdef HAVE_BACKTRACE_SUPPORT
+	void *stackdump[32];
+	size_t stackdump_size;
+#endif
+
+	fprintf(stderr, "\n---- unexpected signal (%d) ----\n", sig);
+#ifdef HAVE_BACKTRACE_SUPPORT
+	stackdump_size = backtrace(stackdump, ARRAY_SIZE(stackdump));
+	__dump_stack(stderr, stackdump, stackdump_size);
+#endif
 	siglongjmp(run_test_jmp_buf, sig);
 }
 
@@ -243,7 +256,7 @@ static int run_test_child(struct child_process *process)
 
 	err = sigsetjmp(run_test_jmp_buf, 1);
 	if (err) {
-		fprintf(stderr, "\n---- unexpected signal (%d) ----\n", err);
+		/* Received signal. */
 		err = err > 0 ? -err : -1;
 		goto err_out;
 	}
diff --git a/tools/perf/ui/tui/setup.c b/tools/perf/ui/tui/setup.c
index 16c6eff4d241..022534eed68c 100644
--- a/tools/perf/ui/tui/setup.c
+++ b/tools/perf/ui/tui/setup.c
@@ -108,7 +108,7 @@ static void ui__signal_backtrace(int sig)
 
 	printf("-------- backtrace --------\n");
 	size = backtrace(stackdump, ARRAY_SIZE(stackdump));
-	backtrace_symbols_fd(stackdump, size, STDOUT_FILENO);
+	__dump_stack(stdout, stackdump, size);
 
 	exit(0);
 }
diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c
index f9ef7d045c92..8987ac250079 100644
--- a/tools/perf/util/debug.c
+++ b/tools/perf/util/debug.c
@@ -14,11 +14,18 @@
 #ifdef HAVE_BACKTRACE_SUPPORT
 #include <execinfo.h>
 #endif
+#include "addr_location.h"
 #include "color.h"
-#include "event.h"
 #include "debug.h"
+#include "event.h"
+#include "machine.h"
+#include "map.h"
 #include "print_binary.h"
+#include "srcline.h"
+#include "symbol.h"
+#include "synthetic-events.h"
 #include "target.h"
+#include "thread.h"
 #include "trace-event.h"
 #include "ui/helpline.h"
 #include "ui/ui.h"
@@ -298,21 +305,56 @@ void perf_debug_setup(void)
 	libapi_set_print(pr_warning_wrapper, pr_warning_wrapper, pr_debug_wrapper);
 }
 
+void __dump_stack(FILE *file, void **stackdump, size_t stackdump_size)
+{
+	/* TODO: async safety. printf, malloc, etc. aren't safe inside a signal handler. */
+	pid_t pid = getpid();
+	struct machine *machine = machine__new_live(/*kernel_maps=*/false, pid);
+	struct thread *thread = NULL;
+
+	if (machine)
+		thread = machine__find_thread(machine, pid, pid);
+
+	if (!machine || !thread) {
+		/*
+		 * Backtrace functions are async signal safe. Fall back on them
+		 * if machine/thread creation fails.
+		 */
+		backtrace_symbols_fd(stackdump, stackdump_size, fileno(file));
+		machine__delete(machine);
+		return;
+	}
+
+	for (size_t i = 0; i < stackdump_size; i++) {
+		struct addr_location al;
+		u64 addr = (u64)stackdump[i];
+
+		addr_location__init(&al);
+		if (!thread__find_map(thread, PERF_RECORD_MISC_USER, addr, &al))
+			continue;
+
+		al.sym = map__find_symbol(al.map, al.addr);
+		if (al.sym)
+			fprintf(file, "    #%zd %p in %s ", i, stackdump[i], al.sym->name);
+		else
+			fprintf(file, "    #%zd %p ", i, stackdump[i]);
+
+		map__fprintf_srcline(al.map, al.addr, "", file);
+		fprintf(file, "\n");
+		addr_location__exit(&al);
+	}
+	thread__put(thread);
+	machine__delete(machine);
+}
+
 /* Obtain a backtrace and print it to stdout. */
 #ifdef HAVE_BACKTRACE_SUPPORT
 void dump_stack(void)
 {
-	void *array[16];
-	size_t size = backtrace(array, ARRAY_SIZE(array));
-	char **strings = backtrace_symbols(array, size);
-	size_t i;
-
-	printf("Obtained %zd stack frames.\n", size);
-
-	for (i = 0; i < size; i++)
-		printf("%s\n", strings[i]);
+	void *stackdump[32];
+	size_t size = backtrace(stackdump, ARRAY_SIZE(stackdump));
 
-	free(strings);
+	__dump_stack(stdout, stackdump, size);
 }
 #else
 void dump_stack(void) {}
diff --git a/tools/perf/util/debug.h b/tools/perf/util/debug.h
index a4026d1fd6a3..6b737e195ce1 100644
--- a/tools/perf/util/debug.h
+++ b/tools/perf/util/debug.h
@@ -85,6 +85,7 @@ void debug_set_display_time(bool set);
 void perf_debug_setup(void);
 int perf_quiet_option(void);
 
+void __dump_stack(FILE *file, void **stackdump, size_t stackdump_size);
 void dump_stack(void);
 void sighandler_dump_stack(int sig);
 
-- 
2.49.0.rc0.332.g42c0ae87b1-goog


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v1 1/2] perf machine: Factor creating a "live" machine out of dwarf-unwind
  2025-03-13  5:29 [PATCH v1 1/2] perf machine: Factor creating a "live" machine out of dwarf-unwind Ian Rogers
  2025-03-13  5:29 ` [PATCH v1 2/2] perf debug: Add function symbols to dump_stack Ian Rogers
@ 2025-03-14 17:18 ` Arnaldo Carvalho de Melo
  2025-03-14 20:00   ` Arnaldo Carvalho de Melo
  1 sibling, 1 reply; 8+ messages in thread
From: Arnaldo Carvalho de Melo @ 2025-03-14 17:18 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Peter Zijlstra, Ingo Molnar, Namhyung Kim, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Adrian Hunter, Kan Liang,
	James Clark, Yicong Yang, Howard Chu, Andi Kleen, Michael Petlan,
	Anne Macedo, Dr. David Alan Gilbert, Dmitry Vyukov,
	linux-perf-users, linux-kernel

On Wed, Mar 12, 2025 at 10:29:51PM -0700, Ian Rogers wrote:
> Factor out for use in places other than the dwarf unwinding tests for
> libunwind.

Testing with another patchset being reviewed/tested, seems to work, if
it showed the line number would be even better!

I'll continue working on that other case with this applied just before
that series and finally will give my Tested-by.

- Arnaldo

root@number:~# perf trace -e landlock_add_rule perf test -w landlock
perf: Segmentation fault
    #0 0x5be81d in dump_stack perf[5be81d]
    #1 0x5be879 in sighandler_dump_stack perf[5be879]
    #2 0x7f313d24efd0 in __restore_rt libc.so.6[40fd0]
    #3 0x491bc1 in cmd_trace perf[491bc1]
    #4 0x497090 in run_builtin perf.c:0
    #5 0x4973ab in handle_internal_command perf.c:0
    #6 0x413483 in main perf[413483]
    #7 0x7f313d238088 in __libc_start_call_main libc.so.6[2a088]
    #8 0x7f313d23814b in __libc_start_main@@GLIBC_2.34 libc.so.6[2a14b]
    #9 0x413ad5 in _start perf[413ad5]
Segmentation fault (core dumped)
root@number:~#

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v1 1/2] perf machine: Factor creating a "live" machine out of dwarf-unwind
  2025-03-14 17:18 ` [PATCH v1 1/2] perf machine: Factor creating a "live" machine out of dwarf-unwind Arnaldo Carvalho de Melo
@ 2025-03-14 20:00   ` Arnaldo Carvalho de Melo
  2025-03-14 20:01     ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 8+ messages in thread
From: Arnaldo Carvalho de Melo @ 2025-03-14 20:00 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Peter Zijlstra, Ingo Molnar, Namhyung Kim, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Adrian Hunter, Kan Liang,
	James Clark, Yicong Yang, Howard Chu, Andi Kleen, Michael Petlan,
	Anne Macedo, Dr. David Alan Gilbert, Dmitry Vyukov,
	linux-perf-users, linux-kernel

On Fri, Mar 14, 2025 at 02:18:49PM -0300, Arnaldo Carvalho de Melo wrote:
> On Wed, Mar 12, 2025 at 10:29:51PM -0700, Ian Rogers wrote:
> > Factor out for use in places other than the dwarf unwinding tests for
> > libunwind.
> 
> Testing with another patchset being reviewed/tested, seems to work, if
> it showed the line number would be even better!

But it gets the lines, at least in this secoond attempt, after applying
Namhyungs fix for the previous problem (int16_t):

root@number:~# perf trace -e landlock_add_rule perf test -w landlock
perf: Segmentation fault
    #0 0x6698d0 in dump_stack debug.c:355
    #1 0x66994c in sighandler_dump_stack debug.c:367
    #2 0x7f784be95fd0 in __restore_rt libc.so.6[40fd0]
    #3 0x4d0e56 in trace__find_usable_bpf_prog_entry builtin-trace.c:3882
    #4 0x4cf3de in trace__init_syscalls_bpf_prog_array_maps builtin-trace.c:4040
    #5 0x4bf626 in trace__run builtin-trace.c:4477
    #6 0x4bb7a9 in cmd_trace builtin-trace.c:5741
    #7 0x4d873f in run_builtin perf.c:351
    #8 0x4d7df3 in handle_internal_command perf.c:404
    #9 0x4d860f in run_argv perf.c:451
    #10 0x4d7a4f in main perf.c:558
    #11 0x7f784be7f088 in __libc_start_call_main libc.so.6[2a088]
    #12 0x7f784be7f14b in __libc_start_main@@GLIBC_2.34 libc.so.6[2a14b]
    #13 0x410ff5 in _start perf[410ff5]
Segmentation fault (core dumped)
root@number:~# 
 
> I'll continue working on that other case with this applied just before
> that series and finally will give my Tested-by.
> 
> - Arnaldo
> 
> root@number:~# perf trace -e landlock_add_rule perf test -w landlock
> perf: Segmentation fault
>     #0 0x5be81d in dump_stack perf[5be81d]
>     #1 0x5be879 in sighandler_dump_stack perf[5be879]
>     #2 0x7f313d24efd0 in __restore_rt libc.so.6[40fd0]
>     #3 0x491bc1 in cmd_trace perf[491bc1]
>     #4 0x497090 in run_builtin perf.c:0
>     #5 0x4973ab in handle_internal_command perf.c:0
>     #6 0x413483 in main perf[413483]
>     #7 0x7f313d238088 in __libc_start_call_main libc.so.6[2a088]
>     #8 0x7f313d23814b in __libc_start_main@@GLIBC_2.34 libc.so.6[2a14b]
>     #9 0x413ad5 in _start perf[413ad5]
> Segmentation fault (core dumped)
> root@number:~#

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v1 1/2] perf machine: Factor creating a "live" machine out of dwarf-unwind
  2025-03-14 20:00   ` Arnaldo Carvalho de Melo
@ 2025-03-14 20:01     ` Arnaldo Carvalho de Melo
  2025-03-18 23:47       ` Namhyung Kim
  0 siblings, 1 reply; 8+ messages in thread
From: Arnaldo Carvalho de Melo @ 2025-03-14 20:01 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Peter Zijlstra, Ingo Molnar, Namhyung Kim, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Adrian Hunter, Kan Liang,
	James Clark, Yicong Yang, Howard Chu, Andi Kleen, Michael Petlan,
	Anne Macedo, Dr. David Alan Gilbert, Dmitry Vyukov,
	linux-perf-users, linux-kernel

On Fri, Mar 14, 2025 at 05:00:58PM -0300, Arnaldo Carvalho de Melo wrote:
> On Fri, Mar 14, 2025 at 02:18:49PM -0300, Arnaldo Carvalho de Melo wrote:
> > On Wed, Mar 12, 2025 at 10:29:51PM -0700, Ian Rogers wrote:
> > > Factor out for use in places other than the dwarf unwinding tests for
> > > libunwind.
> > 
> > Testing with another patchset being reviewed/tested, seems to work, if
> > it showed the line number would be even better!
> 
> But it gets the lines, at least in this secoond attempt, after applying
> Namhyungs fix for the previous problem (int16_t):

Nevermind, this time I built with DEBUG=1, so DWARF, probably.

- Arnaldo
 
> root@number:~# perf trace -e landlock_add_rule perf test -w landlock
> perf: Segmentation fault
>     #0 0x6698d0 in dump_stack debug.c:355
>     #1 0x66994c in sighandler_dump_stack debug.c:367
>     #2 0x7f784be95fd0 in __restore_rt libc.so.6[40fd0]
>     #3 0x4d0e56 in trace__find_usable_bpf_prog_entry builtin-trace.c:3882
>     #4 0x4cf3de in trace__init_syscalls_bpf_prog_array_maps builtin-trace.c:4040
>     #5 0x4bf626 in trace__run builtin-trace.c:4477
>     #6 0x4bb7a9 in cmd_trace builtin-trace.c:5741
>     #7 0x4d873f in run_builtin perf.c:351
>     #8 0x4d7df3 in handle_internal_command perf.c:404
>     #9 0x4d860f in run_argv perf.c:451
>     #10 0x4d7a4f in main perf.c:558
>     #11 0x7f784be7f088 in __libc_start_call_main libc.so.6[2a088]
>     #12 0x7f784be7f14b in __libc_start_main@@GLIBC_2.34 libc.so.6[2a14b]
>     #13 0x410ff5 in _start perf[410ff5]
> Segmentation fault (core dumped)
> root@number:~# 
>  
> > I'll continue working on that other case with this applied just before
> > that series and finally will give my Tested-by.
> > 
> > - Arnaldo
> > 
> > root@number:~# perf trace -e landlock_add_rule perf test -w landlock
> > perf: Segmentation fault
> >     #0 0x5be81d in dump_stack perf[5be81d]
> >     #1 0x5be879 in sighandler_dump_stack perf[5be879]
> >     #2 0x7f313d24efd0 in __restore_rt libc.so.6[40fd0]
> >     #3 0x491bc1 in cmd_trace perf[491bc1]
> >     #4 0x497090 in run_builtin perf.c:0
> >     #5 0x4973ab in handle_internal_command perf.c:0
> >     #6 0x413483 in main perf[413483]
> >     #7 0x7f313d238088 in __libc_start_call_main libc.so.6[2a088]
> >     #8 0x7f313d23814b in __libc_start_main@@GLIBC_2.34 libc.so.6[2a14b]
> >     #9 0x413ad5 in _start perf[413ad5]
> > Segmentation fault (core dumped)
> > root@number:~#

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v1 1/2] perf machine: Factor creating a "live" machine out of dwarf-unwind
  2025-03-14 20:01     ` Arnaldo Carvalho de Melo
@ 2025-03-18 23:47       ` Namhyung Kim
  2025-05-27 21:17         ` Ian Rogers
  0 siblings, 1 reply; 8+ messages in thread
From: Namhyung Kim @ 2025-03-18 23:47 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Ian Rogers, Peter Zijlstra, Ingo Molnar, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Adrian Hunter, Kan Liang,
	James Clark, Yicong Yang, Howard Chu, Andi Kleen, Michael Petlan,
	Anne Macedo, Dr. David Alan Gilbert, Dmitry Vyukov,
	linux-perf-users, linux-kernel

On Fri, Mar 14, 2025 at 05:01:51PM -0300, Arnaldo Carvalho de Melo wrote:
> On Fri, Mar 14, 2025 at 05:00:58PM -0300, Arnaldo Carvalho de Melo wrote:
> > On Fri, Mar 14, 2025 at 02:18:49PM -0300, Arnaldo Carvalho de Melo wrote:
> > > On Wed, Mar 12, 2025 at 10:29:51PM -0700, Ian Rogers wrote:
> > > > Factor out for use in places other than the dwarf unwinding tests for
> > > > libunwind.
> > > 
> > > Testing with another patchset being reviewed/tested, seems to work, if
> > > it showed the line number would be even better!
> > 
> > But it gets the lines, at least in this secoond attempt, after applying
> > Namhyungs fix for the previous problem (int16_t):
> 
> Nevermind, this time I built with DEBUG=1, so DWARF, probably.

Can I get your Tested-by?

Thanks,
Namhyung

>  
> > root@number:~# perf trace -e landlock_add_rule perf test -w landlock
> > perf: Segmentation fault
> >     #0 0x6698d0 in dump_stack debug.c:355
> >     #1 0x66994c in sighandler_dump_stack debug.c:367
> >     #2 0x7f784be95fd0 in __restore_rt libc.so.6[40fd0]
> >     #3 0x4d0e56 in trace__find_usable_bpf_prog_entry builtin-trace.c:3882
> >     #4 0x4cf3de in trace__init_syscalls_bpf_prog_array_maps builtin-trace.c:4040
> >     #5 0x4bf626 in trace__run builtin-trace.c:4477
> >     #6 0x4bb7a9 in cmd_trace builtin-trace.c:5741
> >     #7 0x4d873f in run_builtin perf.c:351
> >     #8 0x4d7df3 in handle_internal_command perf.c:404
> >     #9 0x4d860f in run_argv perf.c:451
> >     #10 0x4d7a4f in main perf.c:558
> >     #11 0x7f784be7f088 in __libc_start_call_main libc.so.6[2a088]
> >     #12 0x7f784be7f14b in __libc_start_main@@GLIBC_2.34 libc.so.6[2a14b]
> >     #13 0x410ff5 in _start perf[410ff5]
> > Segmentation fault (core dumped)
> > root@number:~# 
> >  
> > > I'll continue working on that other case with this applied just before
> > > that series and finally will give my Tested-by.
> > > 
> > > - Arnaldo
> > > 
> > > root@number:~# perf trace -e landlock_add_rule perf test -w landlock
> > > perf: Segmentation fault
> > >     #0 0x5be81d in dump_stack perf[5be81d]
> > >     #1 0x5be879 in sighandler_dump_stack perf[5be879]
> > >     #2 0x7f313d24efd0 in __restore_rt libc.so.6[40fd0]
> > >     #3 0x491bc1 in cmd_trace perf[491bc1]
> > >     #4 0x497090 in run_builtin perf.c:0
> > >     #5 0x4973ab in handle_internal_command perf.c:0
> > >     #6 0x413483 in main perf[413483]
> > >     #7 0x7f313d238088 in __libc_start_call_main libc.so.6[2a088]
> > >     #8 0x7f313d23814b in __libc_start_main@@GLIBC_2.34 libc.so.6[2a14b]
> > >     #9 0x413ad5 in _start perf[413ad5]
> > > Segmentation fault (core dumped)
> > > root@number:~#

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v1 1/2] perf machine: Factor creating a "live" machine out of dwarf-unwind
  2025-03-18 23:47       ` Namhyung Kim
@ 2025-05-27 21:17         ` Ian Rogers
  2025-05-28 13:12           ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 8+ messages in thread
From: Ian Rogers @ 2025-05-27 21:17 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Adrian Hunter,
	Kan Liang, James Clark, Yicong Yang, Howard Chu, Andi Kleen,
	Michael Petlan, Anne Macedo, Dr. David Alan Gilbert,
	Dmitry Vyukov, linux-perf-users, linux-kernel

On Tue, Mar 18, 2025 at 4:47 PM Namhyung Kim <namhyung@kernel.org> wrote:
>
> On Fri, Mar 14, 2025 at 05:01:51PM -0300, Arnaldo Carvalho de Melo wrote:
> > On Fri, Mar 14, 2025 at 05:00:58PM -0300, Arnaldo Carvalho de Melo wrote:
> > > On Fri, Mar 14, 2025 at 02:18:49PM -0300, Arnaldo Carvalho de Melo wrote:
> > > > On Wed, Mar 12, 2025 at 10:29:51PM -0700, Ian Rogers wrote:
> > > > > Factor out for use in places other than the dwarf unwinding tests for
> > > > > libunwind.
> > > >
> > > > Testing with another patchset being reviewed/tested, seems to work, if
> > > > it showed the line number would be even better!
> > >
> > > But it gets the lines, at least in this secoond attempt, after applying
> > > Namhyungs fix for the previous problem (int16_t):
> >
> > Nevermind, this time I built with DEBUG=1, so DWARF, probably.
>
> Can I get your Tested-by?

Ping. Thanks,
Ian

> Thanks,
> Namhyung

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v1 1/2] perf machine: Factor creating a "live" machine out of dwarf-unwind
  2025-05-27 21:17         ` Ian Rogers
@ 2025-05-28 13:12           ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 8+ messages in thread
From: Arnaldo Carvalho de Melo @ 2025-05-28 13:12 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Namhyung Kim, Peter Zijlstra, Ingo Molnar, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Adrian Hunter, Kan Liang,
	James Clark, Yicong Yang, Howard Chu, Andi Kleen, Michael Petlan,
	Anne Macedo, Dr. David Alan Gilbert, Dmitry Vyukov,
	linux-perf-users, linux-kernel

On Tue, May 27, 2025 at 02:17:40PM -0700, Ian Rogers wrote:
> On Tue, Mar 18, 2025 at 4:47 PM Namhyung Kim <namhyung@kernel.org> wrote:
> > On Fri, Mar 14, 2025 at 05:01:51PM -0300, Arnaldo Carvalho de Melo wrote:
> > > On Fri, Mar 14, 2025 at 05:00:58PM -0300, Arnaldo Carvalho de Melo wrote:
> > > > On Fri, Mar 14, 2025 at 02:18:49PM -0300, Arnaldo Carvalho de Melo wrote:
> > > > > On Wed, Mar 12, 2025 at 10:29:51PM -0700, Ian Rogers wrote:
> > > > > > Factor out for use in places other than the dwarf unwinding tests for
> > > > > > libunwind.

> > > > > Testing with another patchset being reviewed/tested, seems to work, if
> > > > > it showed the line number would be even better!

> > > > But it gets the lines, at least in this secoond attempt, after applying
> > > > Namhyungs fix for the previous problem (int16_t):

> > > Nevermind, this time I built with DEBUG=1, so DWARF, probably.

> > Can I get your Tested-by?
 
> Ping. Thanks,

⬢ [acme@toolbx perf-tools-next]$ git log --oneline -1 ; time make -C tools/perf build-test
⬢ [acme@toolbx perf-tools-next]$ git log --oneline -1 ; time make -C tools/perf build-test
9360bbbbbe349ad5 (HEAD -> perf-tools-next) perf test trace_summary: Skip --bpf-summary tests if no libbpf
make: Entering directory '/home/acme/git/perf-tools-next/tools/perf'
- tarpkg: ./tests/perf-targz-src-pkg .
                 make_static: cd . && make LDFLAGS=-static NO_PERF_READ_VDSO32=1 NO_PERF_READ_VDSOX32=1 NO_JVMTI=1 NO_LIBTRACEEVENT=1 NO_LIBELF=1 -j32  DESTDIR=/tmp/tmp.pLPZo5eOU4
              make_with_gtk2: cd . && make GTK2=1 -j32  DESTDIR=/tmp/tmp.UCW5KoJO7G
- /home/acme/git/perf-tools-next/tools/perf/BUILD_TEST_FEATURE_DUMP: cd . && make FEATURE_DUMP_COPY=/home/acme/git/perf-tools-next/tools/perf/BUILD_TEST_FEATURE_DUMP  feature-dump
cd . && make FEATURE_DUMP_COPY=/home/acme/git/perf-tools-next/tools/perf/BUILD_TEST_FEATURE_DUMP feature-dump
       make_install_prefix_O: cd . && make install prefix=/tmp/krava FEATURES_DUMP=/home/acme/git/perf-tools-next/tools/perf/BUILD_TEST_FEATURE_DUMP -j32 O=/tmp/tmp.ltUruVMFZe DESTDIR=/tmp/tmp.SF7aKXi9C9
  failed to find: /tmp/krava/etc/bash_completion.d/perf
           make_no_scripts_O: cd . && make NO_LIBPYTHON=1 NO_LIBPERL=1 FEATURES_DUMP=/home/acme/git/perf-tools-next/tools/perf/BUILD_TEST_FEATURE_DUMP -j32 O=/tmp/tmp.dDLcnrMf0E DESTDIR=/tmp/tmp.EPrIBPWlr1
                  make_doc_O: cd . && make doc FEATURES_DUMP=/home/acme/git/perf-tools-next/tools/perf/BUILD_TEST_FEATURE_DUMP -j32 O=/tmp/tmp.BzKY8ivHAr DESTDIR=/tmp/tmp.VzvzdPnp0f
       make_no_syscall_tbl_O: cd . && make FEATURES_DUMP=/home/acme/git/perf-tools-next/tools/perf/BUILD_TEST_FEATURE_DUMP -j32 O=/tmp/tmp.5kxtJHPWTs DESTDIR=/tmp/tmp.jE9lxo6oW9
<SNIP>
              make_minimal_O: cd . && make NO_LIBPERL=1 NO_LIBPYTHON=1 NO_GTK2=1 NO_DEMANGLE=1 NO_LIBELF=1 NO_BACKTRACE=1 NO_LIBNUMA=1 NO_LIBBIONIC=1 NO_LIBDW_DWARF_UNWIND=1 NO_AUXTRACE=1 NO_LIBBPF=1 NO_LIBCRYPTO=1 NO_SDT=1 NO_JVMTI=1 NO_LIBZSTD=1 NO_LIBCAP=1 NO_CAPSTONE=1 FEATURES_DUMP=/home/acme/git/perf-tools-next/tools/perf/BUILD_TEST_FEATURE_DUMP -j32 O=/tmp/tmp.lElrNycGd2 DESTDIR=/tmp/tmp.d7wt9o5uE5
cd . && make NO_LIBPERL=1 NO_LIBPYTHON=1 NO_GTK2=1 NO_DEMANGLE=1 NO_LIBELF=1 NO_BACKTRACE=1 NO_LIBNUMA=1 NO_LIBBIONIC=1 NO_LIBDW_DWARF_UNWIND=1 NO_AUXTRACE=1 NO_LIBBPF=1 NO_LIBCRYPTO=1 NO_SDT=1 NO_JVMTI=1 NO_LIBZSTD=1 NO_LIBCAP=1 NO_CAPSTONE=1 FEATURES_DUMP=/home/acme/git/perf-tools-next/tools/perf/BUILD_TEST_FEATURE_DUMP -j32 O=/tmp/tmp.lElrNycGd2 DESTDIR=/tmp/tmp.d7wt9o5uE5
  BUILD:   Doing 'make -j32' parallel build
Warning: Kernel ABI header differences:
  diff -u tools/arch/arm64/include/asm/cputype.h arch/arm64/include/asm/cputype.h
Makefile.config:685: Warning: Disabled BPF skeletons as libelf is required by bpftool
Makefile.config:726: Disabling post unwind, no support found.
Makefile.config:863: Python support disabled by user
Makefile.config:968: No libllvm 13+ found, slower source file resolution, please install llvm-devel/llvm-dev

  GEN     /tmp/tmp.lElrNycGd2/common-cmds.h
  CC      /tmp/tmp.lElrNycGd2/dlfilters/dlfilter-test-api-v0.o
  CC      /tmp/tmp.lElrNycGd2/dlfilters/dlfilter-test-api-v2.o
<SNIP>
  CC      /tmp/tmp.lElrNycGd2/tests/dlfilter-test.o
  CC      /tmp/tmp.lElrNycGd2/util/tool.o
  CC      /tmp/tmp.lElrNycGd2/tests/sigtrap.o
  CC      /tmp/tmp.lElrNycGd2/tests/event_groups.o
  CC      /tmp/tmp.lElrNycGd2/util/sample.o
  CC      /tmp/tmp.lElrNycGd2/tests/symbols.o
  CC      /tmp/tmp.lElrNycGd2/util/sample-raw.o
  CC      /tmp/tmp.lElrNycGd2/util/s390-sample-raw.o
  CC      /tmp/tmp.lElrNycGd2/tests/util.o
util/debug.c: In function ‘__dump_stack’:
util/debug.c:323:17: error: implicit declaration of function ‘backtrace_symbols_fd’ [-Wimplicit-function-declaration]
  323 |                 backtrace_symbols_fd(stackdump, stackdump_size, fileno(file));
      |                 ^~~~~~~~~~~~~~~~~~~~
  CC      /tmp/tmp.lElrNycGd2/util/amd-sample-raw.o
make[6]: *** [/home/acme/git/perf-tools-next/tools/build/Makefile.build:85: /tmp/tmp.lElrNycGd2/util/debug.o] Error 1
make[6]: *** Waiting for unfinished jobs....
  CC      /tmp/tmp.lElrNycGd2/tests/hwmon_pmu.o
  CC      /tmp/tmp.lElrNycGd2/tests/tool_pmu.o
  MKDIR   /tmp/tmp.lElrNycGd2/tests/workloads/
  CC      /tmp/tmp.lElrNycGd2/tests/workloads/noploop.o
  CC      /tmp/tmp.lElrNycGd2/tests/workloads/thloop.o
  CC      /tmp/tmp.lElrNycGd2/tests/workloads/leafloop.o
  CC      /tmp/tmp.lElrNycGd2/tests/workloads/sqrtloop.o
  CC      /tmp/tmp.lElrNycGd2/tests/workloads/brstack.o
  CC      /tmp/tmp.lElrNycGd2/tests/workloads/datasym.o
  CC      /tmp/tmp.lElrNycGd2/tests/workloads/landlock.o
  LD      /tmp/tmp.lElrNycGd2/tests/workloads/perf-test-in.o
  LD      /tmp/tmp.lElrNycGd2/tests/perf-test-in.o
  LD      /tmp/tmp.lElrNycGd2/perf-test-in.o
  AR      /tmp/tmp.lElrNycGd2/libperf-test.a
  LD      /tmp/tmp.lElrNycGd2/perf-in.o
make[5]: *** [/home/acme/git/perf-tools-next/tools/build/Makefile.build:142: util] Error 2
make[4]: *** [Makefile.perf:798: /tmp/tmp.lElrNycGd2/perf-util-in.o] Error 2
make[4]: *** Waiting for unfinished jobs....
  CC      /tmp/tmp.lElrNycGd2/pmu-events/pmu-events.o
  LD      /tmp/tmp.lElrNycGd2/pmu-events/pmu-events-in.o
make[3]: *** [Makefile.perf:290: sub-make] Error 2
make[2]: *** [Makefile:76: all] Error 2
make[1]: *** [tests/make:341: make_minimal_O] Error 1
make: *** [Makefile:109: build-test] Error 2
make: Leaving directory '/home/acme/git/perf-tools-next/tools/perf'

real	3m7.724s
user	31m43.201s
sys	5m40.288s
⬢ [acme@toolbx perf-tools-next]$

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-05-28 13:12 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-13  5:29 [PATCH v1 1/2] perf machine: Factor creating a "live" machine out of dwarf-unwind Ian Rogers
2025-03-13  5:29 ` [PATCH v1 2/2] perf debug: Add function symbols to dump_stack Ian Rogers
2025-03-14 17:18 ` [PATCH v1 1/2] perf machine: Factor creating a "live" machine out of dwarf-unwind Arnaldo Carvalho de Melo
2025-03-14 20:00   ` Arnaldo Carvalho de Melo
2025-03-14 20:01     ` Arnaldo Carvalho de Melo
2025-03-18 23:47       ` Namhyung Kim
2025-05-27 21:17         ` Ian Rogers
2025-05-28 13:12           ` Arnaldo Carvalho de Melo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).