Tux / System-Info

System::Info - basic information about the system
1 stars 6 forks source link

CPU Speed may not be available on Linux #9

Open sevan opened 1 year ago

sevan commented 1 year ago

I have a RISC-V board which Linux currently doesn't report its CPU speed, result is noise from System::Info as there is no answer for speed.

> ./sysinfo.pl 
Argument "" isn't numeric in sprintf at /usr/share/perl5/System/Info/Linux.pm line 281.
Hostname             : LicheeRV
Number of CPU's      : 1
Processor type       : riscv64
Processor description:  ( 0MHz)
OS and version       : linux - 5.19.0-1012-allwinner [Ubuntu 23.04 (lunar)]
> cat /proc/cpuinfo 
processor       : 0
hart            : 0
isa             : rv64imafdc
mmu             : sv39
uarch           : thead,c906
Tux commented 1 year ago

Thanks, interesting.

Could you post me the results of https://github.com/Tux/System-Info/blob/master/t/etc/get-lsb.pl ← that script?

sevan commented 1 year ago
cat > debian_version <<EOFV
bookworm/sid
EOFV
cat > ec2_version <<EOFV
Ubuntu 22.10 (Kinetic Kudu)
EOFV
cat > lsb-release <<EOFV
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=23.04
DISTRIB_CODENAME=lunar
DISTRIB_DESCRIPTION="Ubuntu 23.04"
EOFV
cat > os-release <<EOFV
PRETTY_NAME="Ubuntu 23.04"
NAME="Ubuntu"
VERSION_ID="23.04"
VERSION="23.04 (Lunar Lobster)"
VERSION_CODENAME=lunar
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=lunar
LOGO=ubuntu-logo
EOFV
cat > issue <<EOFV
Ubuntu 23.04 \n \l

EOFV
sevan commented 1 year ago

Hardware is a Sipeed Lichee RV board with an Allwinner D1 CPU. I started running risc-v Ubuntu 22.10 then upgraded to 23.04 when it became available, so that's probably why there's an inconsistency in version between ec2_version and the rest of the output.

abeltje commented 1 year ago

Could you install the lshw package and show the output of that command? It seems that /proc/cpuinfo is rather useless. Although lshw man page says that cpu-detection may not be supported, we might get lucky.

sevan commented 1 year ago
> find /sys/devices/system/cpu
/sys/devices/system/cpu
/sys/devices/system/cpu/cpuidle
/sys/devices/system/cpu/cpuidle/current_governor_ro
/sys/devices/system/cpu/cpuidle/current_driver
/sys/devices/system/cpu/cpuidle/available_governors
/sys/devices/system/cpu/cpuidle/current_governor
/sys/devices/system/cpu/uevent
/sys/devices/system/cpu/hotplug
/sys/devices/system/cpu/hotplug/states
/sys/devices/system/cpu/possible
/sys/devices/system/cpu/offline
/sys/devices/system/cpu/present
/sys/devices/system/cpu/power
/sys/devices/system/cpu/power/runtime_active_time
/sys/devices/system/cpu/power/runtime_active_kids
/sys/devices/system/cpu/power/runtime_usage
/sys/devices/system/cpu/power/runtime_status
/sys/devices/system/cpu/power/autosuspend_delay_ms
/sys/devices/system/cpu/power/runtime_suspended_time
/sys/devices/system/cpu/power/runtime_enabled
/sys/devices/system/cpu/power/control
/sys/devices/system/cpu/online
/sys/devices/system/cpu/smt
/sys/devices/system/cpu/smt/control
/sys/devices/system/cpu/smt/active
/sys/devices/system/cpu/isolated
/sys/devices/system/cpu/kernel_max
/sys/devices/system/cpu/cpu0
/sys/devices/system/cpu/cpu0/uevent
/sys/devices/system/cpu/cpu0/hotplug
/sys/devices/system/cpu/cpu0/hotplug/target
/sys/devices/system/cpu/cpu0/hotplug/state
/sys/devices/system/cpu/cpu0/hotplug/fail
/sys/devices/system/cpu/cpu0/of_node
/sys/devices/system/cpu/cpu0/crash_notes_size
/sys/devices/system/cpu/cpu0/node0
/sys/devices/system/cpu/cpu0/power
/sys/devices/system/cpu/cpu0/power/runtime_active_time
/sys/devices/system/cpu/cpu0/power/runtime_active_kids
/sys/devices/system/cpu/cpu0/power/pm_qos_resume_latency_us
/sys/devices/system/cpu/cpu0/power/runtime_usage
/sys/devices/system/cpu/cpu0/power/runtime_status
/sys/devices/system/cpu/cpu0/power/autosuspend_delay_ms
/sys/devices/system/cpu/cpu0/power/runtime_suspended_time
/sys/devices/system/cpu/cpu0/power/runtime_enabled
/sys/devices/system/cpu/cpu0/power/control
/sys/devices/system/cpu/cpu0/online
/sys/devices/system/cpu/cpu0/topology
/sys/devices/system/cpu/cpu0/topology/cluster_cpus
/sys/devices/system/cpu/cpu0/topology/cluster_cpus_list
/sys/devices/system/cpu/cpu0/topology/physical_package_id
/sys/devices/system/cpu/cpu0/topology/core_cpus_list
/sys/devices/system/cpu/cpu0/topology/core_siblings
/sys/devices/system/cpu/cpu0/topology/cluster_id
/sys/devices/system/cpu/cpu0/topology/core_siblings_list
/sys/devices/system/cpu/cpu0/topology/package_cpus
/sys/devices/system/cpu/cpu0/topology/package_cpus_list
/sys/devices/system/cpu/cpu0/topology/thread_siblings_list
/sys/devices/system/cpu/cpu0/topology/core_id
/sys/devices/system/cpu/cpu0/topology/core_cpus
/sys/devices/system/cpu/cpu0/topology/thread_siblings
/sys/devices/system/cpu/cpu0/cpu_capacity
/sys/devices/system/cpu/cpu0/cache
/sys/devices/system/cpu/cpu0/cache/uevent
/sys/devices/system/cpu/cpu0/cache/index0
/sys/devices/system/cpu/cpu0/cache/index0/uevent
/sys/devices/system/cpu/cpu0/cache/index0/number_of_sets
/sys/devices/system/cpu/cpu0/cache/index0/ways_of_associativity
/sys/devices/system/cpu/cpu0/cache/index0/shared_cpu_list
/sys/devices/system/cpu/cpu0/cache/index0/type
/sys/devices/system/cpu/cpu0/cache/index0/size
/sys/devices/system/cpu/cpu0/cache/index0/level
/sys/devices/system/cpu/cpu0/cache/index0/coherency_line_size
/sys/devices/system/cpu/cpu0/cache/index0/shared_cpu_map
/sys/devices/system/cpu/cpu0/cache/index1
/sys/devices/system/cpu/cpu0/cache/index1/uevent
/sys/devices/system/cpu/cpu0/cache/index1/number_of_sets
/sys/devices/system/cpu/cpu0/cache/index1/ways_of_associativity
/sys/devices/system/cpu/cpu0/cache/index1/shared_cpu_list
/sys/devices/system/cpu/cpu0/cache/index1/type
/sys/devices/system/cpu/cpu0/cache/index1/size
/sys/devices/system/cpu/cpu0/cache/index1/level
/sys/devices/system/cpu/cpu0/cache/index1/coherency_line_size
/sys/devices/system/cpu/cpu0/cache/index1/shared_cpu_map
/sys/devices/system/cpu/cpu0/crash_notes
/sys/devices/system/cpu/cpu0/subsystem

Serial numbers & addresses redacted from the output of lshw:

> sudo lshw
licheerv                    
    description: Computer
    product: Sipeed Lichee RV Dock
    width: 64 bits
  *-core
       description: Motherboard
       physical id: 0
     *-cpu
          description: CPU
          product: cpu
          physical id: 0
          bus info: cpu@0
          size: 24MHz
          width: 32 bits
        *-cache
             description: L1 Cache
             physical id: 0
             size: 32KiB
     *-memory
          description: System memory
          physical id: 1
          size: 956MiB
  *-usbhost:0
       product: Generic Platform OHCI controller
       vendor: Linux 5.19.0-1012-allwinner ohci_hcd
       physical id: 2
       bus info: usb@1
       logical name: usb1
       version: 5.19
       capabilities: usb-1.10
       configuration: driver=hub slots=1 speed=12Mbit/s
  *-usbhost:1
       product: EHCI Host Controller
       vendor: Linux 5.19.0-1012-allwinner ehci_hcd
       physical id: 3
       bus info: usb@2
       logical name: usb2
       version: 5.19
       capabilities: usb-2.00
       configuration: driver=hub slots=1 speed=480Mbit/s
     *-usb
          description: Generic USB device
          product: Apple USB Ethernet Adapter
          vendor: Apple Inc.
          physical id: 1
          bus info: usb@2:1
          version: 0.01
          serial:
          capabilities: usb-2.00
          configuration: driver=asix maxpower=250mA speed=480Mbit/s
  *-usbhost:2
       product: EHCI Host Controller
       vendor: Linux 5.19.0-1012-allwinner ehci_hcd
       physical id: 4
       bus info: usb@3
       logical name: usb3
       version: 5.19
       capabilities: usb-2.00
       configuration: driver=hub slots=1 speed=480Mbit/s
  *-usbhost:3
       product: Generic Platform OHCI controller
       vendor: Linux 5.19.0-1012-allwinner ohci_hcd
       physical id: 5
       bus info: usb@4
       logical name: usb4
       version: 5.19
       capabilities: usb-1.10
       configuration: driver=hub slots=1 speed=12Mbit/s
  *-usbhost:4
       product: MUSB HDRC host driver
       vendor: Linux 5.19.0-1012-allwinner musb-hcd
       physical id: 1
       bus info: usb@5
       logical name: usb5
       version: 5.19
       capabilities: usb-2.00
       configuration: driver=hub slots=1 speed=480Mbit/s
  *-mmc0
       description: MMC Host
       physical id: 6
       logical name: mmc0
     *-device
          description: SD Card
          product: SC32G
          vendor: SanDisk
          physical id: aaaa
          logical name: /dev/mmcblk0
          version: 8.0
          date: 06/2020
          serial:
          size: 29GiB (31GB)
          capabilities: sd gpt-1.00 partitioned partitioned:gpt
          configuration: guid= logicalsectorsize=512 sectorsize=512
        *-volume:0
             description: EXT4 volume
             vendor: Linux
             physical id: 1
             logical name: /dev/mmcblk0p1
             logical name: /
             version: 1.0
             serial:
             size: 29GiB
             capacity: 29GiB
             capabilities: journaled extended_attributes large_files huge_files dir_nlink recover 64bit extents ext4 ext2 initialized
             configuration: created=2022-10-18 16:48:37 filesystem=ext4 label=cloudimg-rootfs lastmountpoint=/ modified=2023-06-15 16:03:25 mount.fstype=ext4 mount.options=rw,relatime,discard,errors=remount-ro mounted=2023-06-15 16:03:38 state=mounted
        *-volume:1
             description: Windows FAT volume
             vendor: mkfs.fat
             physical id: c
             logical name: /dev/mmcblk0p12
             version: FAT32
             serial: 
             size: 15EiB
             capabilities: fat initialized
             configuration: FATs=2 filesystem=fat label=CIDATA name=CIDATA
        *-volume:2
             description: EFI partition
             physical id: d
             logical name: /dev/mmcblk0p13
             serial: 
             capacity: 12MiB
             configuration: name=loader1
        *-volume:3
             description: EFI partition
             physical id: e
             logical name: /dev/mmcblk0p14
             serial:
             capacity: 5103KiB
             configuration: name=loader2
        *-volume:4
             description: Windows FAT volume
             vendor: mkfs.fat
             physical id: f
             logical name: /dev/mmcblk0p15
             logical name: /boot/efi
             version: FAT32
             serial:
             size: 105MiB
             capacity: 105MiB
             capabilities: boot fat initialized
             configuration: FATs=2 filesystem=fat label=UEFI mount.fstype=vfat mount.options=rw,relatime,fmask=0077,dmask=0077,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro name=ESP state=mounted
        *-volume:5
             description: EFI partition
             physical id: 10
             logical name: /dev/mmcblk0p16
             serial: 
             capacity: 3611KiB
             configuration: name=loader2b
  *-mmc1
       description: MMC Host
       physical id: 7
       logical name: mmc1
     *-device
          description: SDIO Device
          physical id: 1
          bus info: mmc@1:0001:1
          logical name: mmc1:0001:1
          serial: 0
          capabilities: sdio
  *-sound
       description: sun20icodec
       physical id: 8
       logical name: card0
       logical name: /dev/snd/controlC0
       logical name: /dev/snd/pcmC0D0c
       logical name: /dev/snd/pcmC0D0p
  *-input:0
       product: 2009800.keys
       physical id: 9
       logical name: input0
       logical name: /dev/input/event0
       capabilities: platform
  *-input:1
       product: dw_hdmi
       physical id: a
       logical name: input1
       logical name: /dev/input/event1
       capabilities: cec
  *-network:0
       description: Ethernet interface
       physical id: b
       bus info: usb@2:1
       logical name: enx5855ca240ed4
       serial: 58:55:ca:
       size: 100Mbit/s
       capacity: 100Mbit/s
       capabilities: ethernet physical tp mii 10bt 10bt-fd 100bt 100bt-fd autonegotiation
       configuration: autonegotiation=on broadcast=yes driver=asix driverversion=22-Dec-2011 duplex=full firmware=ASIX AX88772 USB 2.0 Ethernet ip= link=yes multicast=yes port=twisted pair speed=100Mbit/s
  *-network:1 DISABLED
       description: Wireless interface
       physical id: c
       bus info: mmc@1:0001:1
       logical name: wlan0
       serial: 2c:05:47:
       capabilities: ethernet physical wireless
       configuration: broadcast=yes driver=rtl8723ds driverversion=5.19.0-1012-allwinner multicast=yes wireless=unassociated
abeltje commented 1 year ago

Thanks @sevan! @Tux my proposal would be to use lshw -C system,processor 2>/dev/null as fallback for Linux hardware. It looks like product may be in either the system or the individual processor section(s), and size would be the processor speed. This is the output as run on my rpi:

$ lshw -C system,processor 2>/dev/null
raspberrypi
    description: Computer
    product: Raspberry Pi 4 Model B Rev 1.4
    width: 32 bits
    capabilities: smp cp15_barrier setend swp tagged_addr_disabled
  *-cpu:0
       description: CPU
       product: cpu
       physical id: 1
       bus info: cpu@0
       size: 1500MHz
       capacity: 1500MHz
       capabilities: fp asimd evtstrm crc32 cpuid cpufreq
  *-cpu:1
       description: CPU
       product: cpu
       physical id: 2
       bus info: cpu@1
       size: 1500MHz
       capacity: 1500MHz
       capabilities: fp asimd evtstrm crc32 cpuid cpufreq
  *-cpu:2
       description: CPU
       product: cpu
       physical id: 3
       bus info: cpu@2
       size: 1500MHz
       capacity: 1500MHz
       capabilities: fp asimd evtstrm crc32 cpuid cpufreq
  *-cpu:3
       description: CPU
       product: cpu
       physical id: 4
       bus info: cpu@3
       size: 1500MHz
       capacity: 1500MHz
       capabilities: fp asimd evtstrm crc32 cpuid cpufreq
  *-cpu:4 DISABLED
       description: CPU
       product: l2-cache0
       physical id: 5
       bus info: cpu@4

This is run on my intelish smokebox:

$ lshw -C system,processor 2>/dev/null
frank
    description: Computer
    width: 64 bits
    capabilities: smp vsyscall32
  *-cpu
       product: AMD Ryzen 7 5700G with Radeon Graphics
       vendor: Advanced Micro Devices [AMD]
       physical id: 1
       bus info: cpu@0
       version: 25.80.0
       width: 64 bits
       capabilities: fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp x86-64 constant_tsc rep_good nopl tsc_reliable nonstop_tsc cpuid extd_apicid tsc_known_freq pni pclmulqdq ssse3 fma cx16 sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm cmp_legacy extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibpb vmmcall fsgsbase bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xsaves clzero arat pku ospke overflow_recov succor
       configuration: microcode=173015052
  *-pnp00:00
       product: PnP device PNP0c02
       physical id: 0
       capabilities: pnp
       configuration: driver=system
  *-pnp00:01
       product: PnP device PNP0b00
       physical id: 1
       capabilities: pnp
       configuration: driver=rtc_cmos
  *-pnp00:04
       product: PnP device PNP0103
       physical id: 4
       capabilities: pnp
       configuration: driver=system
  *-pnp00:06
       product: PnP device PNP0c02
       physical id: 6
       capabilities: pnp
       configuration: driver=system
sevan commented 1 year ago

My hardware is definitely not 24Mhz :D (though it definitely feels like it - single core, uniprocessor running at 1Ghz)

abeltje commented 1 year ago

Ok thanks, so that's useless as well 🙁

Tux commented 1 year ago

Did you come up with an alternative or is this a dead end? I'm very willing to have System::Info dig deeper to get to the desired info, but I need to know how

Merijn

sevan commented 1 year ago

@Tux it's a dead end. I have no experience so take this with a pinch of salt but we need a default/fall through case where your existing means of obtaining CPU speed fails, report something like "speed unknown" to cater for systems which only have rudimentary support from the OS (Linux can't tell what speed the Allwinner D1 SoC is running at and there are more deeper issues for now)

Tux commented 1 year ago

I could have 0 or NULL or UNKNOWN as speed. And then document it. Then again, that would add nothing, as it is used in a string that combines only the known parts.

The code is now cleaned up to omit unknown values and only show what actually is detected. Release is soon, probably today