aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace_functions_graph.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/trace/trace_functions_graph.c')
-rw-r--r--kernel/trace/trace_functions_graph.c30
1 files changed, 4 insertions, 26 deletions
diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c
index abf7c4ae2c8..e30472da15d 100644
--- a/kernel/trace/trace_functions_graph.c
+++ b/kernel/trace/trace_functions_graph.c
@@ -183,43 +183,19 @@ static void graph_trace_reset(struct trace_array *tr)
183 unregister_ftrace_graph(); 183 unregister_ftrace_graph();
184} 184}
185 185
186static inline int log10_cpu(int nb) 186static int max_bytes_for_cpu;
187{
188 if (nb / 100)
189 return 3;
190 if (nb / 10)
191 return 2;
192 return 1;
193}
194 187
195static enum print_line_t 188static enum print_line_t
196print_graph_cpu(struct trace_seq *s, int cpu) 189print_graph_cpu(struct trace_seq *s, int cpu)
197{ 190{
198 int i;
199 int ret; 191 int ret;
200 int log10_this = log10_cpu(cpu);
201 int log10_all = log10_cpu(cpumask_weight(cpu_online_mask));
202
203 192
204 /* 193 /*
205 * Start with a space character - to make it stand out 194 * Start with a space character - to make it stand out
206 * to the right a bit when trace output is pasted into 195 * to the right a bit when trace output is pasted into
207 * email: 196 * email:
208 */ 197 */
209 ret = trace_seq_printf(s, " "); 198 ret = trace_seq_printf(s, " %*d) ", max_bytes_for_cpu, cpu);
210
211 /*
212 * Tricky - we space the CPU field according to the max
213 * number of online CPUs. On a 2-cpu system it would take
214 * a maximum of 1 digit - on a 128 cpu system it would
215 * take up to 3 digits:
216 */
217 for (i = 0; i < log10_all - log10_this; i++) {
218 ret = trace_seq_printf(s, " ");
219 if (!ret)
220 return TRACE_TYPE_PARTIAL_LINE;
221 }
222 ret = trace_seq_printf(s, "%d) ", cpu);
223 if (!ret) 199 if (!ret)
224 return TRACE_TYPE_PARTIAL_LINE; 200 return TRACE_TYPE_PARTIAL_LINE;
225 201
@@ -919,6 +895,8 @@ static struct tracer graph_trace __read_mostly = {
919 895
920static __init int init_graph_trace(void) 896static __init int init_graph_trace(void)
921{ 897{
898 max_bytes_for_cpu = snprintf(NULL, 0, "%d", nr_cpu_ids - 1);
899
922 return register_tracer(&graph_trace); 900 return register_tracer(&graph_trace);
923} 901}
924 902