linux查看cache版本,Linux 查看 cache 信息

Introduction

本文介绍了如何在linux下查看cache的信息,并进行简单的分析。

unix设计哲学

一切皆文件

Linux也很好的继承了这个理念。

cpu cache

我的cpu:

Intel(R) Core(TM) i5-3470 CPU @ 3.20GHz

cpu文件

文件夹/sys/devices/system/cpu就是对cpu的文件映射。进入以后,随便进一个cpu核,可以看到cache文件夹,tree以后:

.

├── index0

│ ├── coherency_line_size

│ ├── level

│ ├── number_of_sets

│ ├── physical_line_partition

│ ├── shared_cpu_list

│ ├── shared_cpu_map

│ ├── size

│ ├── type

│ └── ways_of_associativity

├── index1

│ ├── coherency_line_size

│ ├── level

│ ├── number_of_sets

│ ├── physical_line_partition

│ ├── shared_cpu_list

│ ├── shared_cpu_map

│ ├── size

│ ├── type

│ └── ways_of_associativity

├── index2

│ ├── coherency_line_size

...同上一个文件夹

│ └── ways_of_associativity

└── index3

├── coherency_line_size

...同上一个文件夹

└── ways_of_associativity

复制代码

文件解释

文件

表示内容

表示内容(中)

coherency_line_size

size of each cache line usually representing the minimum amount of data that gets transferred from memory

cache line大小(有的地方叫cache block)

level

represents the hierarchy in the multi-level cache

cache属于第几层

number_of_sets

total number of sets, a set is a collection of cache lines sharing the same index

cache set的数量

physical_line_partition

number of physical cache lines sharing the same cachetag

一个tag对应几个cache line(竟然还可以对应多个???看来了解的还不够全面)

size

Total size of the cache

总大小

type

type of the cache – data, inst or unified

cache的类型:数据、指令、统一,一般商用cpu只有L1划分了指令cache和数据cache

ways_of_associativity

number of ways in which a particular memory block can be placed in the cache

几路组相连

shared_cpu_list

shared_cpu_map

解释一下L3 的shared_cpu_map内容的格式:

00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,0000000f

复制代码

表面上看是2进制,其实是16进制表示,每个bit表示一个cpu,1个数字可以表示4个cpu

截取0000000f的后4位,转换为2进制表示

CPUid

15-4忽略

3

2

1

0

0x000f的二进制表示

1

1

1

1

这就表示L3是四个cpu共享的,cat shared_cpu_list:

0-3

复制代码

是0-3序号的cpu core。

组相连分析

针对L3的数据:

ways_of_associativity: 12

size: 6144K (Bytes)

coherency_line_size: 64 (Bytes)

number_of_sets: 8192

验证:

64*12*8192/1024 = 6144 KByte

复制代码

Reference

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值