From: Prasad Sodagudi <psodagud@codeaurora.org>
To: rostedt@goodmis.org, tglx@linutronix.de, qais.yousef@arm.com,
peterz@infradead.org, mingo@kernel.org, cai@lca.pw,
tyhicks@canonical.com, arnd@arndb.de
Cc: rameezmustafa@codeaurora.org, linux-kernel@vger.kernel.org,
Prasad Sodagudi <psodagud@codeaurora.org>
Subject: [PATCH 1/2] cpu/hotplug: Add cpuhp_latency trace event
Date: Wed, 23 Sep 2020 16:37:45 -0700 [thread overview]
Message-ID: <1600904266-102397-2-git-send-email-psodagud@codeaurora.org> (raw)
In-Reply-To: <1600904266-102397-1-git-send-email-psodagud@codeaurora.org>
Add ftrace event trace_cpuhp_latency to track cpu
hotplug latency. It helps to track the hotplug latency
impact by firmware changes and kernel cpu hotplug callbacks.
Signed-off-by: Prasad Sodagudi <psodagud@codeaurora.org>
---
include/trace/events/cpuhp.h | 29 +++++++++++++++++++++++++++++
kernel/cpu.c | 9 +++++++++
2 files changed, 38 insertions(+)
diff --git a/include/trace/events/cpuhp.h b/include/trace/events/cpuhp.h
index ad16f77..c871850 100644
--- a/include/trace/events/cpuhp.h
+++ b/include/trace/events/cpuhp.h
@@ -6,6 +6,7 @@
#define _TRACE_CPUHP_H
#include <linux/tracepoint.h>
+#include <linux/sched/clock.h>
TRACE_EVENT(cpuhp_enter,
@@ -89,6 +90,34 @@ TRACE_EVENT(cpuhp_exit,
__entry->cpu, __entry->state, __entry->idx, __entry->ret)
);
+TRACE_EVENT(cpuhp_latency,
+
+ TP_PROTO(unsigned int cpu, unsigned int state,
+ u64 start_time, int ret),
+
+ TP_ARGS(cpu, state, start_time, ret),
+
+ TP_STRUCT__entry(
+ __field(unsigned int, cpu)
+ __field(unsigned int, state)
+ __field(u64, time)
+ __field(int, ret)
+ ),
+
+ TP_fast_assign(
+ __entry->cpu = cpu;
+ __entry->state = state;
+ __entry->time = div64_u64(sched_clock() - start_time, 1000);
+ __entry->ret = ret;
+ ),
+
+ TP_printk(" cpu:%d state:%s latency:%llu USEC ret: %d",
+ __entry->cpu, __entry->state ? "online" : "offline",
+ __entry->time, __entry->ret)
+);
+
+
+
#endif
/* This part must be outside protection */
diff --git a/kernel/cpu.c b/kernel/cpu.c
index 6ff2578..68b3740 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -36,6 +36,7 @@
#include <trace/events/power.h>
#define CREATE_TRACE_POINTS
#include <trace/events/cpuhp.h>
+#include <linux/sched/clock.h>
#include "smpboot.h"
@@ -994,6 +995,7 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen,
{
struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, cpu);
int prev_state, ret = 0;
+ u64 start_time = 0;
if (num_online_cpus() == 1)
return -EBUSY;
@@ -1002,6 +1004,8 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen,
return -EINVAL;
cpus_write_lock();
+ if (trace_cpuhp_latency_enabled())
+ start_time = sched_clock();
cpuhp_tasks_frozen = tasks_frozen;
@@ -1040,6 +1044,7 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen,
}
out:
+ trace_cpuhp_latency(cpu, 0, start_time, ret);
cpus_write_unlock();
/*
* Do post unplug cleanup. This is still protected against
@@ -1192,8 +1197,11 @@ static int _cpu_up(unsigned int cpu, int tasks_frozen, enum cpuhp_state target)
struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, cpu);
struct task_struct *idle;
int ret = 0;
+ u64 start_time = 0;
cpus_write_lock();
+ if (trace_cpuhp_latency_enabled())
+ start_time = sched_clock();
if (!cpu_present(cpu)) {
ret = -EINVAL;
@@ -1241,6 +1249,7 @@ static int _cpu_up(unsigned int cpu, int tasks_frozen, enum cpuhp_state target)
target = min((int)target, CPUHP_BRINGUP_CPU);
ret = cpuhp_up_callbacks(cpu, st, target);
out:
+ trace_cpuhp_latency(cpu, 1, start_time, ret);
cpus_write_unlock();
arch_smt_update();
return ret;
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
next prev parent reply other threads:[~2020-09-23 23:38 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-23 23:37 [PATCH 0/2] measure latency of cpu hotplug path Prasad Sodagudi
2020-09-23 23:37 ` Prasad Sodagudi [this message]
2020-09-28 14:58 ` [PATCH 1/2] cpu/hotplug: Add cpuhp_latency trace event Thomas Gleixner
2020-09-23 23:37 ` [PATCH 2/2] cpu-hotplug: Always use real time scheduling when hotplugging a CPU Prasad Sodagudi
2020-09-24 8:34 ` [PATCH 0/2] measure latency of cpu hotplug path peterz
2020-09-24 14:58 ` Steven Rostedt
2020-09-28 2:41 ` psodagud
2020-09-28 7:40 ` Peter Zijlstra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1600904266-102397-2-git-send-email-psodagud@codeaurora.org \
--to=psodagud@codeaurora.org \
--cc=arnd@arndb.de \
--cc=cai@lca.pw \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=qais.yousef@arm.com \
--cc=rameezmustafa@codeaurora.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=tyhicks@canonical.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.