Files
rockchip-kernel/include/linux
Steven Rostedt 03889384ce tracing: Add trace_dump_stack()
I've been asked a few times about how to find out what is calling
some location in the kernel. One way is to use dynamic function tracing
and implement the func_stack_trace. But this only finds out who is
calling a particular function. It does not tell you who is calling
that function and entering a specific if conditional.

I have myself implemented a quick version of trace_dump_stack() for
this purpose a few times, and just needed it now. This is when I realized
that this would be a good tool to have in the kernel like trace_printk().

Using trace_dump_stack() is similar to dump_stack() except that it
writes to the trace buffer instead and can be used in critical locations.

For example:

@@ -5485,8 +5485,12 @@ need_resched_nonpreemptible:
 	if (prev->state && !(preempt_count() & PREEMPT_ACTIVE)) {
 		if (unlikely(signal_pending_state(prev->state, prev)))
 			prev->state = TASK_RUNNING;
-		else
+		else {
 			deactivate_task(rq, prev, 1);
+			trace_printk("Deactivating task %s:%d\n",
+				     prev->comm, prev->pid);
+			trace_dump_stack();
+		}
 		switch_count = &prev->nvcsw;
 	}

Produces:

           <...>-3249  [001]   296.105269: schedule: Deactivating task ntpd:3249
           <...>-3249  [001]   296.105270: <stack trace>
 => schedule
 => schedule_hrtimeout_range
 => poll_schedule_timeout
 => do_select
 => core_sys_select
 => sys_select
 => system_call_fastpath

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
2009-12-11 10:38:47 -05:00
..
2009-11-04 09:50:58 -08:00
2009-11-04 09:50:58 -08:00
2009-11-04 09:50:58 -08:00
2009-09-23 07:39:29 -07:00
2009-06-18 08:46:47 +10:00
2009-11-18 17:09:24 -05:00
2009-10-27 16:47:55 -04:00
2009-11-04 09:50:58 -08:00
2009-11-04 09:50:58 -08:00
2009-09-19 02:14:45 -04:00
2009-06-17 00:36:36 -04:00
2009-09-20 16:09:20 +05:30
2009-09-08 17:42:50 -07:00
2009-06-01 06:21:13 +00:00
2009-04-23 10:06:35 +01:00
2009-11-10 12:31:43 +01:00
2009-06-11 21:36:09 -04:00
2009-11-08 20:57:03 -08:00
2009-07-12 12:22:34 -07:00
2009-09-23 11:01:25 -07:00
2009-06-11 21:36:06 -04:00
2009-09-18 09:48:52 -07:00
2009-06-22 10:12:30 +01:00
2009-05-18 14:46:26 +01:00
2009-11-04 09:50:58 -08:00
2009-10-01 21:17:49 +02:00
2009-10-01 21:17:49 +02:00
2009-09-14 17:41:42 -07:00
2009-06-17 09:33:49 -07:00
2009-07-08 09:18:05 -07:00
2009-11-04 09:50:58 -08:00
2009-11-04 09:50:58 -08:00
2009-06-15 21:30:25 -07:00
2009-06-18 13:04:05 -07:00
2009-11-04 09:50:58 -08:00
2009-11-10 11:50:21 +01:00
2009-12-03 11:58:47 +00:00
2009-09-01 01:13:31 -07:00
2009-09-01 17:52:57 -07:00
2009-11-28 15:05:05 -05:00
2009-11-04 09:50:58 -08:00
2009-11-04 09:50:58 -08:00
2009-11-04 09:50:58 -08:00
2009-11-04 09:50:58 -08:00
2009-11-04 09:50:58 -08:00
2009-11-04 09:50:58 -08:00
2009-11-04 09:50:58 -08:00
2009-11-04 09:50:58 -08:00
2009-11-04 09:50:58 -08:00
2009-11-04 09:50:58 -08:00
2009-11-04 09:50:58 -08:00
2009-11-04 09:50:58 -08:00
2009-11-04 09:50:58 -08:00
2009-11-04 09:50:58 -08:00
2009-06-29 08:59:10 +10:00
2009-11-04 09:50:58 -08:00
2009-11-04 09:50:58 -08:00
2009-09-23 07:39:41 -07:00
2009-11-04 09:50:58 -08:00
2009-06-18 13:03:56 -07:00
2009-09-26 10:17:19 -07:00
2009-04-21 13:41:48 -07:00
2009-04-21 13:41:48 -07:00
2009-10-18 18:52:53 -07:00
2009-08-29 15:53:00 +02:00
2009-09-30 00:32:06 -04:00
2009-09-23 07:39:58 -07:00
2009-12-03 12:03:40 +05:30
2009-12-11 10:38:47 -05:00
2009-09-19 13:13:17 -07:00
2009-09-26 10:17:19 -07:00
2009-09-22 07:17:33 -07:00
2009-12-03 09:32:17 +02:00
2009-04-06 16:06:26 +01:00
2009-06-23 20:21:39 +01:00
2009-07-30 16:03:45 +09:30
2009-04-28 07:37:28 +02:00
2009-10-01 21:17:49 +02:00
2009-06-16 19:47:48 -07:00
2009-09-23 07:39:41 -07:00
2009-09-22 07:17:35 -07:00
2009-06-16 08:40:20 +02:00
2009-04-29 17:32:35 -07:00
2009-07-08 09:31:56 -07:00
2009-06-11 21:36:02 -04:00
2009-11-04 09:50:58 -08:00
2009-11-04 09:50:58 -08:00
2009-09-21 15:14:51 +02:00
2009-11-04 09:50:58 -08:00
2009-11-04 09:50:58 -08:00
2009-11-04 09:50:58 -08:00
2009-06-17 18:02:11 -07:00
2009-06-17 18:02:11 -07:00
2009-09-26 10:17:19 -07:00
2009-06-17 12:24:34 -07:00
2009-06-17 18:02:11 -07:00
2009-11-28 15:05:05 -05:00
2009-06-15 21:44:43 -07:00
2009-11-04 09:50:58 -08:00
2009-11-04 09:50:58 -08:00
2009-04-24 08:54:21 +02:00
2009-09-22 07:17:47 -07:00
2009-10-04 15:05:10 -07:00
2009-12-03 11:43:23 +00:00
2009-06-18 13:04:04 -07:00
2009-07-29 19:10:36 -07:00
2009-12-02 09:55:33 +01:00
2009-09-23 07:39:41 -07:00
2009-06-11 21:36:12 -04:00
2009-12-03 11:53:02 +00:00
2009-11-10 22:26:29 -08:00
2009-10-30 15:06:37 -07:00
2009-06-24 08:17:06 -04:00
2009-05-09 10:49:41 -04:00
2009-11-04 09:50:58 -08:00
2009-11-04 09:50:58 -08:00
2009-04-08 14:33:38 -07:00
2009-08-28 19:57:30 -04:00
2009-04-13 15:04:29 -07:00
2009-12-02 19:57:15 -08:00
2009-06-15 15:50:49 +02:00
2009-11-18 14:52:25 +01:00
2009-04-27 02:45:02 -07:00
2009-05-12 11:11:48 +02:00
2009-10-26 09:40:30 +01:00
2009-10-29 07:39:25 -07:00
2009-07-06 13:57:03 -07:00
2009-11-13 20:46:24 +01:00
2009-08-30 22:26:34 +02:00
2009-10-29 11:17:40 +11:00
2009-11-10 20:54:38 -08:00
2009-09-23 06:46:23 -07:00
2009-09-23 18:13:10 -07:00
2009-08-26 12:39:29 +01:00
2009-09-23 22:26:32 +09:30
2009-09-22 07:17:30 -07:00
2009-11-19 13:43:06 -08:00
2009-09-15 16:51:30 +02:00