What is the equivalent of /proc/cpuinfo on FreeBSD v8.1?
Asked Answered
M

7

27

What is the equivalent of Linux's /proc/cpuinfo on FreeBSD v8.1? My application reads /proc/cpuinfo and saves the information in the log file, what could I do to get similar information logged on FreeBSD?

A sample /proc/cpuinfo looks like this:

processor   : 0
vendor_id   : GenuineIntel
cpu family  : 6
model       : 23
model name  : Intel(R) Xeon(R) CPU           E5420  @ 2.50GHz
stepping    : 8
cpu MHz     : 2499.015
cache size  : 6144 KB
fdiv_bug    : no
hlt_bug     : no
f00f_bug    : no
coma_bug    : no
fpu     : yes
fpu_exception   : yes
cpuid level : 10
wp      : yes
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss nx lm constant_tsc pni ds_cpl
bogomips    : 5004.54

processor   : 1
vendor_id   : GenuineIntel
cpu family  : 6
model       : 23
model name  : Intel(R) Xeon(R) CPU           E5420  @ 2.50GHz
stepping    : 8
cpu MHz     : 2499.015
cache size  : 6144 KB
fdiv_bug    : no
hlt_bug     : no
f00f_bug    : no
coma_bug    : no
fpu     : yes
fpu_exception   : yes
cpuid level : 10
wp      : yes
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss nx lm constant_tsc pni ds_cpl
bogomips    : 5009.45
Maghutte answered 3/11, 2010 at 2:39 Comment(2)
If you mean this in a specifically programming context (as opposed to some kind of user context), you'd better speak up soon, as it will otherwise be migrated off-site...Breather
Correct, currently my product reads this file during execution, I want to find an equivalent action on FreeBSD.Maghutte
G
15

Use dmidecode command:

# dmidecode -t processor -t cache
# dmidecode 3.0
Scanning /dev/mem for entry point.
SMBIOS 2.4 present.

Handle 0x0004, DMI type 4, 35 bytes
Processor Information
        Socket Designation: LGA 775
        Type: Central Processor
        Family: Pentium 4
        Manufacturer: Intel
        ID: F6 06 00 00 FF FB EB BF
        Signature: Type 0, Family 6, Model 15, Stepping 6
        Flags:
                FPU (Floating-point unit on-chip)
                VME (Virtual mode extension)
                DE (Debugging extension)
                PSE (Page size extension)
                TSC (Time stamp counter)
                MSR (Model specific registers)
                PAE (Physical address extension)
                MCE (Machine check exception)
                CX8 (CMPXCHG8 instruction supported)
                APIC (On-chip APIC hardware supported)
                SEP (Fast system call)
                MTRR (Memory type range registers)
                PGE (Page global enable)
                MCA (Machine check architecture)
                CMOV (Conditional move instruction supported)
                PAT (Page attribute table)
                PSE-36 (36-bit page size extension)
                CLFSH (CLFLUSH instruction supported)
                DS (Debug store)
                ACPI (ACPI supported)
                MMX (MMX technology supported)
                FXSR (FXSAVE and FXSTOR instructions supported)
                SSE (Streaming SIMD extensions)
                SSE2 (Streaming SIMD extensions 2)
                SS (Self-snoop)
                HTT (Multi-threading)
                TM (Thermal monitor supported)
                PBE (Pending break enabled)
        Version: Intel(R) Core(TM)2 CPU 6600 @ 2.40GHz
        Voltage: 1.4 V
        External Clock: 266 MHz
        Max Speed: 3800 MHz
        Current Speed: 2394 MHz
        Status: Populated, Enabled
        Upgrade: Other
        L1 Cache Handle: 0x0005
        L2 Cache Handle: 0x0006
        L3 Cache Handle: 0x0007
        Serial Number: To Be Filled By O.E.M.
        Asset Tag: To Be Filled By O.E.M.
        Part Number: To Be Filled By O.E.M.

Handle 0x0005, DMI type 7, 19 bytes
Cache Information
        Socket Designation: L1-Cache
        Configuration: Enabled, Not Socketed, Level 1
        Operational Mode: Write Back
        Location: Internal
......
Guillemette answered 10/6, 2017 at 3:8 Comment(0)
P
23

I don’t believe there is anything as detailed as Linux’s /proc/cpuinfo. Look into sysctl hw and /var/run/dmesg.boot. Most of the information like CPU speed and instruction sets should be in there somewhere.

This is what I see (with a few uninteresting hw.* fields removed):

$ uname -sr
FreeBSD 4.10-RELEASE
$ grep -i cpu /var/run/dmesg.boot 
CPU: Pentium III/Pentium III Xeon/Celeron (448.97-MHz 686-class CPU)
$ /sbin/sysctl hw
hw.machine: i386
hw.model: Pentium III/Pentium III Xeon/Celeron
hw.ncpu: 1
hw.byteorder: 1234
hw.physmem: 665989120
hw.usermem: 604614656
hw.pagesize: 4096
hw.floatingpoint: 1
hw.machine_arch: i386
hw.aac.iosize_max: 65536
hw.an.an_dump: off
hw.an.an_cache_mode: dbm
hw.an.an_cache_mcastonly: 0
hw.an.an_cache_iponly: 1
hw.fxp_rnr: 0
hw.fxp_noflow: 0
hw.dc_quick: 1
hw.ste.rxsyncs: 0
hw.instruction_sse: 0
hw.availpages: 162432

(Note that on OpenBSD, the cpu speed is found in hw.cpuspeed instead of in dmesg.)

Phraseologist answered 3/11, 2010 at 15:16 Comment(3)
There is in FreeBSD but I've been away too long to say where to find it.Spaceless
But unlike/proc/cpuinfo,sysctlrequires root access.Bouldon
Running 'sysctl' does not require root access unless you are changing values that can actually be changed; viewing OIDs does not require any special permissions unless you completely lock out the ability for users to run sysctl.Yclept
G
15

Use dmidecode command:

# dmidecode -t processor -t cache
# dmidecode 3.0
Scanning /dev/mem for entry point.
SMBIOS 2.4 present.

Handle 0x0004, DMI type 4, 35 bytes
Processor Information
        Socket Designation: LGA 775
        Type: Central Processor
        Family: Pentium 4
        Manufacturer: Intel
        ID: F6 06 00 00 FF FB EB BF
        Signature: Type 0, Family 6, Model 15, Stepping 6
        Flags:
                FPU (Floating-point unit on-chip)
                VME (Virtual mode extension)
                DE (Debugging extension)
                PSE (Page size extension)
                TSC (Time stamp counter)
                MSR (Model specific registers)
                PAE (Physical address extension)
                MCE (Machine check exception)
                CX8 (CMPXCHG8 instruction supported)
                APIC (On-chip APIC hardware supported)
                SEP (Fast system call)
                MTRR (Memory type range registers)
                PGE (Page global enable)
                MCA (Machine check architecture)
                CMOV (Conditional move instruction supported)
                PAT (Page attribute table)
                PSE-36 (36-bit page size extension)
                CLFSH (CLFLUSH instruction supported)
                DS (Debug store)
                ACPI (ACPI supported)
                MMX (MMX technology supported)
                FXSR (FXSAVE and FXSTOR instructions supported)
                SSE (Streaming SIMD extensions)
                SSE2 (Streaming SIMD extensions 2)
                SS (Self-snoop)
                HTT (Multi-threading)
                TM (Thermal monitor supported)
                PBE (Pending break enabled)
        Version: Intel(R) Core(TM)2 CPU 6600 @ 2.40GHz
        Voltage: 1.4 V
        External Clock: 266 MHz
        Max Speed: 3800 MHz
        Current Speed: 2394 MHz
        Status: Populated, Enabled
        Upgrade: Other
        L1 Cache Handle: 0x0005
        L2 Cache Handle: 0x0006
        L3 Cache Handle: 0x0007
        Serial Number: To Be Filled By O.E.M.
        Asset Tag: To Be Filled By O.E.M.
        Part Number: To Be Filled By O.E.M.

Handle 0x0005, DMI type 7, 19 bytes
Cache Information
        Socket Designation: L1-Cache
        Configuration: Enabled, Not Socketed, Level 1
        Operational Mode: Write Back
        Location: Internal
......
Guillemette answered 10/6, 2017 at 3:8 Comment(0)
S
5

FreeBSD 11.2

sysctl hw.model

Result:

hw.model: Intel(R) Xeon(R) CPU E5620 @ 2.40GHz

Supplemental answered 3/6, 2020 at 11:56 Comment(0)
W
4

Just to add to jleedev’s comment, you can use the sysctl(3) syscall to get this information out of the kernel from your application. See the CTL_HW top-level name

Whig answered 4/11, 2010 at 23:9 Comment(1)
Thanks, using sysctl(8) was the simplest to adopt.Maghutte
Z
3

If you're interested in CPU flags, you also could take a look at

dmesg -a | grep Features

or

 grep Features /var/run/dmesg.boot

That would show something like

Features=0xfebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,
PAT,PSE36,CLFLUSH,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS>
Features2=0x82982203<SSE3,PCLMULQDQ,SSSE3,CX16,SSE4.1,SSE4.2,POPCNT,
AESNI,<b31>>
AMD Features=0x28100000<NX,RDTSCP,LM>
AMD Features2=0x1<LAHF>
Zetta answered 15/4, 2015 at 9:42 Comment(1)
Catting the file is reduntant, you can do this: 'grep Features /var/run/dmesg.boot 'Kerk
W
2

Note that information like the CPU features and various CPU cache sizes are not in the sysctl output, but they are available in the output from dmidecode under FreeBSD.

Waltner answered 21/8, 2013 at 19:32 Comment(0)
S
0

Maybe you could use lscpu, it's a port of lscpu utility in Linux to the FreeBSD. Running

pkg install lscpu

is suffice to install it.

Scotland answered 2/7 at 6:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.