aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace
diff options
context:
space:
mode:
authorSteven Rostedt (Red Hat) <rostedt@goodmis.org>2014-11-12 14:57:38 -0500
committerSteven Rostedt <rostedt@goodmis.org>2014-11-19 15:25:42 -0500
commit9d9add34ec7b2cdd438b0b26481f8d1861bde45c (patch)
treeaab39b52cabc986bac5486d873989fa087d11f00 /kernel/trace
parent7d40f67165d9a4c9add5c0f7e599637a292bbfb2 (diff)
tracing: Have function_graph use trace_seq_has_overflowed()
Instead of doing individual checks all over the place that makes the code very messy. Just check trace_seq_has_overflowed() at the end or in strategic places. This makes the code much cleaner and also helps with getting closer to removing the return values of trace_seq_printf() and friends. Link: http://lkml.kernel.org/r/20141114011410.987913836@goodmis.org Reviewed-by: Petr Mladek <pmladek@suse.cz> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace')
-rw-r--r--kernel/trace/trace.h2
-rw-r--r--kernel/trace/trace_functions_graph.c382
2 files changed, 118 insertions, 266 deletions
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 19418221b302..c3a37e55ec8b 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -726,7 +726,7 @@ extern unsigned long trace_flags;
726extern enum print_line_t 726extern enum print_line_t
727print_graph_function_flags(struct trace_iterator *iter, u32 flags); 727print_graph_function_flags(struct trace_iterator *iter, u32 flags);
728extern void print_graph_headers_flags(struct seq_file *s, u32 flags); 728extern void print_graph_headers_flags(struct seq_file *s, u32 flags);
729extern enum print_line_t 729extern void
730trace_print_graph_duration(unsigned long long duration, struct trace_seq *s); 730trace_print_graph_duration(unsigned long long duration, struct trace_seq *s);
731extern void graph_trace_open(struct trace_iterator *iter); 731extern void graph_trace_open(struct trace_iterator *iter);
732extern void graph_trace_close(struct trace_iterator *iter); 732extern void graph_trace_close(struct trace_iterator *iter);
diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c
index 55bdf9d7f714..100288d10e1f 100644
--- a/kernel/trace/trace_functions_graph.c
+++ b/kernel/trace/trace_functions_graph.c
@@ -107,7 +107,7 @@ enum {
107 FLAGS_FILL_END = 3 << TRACE_GRAPH_PRINT_FILL_SHIFT, 107 FLAGS_FILL_END = 3 << TRACE_GRAPH_PRINT_FILL_SHIFT,
108}; 108};
109 109
110static enum print_line_t 110static void
111print_graph_duration(unsigned long long duration, struct trace_seq *s, 111print_graph_duration(unsigned long long duration, struct trace_seq *s,
112 u32 flags); 112 u32 flags);
113 113
@@ -483,33 +483,24 @@ static int graph_trace_update_thresh(struct trace_array *tr)
483 483
484static int max_bytes_for_cpu; 484static int max_bytes_for_cpu;
485 485
486static enum print_line_t 486static void print_graph_cpu(struct trace_seq *s, int cpu)
487print_graph_cpu(struct trace_seq *s, int cpu)
488{ 487{
489 int ret;
490
491 /* 488 /*
492 * Start with a space character - to make it stand out 489 * Start with a space character - to make it stand out
493 * to the right a bit when trace output is pasted into 490 * to the right a bit when trace output is pasted into
494 * email: 491 * email:
495 */ 492 */
496 ret = trace_seq_printf(s, " %*d) ", max_bytes_for_cpu, cpu); 493 trace_seq_printf(s, " %*d) ", max_bytes_for_cpu, cpu);
497 if (!ret)
498 return TRACE_TYPE_PARTIAL_LINE;
499
500 return TRACE_TYPE_HANDLED;
501} 494}
502 495
503#define TRACE_GRAPH_PROCINFO_LENGTH 14 496#define TRACE_GRAPH_PROCINFO_LENGTH 14
504 497
505static enum print_line_t 498static void print_graph_proc(struct trace_seq *s, pid_t pid)
506print_graph_proc(struct trace_seq *s, pid_t pid)
507{ 499{
508 char comm[TASK_COMM_LEN]; 500 char comm[TASK_COMM_LEN];
509 /* sign + log10(MAX_INT) + '\0' */ 501 /* sign + log10(MAX_INT) + '\0' */
510 char pid_str[11]; 502 char pid_str[11];
511 int spaces = 0; 503 int spaces = 0;
512 int ret;
513 int len; 504 int len;
514 int i; 505 int i;
515 506
@@ -524,56 +515,43 @@ print_graph_proc(struct trace_seq *s, pid_t pid)
524 spaces = TRACE_GRAPH_PROCINFO_LENGTH - len; 515 spaces = TRACE_GRAPH_PROCINFO_LENGTH - len;
525 516
526 /* First spaces to align center */ 517 /* First spaces to align center */
527 for (i = 0; i < spaces / 2; i++) { 518 for (i = 0; i < spaces / 2; i++)
528 ret = trace_seq_putc(s, ' '); 519 trace_seq_putc(s, ' ');
529 if (!ret)
530 return TRACE_TYPE_PARTIAL_LINE;
531 }
532 520
533 ret = trace_seq_printf(s, "%s-%s", comm, pid_str); 521 trace_seq_printf(s, "%s-%s", comm, pid_str);
534 if (!ret)
535 return TRACE_TYPE_PARTIAL_LINE;
536 522
537 /* Last spaces to align center */ 523 /* Last spaces to align center */
538 for (i = 0; i < spaces - (spaces / 2); i++) { 524 for (i = 0; i < spaces - (spaces / 2); i++)
539 ret = trace_seq_putc(s, ' '); 525 trace_seq_putc(s, ' ');
540 if (!ret)
541 return TRACE_TYPE_PARTIAL_LINE;
542 }
543 return TRACE_TYPE_HANDLED;
544} 526}
545 527
546 528
547static enum print_line_t 529static void print_graph_lat_fmt(struct trace_seq *s, struct trace_entry *entry)
548print_graph_lat_fmt(struct trace_seq *s, struct trace_entry *entry)
549{ 530{
550 if (!trace_seq_putc(s, ' ')) 531 trace_seq_putc(s, ' ');
551 return 0; 532 trace_print_lat_fmt(s, entry);
552
553 return trace_print_lat_fmt(s, entry);
554} 533}
555 534
556/* If the pid changed since the last trace, output this event */ 535/* If the pid changed since the last trace, output this event */
557static enum print_line_t 536static void
558verif_pid(struct trace_seq *s, pid_t pid, int cpu, struct fgraph_data *data) 537verif_pid(struct trace_seq *s, pid_t pid, int cpu, struct fgraph_data *data)
559{ 538{
560 pid_t prev_pid; 539 pid_t prev_pid;
561 pid_t *last_pid; 540 pid_t *last_pid;
562 int ret;
563 541
564 if (!data) 542 if (!data)
565 return TRACE_TYPE_HANDLED; 543 return;
566 544
567 last_pid = &(per_cpu_ptr(data->cpu_data, cpu)->last_pid); 545 last_pid = &(per_cpu_ptr(data->cpu_data, cpu)->last_pid);
568 546
569 if (*last_pid == pid) 547 if (*last_pid == pid)
570 return TRACE_TYPE_HANDLED; 548 return;
571 549
572 prev_pid = *last_pid; 550 prev_pid = *last_pid;
573 *last_pid = pid; 551 *last_pid = pid;
574 552
575 if (prev_pid == -1) 553 if (prev_pid == -1)
576 return TRACE_TYPE_HANDLED; 554 return;
577/* 555/*
578 * Context-switch trace line: 556 * Context-switch trace line:
579 557
@@ -582,33 +560,12 @@ verif_pid(struct trace_seq *s, pid_t pid, int cpu, struct fgraph_data *data)
582 ------------------------------------------ 560 ------------------------------------------
583 561
584 */ 562 */
585 ret = trace_seq_puts(s, 563 trace_seq_puts(s, " ------------------------------------------\n");
586 " ------------------------------------------\n"); 564 print_graph_cpu(s, cpu);
587 if (!ret) 565 print_graph_proc(s, prev_pid);
588 return TRACE_TYPE_PARTIAL_LINE; 566 trace_seq_puts(s, " => ");
589 567 print_graph_proc(s, pid);
590 ret = print_graph_cpu(s, cpu); 568 trace_seq_puts(s, "\n ------------------------------------------\n\n");
591 if (ret == TRACE_TYPE_PARTIAL_LINE)
592 return TRACE_TYPE_PARTIAL_LINE;
593
594 ret = print_graph_proc(s, prev_pid);
595 if (ret == TRACE_TYPE_PARTIAL_LINE)
596 return TRACE_TYPE_PARTIAL_LINE;
597
598 ret = trace_seq_puts(s, " => ");
599 if (!ret)
600 return TRACE_TYPE_PARTIAL_LINE;
601
602 ret = print_graph_proc(s, pid);
603 if (ret == TRACE_TYPE_PARTIAL_LINE)
604 return TRACE_TYPE_PARTIAL_LINE;
605
606 ret = trace_seq_puts(s,
607 "\n ------------------------------------------\n\n");
608 if (!ret)
609 return TRACE_TYPE_PARTIAL_LINE;
610
611 return TRACE_TYPE_HANDLED;
612} 569}
613 570
614static struct ftrace_graph_ret_entry * 571static struct ftrace_graph_ret_entry *
@@ -682,103 +639,74 @@ get_return_for_leaf(struct trace_iterator *iter,
682 return next; 639 return next;
683} 640}
684 641
685static int print_graph_abs_time(u64 t, struct trace_seq *s) 642static void print_graph_abs_time(u64 t, struct trace_seq *s)
686{ 643{
687 unsigned long usecs_rem; 644 unsigned long usecs_rem;
688 645
689 usecs_rem = do_div(t, NSEC_PER_SEC); 646 usecs_rem = do_div(t, NSEC_PER_SEC);
690 usecs_rem /= 1000; 647 usecs_rem /= 1000;
691 648
692 return trace_seq_printf(s, "%5lu.%06lu | ", 649 trace_seq_printf(s, "%5lu.%06lu | ",
693 (unsigned long)t, usecs_rem); 650 (unsigned long)t, usecs_rem);
694} 651}
695 652
696static enum print_line_t 653static void
697print_graph_irq(struct trace_iterator *iter, unsigned long addr, 654print_graph_irq(struct trace_iterator *iter, unsigned long addr,
698 enum trace_type type, int cpu, pid_t pid, u32 flags) 655 enum trace_type type, int cpu, pid_t pid, u32 flags)
699{ 656{
700 int ret;
701 struct trace_seq *s = &iter->seq; 657 struct trace_seq *s = &iter->seq;
702 struct trace_entry *ent = iter->ent; 658 struct trace_entry *ent = iter->ent;
703 659
704 if (addr < (unsigned long)__irqentry_text_start || 660 if (addr < (unsigned long)__irqentry_text_start ||
705 addr >= (unsigned long)__irqentry_text_end) 661 addr >= (unsigned long)__irqentry_text_end)
706 return TRACE_TYPE_UNHANDLED; 662 return;
707 663
708 if (trace_flags & TRACE_ITER_CONTEXT_INFO) { 664 if (trace_flags & TRACE_ITER_CONTEXT_INFO) {
709 /* Absolute time */ 665 /* Absolute time */
710 if (flags & TRACE_GRAPH_PRINT_ABS_TIME) { 666 if (flags & TRACE_GRAPH_PRINT_ABS_TIME)
711 ret = print_graph_abs_time(iter->ts, s); 667 print_graph_abs_time(iter->ts, s);
712 if (!ret)
713 return TRACE_TYPE_PARTIAL_LINE;
714 }
715 668
716 /* Cpu */ 669 /* Cpu */
717 if (flags & TRACE_GRAPH_PRINT_CPU) { 670 if (flags & TRACE_GRAPH_PRINT_CPU)
718 ret = print_graph_cpu(s, cpu); 671 print_graph_cpu(s, cpu);
719 if (ret == TRACE_TYPE_PARTIAL_LINE)
720 return TRACE_TYPE_PARTIAL_LINE;
721 }
722 672
723 /* Proc */ 673 /* Proc */
724 if (flags & TRACE_GRAPH_PRINT_PROC) { 674 if (flags & TRACE_GRAPH_PRINT_PROC) {
725 ret = print_graph_proc(s, pid); 675 print_graph_proc(s, pid);
726 if (ret == TRACE_TYPE_PARTIAL_LINE) 676 trace_seq_puts(s, " | ");
727 return TRACE_TYPE_PARTIAL_LINE;
728 ret = trace_seq_puts(s, " | ");
729 if (!ret)
730 return TRACE_TYPE_PARTIAL_LINE;
731 } 677 }
732 678
733 /* Latency format */ 679 /* Latency format */
734 if (trace_flags & TRACE_ITER_LATENCY_FMT) { 680 if (trace_flags & TRACE_ITER_LATENCY_FMT)
735 ret = print_graph_lat_fmt(s, ent); 681 print_graph_lat_fmt(s, ent);
736 if (ret == TRACE_TYPE_PARTIAL_LINE)
737 return TRACE_TYPE_PARTIAL_LINE;
738 }
739
740 } 682 }
741 683
742 /* No overhead */ 684 /* No overhead */
743 ret = print_graph_duration(0, s, flags | FLAGS_FILL_START); 685 print_graph_duration(0, s, flags | FLAGS_FILL_START);
744 if (ret != TRACE_TYPE_HANDLED)
745 return ret;
746 686
747 if (type == TRACE_GRAPH_ENT) 687 if (type == TRACE_GRAPH_ENT)
748 ret = trace_seq_puts(s, "==========>"); 688 trace_seq_puts(s, "==========>");
749 else 689 else
750 ret = trace_seq_puts(s, "<=========="); 690 trace_seq_puts(s, "<==========");
751
752 if (!ret)
753 return TRACE_TYPE_PARTIAL_LINE;
754
755 ret = print_graph_duration(0, s, flags | FLAGS_FILL_END);
756 if (ret != TRACE_TYPE_HANDLED)
757 return ret;
758 691
759 ret = trace_seq_putc(s, '\n'); 692 print_graph_duration(0, s, flags | FLAGS_FILL_END);
760 693 trace_seq_putc(s, '\n');
761 if (!ret)
762 return TRACE_TYPE_PARTIAL_LINE;
763 return TRACE_TYPE_HANDLED;
764} 694}
765 695
766enum print_line_t 696void
767trace_print_graph_duration(unsigned long long duration, struct trace_seq *s) 697trace_print_graph_duration(unsigned long long duration, struct trace_seq *s)
768{ 698{
769 unsigned long nsecs_rem = do_div(duration, 1000); 699 unsigned long nsecs_rem = do_div(duration, 1000);
770 /* log10(ULONG_MAX) + '\0' */ 700 /* log10(ULONG_MAX) + '\0' */
771 char usecs_str[21]; 701 char usecs_str[21];
772 char nsecs_str[5]; 702 char nsecs_str[5];
773 int ret, len; 703 int len;
774 int i; 704 int i;
775 705
776 sprintf(usecs_str, "%lu", (unsigned long) duration); 706 sprintf(usecs_str, "%lu", (unsigned long) duration);
777 707
778 /* Print msecs */ 708 /* Print msecs */
779 ret = trace_seq_printf(s, "%s", usecs_str); 709 trace_seq_printf(s, "%s", usecs_str);
780 if (!ret)
781 return TRACE_TYPE_PARTIAL_LINE;
782 710
783 len = strlen(usecs_str); 711 len = strlen(usecs_str);
784 712
@@ -787,79 +715,63 @@ trace_print_graph_duration(unsigned long long duration, struct trace_seq *s)
787 size_t slen = min_t(size_t, sizeof(nsecs_str), 8UL - len); 715 size_t slen = min_t(size_t, sizeof(nsecs_str), 8UL - len);
788 716
789 snprintf(nsecs_str, slen, "%03lu", nsecs_rem); 717 snprintf(nsecs_str, slen, "%03lu", nsecs_rem);
790 ret = trace_seq_printf(s, ".%s", nsecs_str); 718 trace_seq_printf(s, ".%s", nsecs_str);
791 if (!ret)
792 return TRACE_TYPE_PARTIAL_LINE;
793 len += strlen(nsecs_str); 719 len += strlen(nsecs_str);
794 } 720 }
795 721
796 ret = trace_seq_puts(s, " us "); 722 trace_seq_puts(s, " us ");
797 if (!ret)
798 return TRACE_TYPE_PARTIAL_LINE;
799 723
800 /* Print remaining spaces to fit the row's width */ 724 /* Print remaining spaces to fit the row's width */
801 for (i = len; i < 7; i++) { 725 for (i = len; i < 7; i++)
802 ret = trace_seq_putc(s, ' '); 726 trace_seq_putc(s, ' ');
803 if (!ret)
804 return TRACE_TYPE_PARTIAL_LINE;
805 }
806 return TRACE_TYPE_HANDLED;
807} 727}
808 728
809static enum print_line_t 729static void
810print_graph_duration(unsigned long long duration, struct trace_seq *s, 730print_graph_duration(unsigned long long duration, struct trace_seq *s,
811 u32 flags) 731 u32 flags)
812{ 732{
813 int ret = -1; 733 bool duration_printed = false;
814 734
815 if (!(flags & TRACE_GRAPH_PRINT_DURATION) || 735 if (!(flags & TRACE_GRAPH_PRINT_DURATION) ||
816 !(trace_flags & TRACE_ITER_CONTEXT_INFO)) 736 !(trace_flags & TRACE_ITER_CONTEXT_INFO))
817 return TRACE_TYPE_HANDLED; 737 return;
818 738
819 /* No real adata, just filling the column with spaces */ 739 /* No real adata, just filling the column with spaces */
820 switch (flags & TRACE_GRAPH_PRINT_FILL_MASK) { 740 switch (flags & TRACE_GRAPH_PRINT_FILL_MASK) {
821 case FLAGS_FILL_FULL: 741 case FLAGS_FILL_FULL:
822 ret = trace_seq_puts(s, " | "); 742 trace_seq_puts(s, " | ");
823 return ret ? TRACE_TYPE_HANDLED : TRACE_TYPE_PARTIAL_LINE; 743 return;
824 case FLAGS_FILL_START: 744 case FLAGS_FILL_START:
825 ret = trace_seq_puts(s, " "); 745 trace_seq_puts(s, " ");
826 return ret ? TRACE_TYPE_HANDLED : TRACE_TYPE_PARTIAL_LINE; 746 return;
827 case FLAGS_FILL_END: 747 case FLAGS_FILL_END:
828 ret = trace_seq_puts(s, " |"); 748 trace_seq_puts(s, " |");
829 return ret ? TRACE_TYPE_HANDLED : TRACE_TYPE_PARTIAL_LINE; 749 return;
830 } 750 }
831 751
832 /* Signal a overhead of time execution to the output */ 752 /* Signal a overhead of time execution to the output */
833 if (flags & TRACE_GRAPH_PRINT_OVERHEAD) { 753 if (flags & TRACE_GRAPH_PRINT_OVERHEAD) {
834 /* Duration exceeded 100 usecs */ 754 /* Duration exceeded 100 usecs */
835 if (duration > 100000ULL) 755 if (duration > 100000ULL) {
836 ret = trace_seq_puts(s, "! "); 756 trace_seq_puts(s, "! ");
757 duration_printed = true;
758
837 /* Duration exceeded 10 usecs */ 759 /* Duration exceeded 10 usecs */
838 else if (duration > 10000ULL) 760 } else if (duration > 10000ULL) {
839 ret = trace_seq_puts(s, "+ "); 761 trace_seq_puts(s, "+ ");
762 duration_printed = true;
763 }
840 } 764 }
841 765
842 /* 766 /*
843 * The -1 means we either did not exceed the duration tresholds 767 * If we did not exceed the duration tresholds or we dont want
844 * or we dont want to print out the overhead. Either way we need 768 * to print out the overhead. Either way we need to fill out the space.
845 * to fill out the space.
846 */ 769 */
847 if (ret == -1) 770 if (!duration_printed)
848 ret = trace_seq_puts(s, " "); 771 trace_seq_puts(s, " ");
849
850 /* Catching here any failure happenned above */
851 if (!ret)
852 return TRACE_TYPE_PARTIAL_LINE;
853
854 ret = trace_print_graph_duration(duration, s);
855 if (ret != TRACE_TYPE_HANDLED)
856 return ret;
857 772
858 ret = trace_seq_puts(s, "| "); 773 trace_print_graph_duration(duration, s);
859 if (!ret) 774 trace_seq_puts(s, "| ");
860 return TRACE_TYPE_PARTIAL_LINE;
861
862 return TRACE_TYPE_HANDLED;
863} 775}
864 776
865/* Case of a leaf function on its call entry */ 777/* Case of a leaf function on its call entry */
@@ -873,7 +785,6 @@ print_graph_entry_leaf(struct trace_iterator *iter,
873 struct ftrace_graph_ret *graph_ret; 785 struct ftrace_graph_ret *graph_ret;
874 struct ftrace_graph_ent *call; 786 struct ftrace_graph_ent *call;
875 unsigned long long duration; 787 unsigned long long duration;
876 int ret;
877 int i; 788 int i;
878 789
879 graph_ret = &ret_entry->ret; 790 graph_ret = &ret_entry->ret;
@@ -899,22 +810,15 @@ print_graph_entry_leaf(struct trace_iterator *iter,
899 } 810 }
900 811
901 /* Overhead and duration */ 812 /* Overhead and duration */
902 ret = print_graph_duration(duration, s, flags); 813 print_graph_duration(duration, s, flags);
903 if (ret == TRACE_TYPE_PARTIAL_LINE)
904 return TRACE_TYPE_PARTIAL_LINE;
905 814
906 /* Function */ 815 /* Function */
907 for (i = 0; i < call->depth * TRACE_GRAPH_INDENT; i++) { 816 for (i = 0; i < call->depth * TRACE_GRAPH_INDENT; i++)
908 ret = trace_seq_putc(s, ' '); 817 trace_seq_putc(s, ' ');
909 if (!ret)
910 return TRACE_TYPE_PARTIAL_LINE;
911 }
912 818
913 ret = trace_seq_printf(s, "%ps();\n", (void *)call->func); 819 trace_seq_printf(s, "%ps();\n", (void *)call->func);
914 if (!ret)
915 return TRACE_TYPE_PARTIAL_LINE;
916 820
917 return TRACE_TYPE_HANDLED; 821 return trace_handle_return(s);
918} 822}
919 823
920static enum print_line_t 824static enum print_line_t
@@ -924,7 +828,6 @@ print_graph_entry_nested(struct trace_iterator *iter,
924{ 828{
925 struct ftrace_graph_ent *call = &entry->graph_ent; 829 struct ftrace_graph_ent *call = &entry->graph_ent;
926 struct fgraph_data *data = iter->private; 830 struct fgraph_data *data = iter->private;
927 int ret;
928 int i; 831 int i;
929 832
930 if (data) { 833 if (data) {
@@ -940,19 +843,15 @@ print_graph_entry_nested(struct trace_iterator *iter,
940 } 843 }
941 844
942 /* No time */ 845 /* No time */
943 ret = print_graph_duration(0, s, flags | FLAGS_FILL_FULL); 846 print_graph_duration(0, s, flags | FLAGS_FILL_FULL);
944 if (ret != TRACE_TYPE_HANDLED)
945 return ret;
946 847
947 /* Function */ 848 /* Function */
948 for (i = 0; i < call->depth * TRACE_GRAPH_INDENT; i++) { 849 for (i = 0; i < call->depth * TRACE_GRAPH_INDENT; i++)
949 ret = trace_seq_putc(s, ' '); 850 trace_seq_putc(s, ' ');
950 if (!ret) 851
951 return TRACE_TYPE_PARTIAL_LINE; 852 trace_seq_printf(s, "%ps() {\n", (void *)call->func);
952 }
953 853
954 ret = trace_seq_printf(s, "%ps() {\n", (void *)call->func); 854 if (trace_seq_has_overflowed(s))
955 if (!ret)
956 return TRACE_TYPE_PARTIAL_LINE; 855 return TRACE_TYPE_PARTIAL_LINE;
957 856
958 /* 857 /*
@@ -962,62 +861,43 @@ print_graph_entry_nested(struct trace_iterator *iter,
962 return TRACE_TYPE_NO_CONSUME; 861 return TRACE_TYPE_NO_CONSUME;
963} 862}
964 863
965static enum print_line_t 864static void
966print_graph_prologue(struct trace_iterator *iter, struct trace_seq *s, 865print_graph_prologue(struct trace_iterator *iter, struct trace_seq *s,
967 int type, unsigned long addr, u32 flags) 866 int type, unsigned long addr, u32 flags)
968{ 867{
969 struct fgraph_data *data = iter->private; 868 struct fgraph_data *data = iter->private;
970 struct trace_entry *ent = iter->ent; 869 struct trace_entry *ent = iter->ent;
971 int cpu = iter->cpu; 870 int cpu = iter->cpu;
972 int ret;
973 871
974 /* Pid */ 872 /* Pid */
975 if (verif_pid(s, ent->pid, cpu, data) == TRACE_TYPE_PARTIAL_LINE) 873 verif_pid(s, ent->pid, cpu, data);
976 return TRACE_TYPE_PARTIAL_LINE;
977 874
978 if (type) { 875 if (type)
979 /* Interrupt */ 876 /* Interrupt */
980 ret = print_graph_irq(iter, addr, type, cpu, ent->pid, flags); 877 print_graph_irq(iter, addr, type, cpu, ent->pid, flags);
981 if (ret == TRACE_TYPE_PARTIAL_LINE)
982 return TRACE_TYPE_PARTIAL_LINE;
983 }
984 878
985 if (!(trace_flags & TRACE_ITER_CONTEXT_INFO)) 879 if (!(trace_flags & TRACE_ITER_CONTEXT_INFO))
986 return 0; 880 return;
987 881
988 /* Absolute time */ 882 /* Absolute time */
989 if (flags & TRACE_GRAPH_PRINT_ABS_TIME) { 883 if (flags & TRACE_GRAPH_PRINT_ABS_TIME)
990 ret = print_graph_abs_time(iter->ts, s); 884 print_graph_abs_time(iter->ts, s);
991 if (!ret)
992 return TRACE_TYPE_PARTIAL_LINE;
993 }
994 885
995 /* Cpu */ 886 /* Cpu */
996 if (flags & TRACE_GRAPH_PRINT_CPU) { 887 if (flags & TRACE_GRAPH_PRINT_CPU)
997 ret = print_graph_cpu(s, cpu); 888 print_graph_cpu(s, cpu);
998 if (ret == TRACE_TYPE_PARTIAL_LINE)
999 return TRACE_TYPE_PARTIAL_LINE;
1000 }
1001 889
1002 /* Proc */ 890 /* Proc */
1003 if (flags & TRACE_GRAPH_PRINT_PROC) { 891 if (flags & TRACE_GRAPH_PRINT_PROC) {
1004 ret = print_graph_proc(s, ent->pid); 892 print_graph_proc(s, ent->pid);
1005 if (ret == TRACE_TYPE_PARTIAL_LINE) 893 trace_seq_puts(s, " | ");
1006 return TRACE_TYPE_PARTIAL_LINE;
1007
1008 ret = trace_seq_puts(s, " | ");
1009 if (!ret)
1010 return TRACE_TYPE_PARTIAL_LINE;
1011 } 894 }
1012 895
1013 /* Latency format */ 896 /* Latency format */
1014 if (trace_flags & TRACE_ITER_LATENCY_FMT) { 897 if (trace_flags & TRACE_ITER_LATENCY_FMT)
1015 ret = print_graph_lat_fmt(s, ent); 898 print_graph_lat_fmt(s, ent);
1016 if (ret == TRACE_TYPE_PARTIAL_LINE)
1017 return TRACE_TYPE_PARTIAL_LINE;
1018 }
1019 899
1020 return 0; 900 return;
1021} 901}
1022 902
1023/* 903/*
@@ -1135,8 +1015,7 @@ print_graph_entry(struct ftrace_graph_ent_entry *field, struct trace_seq *s,
1135 if (check_irq_entry(iter, flags, call->func, call->depth)) 1015 if (check_irq_entry(iter, flags, call->func, call->depth))
1136 return TRACE_TYPE_HANDLED; 1016 return TRACE_TYPE_HANDLED;
1137 1017
1138 if (print_graph_prologue(iter, s, TRACE_GRAPH_ENT, call->func, flags)) 1018 print_graph_prologue(iter, s, TRACE_GRAPH_ENT, call->func, flags);
1139 return TRACE_TYPE_PARTIAL_LINE;
1140 1019
1141 leaf_ret = get_return_for_leaf(iter, field); 1020 leaf_ret = get_return_for_leaf(iter, field);
1142 if (leaf_ret) 1021 if (leaf_ret)
@@ -1169,7 +1048,6 @@ print_graph_return(struct ftrace_graph_ret *trace, struct trace_seq *s,
1169 pid_t pid = ent->pid; 1048 pid_t pid = ent->pid;
1170 int cpu = iter->cpu; 1049 int cpu = iter->cpu;
1171 int func_match = 1; 1050 int func_match = 1;
1172 int ret;
1173 int i; 1051 int i;
1174 1052
1175 if (check_irq_return(iter, flags, trace->depth)) 1053 if (check_irq_return(iter, flags, trace->depth))
@@ -1195,20 +1073,14 @@ print_graph_return(struct ftrace_graph_ret *trace, struct trace_seq *s,
1195 } 1073 }
1196 } 1074 }
1197 1075
1198 if (print_graph_prologue(iter, s, 0, 0, flags)) 1076 print_graph_prologue(iter, s, 0, 0, flags);
1199 return TRACE_TYPE_PARTIAL_LINE;
1200 1077
1201 /* Overhead and duration */ 1078 /* Overhead and duration */
1202 ret = print_graph_duration(duration, s, flags); 1079 print_graph_duration(duration, s, flags);
1203 if (ret == TRACE_TYPE_PARTIAL_LINE)
1204 return TRACE_TYPE_PARTIAL_LINE;
1205 1080
1206 /* Closing brace */ 1081 /* Closing brace */
1207 for (i = 0; i < trace->depth * TRACE_GRAPH_INDENT; i++) { 1082 for (i = 0; i < trace->depth * TRACE_GRAPH_INDENT; i++)
1208 ret = trace_seq_putc(s, ' '); 1083 trace_seq_putc(s, ' ');
1209 if (!ret)
1210 return TRACE_TYPE_PARTIAL_LINE;
1211 }
1212 1084
1213 /* 1085 /*
1214 * If the return function does not have a matching entry, 1086 * If the return function does not have a matching entry,
@@ -1217,30 +1089,20 @@ print_graph_return(struct ftrace_graph_ret *trace, struct trace_seq *s,
1217 * belongs to, write out the function name. Always do 1089 * belongs to, write out the function name. Always do
1218 * that if the funcgraph-tail option is enabled. 1090 * that if the funcgraph-tail option is enabled.
1219 */ 1091 */
1220 if (func_match && !(flags & TRACE_GRAPH_PRINT_TAIL)) { 1092 if (func_match && !(flags & TRACE_GRAPH_PRINT_TAIL))
1221 ret = trace_seq_puts(s, "}\n"); 1093 trace_seq_puts(s, "}\n");
1222 if (!ret) 1094 else
1223 return TRACE_TYPE_PARTIAL_LINE; 1095 trace_seq_printf(s, "} /* %ps */\n", (void *)trace->func);
1224 } else {
1225 ret = trace_seq_printf(s, "} /* %ps */\n", (void *)trace->func);
1226 if (!ret)
1227 return TRACE_TYPE_PARTIAL_LINE;
1228 }
1229 1096
1230 /* Overrun */ 1097 /* Overrun */
1231 if (flags & TRACE_GRAPH_PRINT_OVERRUN) { 1098 if (flags & TRACE_GRAPH_PRINT_OVERRUN)
1232 ret = trace_seq_printf(s, " (Overruns: %lu)\n", 1099 trace_seq_printf(s, " (Overruns: %lu)\n",
1233 trace->overrun); 1100 trace->overrun);
1234 if (!ret)
1235 return TRACE_TYPE_PARTIAL_LINE;
1236 }
1237 1101
1238 ret = print_graph_irq(iter, trace->func, TRACE_GRAPH_RET, 1102 print_graph_irq(iter, trace->func, TRACE_GRAPH_RET,
1239 cpu, pid, flags); 1103 cpu, pid, flags);
1240 if (ret == TRACE_TYPE_PARTIAL_LINE)
1241 return TRACE_TYPE_PARTIAL_LINE;
1242 1104
1243 return TRACE_TYPE_HANDLED; 1105 return trace_handle_return(s);
1244} 1106}
1245 1107
1246static enum print_line_t 1108static enum print_line_t
@@ -1257,26 +1119,18 @@ print_graph_comment(struct trace_seq *s, struct trace_entry *ent,
1257 if (data) 1119 if (data)
1258 depth = per_cpu_ptr(data->cpu_data, iter->cpu)->depth; 1120 depth = per_cpu_ptr(data->cpu_data, iter->cpu)->depth;
1259 1121
1260 if (print_graph_prologue(iter, s, 0, 0, flags)) 1122 print_graph_prologue(iter, s, 0, 0, flags);
1261 return TRACE_TYPE_PARTIAL_LINE;
1262 1123
1263 /* No time */ 1124 /* No time */
1264 ret = print_graph_duration(0, s, flags | FLAGS_FILL_FULL); 1125 print_graph_duration(0, s, flags | FLAGS_FILL_FULL);
1265 if (ret != TRACE_TYPE_HANDLED)
1266 return ret;
1267 1126
1268 /* Indentation */ 1127 /* Indentation */
1269 if (depth > 0) 1128 if (depth > 0)
1270 for (i = 0; i < (depth + 1) * TRACE_GRAPH_INDENT; i++) { 1129 for (i = 0; i < (depth + 1) * TRACE_GRAPH_INDENT; i++)
1271 ret = trace_seq_putc(s, ' '); 1130 trace_seq_putc(s, ' ');
1272 if (!ret)
1273 return TRACE_TYPE_PARTIAL_LINE;
1274 }
1275 1131
1276 /* The comment */ 1132 /* The comment */
1277 ret = trace_seq_puts(s, "/* "); 1133 trace_seq_puts(s, "/* ");
1278 if (!ret)
1279 return TRACE_TYPE_PARTIAL_LINE;
1280 1134
1281 switch (iter->ent->type) { 1135 switch (iter->ent->type) {
1282 case TRACE_BPRINT: 1136 case TRACE_BPRINT:
@@ -1305,11 +1159,9 @@ print_graph_comment(struct trace_seq *s, struct trace_entry *ent,
1305 s->len--; 1159 s->len--;
1306 } 1160 }
1307 1161
1308 ret = trace_seq_puts(s, " */\n"); 1162 trace_seq_puts(s, " */\n");
1309 if (!ret)
1310 return TRACE_TYPE_PARTIAL_LINE;
1311 1163
1312 return TRACE_TYPE_HANDLED; 1164 return trace_handle_return(s);
1313} 1165}
1314 1166
1315 1167