Chinaunix首页 | 论坛 | 博客
  • 博客访问: 635743
  • 博文数量: 171
  • 博客积分: 2246
  • 博客等级: 大尉
  • 技术积分: 1574
  • 用 户 组: 普通用户
  • 注册时间: 2012-05-31 11:45
文章分类

全部博文(171)

文章存档

2018年(3)

2017年(4)

2015年(1)

2014年(20)

2013年(57)

2012年(86)

分类: LINUX

2013-11-26 15:07:38

查看当前操作系统内核信息

  1. # uname -a
  2. Linux redcat 2.6.31-20-generic #58-Ubuntu SMP Fri Mar 12 05:23:09 UTC 2010 i686 GNU/Linux
查看当前操作系统发行版本信息

  1. #cat /etc/issue
  2. Ubuntu 9.10 \n \l

查看cpu型号


  1. # cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c
  2. 2 Intel(R) Core(TM)2 Duo CPU P8600 @ 2.40GHz
  3. (看到有2个逻辑CPU, 也知道了CPU型号)


查看物理cpu颗数

  1. # cat /proc/cpuinfo | grep physical | uniq -c
  2. 2 physical id : 0
  3. (说明实际上是1颗2核的CPU)

查看cpu运行模式

  1. # getconf LONG_BIT
  2. 32
  3. (说明当前CPU运行在32bit模式下, 但不代表CPU不支持64bit)


查看cpu是否支持64bit

  1. # cat /proc/cpuinfo | grep flags | grep ' lm ' | wc -l
  2. 2

(结果大于0, 说明支持64bit计算. lm指long mode, 支持lm则是64bit)


查看cpu信息概要(昨天看aix的时候刚发现的,在ubuntu上竟然也有~):


  1. #lscpu

  2. Architecture      : i686   #架构686
  3. CPU(s)            : 2      #逻辑cpu颗数是2
  4. Thread(s) per core: 1       #每个核心线程数是1
  5. Core(s) per socket: 2      #每个cpu插槽核数/每颗物理cpu核数是2
  6. CPU socket(s)     : 1      #cpu插槽数是1
  7. Vendor ID: GenuineIntel #cpu厂商ID是GenuineIntel
  8. CPU family: 6 #cpu系列是6
  9. Model: 23 #型号23
  10. Stepping: 10 #步进是10
  11. CPU MHz: 800.000 #cpu主频是800MHz
  12. Virtualization: VT-x #cpu支持的虚拟化技术VT-x(对此在下一博文中解释下
  13. L1d cache: 32K #一级缓存32K(google了下,这具体表示表示cpu的L1数据缓存为32k)
  14. L1i cache: 32K #一级缓存32K(具体为L1指令缓存为32K)
  15. L2 cache: 3072K #二级缓存3072K

最后来个大而全的:


  1. #cat /proc/cpuinfo

  2. processor : 0
  3. vendor_id : GenuineIntel
  4. cpu family : 6
  5. model : 23
  6. model name : Intel(R) Core(TM)2 Duo CPU P8600 @ 2.40GHz
  7. stepping : 10
  8. cpu MHz : 800.000
  9. cache size : 3072 KB
  10. physical id : 0
  11. siblings : 2
  12. core id : 0
  13. cpu cores : 2
  14. apicid : 0
  15. initial apicid : 0
  16. fdiv_bug : no
  17. hlt_bug : no
  18. f00f_bug : no
  19. coma_bug : no
  20. fpu : yes
  21. fpu_exception : yes
  22. cpuid level : 13
  23. wp : yes
  24. flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc arch_perfmon pebs bts pni dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm sse4_1 xsave lahf_lm ida tpr_shadow vnmi flexpriority
  25. bogomips : 4788.60
  26. clflush size : 64
  27. power management:
  28. processor : 1
  29. vendor_id : GenuineIntel
  30. cpu family : 6
  31. model : 23
  32. model name : Intel(R) Core(TM)2 Duo CPU P8600 @ 2.40GHz
  33. stepping : 10
  34. cpu MHz : 800.000
  35. cache size : 3072 KB
  36. physical id : 0
  37. siblings : 2
  38. core id : 1
  39. cpu cores : 2
  40. apicid : 1
  41. initial apicid : 1
  42. fdiv_bug : no
  43. hlt_bug : no
  44. f00f_bug : no
  45. coma_bug : no
  46. fpu : yes
  47. fpu_exception : yes
  48. cpuid level : 13
  49. wp : yes
  50. flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc arch_perfmon pebs bts pni dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm sse4_1 xsave lahf_lm ida tpr_shadow vnmi flexpriority
  51. bogomips : 4787.96
  52. clflush size : 64
  53. power management:

FROM:http://blog.chinaunix.net/uid-20548989-id-1667301.html

近期的工作中需要对cpu的结构做更多的了解,项目中见到比较多cpu cache的信息,想对其做一个基本的了解。

第一步肯定是希望知道哪里能看到cpu cache的信息呢?

有多种办法,lscpu, cat /proc/cpuinfo等。

这里发现通过查看系统的/sys/目录能看到一些更详细的信息。


  1. tree /sys/devices/system/cpu/cpu0/cache/
  2. /sys/devices/system/cpu/cpu0/cache/
  3. ├── index0 //L1 data cache
  4. │ ├── coherency_line_size //记录cache line大小
  5. │ ├── level
  6. │ ├── number_of_sets
  7. │ ├── physical_line_partition
  8. │ ├── shared_cpu_list
  9. │ ├── shared_cpu_map
  10. │ ├── size //cache 大小
  11. │ ├── type //cache类型
  12. │ └── ways_of_associativity
  13. ├── index1 //L1 instruction cache
  14. │ ├── coherency_line_size
  15. │ ├── level
  16. │ ├── number_of_sets
  17. │ ├── physical_line_partition
  18. │ ├── shared_cpu_list
  19. │ ├── shared_cpu_map
  20. │ ├── size
  21. │ ├── type
  22. │ └── ways_of_associativity
  23. ├── index2 //L2 cache
  24. │ ├── coherency_line_size
  25. │ ├── level
  26. │ ├── number_of_sets
  27. │ ├── physical_line_partition
  28. │ ├── shared_cpu_list
  29. │ ├── shared_cpu_map
  30. │ ├── size
  31. │ ├── type
  32. │ └── ways_of_associativity
  33. └── index3 //L3 cache
  34.     ├── coherency_line_size
  35.     ├── level
  36.     ├── number_of_sets
  37.     ├── physical_line_partition
  38.     ├── shared_cpu_list
  39.     ├── shared_cpu_map
  40.     ├── size
  41.     ├── type
  42.     └── ways_of_associativity

举例:

  1. cat /sys/devices/system/cpu/cpu0/cache/index0/coherency_line_size
  2. 64 //cache line 大小为64字节
FROM:http://blog.chinaunix.net/uid-24830931-id-3476397.html


1、ubuntu下可以使用cpuid

  1. #cpuid
  2. Processor name string: AMD Opteron(tm) Processor 6128
  3. L1 Cache Information:
  4. 2/4-MB Pages:
  5.   Data TLB: associativity 255-way #entries 48
  6.   Instruction TLB: associativity 255-way #entries 16
  7. 4-KB Pages:
  8.   Data TLB: associativity 255-way #entries 48
  9.   Instruction TLB: associativity 255-way #entries 32
  10. L1 Data cache:
  11.   size 64 KB associativity 2-way lines per tag 1 line size 64
  12. L1 Instruction cache:
  13.   size 64 KB associativity 2-way lines per tag 1 line size 64

  14. L2 Cache Information:
  15. 2/4-MB Pages:
  16.   Data TLB: associativity L2 off #entries 128
  17.   Instruction TLB: associativity L2 off #entries 0
  18. 4-KB Pages:
  19.   Data TLB: associativity 2-way #entries 0
  20.   Instruction TLB: associativity 2-way #entries 0
  21.   size 2 KB associativity L2 off lines per tag 129 line size 64
2、想观察cache细节也可以这样做:
  1. [root@gc15 ~]# ls /sys/devices/system/cpu/cpu0/cache/index
  2. index0/ index1/ index2/ index3/
一级cache, Data cache
index0和Index1是一级cache中的data和instruction cache

  1. [root@gc15 ~]# cat /sys/devices/system/cpu/cpu0/cache/index0/level
  2. 1
  3. [root@gc15 ~]# cat /sys/devices/system/cpu/cpu0/cache/index0/type
  4. Data
  5. [root@gc15 ~]# cat /sys/devices/system/cpu/cpu0/cache/index0/size
  6. 32K

  7. 一级cache, Instruction cache
  8. [root@gc15 ~]# cat /sys/devices/system/cpu/cpu0/cache/index1/level
  9. 1
  10. [root@gc15 ~]# cat /sys/devices/system/cpu/cpu0/cache/index1/type
  11. Instruction
  12. [root@gc15 ~]# cat /sys/devices/system/cpu/cpu0/cache/index1/size
  13. 32K

  14. 二级cache,共享的
  15. [root@gc15 ~]# cat /sys/devices/system/cpu/cpu0/cache/index2/level
  16. 2
  17. [root@gc15 ~]# cat /sys/devices/system/cpu/cpu0/cache/index2/type
  18. Unified
  19. [root@gc15 ~]# cat /sys/devices/system/cpu/cpu0/cache/index2/size
  20. 256K

  21. 三级cache,共享的(有的cpu没有)
  22. [root@gc15 ~]# cat /sys/devices/system/cpu/cpu0/cache/index3/level
  23. 3
  24. [root@gc15 ~]# cat /sys/devices/system/cpu/cpu0/cache/index3/type
  25. Unified
  26. [root@gc15 ~]# cat /sys/devices/system/cpu/cpu0/cache/index3/size
  27. 12288K


文件描述符最大值修改

linux下最大文件描述符的限制有两个方面,一个是用户级的限制,另外一个则是系统级限制。

先介绍如何修改系统级的限制
通常我们通过终端连接到linux系统后执行ulimit -n 命令可以看到本次登录的session其文件描述符的限制,如下:
$ulimit -n
   1024

当然可以通过ulimit -SHn 102400 命令来修改该限制,但这个变更只对当前的session有效,当断开连接重新连接后更改就失效了。

如果想永久变更需要修改/etc/security/limits.conf 文件,如下:
vi /etc/security/limits.conf
* hard nofile 102400
* soft nofile 102400

保存退出后重新登录,其最大文件描述符已经被永久更改了。

这只是修改用户级的最大文件描述符限制,也就是说每一个用户登录后执行的程序占用文件描述符的总数不能超过这个限制。

系统级的限制

它是限制所有用户打开文件描述符的总和,可以通过修改内核参数来更改该限制:
sysctl -w fs.file-max=102400

使用sysctl命令更改也是临时的,如果想永久更改需要在/etc/sysctl.conf添加
fs.file-max=102400
保存退出后使用sysctl -p 命令使其生效。

与file-max参数相对应的还有file-nr,这个参数是只读的,可以查看当前文件描述符的使用情况。

sysctl -a | grep file-nr

下面是摘自kernel document中关于file-max和file-nr参数的说明

file-max & file-nr:

The kernel allocates file handles dynamically, but as yet it doesn't free them again.
内核可以动态的分配文件句柄,但到目前为止是不会释放它们的

The value in file-max denotes the maximum number of file handles that the Linux kernel will allocate. When you get lots of error messages about running out of file handles, you might want to increase this limit.
file-max的值是linux内核可以分配的最大文件句柄数。如果你看到了很多关于打开文件数已经达到了最大值的错误信息,你可以试着增加该值的限制

Historically, the three values in file-nr denoted the number of allocated file handles, the number of allocated but unused file handles, and the maximum number of file handles. Linux 2.6 always reports 0 as the number of free file handles -- this is not an error, it just means that the number of allocated file handles exactly matches the number of used file handles.
在kernel 2.6之前的版本中,file-nr 中的值由三部分组成,分别为:1.已经分配的文件句柄数,2.已经分配单没有使用的文件句柄数,3.最大文件句柄数。但在kernel 2.6版本中第二项的值总为0,这并不是一个错误,它实际上意味着已经分配的文件句柄无一浪费的都已经被使用了
file-max的默认值大概是系统内存的10%(系统内存以kb计算)
FROM:http://www.cnblogs.com/ghost240/archive/2012/05/30/2526694.html

阅读(1690) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~