Skip to content

Commit

Permalink
Merge pull request #1065 from askervin/5QX_e2e_terminated_pids
Browse files Browse the repository at this point in the history
e2e: ignore terminated processes on fetching allowed resources
  • Loading branch information
marquiz committed Aug 24, 2023
2 parents d659cbd + 18a74bc commit 7ab4761
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion demo/lib/topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

_bash_topology_dump = """for cpu in /sys/devices/system/cpu/cpu[0-9]*; do cpu_id=${cpu#/sys/devices/system/cpu/cpu}; echo "cpu p:$(< ${cpu}/topology/physical_package_id) d:$(< ${cpu}/topology/die_id) n:$(basename ${cpu}/node* | sed 's:node::g') c:$(< ${cpu}/topology/core_id) t:$(< ${cpu}/topology/thread_siblings) cpu:${cpu_id}" ; done; for node in /sys/devices/system/node/node[0-9]*; do node_id=${node#/sys/devices/system/node/node}; echo "dist n:$node_id d:$(< $node/distance)"; echo "mem n:$node_id s:$(awk '/MemTotal/{print $4/1024}' < $node/meminfo)"; done"""

_bash_res_allowed = r"""for process in '%s'; do for pid in $(pgrep -f "$process"); do name=$(cat /proc/$pid/cmdline | tr '\0 ' '\n' | grep -E "^$process" | head -n 1); [ -n "$name" ] && [ "$pid" != "$$" ] && [ "$pid" != "$PPID" ] && echo "${name}/${pid} $(awk '/Cpus_allowed:/{c=$2}/Mems_allowed:/{m=$2}END{print "c:"c" m:"m}' < /proc/$pid/status)"; done; done"""
_bash_res_allowed = r"""for process in '%s'; do for pid in $(pgrep -f "$process"); do proc_pid_cmdline=$(< /proc/$pid/cmdline) || continue; proc_pid_status=$(< /proc/$pid/status) || continue; name=$(echo "$proc_pid_cmdline" | tr '\0 ' '\n' | grep -E "^$process" | head -n 1); [ -n "$name" ] && [ "$pid" != "$$" ] && [ "$pid" != "$PPID" ] && echo "${name}/${pid} $(awk '/Cpus_allowed:/{c=$2}/Mems_allowed:/{m=$2}END{print "c:"c" m:"m}' <<< "$proc_pid_status")"; done 2>/dev/null; done"""

def error(msg, exit_status=1):
"""Print error message and exit."""
Expand Down

0 comments on commit 7ab4761

Please sign in to comment.