2022-06-22 03:41:23

by Gang Li

[permalink] [raw]
Subject: [RESEND PATCH v1] perf stat: Enable ignore_missing_thread for stat

perf already support ignore_missing_thread for -p, but not yet
applied to `perf stat -p <pid>`. This patch enables ignore_missing_thread
for `perf stat -p <pid>`.

Signed-off-by: Gang Li <[email protected]>
---
tools/perf/builtin-stat.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 4ce87a8eb7d7..d2ecd4d29624 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -2586,6 +2586,8 @@ int cmd_stat(int argc, const char **argv)
if (evlist__initialize_ctlfd(evsel_list, stat_config.ctl_fd, stat_config.ctl_fd_ack))
goto out;

+ /* Enable ignoring missing threads when -p option is defined. */
+ evlist__first(evsel_list)->ignore_missing_thread = target.pid;
status = 0;
for (run_idx = 0; forever || run_idx < stat_config.run_count; run_idx++) {
if (stat_config.run_count != 1 && verbose > 0)
--
2.20.1


2022-06-23 15:44:36

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: [RESEND PATCH v1] perf stat: Enable ignore_missing_thread for stat

Em Wed, Jun 22, 2022 at 11:00:37AM +0800, Gang Li escreveu:
> perf already support ignore_missing_thread for -p, but not yet
> applied to `perf stat -p <pid>`. This patch enables ignore_missing_thread
> for `perf stat -p <pid>`.

Thanks, will add it and stick the original explanation about
ignore_missing_thread so that reviewers of this patch can get a
refresher:

From ca8000684ec4e66f965e1f9547a3c6cb834154ca
----------
While monitoring a multithread process with pid option, perf sometimes
may return sys_perf_event_open failure with 3(No such process) if any of
the process's threads die before we open the event. However, we want
perf continue monitoring the remaining threads and do not exit with
error.
----------

Thanks,

- Arnaldo

> Signed-off-by: Gang Li <[email protected]>
> ---
> tools/perf/builtin-stat.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
> index 4ce87a8eb7d7..d2ecd4d29624 100644
> --- a/tools/perf/builtin-stat.c
> +++ b/tools/perf/builtin-stat.c
> @@ -2586,6 +2586,8 @@ int cmd_stat(int argc, const char **argv)
> if (evlist__initialize_ctlfd(evsel_list, stat_config.ctl_fd, stat_config.ctl_fd_ack))
> goto out;
>
> + /* Enable ignoring missing threads when -p option is defined. */
> + evlist__first(evsel_list)->ignore_missing_thread = target.pid;
> status = 0;
> for (run_idx = 0; forever || run_idx < stat_config.run_count; run_idx++) {
> if (stat_config.run_count != 1 && verbose > 0)
> --
> 2.20.1

--

- Arnaldo