From 5f664e319d044533cf48d0695dd32692f334dc13 Mon Sep 17 00:00:00 2001 From: liaozhaoyan Date: Fri, 28 Oct 2022 10:12:14 +0800 Subject: [PATCH 1/2] add perf hardware breakpoint for coolbpf. --- compile/remote-compile/lbc/Makefile | 8 ++-- compile/remote-compile/lbc/tool/surfServer.py | 17 +++++++ lcc/pylcc/guide/attach.py | 3 +- lcc/pylcc/guide/callStack.py | 8 ++-- lcc/pylcc/guide/codeSeparate.py | 3 +- lcc/pylcc/guide/dynamicVar.py | 3 +- lcc/pylcc/guide/eventOut.py | 3 +- lcc/pylcc/guide/hashMap.py | 8 ++-- lcc/pylcc/guide/hello.py | 3 +- lcc/pylcc/guide/javaProbe.py | 3 +- lcc/pylcc/guide/mulitEvent.py | 3 +- lcc/pylcc/guide/perfBreakpoint.py | 5 +-- lcc/pylcc/guide/testPerf.py | 3 +- lcc/pylcc/guide/testUprobe.py | 3 +- lcc/pylcc/guide/traceUprobe.py | 40 ++++++++++++++--- lcc/pylcc/lib/lbcBase.py | 42 +++++++++++++++++- lcc/pylcc/lib/lbcMaps.py | 44 ++----------------- lcc/pylcc/pytool/bindsnoop.py | 4 +- 18 files changed, 122 insertions(+), 81 deletions(-) diff --git a/compile/remote-compile/lbc/Makefile b/compile/remote-compile/lbc/Makefile index 582c951..1e6019c 100644 --- a/compile/remote-compile/lbc/Makefile +++ b/compile/remote-compile/lbc/Makefile @@ -13,6 +13,7 @@ INCLUDES := -I$(OUTPUT) -I$(INC) -Iinclude -Ibpf -Ilibbpf/include/uapi CFLAGS := -g -fPIC $(INCLUDES) ARCH := $(shell uname -m) CARCH := $(shell uname -m | sed 's/x86_64/x86/') +LIB_Z_ELF_BFD_OBJ := /root/staticlib/x86_64/libz.a /root/staticlib/x86_64/libelf.a SO = bpf.so SOURCE = $(wildcard ${SRC}/*.c) @@ -36,6 +37,7 @@ $(OUTPUT) $(OUTPUT)/libbpf: # build libbpf.a $(LIBBPF_OBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(OUTPUT)/libbpf + touch src/bpf_init.c $(MAKE) -C $(LIBBPF_SRC) BUILD_STATIC_ONLY=1 cp $(LIBBPF_SRC)/libbpf.a ./ @@ -78,7 +80,5 @@ $(SRC)/lbc_static.o: $(SRC)/lbc_static.c $(SKEL) $(SRC)/perf_event_attr.h OBJS=$(SRC)/bpf_init.o $(SRC)/perf_event_attr.o $(SRC)/cJSON.o $(SRC)/lbc_static.o -$(SO): %: $(OBJECT) $(LIBBPF_OBJ) $(wildcard $(INC)/%.h) | $(OUTPUT) - $(CC) $(CFLAGS) -shared -fPIC -lelf -lz -o $@ $^ - - +$(SO): %: $(OBJECT) $(LIBBPF_OBJ) $(LIB_Z_ELF_BFD_OBJ) $(wildcard $(INC)/%.h) | $(OUTPUT) + $(CC) $(CFLAGS) -shared -fPIC -o $@ $^ diff --git a/compile/remote-compile/lbc/tool/surfServer.py b/compile/remote-compile/lbc/tool/surfServer.py index 61eda20..c91ebf5 100644 --- a/compile/remote-compile/lbc/tool/surfServer.py +++ b/compile/remote-compile/lbc/tool/surfServer.py @@ -26,6 +26,8 @@ dbDir = os.path.join(rootDir, "hive/db") btfDir = os.path.join(rootDir, "hive/btf") compileDir = os.path.join(rootDir, "lbc") koBuildDir = os.path.join(rootDir, "lbc/ko") +elfSoDir = os.path.join(rootDir, "lbc/elf_sym") + soFile = "bpf.so" objFile = ".output/lbc.bpf.o" dfFile = "pre.db" @@ -80,6 +82,7 @@ class CsurfServer(object): "c": self._compileSo, "obj": self._compileObj, "ko": self._koBuild, + "elf_so": self._sendElfSo, } self._reSql = re.compile(r"[^a-zA-Z0-9_% ]") self._lock = lock @@ -162,6 +165,19 @@ class CsurfServer(object): dSend['res'] = i.getFunc(t) return dSend + def _sendElfSo(self, dRecv): + arch = self._setupArch(dRecv) + soPath = os.path.join(elfSoDir, arch) + os.chdir(soPath) + dSend = {'ver': dRecv['ver'], 'arch': arch} + try: + with open("syms.so", "rb") as f: + dSend['so'] = segEncode(f.read()).decode() + dSend['log'] = "ok." + except IOError: + dSend['log'] = "read elf so file failed." + return dSend + def _sendBtf(self, dRecv): arch = self._setupArch(dRecv) btfPath = os.path.join(btfDir, arch) @@ -236,6 +252,7 @@ class CsurfServer(object): self._transArch(arch), dRecv['env'])) print(dSend['clog']) + # self._c.cmd("strip -x %s" % filePath) try: with open(filePath, 'rb') as f: dSend[k] = base64.b64encode(f.read()).decode() diff --git a/lcc/pylcc/guide/attach.py b/lcc/pylcc/guide/attach.py index 36b2587..a927b2b 100644 --- a/lcc/pylcc/guide/attach.py +++ b/lcc/pylcc/guide/attach.py @@ -12,7 +12,6 @@ """ __author__ = 'liaozhaoyan' -from signal import pause from pylcc.lbcBase import ClbcBase bpfPog = r""" @@ -35,7 +34,7 @@ class Cattach(ClbcBase): def __init__(self): super(Cattach, self).__init__("attach", bpf_str=bpfPog, attach=0) self.attachKprobe("j_wake_up_new_task2", "wake_up_new_task") - pause() + self.waitInterrupt() if __name__ == "__main__": diff --git a/lcc/pylcc/guide/callStack.py b/lcc/pylcc/guide/callStack.py index 935879b..035251f 100644 --- a/lcc/pylcc/guide/callStack.py +++ b/lcc/pylcc/guide/callStack.py @@ -13,8 +13,9 @@ """ __author__ = 'liaozhaoyan' -from signal import pause from pylcc.lbcBase import ClbcBase, CeventThread +from surftrace.surfElf import CelfKsym +from pylcc.lbcStack import getKStacks bpfPog = r""" #include "lbc.h" @@ -52,19 +53,20 @@ char _license[] SEC("license") = "GPL"; class CcallStack(ClbcBase): def __init__(self): super(CcallStack, self).__init__("callStack", bpf_str=bpfPog) + self._ksym = CelfKsym() def _cb(self, cpu, e): print("cpu: %d current pid:%d, comm:%s. wake_up_new_task pid: %d, comm: %s" % ( cpu, e.c_pid, e.c_comm, e.p_pid, e.p_comm )) - stacks = self.maps['call_stack'].getStacks(e.stack_id) + stacks = getKStacks(self.maps['call_stack'], e.stack_id, self._ksym) print("call trace:") for s in stacks: print(s) def loop(self): CeventThread(self, 'e_out', self._cb) - pause() + self.waitInterrupt() if __name__ == "__main__": diff --git a/lcc/pylcc/guide/codeSeparate.py b/lcc/pylcc/guide/codeSeparate.py index 0d6e09f..1f2748f 100644 --- a/lcc/pylcc/guide/codeSeparate.py +++ b/lcc/pylcc/guide/codeSeparate.py @@ -13,7 +13,6 @@ """ __author__ = 'liaozhaoyan' -from signal import pause from pylcc.lbcBase import ClbcBase, CeventThread @@ -28,7 +27,7 @@ class codeSeparate(ClbcBase): def loop(self): CeventThread(self, 'e_out', self._cb) - pause() + self.waitInterrupt() if __name__ == "__main__": diff --git a/lcc/pylcc/guide/dynamicVar.py b/lcc/pylcc/guide/dynamicVar.py index 3835187..26e25fd 100644 --- a/lcc/pylcc/guide/dynamicVar.py +++ b/lcc/pylcc/guide/dynamicVar.py @@ -14,7 +14,6 @@ __author__ = 'liaozhaoyan' import sys -from signal import pause from pylcc.lbcBase import ClbcBase, CeventThread bpfPog = r""" @@ -62,7 +61,7 @@ class CdynamicVar(ClbcBase): def loop(self): CeventThread(self, 'e_out', self._cb) - pause() + self.waitInterrupt() if __name__ == "__main__": diff --git a/lcc/pylcc/guide/eventOut.py b/lcc/pylcc/guide/eventOut.py index 4e5928e..79f7fa7 100644 --- a/lcc/pylcc/guide/eventOut.py +++ b/lcc/pylcc/guide/eventOut.py @@ -13,7 +13,6 @@ """ __author__ = 'liaozhaoyan' -from signal import pause from pylcc.lbcBase import ClbcBase, CeventThread bpfPog = r""" @@ -57,7 +56,7 @@ class CeventOut(ClbcBase): def loop(self): CeventThread(self, 'e_out', self._cb) - pause() + self.waitInterrupt() if __name__ == "__main__": diff --git a/lcc/pylcc/guide/hashMap.py b/lcc/pylcc/guide/hashMap.py index c725038..cf69500 100644 --- a/lcc/pylcc/guide/hashMap.py +++ b/lcc/pylcc/guide/hashMap.py @@ -62,12 +62,14 @@ class ChashMap(ClbcBase): cpu, e.c_pid, e.c_comm, e.p_pid, e.p_comm )) - def loop(self): - CeventThread(self, 'e_out', self._cb) - pause() + def _exit(self): dMap = self.maps['pid_cnt'] print(dMap.get()) + def loop(self): + CeventThread(self, 'e_out', self._cb) + self.waitInterrupt(self._exit) + if __name__ == "__main__": e = ChashMap() diff --git a/lcc/pylcc/guide/hello.py b/lcc/pylcc/guide/hello.py index ad14337..149e2ab 100644 --- a/lcc/pylcc/guide/hello.py +++ b/lcc/pylcc/guide/hello.py @@ -35,8 +35,7 @@ char _license[] SEC("license") = "GPL"; class Chello(ClbcBase): def __init__(self): super(Chello, self).__init__("hello", bpf_str=bpfPog) - while True: - time.sleep(1) + self.waitInterrupt() if __name__ == "__main__": diff --git a/lcc/pylcc/guide/javaProbe.py b/lcc/pylcc/guide/javaProbe.py index 50b24ca..547c275 100644 --- a/lcc/pylcc/guide/javaProbe.py +++ b/lcc/pylcc/guide/javaProbe.py @@ -13,7 +13,6 @@ __author__ = 'liaozhaoyan' import sys -from signal import pause from pylcc.lbcBase import ClbcBase bpfPog = r""" @@ -36,7 +35,7 @@ class CjavaProbe(ClbcBase): self.attachJavaSym("bpf_prog", pid, sym) def loop(self): - pause() + self.waitInterrupt() if __name__ == "__main__": diff --git a/lcc/pylcc/guide/mulitEvent.py b/lcc/pylcc/guide/mulitEvent.py index accb5dc..59ccca9 100644 --- a/lcc/pylcc/guide/mulitEvent.py +++ b/lcc/pylcc/guide/mulitEvent.py @@ -13,7 +13,6 @@ __author__ = 'liaozhaoyan' from pylcc.lbcBase import ClbcBase, CeventThread -from signal import pause bpfPog = r""" #include "lbc.h" @@ -79,7 +78,7 @@ class CmulitEvent(ClbcBase): def loop(self): CeventThread(self, "e1_out", self._cb_e1) CeventThread(self, "e2_out", self._cb_e2) - pause() + self.waitInterrupt() if __name__ == "__main__": diff --git a/lcc/pylcc/guide/perfBreakpoint.py b/lcc/pylcc/guide/perfBreakpoint.py index 5d953b9..dc62a17 100644 --- a/lcc/pylcc/guide/perfBreakpoint.py +++ b/lcc/pylcc/guide/perfBreakpoint.py @@ -13,7 +13,6 @@ __author__ = 'liaozhaoyan' import sys -from signal import pause import time from pylcc.lbcBase import ClbcBase from pylcc.perfEvent import * @@ -51,7 +50,7 @@ class CperfBreakPoint(ClbcBase): "bp_len": 8, } self.attachPerfEvent("bpf_prog", pfConfig, pid=self._pid, flags=PerfFlag.FD_CLOEXEC) - pause() + self.waitInterrupt() def loop3(self): print(self._pid, self._addr) @@ -66,7 +65,7 @@ class CperfBreakPoint(ClbcBase): "bp_len": 8, } self.attachPerfEvent("bpf_prog", pfConfig, pid=self._pid, flags=PerfFlag.FD_CLOEXEC) - pause() + self.waitInterrupt() def loop1(self): print(self._pid, self._addr) diff --git a/lcc/pylcc/guide/testPerf.py b/lcc/pylcc/guide/testPerf.py index 6aca2c4..21d0654 100644 --- a/lcc/pylcc/guide/testPerf.py +++ b/lcc/pylcc/guide/testPerf.py @@ -12,7 +12,6 @@ """ __author__ = 'liaozhaoyan' -from signal import pause from pylcc.lbcBase import ClbcBase from pylcc.perfEvent import * @@ -42,7 +41,7 @@ class CtestPerf(ClbcBase): "config": PerfSwIds.PAGE_FAULTS, } self.attachPerfEvent("bpf_prog", pfConfig) - pause() + self.waitInterrupt() if __name__ == "__main__": diff --git a/lcc/pylcc/guide/testUprobe.py b/lcc/pylcc/guide/testUprobe.py index 39d0c4e..c0ee271 100644 --- a/lcc/pylcc/guide/testUprobe.py +++ b/lcc/pylcc/guide/testUprobe.py @@ -12,7 +12,6 @@ """ __author__ = 'liaozhaoyan' -from signal import pause from pylcc.lbcBase import ClbcBase bpfPog = r""" @@ -34,7 +33,7 @@ class CtestUprobe(ClbcBase): super(CtestUprobe, self).__init__("tUprobe", bpf_str=bpfPog, attach=0) self.attachUprobe("call_symbol", -1, "/usr/bin/bash", 0x8a870) - pause() + self.waitInterrupt() if __name__ == "__main__": diff --git a/lcc/pylcc/guide/traceUprobe.py b/lcc/pylcc/guide/traceUprobe.py index f1aa266..3d6093a 100644 --- a/lcc/pylcc/guide/traceUprobe.py +++ b/lcc/pylcc/guide/traceUprobe.py @@ -12,16 +12,31 @@ """ __author__ = 'liaozhaoyan' -from signal import pause -from pylcc.lbcBase import ClbcBase +import time +import os +from pylcc.lbcBase import ClbcBase, CeventThread +from pylcc.lbcStack import ClbcUstack bpfPog = r""" #include "lbc.h" +struct data_t { + u32 c_pid; + u32 stack_id; +}; + +LBC_PERF_OUTPUT(e_out, struct data_t, 32); +LBC_STACK(call_stack,32); + SEC("uprobe/*") int call_symbol(struct pt_regs *ctx) { - bpf_printk("catch uprobe.\n"); + struct data_t data = {}; + + data.c_pid = bpf_get_current_pid_tgid() >> 32; + data.stack_id = bpf_get_stackid(ctx, &call_stack, USER_STACKID_FLAGS); + + bpf_perf_event_output(ctx, &e_out, BPF_F_CURRENT_CPU, &data, sizeof(data)); return 0; } @@ -32,11 +47,24 @@ char _license[] SEC("license") = "GPL"; class CtraceUprobe(ClbcBase): def __init__(self): super(CtraceUprobe, self).__init__("traceUprobe", bpf_str=bpfPog, attach=0) - self.traceUprobes("call_symbol", -1, "bash:readline") - pause() + print(os.getpid()) + # self.attachUprobes("call_symbol", -1, "/usr/bin/bash", 567408) + self.traceUprobes("call_symbol", -1, "./user:readline") + + def _cb(self, cpu, e): + print("pool event cpu %d, pid:%d, stackid:%d" % (cpu, e.c_pid, e.stack_id)) + stacks = self.maps['call_stack'].getArr(e.stack_id) + print(stacks) + uStack = ClbcUstack(e.c_pid, stacks) + print(uStack.dumpStacks()) + + def loop(self): + CeventThread(self, 'e_out', self._cb) + self.waitInterrupt() if __name__ == "__main__": - CtraceUprobe() + u = CtraceUprobe() + u.loop() pass diff --git a/lcc/pylcc/lib/lbcBase.py b/lcc/pylcc/lib/lbcBase.py index 20401a0..206b065 100644 --- a/lcc/pylcc/lib/lbcBase.py +++ b/lcc/pylcc/lib/lbcBase.py @@ -20,6 +20,7 @@ import _ctypes as _ct import psutil import json import hashlib +import signal from threading import Thread from multiprocessing import cpu_count from pylcc.lbcMaps import mapsDict @@ -276,9 +277,38 @@ class ClbcBase(ClbcLoad): bpf_so = self._setupSoName(bpf) self._loadSo(bpf_so) self._initSo(attach) + self._setupAttatchs() + self._setupOtherSyms() + self.maps = {} self._loadMaps() + self._cbInterrupt = None + + def so(self): + return self._so + + def _setupOtherSyms(self): + self._so.lbc_bpf_get_maps_id.restype = ct.c_int + self._so.lbc_bpf_get_maps_id.argtypes = [ct.c_char_p] + self._so.lbc_map_lookup_elem.restype = ct.c_int + self._so.lbc_map_lookup_elem.argtypes = [ct.c_int, ct.c_void_p, ct.c_void_p] + self._so.lbc_map_lookup_and_delete_elem.restype = ct.c_int + self._so.lbc_map_lookup_and_delete_elem.argtypes = [ct.c_int, ct.c_void_p, ct.c_void_p] + self._so.lbc_map_delete_elem.restype = ct.c_int + self._so.lbc_map_delete_elem.argtypes = [ct.c_int, ct.c_void_p] + self._so.lbc_map_get_next_key.restype = ct.c_int + self._so.lbc_map_get_next_key.argtypes = [ct.c_int, ct.c_void_p, ct.c_void_p] + + self._so.lbc_event_loop.restype = ct.c_int + self._so.lbc_event_loop.argtypes = [ct.c_int, ct.c_int] + + eventCallback = ct.CFUNCTYPE(None, ct.c_void_p, ct.c_int, ct.c_void_p, ct.c_ulong) + lostCallback = ct.CFUNCTYPE(None, ct.c_void_p, ct.c_int, ct.c_ulonglong) + + self._so.lbc_set_event_cb.restype = ct.c_int + self._so.lbc_set_event_cb.argtypes = [ct.c_int, eventCallback, lostCallback] + def _setupAttatchs(self): # int lbc_attach_perf_event(const char* func, const char* attrs, int pid, int cpu, int group_fd) self._so.lbc_attach_perf_event.restype = ct.c_int @@ -429,7 +459,8 @@ class ClbcBase(ClbcLoad): binaryPath, func = fxpr.split(":", 1) parser = CuprobeParser(binaryPath) fullPath = parser.fullObj() - offset = parser.funAddr(func) + offset = int(parser.funAddr(func), 16) + print(fullPath, offset) self.attachUprobes(function, pid, fullPath, offset) def traceUretprobes(self, function, pid, fxpr): @@ -464,6 +495,15 @@ class ClbcBase(ClbcLoad): if res != 0: raise InvalidArgsException("attach %s to xdp %d failed." % (function, ifindex)) + def _signalInterrupt(self, signum, frame): + self._cbInterrupt() + + def waitInterrupt(self, cb=None): + if cb: + self._cbInterrupt = cb + signal.signal(signal.SIGINT, self._signalInterrupt) + signal.pause() + class CeventThread(Thread): def __init__(self, lbc, event, cb, lost=None): diff --git a/lcc/pylcc/lib/lbcMaps.py b/lcc/pylcc/lib/lbcMaps.py index b58bf1b..f4997e1 100644 --- a/lcc/pylcc/lib/lbcMaps.py +++ b/lcc/pylcc/lib/lbcMaps.py @@ -15,6 +15,7 @@ __author__ = 'liaozhaoyan' import ctypes as ct import struct +from surftrace.surfElf import CstructKsym from sys import version_info try: @@ -124,8 +125,6 @@ class CtypeTable(CtypeData): class CeventBase(object): def __init__(self, so, name): self._so = so - self._so.lbc_bpf_get_maps_id.restype = ct.c_int - self._so.lbc_bpf_get_maps_id.argtypes = [ct.c_char_p] self._id = self._so.lbc_bpf_get_maps_id(ct.c_char_p(name.encode('utf-8'))) if self._id < 0: raise InvalidArgsException("map %s, not such event" % name) @@ -140,17 +139,6 @@ class CtableBase(CeventBase): self._vd = dTypes['vtype'] self.keys = CtypeTable(self._kd) self.values = CtypeTable(self._vd) - self.__setup_localCalls() - - def __setup_localCalls(self): - self._so.lbc_map_lookup_elem.restype = ct.c_int - self._so.lbc_map_lookup_elem.argtypes = [ct.c_int, ct.c_void_p, ct.c_void_p] - self._so.lbc_map_lookup_and_delete_elem.restype = ct.c_int - self._so.lbc_map_lookup_and_delete_elem.argtypes = [ct.c_int, ct.c_void_p, ct.c_void_p] - self._so.lbc_map_delete_elem.restype = ct.c_int - self._so.lbc_map_delete_elem.argtypes = [ct.c_int, ct.c_void_p] - self._so.lbc_map_get_next_key.restype = ct.c_int - self._so.lbc_map_get_next_key.argtypes = [ct.c_int, ct.c_void_p, ct.c_void_p] def _getSize(self, dCell): if dCell['array']: @@ -288,29 +276,12 @@ class CmapsLruPerHash(CtableBase): super(CmapsLruPerHash, self).__init__(so, name, dTypes) -class structKsym(ct.Structure): - _fields_ = [("addr", ct.c_ulong), ("name", ct.c_char_p)] - - class CmapsStack(CtableBase): def __init__(self, so, name, dTypes): super(CmapsStack, self).__init__(so, name, dTypes) - self._so.ksym_search.restype = ct.POINTER(structKsym) - self._so.ksym_search.argtypes = [ct.c_ulong] - - def getStacks(self, stack_id, sLen=-1): - arr = [] - stks = self.getKeyValue(stack_id) - if stks: - if sLen == -1: - sLen = len(stks) - for i in range(sLen): - if stks[i]: - p = self._so.ksym_search(stks[i]) - arr.append(p.contents.name.decode()) - else: - break - return arr + + def getArr(self, stack_id): + return self.getKeyValue(stack_id) class CmapsEvent(CeventBase): @@ -319,11 +290,6 @@ class CmapsEvent(CeventBase): self.__d = dTypes['vtype'] self.cb = None self.lostcb = None - self.__setup_localCalls() - - def __setup_localCalls(self): - self._so.lbc_event_loop.restype = ct.c_int - self._so.lbc_event_loop.argtypes = [ct.c_int, ct.c_int] def open_perf_buffer(self, cb, lost=None): self.cb = cb @@ -352,8 +318,6 @@ class CmapsEvent(CeventBase): lostCallback = ct.CFUNCTYPE(None, ct.c_void_p, ct.c_int, ct.c_ulonglong) _cb = eventCallback(_callback) _lost = lostCallback(_lostcb) - self._so.lbc_set_event_cb.restype = ct.c_int - self._so.lbc_set_event_cb.argtypes = [ct.c_int, eventCallback, lostCallback] self._so.lbc_set_event_cb(self._id, _cb, _lost) self._so.lbc_event_loop(self._id, timeout) diff --git a/lcc/pylcc/pytool/bindsnoop.py b/lcc/pylcc/pytool/bindsnoop.py index 35677fd..3e28194 100644 --- a/lcc/pylcc/pytool/bindsnoop.py +++ b/lcc/pylcc/pytool/bindsnoop.py @@ -13,7 +13,6 @@ __author__ = 'liaozhaoyan' import argparse -from signal import pause from pylcc.lbcBase import ClbcBase # arguments @@ -208,8 +207,7 @@ class Cbindsnoop(ClbcBase): print(maps) def loopCount(self): - pause() - self._showMaps() + self.waitInterrupt(self._showMaps) pass -- Gitee From 44a24d68a099441f0acdeba89068dac65562e3da Mon Sep 17 00:00:00 2001 From: liaozhaoyan Date: Fri, 28 Oct 2022 10:24:57 +0800 Subject: [PATCH 2/2] add sample file for perf hbp. --- lcc/pylcc/inject/sysHigh/20221020_145304.svg | 515 +++++++++++++++++++ lcc/pylcc/inject/sysHigh/Makefile | 21 + lcc/pylcc/inject/sysHigh/fly.py | 60 +++ lcc/pylcc/inject/sysHigh/inject.py | 56 ++ lcc/pylcc/inject/sysHigh/mem.json | 1 + lcc/pylcc/inject/sysHigh/proc_def.h | 34 ++ lcc/pylcc/inject/sysHigh/sys_high.c | 88 ++++ lcc/pylcc/lib/lbcStack.py | 88 ++++ lcc/pylcc/pytool/perfMemFly.py | 139 +++++ 9 files changed, 1002 insertions(+) create mode 100644 lcc/pylcc/inject/sysHigh/20221020_145304.svg create mode 100644 lcc/pylcc/inject/sysHigh/Makefile create mode 100644 lcc/pylcc/inject/sysHigh/fly.py create mode 100644 lcc/pylcc/inject/sysHigh/inject.py create mode 100644 lcc/pylcc/inject/sysHigh/mem.json create mode 100644 lcc/pylcc/inject/sysHigh/proc_def.h create mode 100644 lcc/pylcc/inject/sysHigh/sys_high.c create mode 100644 lcc/pylcc/lib/lbcStack.py create mode 100644 lcc/pylcc/pytool/perfMemFly.py diff --git a/lcc/pylcc/inject/sysHigh/20221020_145304.svg b/lcc/pylcc/inject/sysHigh/20221020_145304.svg new file mode 100644 index 0000000..d214736 --- /dev/null +++ b/lcc/pylcc/inject/sysHigh/20221020_145304.svg @@ -0,0 +1,515 @@ + + + + + + + + + + + + + sysHigh for cpu 0 + + Reset Zoom + Search + + + + total + total (catch 552 samples, 100.000000% from root, 100.000000% from parent) + + total + + + x86_64_start_kernel + x86_64_start_kernel (catch 138 samples, 25.000000% from root, 25.000000% from parent) + + x86_64_start_kernel + + + x86_64_start_reservations + x86_64_start_reservations (catch 138 samples, 25.000000% from root, 100.000000% from parent) + + x86_64_start_reservations + + + start_kernel + start_kernel (catch 138 samples, 25.000000% from root, 100.000000% from parent) + + start_kernel + + + rest_init + rest_init (catch 138 samples, 25.000000% from root, 100.000000% from parent) + + rest_init + + + cpu_startup_entry + cpu_startup_entry (catch 138 samples, 25.000000% from root, 100.000000% from parent) + + cpu_startup_entry + + + default_idle_call + default_idle_call (catch 138 samples, 25.000000% from root, 100.000000% from parent) + + default_idle_call + + + arch_cpu_idle + arch_cpu_idle (catch 138 samples, 25.000000% from root, 100.000000% from parent) + + arch_cpu_idle + + + default_idle + default_idle (catch 138 samples, 25.000000% from root, 100.000000% from parent) + + default_idle + + + reschedule_interrupt + reschedule_interrupt (catch 1 samples, 0.181159% from root, 0.724638% from parent) + + + + + smp_reschedule_interrupt + smp_reschedule_interrupt (catch 1 samples, 0.181159% from root, 100.000000% from parent) + + + + + irq_exit + irq_exit (catch 1 samples, 0.181159% from root, 100.000000% from parent) + + + + + startup_64 + startup_64 (catch 1 samples, 0.181159% from root, 100.000000% from parent) + + + + + native_safe_halt + native_safe_halt (catch 137 samples, 24.818841% from root, 99.275362% from parent) + + native_safe_halt + + + entry_SYSCALL_64_after_swapgs + entry_SYSCALL_64_after_swapgs (catch 414 samples, 75.000000% from root, 75.000000% from parent) + + entry_SYSCALL_64_after_swapgs + + + do_syscall_64 + do_syscall_64 (catch 414 samples, 75.000000% from root, 100.000000% from parent) + + do_syscall_64 + + + sys_write + sys_write (catch 414 samples, 75.000000% from root, 100.000000% from parent) + + sys_write + + + vfs_write + vfs_write (catch 414 samples, 75.000000% from root, 100.000000% from parent) + + vfs_write + + + __vfs_write + __vfs_write (catch 414 samples, 75.000000% from root, 100.000000% from parent) + + __vfs_write + + + proc_reg_write + proc_reg_write (catch 414 samples, 75.000000% from root, 100.000000% from parent) + + proc_reg_write + + + sys_high_write [sys_high] + sys_high_write [sys_high] (catch 414 samples, 75.000000% from root, 100.000000% from parent) + + sys_high_write [sys_high] + + + apic_timer_interrupt + apic_timer_interrupt (catch 8 samples, 1.449275% from root, 1.932367% from parent) + + + + + smp_apic_timer_interrupt + smp_apic_timer_interrupt (catch 8 samples, 1.449275% from root, 100.000000% from parent) + + + + + irq_exit + irq_exit (catch 8 samples, 1.449275% from root, 100.000000% from parent) + + + + + __do_softirq + __do_softirq (catch 7 samples, 1.268116% from root, 87.500000% from parent) + + + + + _raw_spin_lock_irq + _raw_spin_lock_irq (catch 1 samples, 0.181159% from root, 14.285714% from parent) + + + + + run_timer_softirq + run_timer_softirq (catch 1 samples, 0.181159% from root, 12.500000% from parent) + + + + + sys_high_store [sys_high] + sys_high_store [sys_high] (catch 406 samples, 73.550725% from root, 98.067633% from parent) + + sys_high_store [sys_high] + + + \ No newline at end of file diff --git a/lcc/pylcc/inject/sysHigh/Makefile b/lcc/pylcc/inject/sysHigh/Makefile new file mode 100644 index 0000000..d26e63e --- /dev/null +++ b/lcc/pylcc/inject/sysHigh/Makefile @@ -0,0 +1,21 @@ +obj-m += sys_high.o + +ifneq ($(KERNELVER),) + KERNELDIR := /usr/src/kernels/$(KERNELVER) +endif + +ifeq ($(KERNELDIR),) + KERNELDIR := /lib/modules/$(shell uname -r)/build +endif +PWD := $(shell pwd) +all: + $(MAKE) -C $(KERNELDIR) M=$(PWD) modules + +clean: + rm -rf *.ko *.mod* *.o modules.* Module.symvers + +install: + insmod sys_high.ko + +remove: + rmmod sys_high \ No newline at end of file diff --git a/lcc/pylcc/inject/sysHigh/fly.py b/lcc/pylcc/inject/sysHigh/fly.py new file mode 100644 index 0000000..ccc046f --- /dev/null +++ b/lcc/pylcc/inject/sysHigh/fly.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- +""" +------------------------------------------------- + File Name: fly + Description : + Author : liaozhaoyan + date: 2022/10/27 +------------------------------------------------- + Change Activity: + 2022/10/27: +------------------------------------------------- +""" +__author__ = 'liaozhaoyan' + +import os +import time +import random +from multiprocessing import Process + + +PROC_FILE = "/proc/coolbpf/sys_fly" + + +class CworkThread(Process): + def __init__(self): + super(CworkThread, self).__init__() + self.start() + + def run(self): + while True: + fd = os.open(PROC_FILE, os.O_RDWR) + p, v = os.read(fd, 64).decode().split(':') + v = int(v) + 1 + os.write(fd, "%d".encode() % v) + os.close(fd) + + time.sleep(1) + + +class CnoiseThread(Process): + def __init__(self): + super(CnoiseThread, self).__init__() + self.start() + + def run(self): + while True: + time.sleep(random.randint(15, 30)) + fd = os.open(PROC_FILE, os.O_RDWR) + p, v = os.read(fd, 64).decode().split(':') + v = int(v) + 10 + os.write(fd, "%d".encode() % v) + os.close(fd) + + +if __name__ == "__main__": + w = CworkThread() + n = CnoiseThread() + w.join() + n.join() + pass diff --git a/lcc/pylcc/inject/sysHigh/inject.py b/lcc/pylcc/inject/sysHigh/inject.py new file mode 100644 index 0000000..8026cfa --- /dev/null +++ b/lcc/pylcc/inject/sysHigh/inject.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +""" +------------------------------------------------- + File Name: inject.py + Description : + Author : liaozhaoyan + date: 2022/10/20 +------------------------------------------------- + Change Activity: + 2022/10/20: +------------------------------------------------- +""" +__author__ = 'liaozhaoyan' + +import time +import argparse + + +class Cinject(object): + def __init__(self, interval, loop, total): + super(Cinject, self).__init__() + self._interval = interval + self._loop = loop + self._total = total + + def _inject(self): + with open("/proc/coolbpf/sys_high", "w") as f: + f.write("%d" % self._loop) + + def work(self): + start = time.time() + for i in range(self._total): + self._inject() + time.sleep(self._interval) + end = time.time() + print("test use %f seconds." % (end - start)) + + +if __name__ == "__main__": + examples = """examples: python inject -i 0.5 -l 1000000 -t 100""" + + parser = argparse.ArgumentParser( + description="inject sys high.", + formatter_class=argparse.RawDescriptionHelpFormatter, + epilog=examples + ) + parser.add_argument('-i', '--interval', type=float, dest='interval', default=0.1, + help='set injecting interval time, uint second.') + parser.add_argument('-l', '--loop', type=int, dest='loop', default=10000, + help='set kernel loops.') + parser.add_argument('-t', '--total', type=int, dest='total', default=100, + help='set total inject times.') + args = parser.parse_args() + inj = Cinject(args.interval, args.loop, args.total) + inj.work() + pass diff --git a/lcc/pylcc/inject/sysHigh/mem.json b/lcc/pylcc/inject/sysHigh/mem.json new file mode 100644 index 0000000..c48d2a6 --- /dev/null +++ b/lcc/pylcc/inject/sysHigh/mem.json @@ -0,0 +1 @@ +[{"name": "11030", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 0, "tid": "python:15237", "ph": "B"}, {"name": "11030", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 1001302}, {"name": "11031", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 1001302, "tid": "python:15237", "ph": "B"}, {"name": "11031", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 2002607}, {"name": "11032", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 2002607, "tid": "python:15237", "ph": "B"}, {"name": "11032", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 3003935}, {"name": "11033", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 3003935, "tid": "python:15237", "ph": "B"}, {"name": "11033", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 4005213}, {"name": "11034", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 4005213, "tid": "python:15237", "ph": "B"}, {"name": "11034", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 5006511}, {"name": "11035", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 5006511, "tid": "python:15237", "ph": "B"}, {"name": "11035", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 6007797}, {"name": "11036", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 6007797, "tid": "python:15237", "ph": "B"}, {"name": "11036", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 7009042}, {"name": "11037", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 7009042, "tid": "python:15237", "ph": "B"}, {"name": "11037", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 8010328}, {"name": "11038", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 8010328, "tid": "python:15237", "ph": "B"}, {"name": "11038", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 9002505}, {"name": "11048", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 9002505, "tid": "python:15238", "ph": "B"}, {"name": "11048", "tid": "python:15238", "ph": "E", "pid": "mem", "ts": 9011529}, {"name": "11049", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 9011529, "tid": "python:15237", "ph": "B"}, {"name": "11049", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 10012828}, {"name": "11050", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 10012828, "tid": "python:15237", "ph": "B"}, {"name": "11050", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 11014120}, {"name": "11051", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 11014120, "tid": "python:15237", "ph": "B"}, {"name": "11051", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 12015429}, {"name": "11052", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 12015429, "tid": "python:15237", "ph": "B"}, {"name": "11052", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 13016726}, {"name": "11053", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 13016726, "tid": "python:15237", "ph": "B"}, {"name": "11053", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 14018019}, {"name": "11054", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 14018019, "tid": "python:15237", "ph": "B"}, {"name": "11054", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 15019308}, {"name": "11055", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 15019308, "tid": "python:15237", "ph": "B"}, {"name": "11055", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 16020634}, {"name": "11056", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 16020634, "tid": "python:15237", "ph": "B"}, {"name": "11056", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 17022030}, {"name": "11057", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 17022030, "tid": "python:15237", "ph": "B"}, {"name": "11057", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 18023363}, {"name": "11058", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 18023363, "tid": "python:15237", "ph": "B"}, {"name": "11058", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 19024786}, {"name": "11059", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 19024786, "tid": "python:15237", "ph": "B"}, {"name": "11059", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 20026219}, {"name": "11060", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 20026219, "tid": "python:15237", "ph": "B"}, {"name": "11060", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 21027583}, {"name": "11061", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 21027583, "tid": "python:15237", "ph": "B"}, {"name": "11061", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 22028935}, {"name": "11062", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 22028935, "tid": "python:15237", "ph": "B"}, {"name": "11062", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 23030257}, {"name": "11063", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 23030257, "tid": "python:15237", "ph": "B"}, {"name": "11063", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 24004091}, {"name": "11073", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 24004091, "tid": "python:15238", "ph": "B"}, {"name": "11073", "tid": "python:15238", "ph": "E", "pid": "mem", "ts": 24031475}, {"name": "11074", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 24031475, "tid": "python:15237", "ph": "B"}, {"name": "11074", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 25032758}, {"name": "11075", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 25032758, "tid": "python:15237", "ph": "B"}, {"name": "11075", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 26034088}, {"name": "11076", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 26034088, "tid": "python:15237", "ph": "B"}, {"name": "11076", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 27035415}, {"name": "11077", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 27035415, "tid": "python:15237", "ph": "B"}, {"name": "11077", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 28036704}, {"name": "11078", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 28036704, "tid": "python:15237", "ph": "B"}, {"name": "11078", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 29038018}, {"name": "11079", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 29038018, "tid": "python:15237", "ph": "B"}, {"name": "11079", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 30039320}, {"name": "11080", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 30039320, "tid": "python:15237", "ph": "B"}, {"name": "11080", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 31040694}, {"name": "11081", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 31040694, "tid": "python:15237", "ph": "B"}, {"name": "11081", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 32042000}, {"name": "11082", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 32042000, "tid": "python:15237", "ph": "B"}, {"name": "11082", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 33043317}, {"name": "11083", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 33043317, "tid": "python:15237", "ph": "B"}, {"name": "11083", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 34044610}, {"name": "11084", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 34044610, "tid": "python:15237", "ph": "B"}, {"name": "11084", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 35045968}, {"name": "11085", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 35045968, "tid": "python:15237", "ph": "B"}, {"name": "11085", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 36046978}, {"name": "11086", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 36046978, "tid": "python:15237", "ph": "B"}, {"name": "11086", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 37048272}, {"name": "11087", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 37048272, "tid": "python:15237", "ph": "B"}, {"name": "11087", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 38049577}, {"name": "11088", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 38049577, "tid": "python:15237", "ph": "B"}, {"name": "11088", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 39050891}, {"name": "11089", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 39050891, "tid": "python:15237", "ph": "B"}, {"name": "11089", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 40052181}, {"name": "11090", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 40052181, "tid": "python:15237", "ph": "B"}, {"name": "11090", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 41053476}, {"name": "11091", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 41053476, "tid": "python:15237", "ph": "B"}, {"name": "11091", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 42054767}, {"name": "11092", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 42054767, "tid": "python:15237", "ph": "B"}, {"name": "11092", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 43056104}, {"name": "11093", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 43056104, "tid": "python:15237", "ph": "B"}, {"name": "11093", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 44057011}, {"name": "11094", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 44057011, "tid": "python:15237", "ph": "B"}, {"name": "11094", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 45025406}, {"name": "11104", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 45025406, "tid": "python:15238", "ph": "B"}, {"name": "11104", "tid": "python:15238", "ph": "E", "pid": "mem", "ts": 45058261}, {"name": "11105", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 45058261, "tid": "python:15237", "ph": "B"}, {"name": "11105", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 46059564}, {"name": "11106", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 46059564, "tid": "python:15237", "ph": "B"}, {"name": "11106", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 47060887}, {"name": "11107", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 47060887, "tid": "python:15237", "ph": "B"}, {"name": "11107", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 48061895}, {"name": "11108", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 48061895, "tid": "python:15237", "ph": "B"}, {"name": "11108", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 49063204}, {"name": "11109", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 49063204, "tid": "python:15237", "ph": "B"}, {"name": "11109", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 50063778}, {"name": "11110", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 50063778, "tid": "python:15237", "ph": "B"}, {"name": "11110", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 51065158}, {"name": "11111", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 51065158, "tid": "python:15237", "ph": "B"}, {"name": "11111", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 52066498}, {"name": "11112", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 52066498, "tid": "python:15237", "ph": "B"}, {"name": "11112", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 53067788}, {"name": "11113", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 53067788, "tid": "python:15237", "ph": "B"}, {"name": "11113", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 54069098}, {"name": "11114", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 54069098, "tid": "python:15237", "ph": "B"}, {"name": "11114", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 55070408}, {"name": "11115", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 55070408, "tid": "python:15237", "ph": "B"}, {"name": "11115", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 56071719}, {"name": "11116", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 56071719, "tid": "python:15237", "ph": "B"}, {"name": "11116", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 57073028}, {"name": "11117", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 57073028, "tid": "python:15237", "ph": "B"}, {"name": "11117", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 58074009}, {"name": "11118", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 58074009, "tid": "python:15237", "ph": "B"}, {"name": "11118", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 59074970}, {"name": "11119", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 59074970, "tid": "python:15237", "ph": "B"}, {"name": "11119", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 60075715}, {"name": "11120", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 60075715, "tid": "python:15237", "ph": "B"}, {"name": "11120", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 61077019}, {"name": "11121", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 61077019, "tid": "python:15237", "ph": "B"}, {"name": "11121", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 62078316}, {"name": "11122", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 62078316, "tid": "python:15237", "ph": "B"}, {"name": "11122", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 63079676}, {"name": "11123", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 63079676, "tid": "python:15237", "ph": "B"}, {"name": "11123", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 64080996}, {"name": "11124", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 64080996, "tid": "python:15237", "ph": "B"}, {"name": "11124", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 65082290}, {"name": "11125", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 65082290, "tid": "python:15237", "ph": "B"}, {"name": "11125", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 66046727}, {"name": "11135", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 66046727, "tid": "python:15238", "ph": "B"}, {"name": "11135", "tid": "python:15238", "ph": "E", "pid": "mem", "ts": 66083521}, {"name": "11136", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 66083521, "tid": "python:15237", "ph": "B"}, {"name": "11136", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 67084847}, {"name": "11137", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 67084847, "tid": "python:15237", "ph": "B"}, {"name": "11137", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 68086149}, {"name": "11138", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 68086149, "tid": "python:15237", "ph": "B"}, {"name": "11138", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 69087482}, {"name": "11139", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 69087482, "tid": "python:15237", "ph": "B"}, {"name": "11139", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 70088794}, {"name": "11140", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 70088794, "tid": "python:15237", "ph": "B"}, {"name": "11140", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 71090108}, {"name": "11141", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 71090108, "tid": "python:15237", "ph": "B"}, {"name": "11141", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 72091409}, {"name": "11142", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 72091409, "tid": "python:15237", "ph": "B"}, {"name": "11142", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 73092720}, {"name": "11143", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 73092720, "tid": "python:15237", "ph": "B"}, {"name": "11143", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 74094024}, {"name": "11144", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 74094024, "tid": "python:15237", "ph": "B"}, {"name": "11144", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 75095325}, {"name": "11145", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 75095325, "tid": "python:15237", "ph": "B"}, {"name": "11145", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 76096708}, {"name": "11146", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 76096708, "tid": "python:15237", "ph": "B"}, {"name": "11146", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 77098036}, {"name": "11147", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 77098036, "tid": "python:15237", "ph": "B"}, {"name": "11147", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 78099359}, {"name": "11148", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 78099359, "tid": "python:15237", "ph": "B"}, {"name": "11148", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 79100750}, {"name": "11149", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 79100750, "tid": "python:15237", "ph": "B"}, {"name": "11149", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 80102121}, {"name": "11150", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 80102121, "tid": "python:15237", "ph": "B"}, {"name": "11150", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 81103442}, {"name": "11151", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 81103442, "tid": "python:15237", "ph": "B"}, {"name": "11151", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 82104757}, {"name": "11152", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 82104757, "tid": "python:15237", "ph": "B"}, {"name": "11152", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 83106123}, {"name": "11153", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 83106123, "tid": "python:15237", "ph": "B"}, {"name": "11153", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 84107458}, {"name": "11154", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 84107458, "tid": "python:15237", "ph": "B"}, {"name": "11154", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 85108769}, {"name": "11155", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 85108769, "tid": "python:15237", "ph": "B"}, {"name": "11155", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 86110099}, {"name": "11156", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 86110099, "tid": "python:15237", "ph": "B"}, {"name": "11156", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 87111407}, {"name": "11157", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 87111407, "tid": "python:15237", "ph": "B"}, {"name": "11157", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 88112742}, {"name": "11158", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 88112742, "tid": "python:15237", "ph": "B"}, {"name": "11158", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 89114077}, {"name": "11159", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 89114077, "tid": "python:15237", "ph": "B"}, {"name": "11159", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 90115498}, {"name": "11160", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 90115498, "tid": "python:15237", "ph": "B"}, {"name": "11160", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 91116927}, {"name": "11161", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 91116927, "tid": "python:15237", "ph": "B"}, {"name": "11161", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 92118286}, {"name": "11162", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 92118286, "tid": "python:15237", "ph": "B"}, {"name": "11162", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 93074099}, {"name": "11172", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 93074099, "tid": "python:15238", "ph": "B"}, {"name": "11172", "tid": "python:15238", "ph": "E", "pid": "mem", "ts": 93119626}, {"name": "11173", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 93119626, "tid": "python:15237", "ph": "B"}, {"name": "11173", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 94120996}, {"name": "11174", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 94120996, "tid": "python:15237", "ph": "B"}, {"name": "11174", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 95122317}, {"name": "11175", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 95122317, "tid": "python:15237", "ph": "B"}, {"name": "11175", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 96123628}, {"name": "11176", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 96123628, "tid": "python:15237", "ph": "B"}, {"name": "11176", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 97124959}, {"name": "11177", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 97124959, "tid": "python:15237", "ph": "B"}, {"name": "11177", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 98126249}, {"name": "11178", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 98126249, "tid": "python:15237", "ph": "B"}, {"name": "11178", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 99127568}, {"name": "11179", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 99127568, "tid": "python:15237", "ph": "B"}, {"name": "11179", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 100128924}, {"name": "11180", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 100128924, "tid": "python:15237", "ph": "B"}, {"name": "11180", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 101130240}, {"name": "11181", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 101130240, "tid": "python:15237", "ph": "B"}, {"name": "11181", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 102131555}, {"name": "11182", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 102131555, "tid": "python:15237", "ph": "B"}, {"name": "11182", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 103132882}, {"name": "11183", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 103132882, "tid": "python:15237", "ph": "B"}, {"name": "11183", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 104134187}, {"name": "11184", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 104134187, "tid": "python:15237", "ph": "B"}, {"name": "11184", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 105135519}, {"name": "11185", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 105135519, "tid": "python:15237", "ph": "B"}, {"name": "11185", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 106136851}, {"name": "11186", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 106136851, "tid": "python:15237", "ph": "B"}, {"name": "11186", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 107138159}, {"name": "11187", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 107138159, "tid": "python:15237", "ph": "B"}, {"name": "11187", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 108139467}, {"name": "11188", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 108139467, "tid": "python:15237", "ph": "B"}, {"name": "11188", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 109140752}, {"name": "11189", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 109140752, "tid": "python:15237", "ph": "B"}, {"name": "11189", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 110142064}, {"name": "11190", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 110142064, "tid": "python:15237", "ph": "B"}, {"name": "11190", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 111143373}, {"name": "11191", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 111143373, "tid": "python:15237", "ph": "B"}, {"name": "11191", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 112144687}, {"name": "11192", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 112144687, "tid": "python:15237", "ph": "B"}, {"name": "11192", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 113146003}, {"name": "11193", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 113146003, "tid": "python:15237", "ph": "B"}, {"name": "11193", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 114147306}, {"name": "11194", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 114147306, "tid": "python:15237", "ph": "B"}, {"name": "11194", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 115148628}, {"name": "11195", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 115148628, "tid": "python:15237", "ph": "B"}, {"name": "11195", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 116149956}, {"name": "11196", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 116149956, "tid": "python:15237", "ph": "B"}, {"name": "11196", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 117095063}, {"name": "11206", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 117095063, "tid": "python:15238", "ph": "B"}, {"name": "11206", "tid": "python:15238", "ph": "E", "pid": "mem", "ts": 117151184}, {"name": "11207", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 117151184, "tid": "python:15237", "ph": "B"}, {"name": "11207", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 118152490}, {"name": "11208", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 118152490, "tid": "python:15237", "ph": "B"}, {"name": "11208", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 119153800}, {"name": "11209", "args": {"stacks": "_kstrtoull\nkstrtoull_from_user\nsys_fly_write [sys_high]"}, "pid": "mem", "ts": 119153800, "tid": "python:15237", "ph": "B"}, {"name": "11209", "tid": "python:15237", "ph": "E", "pid": "mem", "ts": 119153801}] \ No newline at end of file diff --git a/lcc/pylcc/inject/sysHigh/proc_def.h b/lcc/pylcc/inject/sysHigh/proc_def.h new file mode 100644 index 0000000..ca12bfd --- /dev/null +++ b/lcc/pylcc/inject/sysHigh/proc_def.h @@ -0,0 +1,34 @@ +#ifndef PROC_DEF_H +#define PROC_DEF_H +#include +#include + +#define DEFINE_PROC_ATTRIBUTE(name, __write) \ + static int name##_open(struct inode *inode, struct file *file) \ + { \ + return single_open(file, name##_show, PDE_DATA(inode)); \ + } \ + \ + static const struct file_operations name##_fops = { \ + .owner = THIS_MODULE, \ + .open = name##_open, \ + .read = seq_read, \ + .write = __write, \ + .llseek = seq_lseek, \ + .release = single_release, \ + } + +#define DEFINE_PROC_ATTRIBUTE_RW(name) \ + static ssize_t name##_write(struct file *file, \ + const char __user *buf, \ + size_t count, loff_t *ppos) \ + { \ + return name##_store(PDE_DATA(file_inode(file)), buf, \ + count); \ + } \ + DEFINE_PROC_ATTRIBUTE(name, name##_write) + +#define DEFINE_PROC_ATTRIBUTE_RO(name) \ + DEFINE_PROC_ATTRIBUTE(name, NULL) + +#endif \ No newline at end of file diff --git a/lcc/pylcc/inject/sysHigh/sys_high.c b/lcc/pylcc/inject/sysHigh/sys_high.c new file mode 100644 index 0000000..b8290cf --- /dev/null +++ b/lcc/pylcc/inject/sysHigh/sys_high.c @@ -0,0 +1,88 @@ +#include +#include +#include +#include "proc_def.h" + +#define PROC_PATH "coolbpf" + +static int sys_high_show(struct seq_file *m, void *ptr) +{ + seq_printf(m, "%llu\n", 0ULL); + return 0; +} + +static ssize_t __attribute__((optimize("O0"))) sys_high_store(void *priv, const char __user *buf, size_t count) +{ + u64 val; + u64 i, j; + + if (kstrtou64_from_user(buf, count, 0, &val)) + return -EINVAL; + + for (i = 0; i < val; i ++) + for (j = 0; j < val; j ++); + return count; +} +DEFINE_PROC_ATTRIBUTE_RW(sys_high); + +static u64* sys_fly_var = NULL; +static int sys_fly_show(struct seq_file *m, void *ptr) +{ + seq_printf(m, "0x%llx: %llu\n", (u64)sys_fly_var, *sys_fly_var); + return 0; +} + +static ssize_t sys_fly_store(void *priv, const char __user *buf, size_t count) +{ + if (kstrtou64_from_user(buf, count, 0, sys_fly_var)) + return -EINVAL; + + return count; +} +DEFINE_PROC_ATTRIBUTE_RW(sys_fly); + +static int __init sys_high_init(void) +{ + int ret; + struct proc_dir_entry *root_dir = NULL; + + root_dir = proc_mkdir(PROC_PATH, NULL); + if (!root_dir) { + ret = -ENOMEM; + } + + if (!proc_create("sys_high", S_IRUSR | S_IWUSR, root_dir, + &sys_high_fops)){ + ret = -ENOMEM; + goto remove_proc; + } + + sys_fly_var = (u64*)kmalloc(sizeof(u64), GFP_KERNEL); + *sys_fly_var = 0ULL; + if (sys_fly_var == NULL) { + ret = -ENOMEM; + goto remove_proc; + } + if (!proc_create("sys_fly", S_IRUSR | S_IWUSR, root_dir, + &sys_fly_fops)){ + ret = -ENOMEM; + goto free_var; + } + return 0; + +free_var: + kfree(sys_fly_var); +remove_proc: + remove_proc_subtree(PROC_PATH, NULL); + return -ret; +} + +static void __exit sys_high_exit(void) +{ + kfree(sys_fly_var); + remove_proc_subtree(PROC_PATH, NULL); +} + +module_init(sys_high_init); +module_exit(sys_high_exit); +MODULE_LICENSE("GPL"); diff --git a/lcc/pylcc/lib/lbcStack.py b/lcc/pylcc/lib/lbcStack.py new file mode 100644 index 0000000..6c3250c --- /dev/null +++ b/lcc/pylcc/lib/lbcStack.py @@ -0,0 +1,88 @@ +# -*- coding: utf-8 -*- +""" +------------------------------------------------- + File Name: lbcUstack + Description : + Author : liaozhaoyan + date: 2022/10/23 +------------------------------------------------- + Change Activity: + 2022/10/23: +------------------------------------------------- +""" +__author__ = 'liaozhaoyan' + +import re +from surftrace.surfElf import CelfSym + + +class ClbcUstack(object): + def __init__(self, pid, addrs): + super(ClbcUstack, self).__init__() + self._pid = pid + self._addrs = addrs + self._mmap = self._loadMmaps() + self._elfs = {} + + def _loadMmaps(self): + pathName = "/proc/%d/maps" % self._pid + + with open(pathName, 'r') as f: + lines = f.readlines() + + maps = [] + for line in lines: + line = re.sub(r" +", " ", line.strip()) + cells = line.split(' ') + if 'x' in cells[1]: + start, end = cells[0].split('-') + d = {"start": int(start, 16), "end": int(end, 16)} + if len(cells) == 5: + d["path"] = None + else: + d["path"] = cells[5] + maps.append(d) + return maps + + def _queryElf(self, addr): + for mmap in self._mmap: + if mmap['start'] <= addr < mmap['end']: + return mmap["path"], mmap['start'] + + raise OSError("addr 0x%x is an illegal value" % addr) + + def dumpStacks(self): + lines = [] + for addr in self._addrs: + if addr == 0: + break + try: + fPath, start = self._queryElf(addr) + except OSError: + break + addr -= start + if fPath not in self._elfs: + self._elfs[fPath] = CelfSym(fPath) + + sym, offset = self._elfs[fPath].addr2sym(addr) + lines.append("%s + 0x%x" % (sym, offset)) + return lines + + +def getKStacks(maps, stack_id, elfSym, sLen=-1): + arr = [] + stks = maps.getArr(stack_id) + if stks: + if sLen == -1: + sLen = len(stks) + for i in range(sLen): + if stks[i]: + name, _ = elfSym.ksymSearch(stks[i]) + arr.append(name) + else: + break + return arr + + +if __name__ == "__main__": + pass diff --git a/lcc/pylcc/pytool/perfMemFly.py b/lcc/pylcc/pytool/perfMemFly.py new file mode 100644 index 0000000..a6d1f74 --- /dev/null +++ b/lcc/pylcc/pytool/perfMemFly.py @@ -0,0 +1,139 @@ +# -*- coding: utf-8 -*- +""" +------------------------------------------------- + File Name: perfMemFly + Description : + Author : liaozhaoyan + date: 2022/10/27 +------------------------------------------------- + Change Activity: + 2022/10/27: +------------------------------------------------- +""" +__author__ = 'liaozhaoyan' + +import os +import json +from pylcc.lbcBase import ClbcBase, CeventThread +from surftrace.surfElf import CelfKsym +from pylcc.lbcStack import getKStacks +from pylcc.perfEvent import * + +PROC_FILE = "/proc/coolbpf/sys_fly" + + +bpfPog = r""" +#include "lbc.h" +struct data_t { + int pid; + int stack_id; + u64 ts; + u64 addr; + u64 value; + char comm[16]; +}; + +LBC_PERF_OUTPUT(e_out, struct data_t, 128); +LBC_STACK(call_stack, 4096); + +SEC("perf_event") +int bpf_prog(struct bpf_perf_event_data *ctx) +{ + struct data_t data = {}; + u64* addr = (u64*)(ctx->addr); + + data.stack_id = bpf_get_stackid(ctx, &call_stack, KERN_STACKID_FLAGS); + data.pid = bpf_get_current_pid_tgid() >> 32; + bpf_get_current_comm(&data.comm, 16); + + data.ts = bpf_ktime_get_ns(); + data.addr = ctx->addr; + data.value = _(*addr); + + bpf_perf_event_output(ctx, &e_out, BPF_F_CURRENT_CPU, &data, sizeof(data)); + return 0; +} + +char _license[] SEC("license") = "GPL"; +""" + + +class CperfMemFly(ClbcBase): + def __init__(self): + super(CperfMemFly, self).__init__("pMmeFly", bpf_str=bpfPog) + addr = self._getAddr() + self._setupPerf(addr) + self._ksym = CelfKsym() + + self._lastTs = 0 + self._beg = 0 + self._lastD = {} + self._arr = [] + + @staticmethod + def _getAddr(): + fd = os.open(PROC_FILE, os.O_RDWR) + p, v = os.read(fd, 64).decode().split(':') + os.close(fd) + return int(p, 16) + + def _setupPerf(self, addr): + pfConfig = { + "type": PerfType.BREAKPOINT, + "size": PERF_ATTR_SIZE_VER5, + "sample_period": 1, + "precise_ip": 2, + "wakeup_events": 1, + "bp_type": PerfBreakPointType.W, + "bp_addr": addr, + "bp_len": 8, + } + self.attachAllCpuPerf("bpf_prog", pfConfig, flags=PerfFlag.FD_CLOEXEC) + + def _cb(self, cpu, e): + print("cpu %d, pid: %d, comm:%s" % (cpu, e.pid, e.comm)) + print("set addr 0x%x to %d in %d ns" % (e.addr, e.value, e.ts)) + stacks = getKStacks(self.maps['call_stack'], e.stack_id, self._ksym) + print("call stack:") + print("\t" + "\n\t".join(stacks)) + self._saveTrace(e) + + def _saveTrace(self, e): + now = int(e.ts / 1000) + if self._lastTs: + self._lastD["ph"] = "E" + self._lastD["ts"] = now - self._beg + self._arr.append(self._lastD) + else: + self._beg = now + + d = {"name": str(e.value), + "pid": "mem", + "tid": "%s:%d" % (e.comm, e.pid), + "ph": "B", + "ts": now - self._beg, + "args": {"stacks": "\n".join(getKStacks(self.maps['call_stack'], e.stack_id, self._ksym))} + } + self._arr.append(d) + + self._lastTs = now + self._lastD = d.copy() + del self._lastD["args"] + + def _cbExit(self): + self._lastD["ph"] = "E" + self._lastD["ts"] += 1 + self._arr.append(self._lastD) + + with open("mem.json", "w") as f: + json.dump(self._arr, f) + + def loop(self): + CeventThread(self, 'e_out', self._cb) + self.waitInterrupt(self._cbExit) + + +if __name__ == "__main__": + fly = CperfMemFly() + fly.loop() + pass -- Gitee