sched: make early bootup sched_clock() use safer
[wrt350n-kernel.git] / arch / x86 / kernel / stacktrace.c
blob02f0f61f5b1131a511851546393ef06665787507
1 /*
2 * Stack trace management functions
4 * Copyright (C) 2006 Red Hat, Inc., Ingo Molnar <mingo@redhat.com>
5 */
6 #include <linux/sched.h>
7 #include <linux/stacktrace.h>
8 #include <linux/module.h>
9 #include <asm/stacktrace.h>
11 static void save_stack_warning(void *data, char *msg)
15 static void
16 save_stack_warning_symbol(void *data, char *msg, unsigned long symbol)
20 static int save_stack_stack(void *data, char *name)
22 return -1;
25 static void save_stack_address(void *data, unsigned long addr, int reliable)
27 struct stack_trace *trace = data;
28 if (trace->skip > 0) {
29 trace->skip--;
30 return;
32 if (trace->nr_entries < trace->max_entries)
33 trace->entries[trace->nr_entries++] = addr;
36 static void
37 save_stack_address_nosched(void *data, unsigned long addr, int reliable)
39 struct stack_trace *trace = (struct stack_trace *)data;
40 if (in_sched_functions(addr))
41 return;
42 if (trace->skip > 0) {
43 trace->skip--;
44 return;
46 if (trace->nr_entries < trace->max_entries)
47 trace->entries[trace->nr_entries++] = addr;
50 static const struct stacktrace_ops save_stack_ops = {
51 .warning = save_stack_warning,
52 .warning_symbol = save_stack_warning_symbol,
53 .stack = save_stack_stack,
54 .address = save_stack_address,
57 static const struct stacktrace_ops save_stack_ops_nosched = {
58 .warning = save_stack_warning,
59 .warning_symbol = save_stack_warning_symbol,
60 .stack = save_stack_stack,
61 .address = save_stack_address_nosched,
65 * Save stack-backtrace addresses into a stack_trace buffer.
67 void save_stack_trace(struct stack_trace *trace)
69 dump_trace(current, NULL, NULL, 0, &save_stack_ops, trace);
70 if (trace->nr_entries < trace->max_entries)
71 trace->entries[trace->nr_entries++] = ULONG_MAX;
74 void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
76 dump_trace(tsk, NULL, NULL, 0, &save_stack_ops_nosched, trace);
77 if (trace->nr_entries < trace->max_entries)
78 trace->entries[trace->nr_entries++] = ULONG_MAX;