Skip to content

Commit

Permalink
remove depreciated pmu contention detection
Browse files Browse the repository at this point in the history
  • Loading branch information
hilldani committed Mar 1, 2023
1 parent 140e970 commit 0744d6e
Showing 1 changed file with 0 additions and 76 deletions.
76 changes: 0 additions & 76 deletions src/perf_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,82 +161,6 @@ def enumerate_uncore(event, n):
return event_list


# read the MSR register and return the value in dec format
def readmsr(msr, cpu=0):
f = os.open("/dev/cpu/%d/msr" % (cpu,), os.O_RDONLY)
os.lseek(f, msr, os.SEEK_SET)
val = struct.unpack("Q", os.read(f, 8))[0]
os.close(f)
return val


# parse hex to int
def parse_hex(s):
try:
return int(s, 16)
except ValueError:
raise argparse.ArgumentError("Bad hex number %s" % (s))


# detect if PMU counters are in use
def pmu_contention_detect(iterations=6):
interval = 10
msrregs = [
"0x309",
"0x30a",
"0x30b",
"0x30c",
"0xc1",
"0xc2",
"0xc3",
"0xc4",
"0xc5",
"0xc6",
"0xc7",
"0xc8",
]
values = [0] * len(msrregs)
prev_values = [0] * len(msrregs)

for count in range(iterations):
for i, reg in enumerate(msrregs):
msrreg = parse_hex(reg)
values[i] = readmsr(msrreg)

in_use = 0
if count > 0:
for j, val in enumerate(values):
if val != prev_values[j]:
in_use = 1
if msrregs[j] == "0x309":
print("PMU in use, hint: instructions")
if msrregs[j] == "0x30a":
print(
"PMU in use, hint: cpu-cycles or Check NMI watchdog. Try: echo 0 > /proc/sys/kernel/nmi_watchdog as sudo"
)
if msrregs[j] == "0x30b":
print("PMU in use, hint: ref-cycles")
if (
msrregs[j] == "0xc1"
or msrregs[j] == "0xc2"
or msrregs[j] == "0xc3"
or msrregs[j] == "0xc4"
):
print("Some PMUs in use")
if in_use != 0:
print("FAIL: PMUs in use")
return True

print(
"checking iteration= %d waiting for %d seconds " % ((count + 1), interval)
)
time.sleep(interval)
prev_values = values[:]

print("PASS: PMUs not in use")
return False


# get linux kernel version
def get_version():
version = ""
Expand Down

0 comments on commit 0744d6e

Please sign in to comment.