[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230406075718.68672-1-leobras@redhat.com>
Date: Thu, 6 Apr 2023 04:57:18 -0300
From: Leonardo Bras <leobras@...hat.com>
To: Steven Rostedt <rostedt@...dmis.org>,
Masami Hiramatsu <mhiramat@...nel.org>,
Leonardo Bras <leobras@...hat.com>,
Thomas Gleixner <tglx@...utronix.de>,
Yury Norov <yury.norov@...il.com>,
"Paul E. McKenney" <paulmck@...nel.org>,
"Peter Zijlstra (Intel)" <peterz@...radead.org>,
Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
Nadav Amit <namit@...are.com>,
Zhen Lei <thunder.leizhen@...wei.com>,
Chen Zhongjin <chenzhongjin@...wei.com>
Cc: linux-kernel@...r.kernel.org, linux-trace-kernel@...r.kernel.org,
Marcelo Tosatti <mtosatti@...hat.com>
Subject: [RFC PATCH 1/1] smp: Add tracepoints for functions called with smp_call_function*()
When running RT workloads in isolated CPUs, many cases of deadline misses
are caused by remote CPU requests such as smp_call_function*().
For those cases, having the names of those functions running around the
deadline miss moment could help finding a target for the next improvements.
Add tracepoints for acquiring the funtion name & argument before entry and
after exitting the called function.
Signed-off-by: Leonardo Bras <leobras@...hat.com>
---
include/trace/events/smp.h | 56 ++++++++++++++++++++++++++++++++++++++
kernel/smp.c | 11 ++++++++
2 files changed, 67 insertions(+)
create mode 100644 include/trace/events/smp.h
diff --git a/include/trace/events/smp.h b/include/trace/events/smp.h
new file mode 100644
index 0000000000000..94aae8d71705d
--- /dev/null
+++ b/include/trace/events/smp.h
@@ -0,0 +1,56 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM smp
+
+#if !defined(_TRACE_SMP_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_SMP_H
+
+#include <linux/tracepoint.h>
+#include <linux/smp.h>
+
+/*
+ * Tracepoints for a function which is called as an effect of smp_call_function.*
+ */
+TRACE_EVENT(smp_call_function_entry,
+
+ TP_PROTO(smp_call_func_t func, void *info),
+
+ TP_ARGS(func, info),
+
+ TP_STRUCT__entry(
+ __field(void *, func)
+ __field(void *, info)
+ ),
+
+ TP_fast_assign(
+ __entry->func = func;
+ __entry->info = info;
+ ),
+
+ TP_printk("function %ps, argument = %p", __entry->func, __entry->info)
+);
+
+
+TRACE_EVENT(smp_call_function_exit,
+
+ TP_PROTO(smp_call_func_t func, void *info),
+
+ TP_ARGS(func, info),
+
+ TP_STRUCT__entry(
+ __field(void *, func)
+ __field(void *, info)
+ ),
+
+ TP_fast_assign(
+ __entry->func = func;
+ __entry->info = info;
+ ),
+
+ TP_printk("function %ps with argument = %p", __entry->func, __entry->info)
+);
+
+#endif /* _TRACE_SMP_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
diff --git a/kernel/smp.c b/kernel/smp.c
index 06a413987a14a..38d8dec28c39c 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -29,6 +29,9 @@
#include "smpboot.h"
#include "sched/smp.h"
+#define CREATE_TRACE_POINTS
+#include <trace/events/smp.h>
+
#define CSD_TYPE(_csd) ((_csd)->node.u_flags & CSD_FLAG_TYPE_MASK)
#ifdef CONFIG_CSD_LOCK_WAIT_DEBUG
@@ -517,7 +520,9 @@ static int generic_exec_single(int cpu, struct __call_single_data *csd)
csd_lock_record(csd);
csd_unlock(csd);
local_irq_save(flags);
+ trace_smp_call_function_entry(func, info);
func(info);
+ trace_smp_call_function_exit(func, info);
csd_lock_record(NULL);
local_irq_restore(flags);
return 0;
@@ -627,7 +632,9 @@ static void __flush_smp_call_function_queue(bool warn_cpu_offline)
}
csd_lock_record(csd);
+ trace_smp_call_function_entry(func, info);
func(info);
+ trace_smp_call_function_exit(func, info);
csd_unlock(csd);
csd_lock_record(NULL);
} else {
@@ -662,7 +669,9 @@ static void __flush_smp_call_function_queue(bool warn_cpu_offline)
csd_lock_record(csd);
csd_unlock(csd);
+ trace_smp_call_function_entry(func, info);
func(info);
+ trace_smp_call_function_exit(func, info);
csd_lock_record(NULL);
} else if (type == CSD_TYPE_IRQ_WORK) {
irq_work_single(csd);
@@ -975,7 +984,9 @@ static void smp_call_function_many_cond(const struct cpumask *mask,
unsigned long flags;
local_irq_save(flags);
+ trace_smp_call_function_entry(func, info);
func(info);
+ trace_smp_call_function_exit(func, info);
local_irq_restore(flags);
}
--
2.40.0
Powered by blists - more mailing lists