@@ -200,25 +200,27 @@ void trace_likely_condition(struct ftrace_branch_data *f, int val, int expect)
200200}
201201#endif /* CONFIG_BRANCH_TRACER */
202202
203- void ftrace_likely_update (struct ftrace_branch_data * f , int val ,
203+ void ftrace_likely_update (struct ftrace_likely_data * f , int val ,
204204 int expect , int is_constant )
205205{
206206 /* A constant is always correct */
207- if (is_constant )
207+ if (is_constant ) {
208+ f -> constant ++ ;
208209 val = expect ;
210+ }
209211 /*
210212 * I would love to have a trace point here instead, but the
211213 * trace point code is so inundated with unlikely and likely
212214 * conditions that the recursive nightmare that exists is too
213215 * much to try to get working. At least for now.
214216 */
215- trace_likely_condition (f , val , expect );
217+ trace_likely_condition (& f -> data , val , expect );
216218
217219 /* FIXME: Make this atomic! */
218220 if (val == expect )
219- f -> correct ++ ;
221+ f -> data . correct ++ ;
220222 else
221- f -> incorrect ++ ;
223+ f -> data . incorrect ++ ;
222224}
223225EXPORT_SYMBOL (ftrace_likely_update );
224226
@@ -249,29 +251,60 @@ static inline long get_incorrect_percent(struct ftrace_branch_data *p)
249251 return percent ;
250252}
251253
252- static int branch_stat_show (struct seq_file * m , void * v )
254+ static const char * branch_stat_process_file (struct ftrace_branch_data * p )
253255{
254- struct ftrace_branch_data * p = v ;
255256 const char * f ;
256- long percent ;
257257
258258 /* Only print the file, not the path */
259259 f = p -> file + strlen (p -> file );
260260 while (f >= p -> file && * f != '/' )
261261 f -- ;
262- f ++ ;
262+ return ++ f ;
263+ }
264+
265+ static void branch_stat_show (struct seq_file * m ,
266+ struct ftrace_branch_data * p , const char * f )
267+ {
268+ long percent ;
263269
264270 /*
265271 * The miss is overlayed on correct, and hit on incorrect.
266272 */
267273 percent = get_incorrect_percent (p );
268274
269- seq_printf (m , "%8lu %8lu " , p -> correct , p -> incorrect );
270275 if (percent < 0 )
271276 seq_puts (m , " X " );
272277 else
273278 seq_printf (m , "%3ld " , percent );
279+
274280 seq_printf (m , "%-30.30s %-20.20s %d\n" , p -> func , f , p -> line );
281+ }
282+
283+ static int branch_stat_show_normal (struct seq_file * m ,
284+ struct ftrace_branch_data * p , const char * f )
285+ {
286+ seq_printf (m , "%8lu %8lu " , p -> correct , p -> incorrect );
287+ branch_stat_show (m , p , f );
288+ return 0 ;
289+ }
290+
291+ static int annotate_branch_stat_show (struct seq_file * m , void * v )
292+ {
293+ struct ftrace_likely_data * p = v ;
294+ const char * f ;
295+ int l ;
296+
297+ f = branch_stat_process_file (& p -> data );
298+
299+ if (!p -> constant )
300+ return branch_stat_show_normal (m , & p -> data , f );
301+
302+ l = snprintf (NULL , 0 , "/%lu" , p -> constant );
303+ l = l > 8 ? 0 : 8 - l ;
304+
305+ seq_printf (m , "%8lu/%lu %*lu " ,
306+ p -> data .correct , p -> constant , l , p -> data .incorrect );
307+ branch_stat_show (m , & p -> data , f );
275308 return 0 ;
276309}
277310
@@ -283,7 +316,7 @@ static void *annotated_branch_stat_start(struct tracer_stat *trace)
283316static void *
284317annotated_branch_stat_next (void * v , int idx )
285318{
286- struct ftrace_branch_data * p = v ;
319+ struct ftrace_likely_data * p = v ;
287320
288321 ++ p ;
289322
@@ -332,7 +365,7 @@ static struct tracer_stat annotated_branch_stats = {
332365 .stat_next = annotated_branch_stat_next ,
333366 .stat_cmp = annotated_branch_stat_cmp ,
334367 .stat_headers = annotated_branch_stat_headers ,
335- .stat_show = branch_stat_show
368+ .stat_show = annotate_branch_stat_show
336369};
337370
338371__init static int init_annotated_branch_stats (void )
@@ -383,12 +416,21 @@ all_branch_stat_next(void *v, int idx)
383416 return p ;
384417}
385418
419+ static int all_branch_stat_show (struct seq_file * m , void * v )
420+ {
421+ struct ftrace_branch_data * p = v ;
422+ const char * f ;
423+
424+ f = branch_stat_process_file (p );
425+ return branch_stat_show_normal (m , p , f );
426+ }
427+
386428static struct tracer_stat all_branch_stats = {
387429 .name = "branch_all" ,
388430 .stat_start = all_branch_stat_start ,
389431 .stat_next = all_branch_stat_next ,
390432 .stat_headers = all_branch_stat_headers ,
391- .stat_show = branch_stat_show
433+ .stat_show = all_branch_stat_show
392434};
393435
394436__init static int all_annotated_branch_stats (void )
0 commit comments