-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: iipeace <[email protected]>
- Loading branch information
Showing
1 changed file
with
117 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
__credits__ = "Peace Lee" | ||
__license__ = "GPLv2" | ||
__version__ = "3.9.8" | ||
__revision__ = "231129" | ||
__revision__ = "231130" | ||
__maintainer__ = "Peace Lee" | ||
__email__ = "[email protected]" | ||
__repository__ = "https://github.com/iipeace/guider" | ||
|
@@ -33560,7 +33560,9 @@ def readMemoryMap(): | |
|
||
@staticmethod | ||
def readDmabufStats(): | ||
if not SysMgr.memEnable or "NODMABUF" in SysMgr.environList: | ||
if "DMABUF" in SysMgr.environList: | ||
pass | ||
elif not SysMgr.memEnable or "NODMABUF" in SysMgr.environList: | ||
return {} | ||
|
||
dpath = "/sys/kernel/dmabuf/buffers" | ||
|
@@ -33575,7 +33577,7 @@ def readDmabufStats(): | |
mpath = os.path.join(dpath, inode) | ||
for f in os.listdir(mpath): | ||
fpath = os.path.join(mpath, f) | ||
stats[inode][f] = SysMgr.readFile(fpath) | ||
stats[inode][f] = SysMgr.readFile(fpath, verb=False) | ||
except SystemExit: | ||
sys.exit(0) | ||
except: | ||
|
@@ -34371,6 +34373,9 @@ def printHelp(force=False, isExit=True): | |
- {3:1} {2:1} with LMK info | ||
# {0:1} {1:1} -q LMKINFO | ||
|
||
- {3:1} {2:1} with dmabuf usage | ||
# {0:1} {1:1} -q DMABUF | ||
|
||
- {3:1} all {2:1} and execute specific commands to save also their output when terminated | ||
# {0:1} {1:1} -a -o -q PRINTCMD:"DLT#GUIDER printdlt -a -q LASTFILE\, TAIL:-3\, UNTIL -d L -Q", DLTTIME | ||
# {0:1} {1:1} -a -o -q PRINTCMD:"KERNEL#GUIDER printkmsg -a -q TAIL:-3\, UNTIL -d L -Q" | ||
|
@@ -106171,6 +106176,7 @@ def __init__(self, fpath=None, onlyInstance=False): | |
self.abnormalTasks = {} | ||
self.intervalData = {} | ||
self.intervalFileData = {} | ||
self.fdinfoData = {} | ||
|
||
# set index of attributes # | ||
self.majfltIdx = ConfigMgr.PROCSTAT_ATTR.index("MAJFLT") | ||
|
@@ -126223,6 +126229,42 @@ def printFileStat(self, filters): | |
# print buffer # | ||
SysMgr.printTopStats() | ||
|
||
def saveFdinfoData(self, pid, filterList=[]): | ||
try: | ||
# skip kernel thread # | ||
if SysMgr.isKernelTask(pid): | ||
return | ||
|
||
dirpath = "%s/%s/fdinfo" % (SysMgr.procPath, pid) | ||
for fd in os.listdir(dirpath): | ||
fdpath = os.path.join(dirpath, fd) | ||
|
||
data = SysMgr.readFile(fdpath, verb=False) | ||
if not data: | ||
continue | ||
elif filterList and not UtilMgr.isValidStr( | ||
data, filterList, inc=True | ||
): | ||
continue | ||
|
||
if not pid in self.fdinfoData: | ||
self.fdinfoData[pid] = {} | ||
if not fd in self.fdinfoData[pid]: | ||
self.fdinfoData[pid][fd] = {} | ||
|
||
for item in data.split("\n"): | ||
name, val = item.split(":", 1) | ||
val = val.strip() | ||
self.fdinfoData[pid][fd][name] = val | ||
except SystemExit: | ||
sys.exit(0) | ||
except: | ||
SysMgr.printWarn( | ||
"failed to get fdinfo data for %s(%s)" | ||
% (pid, self.procData[pid]["comm"]), | ||
reason=True, | ||
) | ||
|
||
def saveFileStat(self, filters): | ||
# save proc and file instance # | ||
SysMgr.topInstance = self | ||
|
@@ -127423,6 +127465,8 @@ def saveSystemStat(self, saveProc=True): | |
self.saveVmInfo() | ||
self.saveZoneInfo() | ||
self.saveDmabufInfo() | ||
elif "DMABUF" in SysMgr.environList: | ||
self.saveDmabufInfo() | ||
|
||
# save GPU memory info # | ||
self.gpuMemData, _ = SysMgr.getGpuMem() | ||
|
@@ -133874,6 +133918,10 @@ def _memFactorPG(stat): | |
if SysMgr.wchanEnable: | ||
self.saveProcWchanData(value["taskPath"], idx) | ||
|
||
# save fdinfo # | ||
if "DMABUF" in SysMgr.environList: | ||
self.saveFdinfoData(idx) | ||
|
||
# save memory map info to get memory details # | ||
if SysMgr.memEnable and ( | ||
smapsEnable or SysMgr.pssEnable or SysMgr.ussEnable | ||
|
@@ -134473,9 +134521,11 @@ def _memFactorPG(stat): | |
pass | ||
|
||
if memstr: | ||
SysMgr.addPrint( | ||
ret = SysMgr.addPrint( | ||
"{0:>39} | {1:111}|\n".format("MEM(SUM)", memstr[:-2]) | ||
) | ||
if not ret: | ||
return | ||
|
||
# print items # | ||
for ef, ev, ee, es, en in ( | ||
|
@@ -134492,20 +134542,24 @@ def _memFactorPG(stat): | |
eeVal = SysMgr.environList.get(ee) | ||
if not eeVal or UtilMgr.isValidStr(value[ev], eeVal): | ||
content = value[ev].rstrip(es) if es else value[ev] | ||
SysMgr.addPrint( | ||
ret = SysMgr.addPrint( | ||
"{0:>39} | {1:1}\n".format(ev.upper(), content), | ||
newline=(value[ev].count("\n") + 1) if en else 1, | ||
) | ||
if not ret: | ||
return | ||
|
||
# print D-Bus unit # | ||
if DbusMgr.pidUnitList: | ||
pidUnit = DbusMgr.pidUnitList.get( | ||
idx if SysMgr.processEnable else pid | ||
) | ||
if pidUnit: | ||
SysMgr.addPrint( | ||
ret = SysMgr.addPrint( | ||
"{0:>39} | {1:1}\n".format("UNIT", pidUnit) | ||
) | ||
if not ret: | ||
return | ||
|
||
# print sched # | ||
if SysMgr.schedEnable and ( | ||
|
@@ -134526,7 +134580,11 @@ def _memFactorPG(stat): | |
waitStr = "Wait: %s(%.1f%%)" % (convTime(waitTime), waitPer) | ||
sliceStr = "NrTimeslice: %s" % convNum(value["nrSlice"]) | ||
schedStr = "%s / %s / %s" % (execStr, waitStr, sliceStr) | ||
SysMgr.addPrint("{0:>39} | {1:1}\n".format("SCHED", schedStr)) | ||
ret = SysMgr.addPrint( | ||
"{0:>39} | {1:1}\n".format("SCHED", schedStr) | ||
) | ||
if not ret: | ||
return | ||
|
||
# print delay # | ||
try: | ||
|
@@ -134538,7 +134596,11 @@ def _memFactorPG(stat): | |
|
||
# print D-Bus # | ||
for line in value.get("dbusList", []): | ||
SysMgr.addPrint("{0:>39} | {1:1}\n".format("D-BUS", line)) | ||
ret = SysMgr.addPrint( | ||
"{0:>39} | {1:1}\n".format("D-BUS", line) | ||
) | ||
if not ret: | ||
return | ||
|
||
# print stack samples # | ||
if SysMgr.stackEnable: | ||
|
@@ -134558,9 +134620,46 @@ def _memFactorPG(stat): | |
except: | ||
pass | ||
|
||
# print dmabuf usage # | ||
if self.dmabufData and idx in self.fdinfoData: | ||
dmabufStat = {} | ||
inoList = {} | ||
|
||
for fd, fvals in self.fdinfoData[idx].items(): | ||
ino = fvals.get("ino") | ||
if not ino or not ino in self.dmabufData or ino in inoList: | ||
continue | ||
|
||
# save ino to skip duplicated ino # | ||
inoList[ino] = 0 | ||
|
||
dname = fvals.get("exp_name") | ||
if not dname: | ||
continue | ||
|
||
dsize = long(fvals.get("size", 0)) | ||
if not dsize: | ||
continue | ||
|
||
dmabufStat[dname] = dmabufStat.get(dname, 0) + dsize | ||
|
||
if dmabufStat: | ||
dmabufStr = "" | ||
for dname, dsize in dmabufStat.items(): | ||
dmabufStr += "%s: %s, " % (dname, convSize(dsize)) | ||
ret = SysMgr.addPrint( | ||
"{0:>39} | {1:1}\n".format( | ||
"DMABUF", dmabufStr.rstrip(" ,") | ||
) | ||
) | ||
if not ret: | ||
return | ||
|
||
procCnt += 1 | ||
if SysMgr.memEnable and smapsEnable: | ||
SysMgr.addPrint("%s\n" % oneLine) | ||
ret = SysMgr.addPrint("%s\n" % oneLine) | ||
if not ret: | ||
return | ||
|
||
# check stream flag # | ||
if self.taskStreamEnable: | ||
|
@@ -134605,7 +134704,7 @@ def _memFactorPG(stat): | |
pass | ||
|
||
# print total stats # | ||
SysMgr.addPrint( | ||
ret = SysMgr.addPrint( | ||
( | ||
"{0:>{td}}|" | ||
"{1:>6}({2:>4}/{3:>4})|" | ||
|
@@ -134631,12 +134730,18 @@ def _memFactorPG(stat): | |
td=cl + (pd * 2) + 14, | ||
) | ||
) | ||
if not ret: | ||
return | ||
|
||
SysMgr.addPrint("%s\n" % oneLine) | ||
ret = SysMgr.addPrint("%s\n" % oneLine) | ||
if not ret: | ||
return | ||
else: | ||
text = "{0:^16}".format("None") | ||
frame = "%s%s|" % (text, " " * (SysMgr.lineLength - len(text) - 1)) | ||
SysMgr.addPrint("{0:1}\n{1:1}\n".format(frame, oneLine)) | ||
ret = SysMgr.addPrint("{0:1}\n{1:1}\n".format(frame, oneLine)) | ||
if not ret: | ||
return | ||
|
||
# check skip special task option # | ||
if "NOSPECIALTASK" in SysMgr.environList: | ||
|