• Adrian Hunter's avatar
    perf intel-pt: Add mispred-all config option to aid use with autofdo · ba11ba65
    Adrian Hunter authored
    autofdo incorrectly expects branch flags to include either mispred or
    predicted.  In fact mispred = predicted = 0 is valid and means the flags
    are not supported, which they aren't by Intel PT.
    
    To make autofdo work, add a config option which will cause Intel PT
    decoder to set the mispred flag on all branches.
    
    Below is an example of using Intel PT with autofdo.  The example is
    also added to the Intel PT documentation.  It requires autofdo
    (https://github.com/google/autofdo) and gcc version 5.  The bubble
    sort example is from the AutoFDO tutorial (https://gcc.gnu.org/wiki/AutoFDO/Tutorial)
    amended to take the number of elements as a parameter.
    
    	$ gcc-5 -O3 sort.c -o sort_optimized
    	$ ./sort_optimized 30000
    	Bubble sorting array of 30000 elements
    	2254 ms
    
    	$ cat ~/.perfconfig
    	[intel-pt]
    		mispred-all
    
    	$ perf record -e intel_pt//u ./sort 3000
    	Bubble sorting array of 3000 elements
    	58 ms
    	[ perf record: Woken up 2 times to write data ]
    	[ perf record: Captured and wrote 3.939 MB perf.data ]
    	$ perf inject -i perf.data -o inj --itrace=i100usle --strip
    	$ ./create_gcov --binary=./sort --profile=inj --gcov=sort.gcov -gcov_version=1
    	$ gcc-5 -O3 -fauto-profile=sort.gcov sort.c -o sort_autofdo
    	$ ./sort_autofdo 30000
    	Bubble sorting array of 30000 elements
    	2155 ms
    
    Note there is currently no advantage to using Intel PT instead of LBR,
    but that may change in the future if greater use is made of the data.
    Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
    Cc: Jiri Olsa <jolsa@redhat.com>
    Link: http://lkml.kernel.org/r/1443186956-18718-26-git-send-email-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    ba11ba65
intel-pt.txt 28.5 KB