우선 경빈님한테 pebs_userspace.c를 확보함

int syscall_pebs_start = 463;
int syscall_pebs_end = 464;
int syscall_history_end = 465;

이렇게 되어있는데, 그 말인 즉 커널의 sys_call_table의 463~465 슬롯에 pebs 매핑된 커널 함수가 실행된다는 뜻. 결국 패치된 커널이어야 한다.

정상동작하는지 확인 (sleep 같은거 pid 뽑아서 확인해봤던 듯)

pke@ubuntu:~/hypothesis_2/pebs_userspace$ chmod +x ./pebs_userspace
pke@ubuntu:~/hypothesis_2/pebs_userspace$ ls -l ./pebs_userspace
-rwxrwxr-x 1 pke pke 16408 Sep 24 16:02 ./pebs_userspace
pke@ubuntu:~/hypothesis_2/pebs_userspace$ sudo ./pebs_userspace start 2034256 /user.slice/user-1003.slice/session-5898.scope 100000
pid: 2034256
cgroup_path: /user.slice/user-1003.slice/session-5898.scope
sampling_interval: 100000
pebs start
pke@ubuntu:~/hypothesis_2/pebs_userspace$ sudo ./pebs_userspace history_end 2034256 /user.slice/user-1003.slice/session-5898.scope 1
00000 1 1 1
pid: 2034256
cgroup_path: /user.slice/user-1003.slice/session-5898.scope
sampling_interval: 100000
history end
prediction_sampling_interval: 1
prediction_distance: 1
prediction_depth: 1
pke@ubuntu:~/hypothesis_2/pebs_userspace$ sudo ./pebs_userspace end 2034256 /user.slice/user-1003.slice/session-5898.scope 100000
pid: 2034256
cgroup_path: /user.slice/user-1003.slice/session-5898.scope
sampling_interval: 100000
pebs end
pke@ubuntu:~/hypothesis_2/pebs_userspace$ 

start는 pebs 기반 메모리 샘플링을 시작하고 (PID, cgroup)

history end는 history(샘플 버퍼) 수집을 마감하고 요약, 재배치 파라미터 적용 (샘플링 인터벌, psi, distance, depth)

end는 샘플링 자체를 종료하고 자원 해제

linux 커널에서 pebs_core.c, pebs_test.c 에서 system call 정의하고

event.c 같은데서 system call table 관리하고 셋업해놓고, kernel build하고 쓰는거임

https://www.notion.so/Reordering-API-1ee3d49c71f08016ad6feab549bb990e

pebs_userspace.c 처럼 system call table 호출하는 실행파일 하나 잡아놓고

스크립트에서 인자 넣어서 호출하면서 쓰는거임. 지금 특이사항으로는 pebs start하고 바로 history_end해서 search 함수로 넘겨야된다는 것.

특별히 커널에서 수정한거는 kprintf 좀 오픈해서 dmesg에 띄우게 해놨고, object size를 4KB로 잡은 것

그 외 reordering같은 원본의 분석 함수는 안타게 조정하는 정도가 있었음