From 45ab05c56af8c57c6f357d4de0926d29b188c348 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Sat, 12 Jun 2021 15:19:22 +0200 Subject: Limit deleted library check Reading and parsing /proc//maps is quite expensive. Do not check for deleted libraries if the main binary has been deleted; in this case the deleted binary takes precedence. Do not check in threads. The check is void for kernel threads and user- land threads can just inherit the state from the main process structure. --- linux/LinuxProcessList.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'linux/LinuxProcessList.c') diff --git a/linux/LinuxProcessList.c b/linux/LinuxProcessList.c index 168c7eb7..8500ffa6 100644 --- a/linux/LinuxProcessList.c +++ b/linux/LinuxProcessList.c @@ -1354,7 +1354,8 @@ static bool LinuxProcessList_recurseProcTree(LinuxProcessList* this, openat_arg_ { bool prev = proc->usesDeletedLib; - if ((lp->m_lrs == 0 && (settings->flags & PROCESS_FLAG_LINUX_LRS_FIX)) || settings->highlightDeletedExe) { + if ((lp->m_lrs == 0 && (settings->flags & PROCESS_FLAG_LINUX_LRS_FIX)) || + (settings->highlightDeletedExe && !proc->procExeDeleted && !proc->isKernelThread && !proc->isUserlandThread)) { // Check if we really should recalculate the M_LRS value for this process uint64_t passedTimeInMs = pl->realtimeMs - lp->last_mlrs_calctime; @@ -1365,8 +1366,8 @@ static bool LinuxProcessList_recurseProcTree(LinuxProcessList* this, openat_arg_ LinuxProcessList_readMaps(lp, procFd, settings->flags & PROCESS_FLAG_LINUX_LRS_FIX, settings->highlightDeletedExe); } } else { - /* reset if setting got disabled */ - proc->usesDeletedLib = false; + /* Copy from process structure in threads and reset if setting got disabled */ + proc->usesDeletedLib = (proc->isUserlandThread && parent) ? parent->usesDeletedLib : false; } proc->mergedCommand.exeChanged |= prev ^ proc->usesDeletedLib; -- cgit v1.2.3