linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4] perf sched: Fix sched latency analysis incorrect
@ 2023-03-28  6:00 Chunxin Zang
  2023-03-29 23:26 ` Namhyung Kim
  0 siblings, 1 reply; 2+ messages in thread
From: Chunxin Zang @ 2023-03-28  6:00 UTC (permalink / raw)
  To: namhyung, peterz, mingo, acme
  Cc: mark.rutland, alexander.shishkin, jolsa, irogers,
	linux-perf-users, linux-kernel, Chunxin Zang, Jerry Zhou

[-- Attachment #1: Type: text/plain, Size: 2958 bytes --]

'perf sched latency' is incorrect to get process schedule latency
when it used 'sched:sched_wakeup' to analysis perf.data.

Because 'perf record' prefer use 'sched:sched_waking' to
'sched:sched_wakeup' since commit d566a9c2d482 ("perf sched: Prefer
sched_waking event when it exists"). It's very reasonable to
evaluate process schedule latency.

Similarly, update sched latency/map/replay to use sched_waking events.

Signed-off-by: Chunxin Zang <zangchunxin@lixiang.com>
Signed-off-by: Jerry Zhou <zhouchunhua@lixiang.com>
---

	changelogs in v4:
	1) disable to process wakeup event if wakingup event is found.

	changelogs in v3:
	1) fix non-ASCII characters in commit log.

	changelogs in v2:
	1) fix email address disappearing in 'signed off by'

 tools/perf/builtin-sched.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 86e18575c9be..ec443df8e05c 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -1516,6 +1516,14 @@ static int process_sched_wakeup_event(struct perf_tool *tool,
 	return 0;
 }
 
+static int process_sched_wakeup_ignore(struct perf_tool *tool __maybe_unused,
+				      struct evsel *evsel __maybe_unused,
+				      struct perf_sample *sample __maybe_unused,
+				      struct machine *machine __maybe_unused)
+{
+	return 0;
+}
+
 union map_priv {
 	void	*ptr;
 	bool	 color;
@@ -1816,10 +1824,11 @@ static int perf_sched__process_comm(struct perf_tool *tool __maybe_unused,
 
 static int perf_sched__read_events(struct perf_sched *sched)
 {
-	const struct evsel_str_handler handlers[] = {
+	struct evsel_str_handler handlers[] = {
 		{ "sched:sched_switch",	      process_sched_switch_event, },
 		{ "sched:sched_stat_runtime", process_sched_runtime_event, },
 		{ "sched:sched_wakeup",	      process_sched_wakeup_event, },
+		{ "sched:sched_waking",	      process_sched_wakeup_event, },
 		{ "sched:sched_wakeup_new",   process_sched_wakeup_event, },
 		{ "sched:sched_migrate_task", process_sched_migrate_task_event, },
 	};
@@ -1839,6 +1848,10 @@ static int perf_sched__read_events(struct perf_sched *sched)
 
 	symbol__init(&session->header.env);
 
+	/* prefer sched_waking if it is captured */
+	if (evlist__find_tracepoint_by_name(session->evlist, "sched:sched_waking"))
+		handlers[2].handler = process_sched_wakeup_ignore;
+
 	if (perf_session__set_tracepoints_handlers(session, handlers))
 		goto out_delete;
 
-- 
2.25.1

声明:这封邮件只允许文件接收者阅读,有很高的机密性要求。禁止其他人使用、打开、复制或转发里面的任何内容。如果本邮件错误地发给了你,请联系邮件发出者并删除这个文件。机密及法律的特权并不因为误发邮件而放弃或丧失。任何提出的观点或意见只属于作者的个人见解,并不一定代表本公司。

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

* Re: [PATCH v4] perf sched: Fix sched latency analysis incorrect
  2023-03-28  6:00 [PATCH v4] perf sched: Fix sched latency analysis incorrect Chunxin Zang
@ 2023-03-29 23:26 ` Namhyung Kim
  0 siblings, 0 replies; 2+ messages in thread
From: Namhyung Kim @ 2023-03-29 23:26 UTC (permalink / raw)
  To: Chunxin Zang
  Cc: peterz, mingo, acme, mark.rutland, alexander.shishkin, jolsa,
	irogers, linux-perf-users, linux-kernel, Jerry Zhou

Hello,

On Mon, Mar 27, 2023 at 11:01 PM Chunxin Zang <zangchunxin@lixiang.com> wrote:
>
> 'perf sched latency' is incorrect to get process schedule latency
> when it used 'sched:sched_wakeup' to analysis perf.data.
>
> Because 'perf record' prefer use 'sched:sched_waking' to
> 'sched:sched_wakeup' since commit d566a9c2d482 ("perf sched: Prefer
> sched_waking event when it exists"). It's very reasonable to
> evaluate process schedule latency.
>
> Similarly, update sched latency/map/replay to use sched_waking events.
>
> Signed-off-by: Chunxin Zang <zangchunxin@lixiang.com>
> Signed-off-by: Jerry Zhou <zhouchunhua@lixiang.com>

Acked-by: Namhyung Kim <namhyung@kernel.org>

Thanks,
Namhyung


> ---
>
>         changelogs in v4:
>         1) disable to process wakeup event if wakingup event is found.
>
>         changelogs in v3:
>         1) fix non-ASCII characters in commit log.
>
>         changelogs in v2:
>         1) fix email address disappearing in 'signed off by'
>
>  tools/perf/builtin-sched.c | 15 ++++++++++++++-
>  1 file changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
> index 86e18575c9be..ec443df8e05c 100644
> --- a/tools/perf/builtin-sched.c
> +++ b/tools/perf/builtin-sched.c
> @@ -1516,6 +1516,14 @@ static int process_sched_wakeup_event(struct perf_tool *tool,
>         return 0;
>  }
>
> +static int process_sched_wakeup_ignore(struct perf_tool *tool __maybe_unused,
> +                                     struct evsel *evsel __maybe_unused,
> +                                     struct perf_sample *sample __maybe_unused,
> +                                     struct machine *machine __maybe_unused)
> +{
> +       return 0;
> +}
> +
>  union map_priv {
>         void    *ptr;
>         bool     color;
> @@ -1816,10 +1824,11 @@ static int perf_sched__process_comm(struct perf_tool *tool __maybe_unused,
>
>  static int perf_sched__read_events(struct perf_sched *sched)
>  {
> -       const struct evsel_str_handler handlers[] = {
> +       struct evsel_str_handler handlers[] = {
>                 { "sched:sched_switch",       process_sched_switch_event, },
>                 { "sched:sched_stat_runtime", process_sched_runtime_event, },
>                 { "sched:sched_wakeup",       process_sched_wakeup_event, },
> +               { "sched:sched_waking",       process_sched_wakeup_event, },
>                 { "sched:sched_wakeup_new",   process_sched_wakeup_event, },
>                 { "sched:sched_migrate_task", process_sched_migrate_task_event, },
>         };
> @@ -1839,6 +1848,10 @@ static int perf_sched__read_events(struct perf_sched *sched)
>
>         symbol__init(&session->header.env);
>
> +       /* prefer sched_waking if it is captured */
> +       if (evlist__find_tracepoint_by_name(session->evlist, "sched:sched_waking"))
> +               handlers[2].handler = process_sched_wakeup_ignore;
> +
>         if (perf_session__set_tracepoints_handlers(session, handlers))
>                 goto out_delete;
>
> --
> 2.25.1
>
> 声明:这封邮件只允许文件接收者阅读,有很高的机密性要求。禁止其他人使用、打开、复制或转发里面的任何内容。如果本邮件错误地发给了你,请联系邮件发出者并删除这个文件。机密及法律的特权并不因为误发邮件而放弃或丧失。任何提出的观点或意见只属于作者的个人见解,并不一定代表本公司。

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

end of thread, other threads:[~2023-03-29 23:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-28  6:00 [PATCH v4] perf sched: Fix sched latency analysis incorrect Chunxin Zang
2023-03-29 23:26 ` Namhyung Kim

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).