tracing/sched: Add trace events to track cpu hotplug.
authorArun Bharadwaj <abharadw@codeaurora.org>
Wed, 3 Jul 2013 17:35:02 +0000 (10:35 -0700)
committerJohn Stultz <john.stultz@linaro.org>
Tue, 16 Feb 2016 21:53:29 +0000 (13:53 -0800)
Add ftrace event trace_sched_cpu_hotplug to track cpu
hot-add and hot-remove events.

This is useful in a variety of power, performance and
debug analysis scenarios.

Change-Id: I5d202c7a229ffacc3aafb7cf9afee0b0ee7b0931
Signed-off-by: Arun Bharadwaj <abharadw@codeaurora.org>
include/trace/events/sched.h
kernel/cpu.c

index 3211890ee7d53a4a1b1eb16387562b38c8e02ed2..d34eba74af27d1cfa0ff8188172c5fa0b3073f4c 100644 (file)
@@ -191,6 +191,31 @@ TRACE_EVENT(sched_migrate_task,
                  __entry->orig_cpu, __entry->dest_cpu)
 );
 
+/*
+ * Tracepoint for a CPU going offline/online:
+ */
+TRACE_EVENT(sched_cpu_hotplug,
+
+       TP_PROTO(int affected_cpu, int error, int status),
+
+       TP_ARGS(affected_cpu, error, status),
+
+       TP_STRUCT__entry(
+               __field(        int,    affected_cpu            )
+               __field(        int,    error                   )
+               __field(        int,    status                  )
+       ),
+
+       TP_fast_assign(
+               __entry->affected_cpu   = affected_cpu;
+               __entry->error          = error;
+               __entry->status         = status;
+       ),
+
+       TP_printk("cpu %d %s error=%d", __entry->affected_cpu,
+               __entry->status ? "online" : "offline", __entry->error)
+);
+
 DECLARE_EVENT_CLASS(sched_process_template,
 
        TP_PROTO(struct task_struct *p),
index 74e411acb1f228969d43f6a99881a4a14266bd46..37731292f8a160581fb1309984ad754effe12306 100644 (file)
@@ -24,6 +24,8 @@
 #include <linux/irq.h>
 #include <trace/events/power.h>
 
+#include <trace/events/sched.h>
+
 #include "smpboot.h"
 
 #ifdef CONFIG_SMP
@@ -425,6 +427,7 @@ static int _cpu_down(unsigned int cpu, int tasks_frozen)
 
 out_release:
        cpu_hotplug_done();
+       trace_sched_cpu_hotplug(cpu, err, 0);
        if (!err)
                cpu_notify_nofail(CPU_POST_DEAD | mod, hcpu);
        return err;
@@ -530,6 +533,7 @@ out_notify:
                __cpu_notify(CPU_UP_CANCELED | mod, hcpu, nr_calls, NULL);
 out:
        cpu_hotplug_done();
+       trace_sched_cpu_hotplug(cpu, ret, 1);
 
        return ret;
 }