PR-140 - Add CPU cache configuration info to pt-summary

- Merge branch '3.x' into HEAD
- Move code to the proper place: library files
- Fix tests
This commit is contained in:
Sveta Smirnova
2024-01-25 01:41:20 +03:00
2167 changed files with 297347 additions and 29069 deletions

View File

@@ -19,7 +19,7 @@
# ###########################################################################
# Package: report_system_info
#
#
set -u
@@ -28,7 +28,7 @@ set -u
# These are called from within report_system_summary() and are separated so
# they can be tested easily.
# ##############################################################################
# ##############################################################################
# Parse Linux's /proc/cpuinfo.
# ##############################################################################
@@ -141,6 +141,7 @@ parse_free_minus_b () { local PTFUNCNAME=parse_free_minus_b;
name_val "Total" $(shorten $(awk '/Mem:/{print $2}' "${file}") 1)
name_val "Free" $(shorten $(awk '/Mem:/{print $4}' "${file}") 1)
name_val "Used" "physical = $(shorten ${physical} 1), swap allocated = $(shorten ${swap_alloc} 1), swap used = $(shorten ${swap_used} 1), virtual = ${virtual}"
name_val "Shared" $(shorten $(awk '/Mem:/{print $5}' "${file}") 1)
name_val "Buffers" $(shorten $(awk '/Mem:/{print $6}' "${file}") 1)
name_val "Caches" $(shorten $(awk '/Mem:/{print $7}' "${file}") 1)
name_val "Dirty" "$(awk '/Dirty:/ {print $2, $3}' "${file}")"
@@ -230,12 +231,59 @@ parse_dmidecode_mem_devices () { local PTFUNCNAME=parse_dmidecode_mem_devices;
-e 's/>/}/g' \
-e 's/[ \t]*\n/\n/g' \
"${file}" \
| awk -F: '/Size|Type|Form.Factor|Type.Detail|^[\t ]+Locator/{printf("|%s", $2)}/^[\t ]+Speed/{print "|" $2}' \
| awk -F: '/Size|Type|Form.Factor|Type.Detail|^[\t ]+Locator|^[\t ]+Speed/{printf("|%s", $2)}/^$/{print}' \
| sed '/^$/d' \
| sed -e 's/No Module Installed/{EMPTY}/' \
| sort \
| awk -F'|' '{printf(" %-9s %-8s %-17s %-13s %-13s %-8s\n", $4, $2, $7, $3, $5, $6);}'
}
# ##############################################################################
# Parse CPU cache from the output of 'dmidecode'.
# ##############################################################################
parse_dmidecode_cache_info () { local PTFUNCNAME=parse_dmidecode_cache_info;
local file="$1"
[ -e "$file" ] || return
echo " Designation Configuration Size Associativity"
echo " ========================= ============================== ======== ======================"
sed -e '/./{H;$!d;}' \
-e 'x;/Cache Information\n/!d;' \
-e 's/: /:/g' \
-e 's/</{/g' \
-e 's/>/}/g' \
-e 's/[ \t]*\n/\n/g' \
"${file}" \
| awk -F: '/Socket Designation|Configuration|Installed Size/{printf("|%s", $2)}/^[\t ]+Associativity/{print "|" $2}' \
| awk -F'|' '{printf(" %-25s %-30s %-8s %-22s\n", $2, $3, $4, $5);}'
}
# ##############################################################################
# Parse the output of 'numactl'.
# ##############################################################################
parse_numactl () { local PTFUNCNAME=parse_numactl;
local file="$1"
[ -e "$file" ] || return
# Print info about NUMA nodes
echo " Node Size Free CPUs"
echo " ==== ==== ==== ===="
sed -n -e 's/node /node/g' \
-e '/node[[:digit:]]/p' \
"${file}" \
| sort -r \
| awk '$1 == cnode {
if (NF > 4) { for(i=3;i<=NF;i++){printf("%s ", $i)} printf "\n" }
else { printf("%-12s", $3" "$4); }
}
$1 != cnode { cnode = $1; printf(" %-8s", $1); printf("%-12s", $3" "$4); }'
echo
}
# ##############################################################################
# Parse the output of 'ip -s link'
# ##############################################################################
@@ -836,12 +884,19 @@ section_Processor () {
parse_psrinfo_cpus "$data_dir/psrinfo_minus_v"
# TODO: prtconf -v actually prints the CPU model name etc.
fi
if [ -s "$data_dir/dmidecode" ]; then
parse_dmidecode_cache_info "$data_dir/dmidecode"
fi
}
section_Memory () {
local platform="$1"
local data_dir="$2"
local name_val_len_orig=$NAME_VAL_LEN;
local NAME_VAL_LEN=14
section "Memory"
if [ "${platform}" = "Linux" ]; then
parse_free_minus_b "$data_dir/memory"
@@ -867,6 +922,16 @@ section_Memory () {
fi
fi
if [ -s "$data_dir/numactl" ]; then
name_val "Numa Nodes" "$(get_var "numa-available" "$data_dir/summary")"
name_val "Numa Policy" "$(get_var "numa-policy" "$data_dir/summary")"
name_val "Preferred Node" "$(get_var "numa-preferred-node" "$data_dir/summary")"
parse_numactl "$data_dir/numactl"
fi
local NAME_VAL_LEN=$name_val_len_orig;
if [ -s "$data_dir/dmidecode" ]; then
parse_dmidecode_mem_devices "$data_dir/dmidecode"
fi
@@ -888,7 +953,7 @@ report_fio_minus_a () {
local file="$1"
name_val "fio Driver" "$(get_var driver_version "$file")"
local adapters="$( get_var "adapters" "$file" )"
for adapter in $( echo $adapters | awk '{for (i=1; i<=NF; i++) print $i;}' ); do
local adapter_for_output="$(echo "$adapter" | sed 's/::[0-9]*$//' | tr ':' ' ')"
@@ -969,7 +1034,7 @@ report_system_summary () { local PTFUNCNAME=report_system_summary;
section "Fusion-io Card"
report_fio_minus_a "$data_dir/fusion-io_card"
fi
if [ -s "$data_dir/mounted_fs" ]; then
section "Mounted Filesystems"
parse_filesystems "$data_dir/mounted_fs" "${platform}"
@@ -984,7 +1049,7 @@ report_system_summary () { local PTFUNCNAME=report_system_summary;
name_val "${disk}" "${scheduler:-"UNREADABLE"}"
done
section "Disk Partioning"
section "Disk Partitioning"
parse_fdisk "$data_dir/partitioning"
section "Kernel Inode State"
@@ -1071,12 +1136,29 @@ report_system_summary () { local PTFUNCNAME=report_system_summary;
"$data_dir/vmstat" \
"$platform"
section "Memory management"
report_transparent_huge_pages
# ########################################################################
# All done. Signal the end so it's explicit.
# ########################################################################
section "The End"
}
report_transparent_huge_pages () {
if [ -f /sys/kernel/mm/transparent_hugepage/enabled ]; then
CONTENT_TRANSHP=$(</sys/kernel/mm/transparent_hugepage/enabled)
STATUS_THP_SYSTEM=$(echo $CONTENT_TRANSHP | grep -cv '\[never\]')
fi
if [ $STATUS_THP_SYSTEM = 0 ]; then
echo "Transparent huge pages are currently disabled on the system."
else
echo "Transparent huge pages are enabled."
fi
}
# ###########################################################################
# End report_system_info package
# ###########################################################################