[GH-ISSUE #4522] [Bug]: Inaccurate CPU core count & frequency reporting in distro_info.sh on multi-core systems with E & P cores #2820

Open
opened 2026-02-27 03:05:38 +03:00 by kerem · 0 comments
Owner

Originally created by @MicLieg on GitHub (Mar 3, 2024).
Original GitHub issue: https://github.com/GameServerManagers/LinuxGSM/issues/4522

User story

As an admin, I want the distro_info.sh script to accurately report the frequencies and # of all CPU cores, including both E and P cores.

Game

All

Linux distro

Ubuntu 22.04

Command

command: details

Further information

The script distro_info.sh currently has limitations in accurately reporting CPU information for systems with hybrid architectures that include both Efficiency (E-cores) and Performance (P-cores) cores and systems that support Multithreading.

The bugs can be found in the output of ./gameserver details.
Screenshot

CPU Frequency Reporting:

The script uses a method to fetch the CPU frequency that does not account for the differing frequencies of E and P cores. It only captures the frequency of a single core, which can lead to misleading information about the system's capabilities: info_distro.sh#L142

cpufreqency="$(awk -F: '/cpu MHz/ {freq=$2} END {print freq}' /proc/cpuinfo | sed 's/^[ \t]//;s/[ \t]$//')" # e.g 2394.503

This should be updated to reflect a more accurate representation of the system's CPU frequencies, especially for hybrid architectures.

  • A possible solution would be to list the number of cores running at different frequencies:
declare -A freq_count

# Loop through each core and collect frequencies
while IFS=: read -r label cpu_id; do
    cpu_freq=$(awk -v id="$cpu_id" '$1 == "processor" {p=$3} $1 == "cpu" && $2 == "MHz" && p == id {print $4; exit}' /proc/cpuinfo)
    ((freq_count[$cpu_freq]++))
done < <(awk -F: '/processor/ {print $1 ":" $2}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//')

# Sort by frequency
for freq in "${!freq_count[@]}"; do
    echo "$freq ${freq_count[$freq]}"
done | sort -rn -k1,1 | awk '{print $2"x " $1 " MHz"}' | paste -sd, - | sed 's/,/, /g'
  • Or use the average frequency of all cores:
# Initialize sum of frequencies and core count
total_freq=0
core_count=0
    
# Loop through each core
for cpu_id in $(awk -F: '/processor/ {print $2}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//'); do
    # Extract the frequency of the current core
    cpu_freq=$(awk -v id="$cpu_id" '$1 == "processor" {p=$3} $1 == "cpu" && $2 == "MHz" && p == id {print $4; exit}' /proc/cpuinfo)
    # Add the frequency to the total
    total_freq=$(echo "$total_freq + $cpu_freq" | bc)
    # Increment the core count
    core_count=$((core_count + 1))
done
    
# Calculate the average frequency
if [ $core_count -gt 0 ]; then
    avg_freq=$(echo "scale=2; $total_freq / $core_count" | bc)
    echo "Average CPU Frequency: $avg_freq MHz"
fi

CPU Core Count Reporting

Additionally, the script inaccurately reports the total number of CPU cores in systems with hybrid architectures. For example, on an Intel i7-13700K, which has 16 physical cores (8 E-cores and 8 P-cores), the script reports a total of 24 cores. This discrepancy arises from the following line: info_distro.sh#141

cpucores="$(awk -F: '/model name/ {core++} END {print core}' /proc/cpuinfo)"

This is likely to be an issue of how logical cores are counted versus physical cores, especially in the context of Intel's Thread Director technology, which can present more logical processors to the operating system than the physical core count.

  • The solution is to use the value of cpu cores listed in /proc/cpuinfo:
cpucores="$(awk -F': ' '/cpu cores/ {print $2; exit}' /proc/cpuinfo)"

Relevant log output

No response

Steps to reproduce

These bugs might only arise on bare metal servers

  1. Install any gameserver
  2. Run ./gameserver details
    • Wrong number of cores displayed (if CPU supports Hyperthreading)
    • Only the frequency of a single core is displayed.
Originally created by @MicLieg on GitHub (Mar 3, 2024). Original GitHub issue: https://github.com/GameServerManagers/LinuxGSM/issues/4522 ### User story As an admin, I want the distro_info.sh script to accurately report the frequencies and # of all CPU cores, including both E and P cores. ### Game All ### Linux distro Ubuntu 22.04 ### Command command: details ### Further information The script `distro_info.sh` currently has limitations in accurately reporting CPU information for systems with hybrid architectures that include both Efficiency (E-cores) and Performance (P-cores) cores and systems that support Multithreading. The bugs can be found in the output of `./gameserver details`. ![Screenshot](https://github.com/GameServerManagers/LinuxGSM/assets/38057464/bd44e8c2-6438-4caf-99ec-543ce46b60bd) # CPU Frequency Reporting: The script uses a method to fetch the CPU frequency that does not account for the differing frequencies of E and P cores. It only captures the frequency of a single core, which can lead to misleading information about the system's capabilities: [info_distro.sh#L142](https://github.com/GameServerManagers/LinuxGSM/blob/master/lgsm/modules/info_distro.sh#L142) > cpufreqency="$(awk -F: '/cpu MHz/ {freq=$2} END {print freq}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//')" # e.g 2394.503 This should be updated to reflect a more accurate representation of the system's CPU frequencies, especially for hybrid architectures. - A possible solution would be to list the number of cores running at different frequencies: ```bash declare -A freq_count # Loop through each core and collect frequencies while IFS=: read -r label cpu_id; do cpu_freq=$(awk -v id="$cpu_id" '$1 == "processor" {p=$3} $1 == "cpu" && $2 == "MHz" && p == id {print $4; exit}' /proc/cpuinfo) ((freq_count[$cpu_freq]++)) done < <(awk -F: '/processor/ {print $1 ":" $2}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//') # Sort by frequency for freq in "${!freq_count[@]}"; do echo "$freq ${freq_count[$freq]}" done | sort -rn -k1,1 | awk '{print $2"x " $1 " MHz"}' | paste -sd, - | sed 's/,/, /g' ``` - Or use the average frequency of all cores: ```bash # Initialize sum of frequencies and core count total_freq=0 core_count=0 # Loop through each core for cpu_id in $(awk -F: '/processor/ {print $2}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//'); do # Extract the frequency of the current core cpu_freq=$(awk -v id="$cpu_id" '$1 == "processor" {p=$3} $1 == "cpu" && $2 == "MHz" && p == id {print $4; exit}' /proc/cpuinfo) # Add the frequency to the total total_freq=$(echo "$total_freq + $cpu_freq" | bc) # Increment the core count core_count=$((core_count + 1)) done # Calculate the average frequency if [ $core_count -gt 0 ]; then avg_freq=$(echo "scale=2; $total_freq / $core_count" | bc) echo "Average CPU Frequency: $avg_freq MHz" fi ``` # CPU Core Count Reporting Additionally, the script inaccurately reports the total number of CPU cores in systems with hybrid architectures. For example, on an Intel i7-13700K, which has 16 physical cores (8 E-cores and 8 P-cores), the script reports a total of 24 cores. This discrepancy arises from the following line: [info_distro.sh#141](https://github.com/GameServerManagers/LinuxGSM/blob/master/lgsm/modules/info_distro.sh#L141) > cpucores="$(awk -F: '/model name/ {core++} END {print core}' /proc/cpuinfo)" This is likely to be an issue of how logical cores are counted versus physical cores, especially in the context of Intel's Thread Director technology, which can present more logical processors to the operating system than the physical core count. - The solution is to use the value of `cpu cores` listed in `/proc/cpuinfo`: ```bash cpucores="$(awk -F': ' '/cpu cores/ {print $2; exit}' /proc/cpuinfo)" ``` ### Relevant log output _No response_ ### Steps to reproduce **These bugs might only arise on bare metal servers** 1. Install any gameserver 2. Run `./gameserver details` - Wrong number of cores displayed (if CPU supports Hyperthreading) - Only the frequency of a single core is displayed.
Sign in to join this conversation.
No labels
Atomic
Epic
cannot reproduce
command: backup
command: console
command: debug
command: details
command: fast-dl
command: install
command: mods
command: monitor
command: post-details
command: restart
command: send
command: start
command: stop
command: update
command: update-lgsm
command: validate
command: wipe
distro: AlmaLinux
distro: Arch Linux
distro: CentOS
distro: Debian
distro: Fedora
distro: RedHat
distro: Rocky Linux
distro: Ubuntu
distro: openSUSE
engine: goldsrc
engine: source
game: 7 Days to Die
game: ARMA 3
game: Ark: Survival Evolved
game: Assetto Corsa
game: Avorion
game: BATTALION: Legacy
game: Barotrauma
game: Battalion 1944
game: Battlefield 1942
game: Black Mesa: Deathmatch
game: Blade Symphony
game: Call of Duty 2
game: Call of Duty 4
game: Call of Duty: United Offensive
game: Counter-Strike 1.6
game: Counter-Strike 2
game: Counter-Strike: Global Offensive
game: Counter-Strike: Source
game: Day of Infamy
game: Dayz
game: Death Match Classic
game: Don't Starve Together
game: ET: Legacy
game: Eco
game: Factorio
game: Factorio
game: Garry's Mod
game: Half-Life
game: Hurtword
game: Insurgecy
game: Insurgecy
game: Insurgency: Sandstorm
game: Just Cause 3
game: Killing Floor
game: Killing Floor 2
game: Left 4 Dead 2
game: Minecraft
game: Minecraft Bedrock
game: Mordhau
game: Multi Theft Auto
game: Mumble
game: Natural Selection 2
game: No More Room in Hell
game: Pavlov VR
game: Post Scriptum
game: Project Zomboid
game: Quake 3
game: QuakeWorld
game: Red Orchestra: Ostfront 41-45
game: Return to Castle Wolfenstein
game: Rising World
game: Rust
game: San Andreas Multiplayer
game: Satisfactory
game: Soldat
game: Soldier of Fortune 2
game: Squad
game: Squad 44
game: Starbound
game: Stationeers
game: Sven Co-op
game: Team Fortress 2
game: Teamspeak 3
game: Teeworlds
game: Terraria
game: The Front
game: Unreal Tournament 2004
game: Unreal Tournament 3
game: Unreal Tournament 99
game: Unturned
game: Valheim
game: Wurm Unlimited
game: Zombie Master Reborn
game: label missing
good first issue
help wanted
info: alerts
info: dependency
info: docker
info: docs
info: email
info: query
info: steamcmd
info: systemd
info: tmux
info: website
info: website
needs more info
outcome: duplicate
outcome: issue resolved
outcome: issue resolved
outcome: issue unresolved
outcome: pr accepted
outcome: pr rejected
outcome: unconfirmed
outcome: wontfix
outcome: wrong forum
potential-duplicate
priority
pull-request
type: bug
type: feature
type: feature
type: feature request
type: game server request
type: refactor
waiting response
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/LinuxGSM#2820
No description provided.