blob: d9619940df8557b10cad10de031b52db0120c4fa [file] [log] [blame]
Ashwin Chaugule4eaee1a2013-03-14 18:37:49 -04001/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12#include <asm/thread_notify.h>
13#define CREATE_TRACE_POINTS
14#include "perf_trace_counters.h"
15
16static int tracectr_notifier(struct notifier_block *self, unsigned long cmd,
17 void *v)
18{
19 static int old_pid = -1;
20 struct thread_info *thread = v;
21 int current_pid;
22
23 if (cmd != THREAD_NOTIFY_SWITCH)
24 return old_pid;
25
26 current_pid = thread->task->pid;
27 if (old_pid != -1)
28 trace_sched_switch_with_ctrs(old_pid, current_pid);
29 old_pid = current_pid;
30 return old_pid;
31}
32
33static struct notifier_block tracectr_notifier_block = {
34 .notifier_call = tracectr_notifier,
35};
36
37int __init init_tracecounters(void)
38{
39 thread_register_notifier(&tracectr_notifier_block);
40 return 0;
41}
42late_initcall(init_tracecounters);