Skip to content

Commit c0aaefd

Browse files
authored
Fix parsing of dmesg line to retrieve # of ARM counters (#529)
1 parent c08869b commit c0aaefd

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

cmd/metrics/metadata.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -829,8 +829,11 @@ func getNumGPCountersARM(target target.Target) (numGPCounters int, err error) {
829829
err = fmt.Errorf("failed to get PMU Driver line: %s, %d, %v", stderr, exitcode, err)
830830
return
831831
}
832-
// example [ 1.339550] hw perfevents: enabled with armv8_pmuv3_0 PMU driver, 5 counters available
833-
counterRegex := regexp.MustCompile(`(\d+) counters available`)
832+
// examples:
833+
// [ 1.339550] hw perfevents: enabled with armv8_pmuv3_0 PMU driver, 5 counters available
834+
// [ 3.663956] hw perfevents: enabled with armv8_pmuv3_0 PMU driver, 6 (0,8000001f) counters available
835+
// regex to match both "5 counters available" and "6 (0,8000001f) counters available"
836+
counterRegex := regexp.MustCompile(`(\d+)\s*(?:\([^)]+\))?\s+counters available`)
834837
matches := counterRegex.FindStringSubmatch(stdout)
835838
if len(matches) > 1 {
836839
numberStr := matches[1]

0 commit comments

Comments
 (0)