Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
98bcd01
add an optional RAPL TPMI path for reading the package energy
rdementi Aug 20, 2026
14e459d
read also the DRAM energy through the RAPL TPMI interface
rdementi Aug 20, 2026
6e3681f
read also the system energy through the RAPL TPMI interface
rdementi Aug 20, 2026
cddd948
use the RAPL TPMI interface by default when it is available
rdementi Aug 20, 2026
f187829
drop the warning about the RAPL TPMI energy unit
rdementi Aug 20, 2026
c519aec
report the RAPL TPMI usage through the debug output only
rdementi Aug 20, 2026
0965fc2
take the system energy unit from the system RAPL TPMI domain
rdementi Aug 20, 2026
da15ede
make the RAPL TPMI package/DRAM/system domain initialization independ…
Copilot Aug 20, 2026
76480af
handle raw counter read failures in CounterWidthExtender without term…
Copilot Aug 20, 2026
111c3b3
Merge remote-tracking branch 'opcm-github/master' into merge-opcm-202…
rdementi Sep 7, 2026
e2d779d
Merge pull request #968 from intel-innersource/merge-opcm-2026-07-09
rdementi Sep 7, 2026
921237d
Fix sensor-server SSL fuzz shutdown use-after-free (#969)
Copilot Sep 8, 2026
63f2f33
drop unused captures
rdementi Sep 7, 2026
7f7f4da
add ufs-die-freq.sh script to change uncore die frequencies (based on…
rdementi Sep 10, 2026
aac1dce
Split CPU topology discovery out of PCM into independent CPUTopology …
Copilot Sep 16, 2026
2649084
Make RDT initialization on demand via public PCM::initRDT() API (#980)
Copilot Sep 16, 2026
d71c7b9
Expose the NUMA node of a PMT telemetry instance
rdementi Sep 18, 2026
a0d86a6
Track RMIDs programmed by initRDT and allocate them from RMID 1
rdementi Sep 18, 2026
99a2c05
Add helpers for the per-RMID Application Energy Telemetry (AET) counters
rdementi Sep 18, 2026
6b59ef3
pcm: display AET metrics CENRG and CDYN with the new --aet option
rdementi Sep 18, 2026
1f831fd
Potential fix for pull request finding
rdementi Sep 18, 2026
60827fd
pcm: mark AET aggregate metrics invalid unless every selected core is…
Copilot Sep 18, 2026
1dfa97f
pcm: speed up cleanupRDT by stopping the MBW watchdog threads concurr…
rdementi Sep 18, 2026
e390396
pcm: join MBW watchdog threads before RMID rollback/cleanup MSR writes
Copilot Sep 18, 2026
0fc0c32
pcm-sensor-server: do not mistake a 0xff first byte for EOF in SSL de…
rdementi Sep 21, 2026
bc163b6
pcm-sensor-server: retry socket operations interrupted by a signal
rdementi Sep 21, 2026
3cb31c1
tests: do not fail the sensor server fuzz run on an interrupted hands…
rdementi Sep 21, 2026
f05d1e3
tests: bound the wait for an interrupted connect by an absolute deadline
rdementi Sep 21, 2026
bdb0bad
Fix unused variable warnings in event-resolver.cpp using PCM_UNUSED (…
Copilot Sep 24, 2026
871ae4e
fix csv fields when qpi util metrics are not available
rdementi Sep 24, 2026
880e384
guard outgoing QPI utilization CSV output with qpiUtilizationMetricsA…
Copilot Sep 24, 2026
fd6599a
use (bar + 8ULL * vsec.fields.Address) instead of bar in discovery
rdementi Jul 27, 2026
551bd8e
Revert "use (bar + 8ULL * vsec.fields.Address) instead of bar in disc…
rdementi Sep 25, 2026
e5c5d44
cpucounters: collect the IA32_PERF_STATUS metrics on demand
rdementi Sep 22, 2026
0b7217f
pcm: add the --perf-status option for the RATIO and VOLT metrics
rdementi Sep 22, 2026
766652a
pcm: do not pad the RATIO field of the CSV output
rdementi Sep 23, 2026
957e50a
cpucounters: expose the uncore voltage and throttling of UFS_STATUS
rdementi Sep 23, 2026
87715ba
pcm: add the --ufs-status option for the uncore voltage and throttling
rdementi Sep 23, 2026
562ccb6
cpucounters: read IA32_PERF_STATUS only where its fields are validated
rdementi Sep 23, 2026
5fbbbe0
msr: report a failed MSR read on Windows instead of asserting
rdementi Sep 23, 2026
4311536
Merge remote-tracking branch 'opcm-github/master' into opcm-merge-202…
rdementi Oct 7, 2026
7953b26
Use Core client package C-state MSRs for ADL/RPL/MTL/LNL/ARL/PTL
twillhal Oct 5, 2026
bce9ac8
Potential fix for pull request finding 'Validate targets before gener…
rdementi Oct 7, 2026
7955daa
Merge pull request #997 from intel-innersource/opcm-merge-2026-10-07
rdementi Oct 7, 2026
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
7 changes: 6 additions & 1 deletion scripts/grafana/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ if [ "$#" -ne 1 ]; then
usage
fi

if [ ! -f "$1" ]; then
if [ -f "$1" ]; then
[ -s "$1" ] || { echo "Error: targets file is empty."; exit 1; }
while IFS= read -r line || [[ -n "$line" ]]; do
validate_url "http://$line"
done < "$1"
else
validate_url "$1"
fi

Expand Down
370 changes: 370 additions & 0 deletions scripts/ufs-die-freq.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,370 @@
#!/bin/bash

echo "Intel(r) Performance Counter Monitor"
echo "Uncore Frequency Scaling: Die Frequency Control Utility"
echo

print_usage() {
echo " Usage: $(basename "$0") --die-type <compute|LLC|memory|IO> [--min <MHz>] [--max <MHz>]"
echo " [--socket <N>] [--numa-node <N>] [--instance <N>] [--die <N>]"
echo
echo " --die-type <type> : die type to configure: compute, LLC, memory or IO"
echo " --min <MHz> : set the minimum uncore frequency (100 MHz granularity, 0..12700)"
echo " --max <MHz> : set the maximum uncore frequency (100 MHz granularity, 0..12700)"
echo " --socket <N> : restrict the operation to socket N (default: all sockets)"
echo " (examples: --socket 1 --socket 0,1 --socket 0,2-3)"
echo " --numa-node <N> : restrict the operation to NUMA node N (default: all NUMA nodes)"
echo " (examples: --numa-node 1 --numa-node 0,1 --numa-node 0,2-3)"
echo " --instance <N> : restrict the operation to TPMI instance N (default: all instances)"
echo " --die <N> : restrict the operation to die (TPMI entry) N (default: all dies)"
echo
echo " Without --min/--max the current frequency limits of the matching dies are printed only."
echo " Note: a die can have several types (e.g. compute/LLC/memory) and is selected by any of them."
echo
echo " Examples:"
echo " $(basename "$0") --die-type compute --min 2000 # pin compute dies to at least 2 GHz"
echo " $(basename "$0") --die-type IO --min 800 --max 2400 # set the IO die frequency window"
echo " $(basename "$0") --die-type memory # show the memory die frequency limits"
echo " $(basename "$0") --die-type compute --max 2400 --socket 0 # limit the compute dies of socket 0"
echo " $(basename "$0") --die-type LLC --min 1600 --numa-node 2 # tune the LLC dies of NUMA node 2"
echo
}

# TPMI UFS (Uncore Frequency Scaling) register offsets and bit fields
UFS_STATUS=0x10 # bits 6:0 current ratio, bits 26:23 die type
UFS_CONTROL=0x18 # bits 14:8 MAX_RATIO, bits 21:15 MIN_RATIO
MAX_RATIO_BITS="14:8"
MIN_RATIO_BITS="21:15"
MIN_MAX_RATIO_BITS="21:8" # both fields, to update them in a single write

die_type=""
min_freq=""
max_freq=""
socket_filter=""
numa_filter=""
instance_filter=""
die_filter=""

while [ $# -gt 0 ]; do
# accept both "--option value" and "--option=value"
opt="${1%%=*}"
if [[ $1 == *=* ]]; then
val="${1#*=}"
shift
else
val="$2"
shift
[ $# -gt 0 ] && shift
fi
case "$opt" in
-h|--help) print_usage; exit 0 ;;
--die-type|--min|--max|--socket|--numa-node|--instance|--die)
if [ -z "$val" ] || [[ $val == -* ]]; then
echo "Error: option '$opt' requires a value"
echo
print_usage
exit 1
fi
case "$opt" in
--die-type) die_type="$val" ;;
--min) min_freq="$val" ;;
--max) max_freq="$val" ;;
--socket) socket_filter="$val" ;;
--numa-node) numa_filter="$val" ;;
--instance) instance_filter="$val" ;;
--die) die_filter="$val" ;;
esac
;;
*)
echo "Error: unknown option '$opt'"
echo
print_usage
exit 1
;;
esac
done

if ! command -v pcm-tpmi > /dev/null 2>&1; then
echo "Error: pcm-tpmi utility is not found in PATH."
echo " Please build PCM or install the PCM package (see doc/LATENCY-OPTIMIZED-MODE.md)."
exit 1
fi

# select the die type bit in the UFS_STATUS register
case "$(echo "$die_type" | tr '[:upper:]' '[:lower:]')" in
compute|core|cor) die_type_bit=23; die_type_name="compute" ;;
llc|cache) die_type_bit=24; die_type_name="LLC" ;;
memory|mem) die_type_bit=25; die_type_name="memory" ;;
io) die_type_bit=26; die_type_name="IO" ;;
"")
echo "Error: --die-type is required."
echo
print_usage
exit 1
;;
*)
echo "Error: unknown die type '$die_type'."
echo
print_usage
exit 1
;;
esac

# Convert a frequency in MHz into an uncore ratio (100 MHz units)
freq_to_ratio() {
local mhz=$1
local name=$2
if ! [[ $mhz =~ ^[0-9]+$ ]]; then
echo "Error: invalid $name frequency '$mhz' (expected a number in MHz)" >&2
return 1
fi
local ratio=$(( (mhz + 50) / 100 ))
if [ "$ratio" -gt 127 ]; then
echo "Error: $name frequency $mhz MHz is out of range (max 12700 MHz)" >&2
return 1
fi
if [ $(( ratio * 100 )) -ne "$mhz" ]; then
echo "Warning: $name frequency $mhz MHz is rounded to $(( ratio * 100 )) MHz (100 MHz granularity)" >&2
fi
echo "$ratio"
}

min_ratio=""
max_ratio=""
if [ -n "$min_freq" ]; then
min_ratio=$(freq_to_ratio "$min_freq" "minimum") || exit 1
fi
if [ -n "$max_freq" ]; then
max_ratio=$(freq_to_ratio "$max_freq" "maximum") || exit 1
fi
if [ -n "$min_ratio" ] && [ -n "$max_ratio" ] && [ "$min_ratio" -gt "$max_ratio" ]; then
echo "Error: minimum frequency $(( min_ratio * 100 )) MHz is higher than maximum frequency $(( max_ratio * 100 )) MHz"
exit 1
fi

# Expand an integer list like "0,2-3" into "0 2 3"
expand_integer_list() {
local list=$1
local name=$2
local item start end i
local result=""
for item in ${list//,/ }; do
if [[ $item =~ ^([0-9]+)-([0-9]+)$ ]]; then
start=${BASH_REMATCH[1]}
end=${BASH_REMATCH[2]}
if [ "$start" -gt "$end" ]; then
echo "Error: invalid $name range '$item'" >&2
return 1
fi
for (( i = start; i <= end; ++i )); do
result="$result $i"
done
elif [[ $item =~ ^[0-9]+$ ]]; then
result="$result $item"
else
echo "Error: invalid $name '$item' (expected a list like 1, 0,1 or 0,2-3)" >&2
return 1
fi
done
echo "$result"
}

sockets=""
numa_nodes=""
location_suffix=""
if [ -n "$socket_filter" ]; then
sockets=$(expand_integer_list "$socket_filter" "socket") || exit 1
location_suffix=" on socket(s)${sockets}"
fi
if [ -n "$numa_filter" ]; then
numa_nodes=$(expand_integer_list "$numa_filter" "NUMA node") || exit 1
location_suffix="$location_suffix on NUMA node(s)${numa_nodes}"
fi

# Check if the value is in the list (an empty list selects everything)
in_list() {
local list=$1
local value=$2
local i
[ -z "$list" ] && return 0
[ -z "$value" ] && return 1
for i in $list; do
if [ "$i" -eq "$value" ]; then
return 0
fi
done
return 1
}

# Check if the die is selected by --socket and --numa-node
die_selected() {
local socket=$1
local numa_node=$2
in_list "$sockets" "$socket" && in_list "$numa_nodes" "$numa_node"
}

# pcm-tpmi instance/entry selection options
select_opts=()
if [ -n "$instance_filter" ]; then
select_opts+=(-i "$instance_filter")
fi
if [ -n "$die_filter" ]; then
select_opts+=(-e "$die_filter")
fi

# Read a single TPMI register of one die and print its value
read_die_register() {
local instance=$1
local entry=$2
local offset=$3
local out
out=$(pcm-tpmi 2 "$offset" -d -i "$instance" -e "$entry")
while read -r line; do
if [[ $line =~ Read\ value\ ([0-9]+) ]]; then
echo "${BASH_REMATCH[1]}"
return 0
fi
done <<< "$out"
return 1
}

# Build the die type string out of the UFS_STATUS register value
die_type_string() {
local value=$1
local str=""
if [ $(( (value >> 23) & 1 )) -ne 0 ]; then
str="compute/"
fi
if [ $(( (value >> 24) & 1 )) -ne 0 ]; then
str="${str}LLC/"
fi
if [ $(( (value >> 25) & 1 )) -ne 0 ]; then
str="${str}memory/"
fi
if [ $(( (value >> 26) & 1 )) -ne 0 ]; then
str="${str}IO/"
fi
echo "${str%/}"
}

# Discover the dies and their types
declare -A die_types
declare -A die_locations
matching_dies=()

output=$(pcm-tpmi 2 $UFS_STATUS -d "${select_opts[@]}")

while read -r line; do
if [[ $line =~ Read\ value\ ([0-9]+)\ from\ TPMI\ ID\ [0-9]+@[0-9]+\ for\ entry\ ([0-9]+)\ in\ instance\ ([0-9]+) ]]; then
value=${BASH_REMATCH[1]}
die=${BASH_REMATCH[2]}
instance=${BASH_REMATCH[3]}

# Extract socket ID if present in the output (format: "(socket X)")
if [[ $line =~ \(socket\ ([0-9]+)\) ]]; then
socket=${BASH_REMATCH[1]}
else
# Fallback to instance ID if socket info is not available
socket=$instance
fi

# Extract NUMA node ID if present in the output (format: "(NUMA node X)")
numa_node=""
location="Socket $socket"
if [[ $line =~ \(NUMA\ node\ ([0-9]+)\) ]]; then
numa_node=${BASH_REMATCH[1]}
location="$location NUMA node $numa_node"
fi
location="$location instance $instance die $die"

die_key="${instance}:${die}"
die_types[$die_key]=$(die_type_string "$value")
die_locations[$die_key]="$location"

if [ $(( (value >> die_type_bit) & 1 )) -ne 0 ] && die_selected "$socket" "$numa_node"; then
matching_dies+=("$die_key")
fi
fi
done <<< "$output"

if [ ${#die_types[@]} -eq 0 ]; then
echo "Error: no uncore frequency scaling dies found."
echo " The platform may not support TPMI UFS or the utility has no access to MSR/PCICFG drivers"
echo " (root privileges are required)."
exit 1
fi

if [ ${#matching_dies[@]} -eq 0 ]; then
echo "Error: no $die_type_name dies found$location_suffix. Available dies:"
for die_key in $(printf '%s\n' "${!die_types[@]}" | sort -t: -k1,1n -k2,2n); do
echo " ${die_locations[$die_key]} (${die_types[$die_key]})"
done
exit 1
fi

# Apply the requested frequency limits
if [ -n "$min_ratio" ] || [ -n "$max_ratio" ]; then
echo -n "Setting"
if [ -n "$min_ratio" ]; then
echo -n " minimum $(( min_ratio * 100 )) MHz"
fi
if [ -n "$max_ratio" ]; then
echo -n " maximum $(( max_ratio * 100 )) MHz"
fi
echo " uncore frequency of the $die_type_name dies$location_suffix..."
echo

for die_key in "${matching_dies[@]}"; do
instance="${die_key%:*}"
entry="${die_key#*:}"

control=$(read_die_register "$instance" "$entry" $UFS_CONTROL)
if [ -z "$control" ]; then
echo "Warning: can not read the control register of ${die_locations[$die_key]}, skipping it"
continue
fi
current_min=$(( (control >> 15) & 0x7F ))
current_max=$(( (control >> 8) & 0x7F ))
new_min=${min_ratio:-$current_min}
new_max=${max_ratio:-$current_max}

if [ "$new_min" -gt "$new_max" ]; then
echo "Warning: ${die_locations[$die_key]}: requested minimum $(( new_min * 100 )) MHz is higher than" \
"the maximum $(( new_max * 100 )) MHz, skipping it"
continue
fi

if [ -n "$min_ratio" ] && [ -n "$max_ratio" ]; then
# MIN_RATIO and MAX_RATIO are adjacent fields: update both in one write
pcm-tpmi 2 $UFS_CONTROL -d -i "$instance" -e "$entry" -b $MIN_MAX_RATIO_BITS \
-w $(( (new_min << 7) | new_max )) > /dev/null
elif [ -n "$min_ratio" ]; then
pcm-tpmi 2 $UFS_CONTROL -d -i "$instance" -e "$entry" -b $MIN_RATIO_BITS -w "$new_min" > /dev/null
else
pcm-tpmi 2 $UFS_CONTROL -d -i "$instance" -e "$entry" -b $MAX_RATIO_BITS -w "$new_max" > /dev/null
fi
done
fi

# Print the resulting state of the selected dies
echo "$die_type_name die uncore frequency limits$location_suffix:"
echo

for die_key in "${matching_dies[@]}"; do
instance="${die_key%:*}"
entry="${die_key#*:}"

control=$(read_die_register "$instance" "$entry" $UFS_CONTROL)
status=$(read_die_register "$instance" "$entry" $UFS_STATUS)
if [ -z "$control" ] || [ -z "$status" ]; then
echo "Warning: can not read the registers of ${die_locations[$die_key]}"
continue
fi

min=$(( ((control >> 15) & 0x7F) * 100 ))
max=$(( ((control >> 8) & 0x7F) * 100 ))
current=$(( (status & 0x7F) * 100 ))

printf "%-60s: min %5d MHz, max %5d MHz, current %5d MHz\n" \
"${die_locations[$die_key]} (${die_types[$die_key]})" "$min" "$max" "$current"
done
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set(PROJECT_NAMES pcm pcm-numa pcm-latency pcm-power pcm-msr pcm-memory pcm-tsx

set(MINIMUM_OPENSSL_VERSION 1.1.1)

file(GLOB COMMON_SOURCES pcm-accel-common.cpp msr.cpp cpucounters.cpp pci.cpp mmio.cpp tpmi.cpp pmt.cpp bw.cpp utils.cpp topology.cpp debug.cpp threadpool.cpp uncore_pmu_discovery.cpp pcm-iio-pmu.cpp pcm-iio-topology.cpp lspci.cpp dashboard.cpp ${PCM_PUGIXML_CPP})
file(GLOB COMMON_SOURCES pcm-accel-common.cpp msr.cpp cpucounters.cpp cputopology.cpp pci.cpp mmio.cpp tpmi.cpp pmt.cpp bw.cpp utils.cpp topology.cpp debug.cpp threadpool.cpp uncore_pmu_discovery.cpp pcm-iio-pmu.cpp pcm-iio-topology.cpp lspci.cpp dashboard.cpp ${PCM_PUGIXML_CPP})

file(GLOB UNIX_SOURCES resctrl.cpp)

Expand Down
Loading
Loading