Linux FreeBSD v8.1上的/proc/cpuinfo等效于什么?

Linux FreeBSD v8.1上的/proc/cpuinfo等效于什么?,linux,cpu,porting,introspection,freebsd,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.50

在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

我不相信有什么比Linux的
/proc/cpuinfo
更详细的了。查看
sysctlhw
/var/run/dmesg.boot
。大多数信息,如CPU速度和指令集,应该在那里的某个地方

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


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

只需添加到jleedev的注释中,您可以使用
sysctl(3)
syscall从应用程序的内核中获取此信息。请参见
CTL\u HW
顶级名称:


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

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

dmesg -a | grep Features

这会显示出

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>
Features=0xfebff
特性2=0x82982203
AMD功能=0x28100000
AMD功能2=0x1

使用
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
......
FreeBSD 11.2

sysctl硬件模型

结果:


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

如果您是在特定的编程环境(而不是某种用户环境)中说这句话的话,您最好马上说出来,否则它将迁移到异地…正确,目前我的产品在执行过程中读取此文件,我想在FreeBSD上找到一个等效的操作。FreeBSD中有,但我已经离开太久,无法说出在哪里可以找到它。但与
/proc/cpuinfo
不同,
sysctl
需要根访问权限。运行“sysctl”不需要根访问权限,除非您正在更改实际上可以更改的值;查看OID不需要任何特殊权限,除非您完全锁定用户运行sysctl的能力。谢谢,使用sysctl(8)是最简单的方法。如果文件是冗余的,您可以这样做:“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>
# 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
......