• Adrian Hunter's avatar
    perf intel-pt: Fix transaction abort handling · cb798783
    Adrian Hunter authored
    When adding support for power events, some handling of FUP packets was
    unified. That resulted in breaking reporting of TSX aborts, by not
    considering the associated TIP packet. Fix that.
    
    Example:
    
    A machine that supports TSX is required. It will have flag "rtm". Kernel
    parameter tsx=on may be required.
    
     # for w in `cat /proc/cpuinfo | grep -m1 flags `;do echo $w | grep rtm ; done
     rtm
    
    Test program:
    
     #include <stdio.h>
     #include <immintrin.h>
    
     int main()
     {
            int x = 0;
    
            if (_xbegin() == _XBEGIN_STARTED) {
                    x = 1;
                    _xabort(1);
            } else {
                    printf("x = %d\n", x);
            }
            return 0;
     }
    
    Compile with -mrtm i.e.
    
     gcc -Wall -Wextra -mrtm xabort.c -o xabort
    
    Record:
    
     perf record -e intel_pt/cyc/u --filter 'filter main @ ./xabort' ./xabort
    
    Before:
    
     # perf script --itrace=be -F+flags,+addr,-period,-event --ns
              xabort  1478 [007] 92161.431348552:   tr strt                             0 [unknown] ([unknown]) =>           400b6d main+0x0 (/root/xabort)
              xabort  1478 [007] 92161.431348624:   jmp                            400b96 main+0x29 (/root/xabort) =>           400bae main+0x41 (/root/xabort)
              xabort  1478 [007] 92161.431348624:   return                         400bb4 main+0x47 (/root/xabort) =>           400b87 main+0x1a (/root/xabort)
              xabort  1478 [007] 92161.431348637:   jcc                            400b8a main+0x1d (/root/xabort) =>           400b98 main+0x2b (/root/xabort)
              xabort  1478 [007] 92161.431348644:   tr end  call                   400ba9 main+0x3c (/root/xabort) =>           40f690 printf+0x0 (/root/xabort)
              xabort  1478 [007] 92161.431360859:   tr strt                             0 [unknown] ([unknown]) =>           400bae main+0x41 (/root/xabort)
              xabort  1478 [007] 92161.431360882:   tr end  return                 400bb4 main+0x47 (/root/xabort) =>           401139 __libc_start_main+0x309 (/root/xabort)
    
    After:
    
     # perf script --itrace=be -F+flags,+addr,-period,-event --ns
              xabort  1478 [007] 92161.431348552:   tr strt                             0 [unknown] ([unknown]) =>           400b6d main+0x0 (/root/xabort)
              xabort  1478 [007] 92161.431348624:   tx abrt                        400b93 main+0x26 (/root/xabort) =>           400b87 main+0x1a (/root/xabort)
              xabort  1478 [007] 92161.431348637:   jcc                            400b8a main+0x1d (/root/xabort) =>           400b98 main+0x2b (/root/xabort)
              xabort  1478 [007] 92161.431348644:   tr end  call                   400ba9 main+0x3c (/root/xabort) =>           40f690 printf+0x0 (/root/xabort)
              xabort  1478 [007] 92161.431360859:   tr strt                             0 [unknown] ([unknown]) =>           400bae main+0x41 (/root/xabort)
              xabort  1478 [007] 92161.431360882:   tr end  return                 400bb4 main+0x47 (/root/xabort) =>           401139 __libc_start_main+0x309 (/root/xabort)
    
    Fixes: a472e65f ("perf intel-pt: Add decoder support for ptwrite and power event packets")
    Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
    Cc: Andi Kleen <ak@linux.intel.com>
    Cc: Jiri Olsa <jolsa@redhat.com>
    Cc: stable@vger.kernel.org
    Link: http://lore.kernel.org/lkml/20210519074515.9262-2-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    cb798783
intel-pt-decoder.c 84.6 KB