Repository: dmwm/wmcore
Issue: read smaps_rollup instead of parsing smaps using "awk"

**Impact of the new feature**
safer

**Is your feature request related to a problem? Please describe.**
inconsistent report of PSS vs RSS (see https://github.com/cms-sw/cmssw/issues/40437)

**Describe the solution you'd like**
read in /proc/pid/smaps_rollup (direclty in python) instead of 
https://github.com/dmwm/WMCore/blob/762bae943528241f67625016fd019ebcd0014af1/src/python/WMCore/WMRuntime/Monitors/PerformanceMonitor.py#L226

**Describe alternatives you've considered**
this is the simplest that come to my mind

**Additional context**
judge yourself
```
[innocent@worker6304 tauCrash]$ cat memDump
#!/usr/bin/csh
while (1)
set pid = `ps -af | grep $USER | grep cmsRun | grep -v grep | awk '{printf $2" "}'`
grep Anon /proc/meminfo;
awk '/^Rss/ {pss += $2} END {print pss}' /proc/$pid/smaps ; awk '/^Pss/ {pss += $2} END {print pss}' /proc/$pid/smaps ; ps -v $pid
sleep 10
end

[innocent@worker6304 tauCrash]$ cat /proc/438416/smaps_rollup
00400000-7ffffffff000 ---p 00000000 00:00 0                              [rollup]
Rss:            10110556 kB
Pss:            10104477 kB
Pss_Anon:        9949060 kB
Pss_File:         155417 kB
Pss_Shmem:             0 kB
Shared_Clean:       6524 kB
Shared_Dirty:          0 kB
Private_Clean:    154972 kB
Private_Dirty:   9949060 kB
Referenced:     10110556 kB
Anonymous:       9949060 kB
LazyFree:              0 kB
AnonHugePages:   5785600 kB
ShmemPmdMapped:        0 kB
FilePmdMapped:         0 kB
Shared_Hugetlb:        0 kB
Private_Hugetlb:       0 kB
Swap:                  0 kB
SwapPss:               0 kB
Locked:                0 kB
[innocent@worker6304 tauCrash]$ ./memDump 438416
AnonPages:      19360932 kB
AnonHugePages:  14716928 kB
10054684
10068043
    PID TTY      STAT   TIME  MAJFL   TRS   DRS   RSS %MEM COMMAND
 438416 pts/1    Rl   231:52   6285    50 17245433 10055624  0.8 cmsRun config.py
```


Changed files:
src/python/WMCore/WMRuntime/Monitors/PerformanceMonitor.py

diff --git a/src/python/WMCore/WMRuntime/Monitors/PerformanceMonitor.py b/src/python/WMCore/WMRuntime/Monitors/PerformanceMonitor.py
index 4508786a7..fd05a2cf0 100644
--- a/src/python/WMCore/WMRuntime/Monitors/PerformanceMonitor.py
+++ b/src/python/WMCore/WMRuntime/Monitors/PerformanceMonitor.py
@@ -84,8 +84,8 @@ class PerformanceMonitor(WMRuntimeMonitor):
 
         self.pid = None
         self.uid = os.getuid()
-        self.monitorBase = "ps -p %i -o pid,ppid,rss,pcpu,pmem,cmd -ww | grep %i"
-        self.pssMemoryCommand = "awk '/^Pss/ {pss += $2} END {print pss}' /proc/%i/smaps"
+        self.monitorBase = "pid=%i; ps -p $pid -o pid,ppid,rss,pcpu,pmem,cmd -ww | grep $pid"
+        self.pssMemoryCommand = "pid=%i; awk '/^Pss:/ {print $2}' /proc/$pid/smaps_rollup 2>/dev/null || awk '/^Pss:/ {pss += $2} END {print pss}' /proc/$pid/smaps"
         self.monitorCommand = None
         self.currentStepSpace = None
         self.currentStepName = None
@@ -210,7 +210,7 @@ class PerformanceMonitor(WMRuntimeMonitor):
 
         # Now we run the ps monitor command and collate the data
         # Gathers RSS, %CPU and %MEM statistics from ps
-        ps_cmd = self.monitorBase % (stepPID, stepPID)
+        ps_cmd = self.monitorBase % (stepPID)
         stdout, _stderr, _retcode = subprocessAlgos.runCommand(ps_cmd)
 
         ps_output = stdout.split()