FreeBSD v8.1上/ proc / cpuinfo的等价物是什么?

时间:2010-11-03 02:39:55

标签: linux cpu porting introspection freebsd

FreeBSD v8.1上Linux的/ proc / cpuinfo相当于什么?我的应用程序读取/ proc / cpuinfo并将信息保存在日志文件中,我该怎么做才能在FreeBSD上记录类似的信息?

示例/ proc / cpuinfo如下所示:

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

6 个答案:

答案 0 :(得分:19)

我认为没有像Linux /proc/cpuinfo那样详细的内容。查看sysctl hw/var/run/dmesg.boot。大多数信息,如CPU速度和指令集应该在某处。

这就是我所看到的(删除了一些不感兴趣的hw.*字段):

$ 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

(请注意,在OpenBSD上,cpu速度可以在hw.cpuspeed而不是在dmesg中找到。)

答案 1 :(得分:8)

使用dmidecode命令:

# 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
......

答案 2 :(得分:3)

只是要添加到jleedev的注释,您可以使用sysctl(3)系统调用从应用程序中获取内核的这些信息。请参阅CTL_HW顶级名称:

http://www.manpages.info/freebsd/sysctl.3.html

答案 3 :(得分:2)

请注意,CPU功能和各种CPU缓存大小等信息不在sysctl输出中,但它们在FreeBSD下的 dmidecode 的输出中可用。

答案 4 :(得分:2)

如果您对CPU标志感兴趣,还可以查看

dmesg -a | grep Features

 grep Features /var/run/dmesg.boot

这会显示类似

的内容
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>

答案 5 :(得分:0)

FreeBSD 11.2

sysctl hw.model

结果:

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