/proc文件系统(一):cpuinfo

0. 前言

/proc 文件系统是一个伪文件系统,它只存在内存当中,而不占用外存空间。

它以文件系统的方式为内核与进程提供通信的接口。用户和应用程序可以通过/proc得到系统的信息,并可以改变内核的某些参数。
由于系统的信息,如进程,是动态改变的,所以用户或应用程序读取/proc目录中的文件时,proc文件系统是动态从系统内核读出所需信息并提交的。

root@jimmy-vm:/proc# ll /proc/
dr-xr-xr-x  9 root             root                           0 11月 28 20:09 <pid>/
......
dr-xr-xr-x  2 root             root                           0 11月 30 16:53 acpi/
dr-xr-xr-x  5 root             root                           0 11月 30 16:53 asound/
-r--r--r--  1 root             root                           0 11月 30 16:53 buddyinfo
dr-xr-xr-x  4 root             root                           0 11月 30 16:53 bus/
-r--r--r--  1 root             root                           0 11月 30 16:53 cgroups
-r--r--r--  1 root             root                           0 11月 30 16:53 cmdline
-r--r--r--  1 root             root                           0 11月 30 16:53 consoles
-r--r--r--  1 root             root                           0 11月 30 16:53 cpuinfo
-r--r--r--  1 root             root                           0 11月 30 16:53 crypto
-r--r--r--  1 root             root                           0 11月 30 16:53 devices
-r--r--r--  1 root             root                           0 11月 30 16:53 diskstats
-r--r--r--  1 root             root                           0 11月 30 16:53 dma
dr-xr-xr-x  2 root             root                           0 11月 30 16:53 driver/
-r--r--r--  1 root             root                           0 11月 30 16:53 execdomains
-r--r--r--  1 root             root                           0 11月 30 16:53 fb
-r--r--r--  1 root             root                           0 11月 30 16:53 filesystems
dr-xr-xr-x  5 root             root                           0 11月 30 16:53 fs/
-r--r--r--  1 root             root                           0 11月 30 16:53 interrupts
-r--r--r--  1 root             root                           0 11月 30 16:53 iomem
-r--r--r--  1 root             root                           0 11月 30 16:53 ioports
dr-xr-xr-x 57 root             root                           0 11月 30 16:53 irq/
-r--r--r--  1 root             root                           0 11月 30 16:53 kallsyms
-r--------  1 root             root             140737477881856 11月 30 16:53 kcore
-r--r--r--  1 root             root                           0 11月 30 16:53 keys
-r--r--r--  1 root             root                           0 11月 30 16:53 key-users
-r--------  1 root             root                           0 11月 16 14:27 kmsg
-r--------  1 root             root                           0 11月 30 16:53 kpagecgroup
-r--------  1 root             root                           0 11月 30 16:53 kpagecount
-r--------  1 root             root                           0 11月 30 16:53 kpageflags
-r--r--r--  1 root             root                           0 11月 30 16:53 loadavg
-r--r--r--  1 root             root                           0 11月 30 16:53 locks
-r--r--r--  1 root             root                           0 11月 30 16:53 mdstat
-r--r--r--  1 root             root                           0 11月 30 16:53 meminfo
-r--r--r--  1 root             root                           0 11月 30 16:53 misc
-r--r--r--  1 root             root                           0 11月 30 16:53 modules
lrwxrwxrwx  1 root             root                          11 11月 30 16:53 mounts -> self/mounts
dr-xr-xr-x  3 root             root                           0 11月 30 16:53 mpt/
-rw-r--r--  1 root             root                           0 11月 30 16:53 mtrr
lrwxrwxrwx  1 root             root                           8 11月 30 16:53 net -> self/net/
-r--r--r--  1 root             root                           0 11月 30 16:53 pagetypeinfo
-r--r--r--  1 root             root                           0 11月 30 16:53 partitions
-r--r--r--  1 root             root                           0 11月 30 16:53 sched_debug
-r--r--r--  1 root             root                           0 11月 30 16:53 schedstat
dr-xr-xr-x  4 root             root                           0 11月 30 16:53 scsi/
lrwxrwxrwx  1 root             root                           0 11月 16 14:27 self -> 107692/
-r--------  1 root             root                           0 11月 30 16:53 slabinfo
-r--r--r--  1 root             root                           0 11月 30 16:53 softirqs
-r--r--r--  1 root             root                           0 11月 30 16:53 stat
-r--r--r--  1 root             root                           0 11月 16 14:27 swaps
dr-xr-xr-x  1 root             root                           0 11月 16 14:27 sys/
--w-------  1 root             root                           0 11月 30 16:53 sysrq-trigger
dr-xr-xr-x  2 root             root                           0 11月 30 16:53 sysvipc/
lrwxrwxrwx  1 root             root                           0 11月 16 14:27 thread-self -> 107692/task/107692/
-r--r--r--  1 root             root                           0 11月 30 16:53 timer_list
-rw-r--r--  1 root             root                           0 11月 30 16:53 timer_stats
dr-xr-xr-x  4 root             root                           0 11月 30 16:53 tty/
-r--r--r--  1 root             root                           0 11月 30 16:53 uptime
-r--r--r--  1 root             root                           0 11月 30 16:53 version
-r--r--r--  1 root             root                           0 11月 30 16:53 version_signature
-r--------  1 root             root                           0 11月 30 16:53 vmallocinfo
-r--r--r--  1 root             root                           0 11月 30 16:53 vmstat
-r--r--r--  1 root             root                           0 11月 30 16:53 zoneinfo

1. /proc/cpuinfo

在linux操作系统中,CPU的信息在启动的过程中被装载到虚拟目录/proc下的cpuinfo文件中,我们可以通过 cat /proc/cpuinfo 查看一下。

该文件中存放了有关 cpu的相关信息(型号,缓存大小等)


root@jimmy-vm:/proc# cat cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 94
model name      : Intel(R) Core(TM) i5-6400 CPU @ 2.70GHz
stepping        : 3
microcode       : 0xc2
cpu MHz         : 2712.002
cache size      : 6144 KB
physical id     : 0
siblings        : 1
core id         : 0
cpu cores       : 1
apicid          : 0
initial apicid  : 0
fpu             : yes
fpu_exception   : yes
cpuid level     : 22
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch epb invpcid_single kaiser fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid rdseed adx smap xsaveopt xsavec xgetbv1 dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp
bugs            : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf
bogomips        : 5424.00
clflush size    : 64
cache_alignment : 64
address sizes   : 42 bits physical, 48 bits virtual
power management:

上面的各个参数的含义解释如下:

属性含义
processor逻辑处理器的id。
vendor idCPU制造商
cpu familyCPU产品系列代号
modelCPU属于其系列中的哪一代的代号
model nameCPU属于的名字及其编号、标称主频
steppingCPU属于制作更新版本
cpu MHzCPU的实际使用主频
cache sizeCPU二级缓存大小
physical id单个CPU的标号
siblings单个CPU逻辑物理核数
core id当前物理核在其所处CPU中的编号,这个编号不一定连续
cpu cores该逻辑核所处CPU的物理核数
apicid用来区分不同逻辑核的编号,系统中每个逻辑核的此编号必然不同,此编号不一定连续
fpu是否具有浮点运算单元(Floating Point Unit)
fpu_exception是否支持浮点计算异常
cpuid level执行cpuid指令前,eax寄存器中的值,根据不同的值cpuid指令会返回不同的内容
wp表明当前CPU是否在内核态支持对用户空间的写保护(Write Protection)
flags当前CPU支持的功能
bogomips在系统内核启动时粗略测算的CPU速度(Million Instructions Per Second)
clflush size每次刷新缓存的大小单位
cache_alignment缓存地址对齐单位
address sizes可访问地址空间位数

转载于:https://www.cnblogs.com/Jimmy1988/p/10045541.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值