@@ -34,14 +34,14 @@ class PerfSDT(Test):
3434 """
3535
3636 def run_cmd (self , cmd ):
37- if process .system (cmd , ignore_status = True , sudo = True , shell = True ):
37+ if process .system (cmd , sudo = True , shell = True ):
3838 self .is_fail += 1
3939 return
4040
4141 @staticmethod
4242 def run_cmd_out (cmd ):
4343 return process .system_output (cmd , shell = True ,
44- ignore_status = True , sudo = True ).decode ("utf-8" )
44+ sudo = True ).decode ("utf-8" )
4545
4646 def add_library (self ):
4747 """
@@ -73,14 +73,14 @@ def add_library(self):
7373 self .run_cmd (perf_add )
7474 if self .is_fail :
7575 self .fail ("Unable to add %s to builid-cache" % self .libpthread )
76- time .sleep (10 )
76+ time .sleep (30 )
7777 # Add the libc.so.6 to perf
7878 perf_libc_add = "perf buildid-cache -v --add %s" % self .libc
7979 self .is_fail = 0
8080 self .run_cmd (perf_libc_add )
8181 if self .is_fail :
8282 self .fail ("Unable to add %s to builid-cache" % self .libc )
83- time .sleep (10 )
83+ time .sleep (30 )
8484 # Check if libpthread has valid SDT markers
8585 new_val = 0
8686 result = self .run_cmd_out ("perf list" )
@@ -98,15 +98,17 @@ def remove_library(self, param):
9898 self .fail ("Unable to remove %s from builid-cache" % param )
9999
100100 def enable_sdt_marker_probe (self ):
101- self .sdt_marker = "sdt_libc:memory_mallopt_mmap_max"
102- if self .sdt_marker not in self .run_cmd_out ("perf list" ):
103- self .fail ("SDT marker %s not available" % self .sdt_marker )
104-
105- enable_sdt_probe = "perf probe --add %s" % self .sdt_marker
106- self .is_fail = 0
107- self .run_cmd (enable_sdt_probe )
108- if self .is_fail :
109- self .fail ("Unable to probe SDT marker event %s" % self .sdt_marker )
101+ self .sdt_events = process .system_output ("perf list --raw-dump sdt" , shell = True ).decode ().split ()
102+ for self .event in self .sdt_events :
103+ self .event = self .event .split ('@' )[0 ].strip ()
104+ try :
105+ self .run_cmd ("perf probe --add %s" % self .event )
106+ except Exception as e :
107+ error_message = str (e )
108+ if 'File exists' in error_message or 'already exists' in error_message :
109+ self .log .info (f"Event { self .event } already exists, skipping." )
110+ else :
111+ self .fail (f"Failed to add event { self .event } : { error_message } " )
110112
111113 def disable_sdt_marker_probe (self ):
112114 disable_sdt_probe = "perf probe -d \\ *"
@@ -118,13 +120,13 @@ def disable_sdt_marker_probe(self):
118120
119121 def record_sdt_marker_probe (self ):
120122 record_sdt_probe = "perf record -o %s -e %s -aR sleep 1" % (
121- self .temp_file , self .sdt_marker )
123+ self .temp_file , self .event )
122124 self .is_fail = 0
123125 self .run_cmd (record_sdt_probe )
124126 if self .is_fail or not os .path .exists (self .temp_file ):
125127 self .disable_sdt_marker_probe ()
126128 self .fail ("Perf record of SDT marker event %s failed"
127- % self .sdt_marker )
129+ % self .event )
128130
129131 def setUp (self ):
130132 """
0 commit comments