Skip to content

Commit 9c61c46

Browse files
authored
cid and percpu bug fixes and cleanup (#20)
* remove unneeded files. fix cid and percore processing errors on icx. improve accuracy of dram bandwidth * remove golang from build and update readme for no golang or lscgroup * install gcc * fix cgroup naming and change output to match other run modes
1 parent d54d178 commit 9c61c46

File tree

25 files changed

+142
-822
lines changed

25 files changed

+142
-822
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ jobs:
1212
- name: install dependencies
1313
run: |
1414
yum update -y
15-
yum install -y make python3 epel-release
16-
yum install -y golang
15+
yum install -y make python3 gcc
1716
python3 -m pip install --upgrade pip
1817
- name: build
1918
run: |

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
build/*
22
dist/*
3-
pmu-checker/pmu-checker
43
src/libtsc.so
54
__pycache__

Makefile

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ clean_dir:
2121
build_dir: clean_dir
2222
mkdir -p build
2323

24-
build/pmu-checker:
25-
cd pmu-checker && make
26-
cp pmu-checker/pmu-checker build/
27-
strip -s -p --strip-unneeded build/pmu-checker
28-
2924
build/libtsc:
3025
gcc -fno-strict-overflow -fno-delete-null-pointer-checks -fwrapv -fPIC -shared -o src/libtsc.so src/calibrate.c
3126

@@ -58,7 +53,7 @@ build-public/postprocess:
5853
cp $(TMPDIR)/dist/perf-postprocess build/
5954
rm -rf $(TMPDIR)
6055

61-
dist/$(PACKAGE_EXTERNAL): build_dir build/pmu-checker build/libtsc build-public/collect build-public/postprocess
56+
dist/$(PACKAGE_EXTERNAL): build_dir build/libtsc build-public/collect build-public/postprocess
6257
rm -rf dist/$(BINARY_FINAL)/
6358
mkdir -p dist/$(BINARY_FINAL)
6459
cp build/$(BINARY_COLLECT) dist/$(BINARY_FINAL)/$(BINARY_COLLECT)

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,12 @@ sudo ./perf-collect --timeout 10
1616
sudo ./perf-postprocess -r results/perfstat.csv --html perfstat.html
1717
```
1818

19-
![PerfSpect BS](images/basic_stats.JPG "perfspect-bs")
20-
![perfspect-demo1](https://user-images.githubusercontent.com/5321018/205159259-3654fa12-74d6-4cb5-8194-ea1b66aadb25.gif)
19+
![basic_stats](https://raw.githubusercontent.com/wiki/intel/PerfSpect/basic_stats.JPG)
20+
![perfspect-demo1](https://raw.githubusercontent.com/wiki/intel/PerfSpect/demo.gif)
2121

2222
## Requirements
2323
### Packages:
2424
- **perf** - PerfSpect uses the Linux perf tool to collect PMU counters
25-
- **lscgroup** - Perfspect needs lscgroup from the cgroup-tools (libcgroup on RHEL/CentOS) package when collecting data for containers
2625

2726
### Supported kernels
2827

@@ -45,7 +44,7 @@ sudo ./perf-postprocess -r results/perfstat.csv --html perfstat.html
4544

4645
## Build from source
4746

48-
Requires recent python and golang.
47+
Requires recent python
4948

5049
```
5150
pip3 install -r requirements.txt

events/icx.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,10 @@ ref-cycles;
120120

121121
# OCR group 1 (ICX PMU supports a maximum of two OCR counters per group)
122122
cpu/event=0xb7,umask=0x01,offcore_rsp=0x104000477,name='OCR.READS_TO_CORE.LOCAL_DRAM'/,
123-
cpu/event=0xb7,umask=0x01,offcore_rsp=0x730000477,name='OCR.READS_TO_CORE.REMOTE_DRAM'/;
123+
cpu/event=0xb7,umask=0x01,offcore_rsp=0x84002380,name='OCR.HWPF_L3.L3_MISS_LOCAL'/;
124124

125125
# OCR group 2 (ICX PMU supports a maximum of two OCR counters per group)
126-
cpu/event=0xb7,umask=0x01,offcore_rsp=0x84002380,name='OCR.HWPF_L3.L3_MISS_LOCAL'/,
126+
cpu/event=0xb7,umask=0x01,offcore_rsp=0x730000477,name='OCR.READS_TO_CORE.REMOTE_DRAM'/,
127127
cpu/event=0xb7,umask=0x01,offcore_rsp=0x90002380,name='OCR.HWPF_L3.REMOTE'/;
128128

129129
#power related

images/basic_stats.JPG

-140 KB
Binary file not shown.

images/metrics.JPG

-151 KB
Binary file not shown.

images/sim.png

-70 KB
Binary file not shown.

perf-collect.py

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
from src import prepare_perf_events as prep_events
1616

1717

18-
from subprocess import PIPE, run # nosec
19-
2018
SUPPORTED_ARCHITECTURES = [
2119
"Broadwell",
2220
"Skylake",
@@ -86,13 +84,40 @@ def write_metadata(
8684
cpusets = ""
8785
if args.cid is not None:
8886
for cgroup in cgroups:
89-
set = open("/sys/fs/cgroup/cpuset/" + cgroup + "/cpuset.cpus", "r")
90-
cpu_set = set.read()
91-
set.close()
92-
cpu_set = cpu_set.strip()
93-
cpu_set = str("," + cpu_set)
94-
cpusets += cpu_set
95-
cpusets = str(cpusets)
87+
cgroup_paths = [
88+
"/sys/fs/cgroup/cpuset/" + cgroup + "/cpuset.cpus", # cgroup v1
89+
"/sys/fs/cgroup/" + cgroup + "/cpuset.cpus", # cgroup v2
90+
]
91+
cg_path_found = False
92+
for cg_path in cgroup_paths:
93+
try:
94+
cpu_set_file = open(
95+
"/sys/fs/cgroup/cpuset/" + cgroup + "/cpuset.cpus", "r"
96+
)
97+
cg_path_found = True
98+
# no need to check other paths
99+
break
100+
except FileNotFoundError:
101+
# check next path
102+
continue
103+
104+
if cg_path_found:
105+
cpu_set = cpu_set_file.read()
106+
cpu_set_file.close()
107+
cpu_set = cpu_set.strip()
108+
109+
if not cg_path_found or cpu_set == "":
110+
# A missing path or an empty cpu-set in v2 indicates that the container is running on all CPUs
111+
cpu_set = "0-" + str(
112+
int(
113+
perf_helpers.get_cpu_count()
114+
* perf_helpers.get_socket_count()
115+
* perf_helpers.get_ht_count()
116+
- 1
117+
)
118+
)
119+
120+
cpusets += "," + cpu_set
96121
else:
97122
cpusets = "disabled"
98123

@@ -468,21 +493,6 @@ def is_safe_file(fname, substr):
468493
args.timeout,
469494
)
470495
elif args.dryrun:
471-
with open("results/pmu-checker.log", "w") as fw:
472-
print("Checking if PMU counters are in-use already...")
473-
pmuargs = resource_path("pmu-checker")
474-
try:
475-
run_result = run( # nosec
476-
shlex.split(pmuargs),
477-
stdout=PIPE,
478-
stderr=PIPE,
479-
universal_newlines=True,
480-
)
481-
fw.write(str(run_result.stdout))
482-
483-
except Exception as e:
484-
print(e)
485-
486496
cmd = "perf stat %s -I %d -x , -e %s -o %s sleep 10" % (
487497
collection_type,
488498
interval,
@@ -498,6 +508,7 @@ def is_safe_file(fname, substr):
498508
)
499509
perfargs = shlex.split(cmd)
500510
validate_perfargs(perfargs)
511+
perf_helpers.pmu_contention_detect()
501512
if args.verbose:
502513
print(cmd)
503514
try:

perf-collect.spec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ block_cipher = None
77
a = Analysis(
88
['perf-collect.py'],
99
pathex=[],
10-
binaries=[('../build/pmu-checker', '.')],
1110
datas=[('./src/libtsc.so', '.'), ('./events/bdx.txt', '.'), ('./events/skx.txt', '.'), ('./events/clx.txt', '.'), ('./events/icx.txt', '.'), ('./events/spr.txt', '.'), ('./events/icx_aws.txt', '.'), ('./events/spr_aws.txt', '.'), ('./events/clx_aws.txt', '.'), ('./events/skx_aws.txt', '.')],
1211
hiddenimports=[],
1312
hookspath=[],

0 commit comments

Comments
 (0)