Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions linux/LinuxProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ typedef struct LinuxProcess_ {
unsigned long ctxt_diff;
char* secattr;
unsigned long long int last_mlrs_calctime;
unsigned long long int last_deleted_lib_calctime;

/* Total GPU time used in nano seconds */
unsigned long long int gpu_time;
Expand Down
41 changes: 32 additions & 9 deletions linux/LinuxProcessTable.c
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,8 @@ static void LinuxProcessTable_calcLibSize_helper(ATTR_UNUSED ht_key_t key, void*
static void LinuxProcessTable_readMaps(LinuxProcess* process, openat_arg_t procFd, const LinuxMachine* host, bool calcSize, bool checkDeletedLib) {
Process* proc = (Process*)process;

proc->usesDeletedLib = false;
if (checkDeletedLib)
proc->usesDeletedLib = false;

FILE* mapsfile = fopenat(procFd, "maps", "r");
if (!mapsfile)
Expand Down Expand Up @@ -1703,17 +1704,39 @@ static bool LinuxProcessTable_recurseProcTree(LinuxProcessTable* this, openat_ar
{
bool prev = proc->usesDeletedLib;

if (!proc->isKernelThread && !proc->isUserlandThread &&
((ss->flags & PROCESS_FLAG_LINUX_LRS_FIX) || (settings->highlightDeletedExe && !proc->procExeDeleted && isOlderThan(proc, 10)))) {
if (!proc->isKernelThread && !proc->isUserlandThread) {
bool checkLrs = false;
bool checkDeletedLib = false;
const bool checkForDeletedLib = settings->highlightDeletedExe && !proc->procExeDeleted && isOlderThan(proc, 10);

// Check if we really should recalculate the M_LRS value for this process
uint64_t passedTimeInMs = host->realtimeMs - lp->last_mlrs_calctime;
if (ss->flags & PROCESS_FLAG_LINUX_LRS_FIX) {
// Check if we really should recalculate the M_LRS value for this process
uint64_t passedTimeInMs = host->realtimeMs - lp->last_mlrs_calctime;

uint64_t recheck = ((uint64_t)rand()) % 2048;
uint64_t recheck = ((uint64_t)rand()) % 2048;

if (passedTimeInMs > recheck) {
lp->last_mlrs_calctime = host->realtimeMs;
LinuxProcessTable_readMaps(lp, procFd, lhost, ss->flags & PROCESS_FLAG_LINUX_LRS_FIX, settings->highlightDeletedExe);
checkLrs = passedTimeInMs > recheck;
}

if (checkForDeletedLib) {
uint64_t passedTimeInMs = host->realtimeMs - lp->last_deleted_lib_calctime;

uint64_t recheck = ((uint64_t)rand()) % 2048;

checkDeletedLib = passedTimeInMs > 10000 + recheck;
}

if (checkLrs || checkDeletedLib) {
if (checkLrs)
lp->last_mlrs_calctime = host->realtimeMs;
if (checkDeletedLib)
lp->last_deleted_lib_calctime = host->realtimeMs;
LinuxProcessTable_readMaps(lp, procFd, lhost, checkLrs, checkDeletedLib);
} else if (!checkForDeletedLib) {
proc->usesDeletedLib = false;
}
if (!(ss->flags & PROCESS_FLAG_LINUX_LRS_FIX)) {
lp->m_lrs = 0;
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}
} else {
/* Copy from process structure in threads and reset if setting got disabled */
Expand Down
Loading