几句话说清楚39:什么是Snoop Filter Back Invalidation

前面提到了Skylake的CPU对缓存的结构进行了一番改动,L2和L3缓存从Inclusive的关系变为了Non-inclusive。这个变化就引入了Skylake中专用的Snoop Filter。和所有Snoop Filter一样,都是服务于MESI协议,探测一下同一条Cache Line在不同的CPU核中的状态。

在Skylake中的区别是,以前的Snoop Filter都是直接用L3缓存,因为缓存之间存在Inclusive的关系,所以所有CPU core L2缓存中存在的数据在L3中都存在,因此方便多个核之间“交流”数据信息。

换成Non-inclusive架构之后,L3便不再具有这一“特殊能力”,为了保证Cache Cohenerence,就需要专门的Snoop Filter。从本质上将,Snoop Filter也就是一块缓存,保存有某个Cache Line在所有CPU核中的状态,以便支持MESI协议。

是缓存的话就存在一个问题,就是缓存的大小始终是有限的。当Snoop Filter中保存的信息超出了它的容量,就需要将一些原有的信息踢出。由于Snoop Filter的特殊性,如果缓存的状态信息不存在了,但缓存仍然存在于CPU核心的L1或L2缓存中,便无法继续保持缓存相干性。所以在Snoop Filter踢出某个Cache Line的信息时,同样需要把各级缓存中存在的该Cache Line从缓存中踢出。这一行为就成为“Snoop Filter Back Invalidation”。

如果你的程序出现Cache Miss,可能并不是因为缓存大小不够或者你要的数据不在缓存之中,还有可能是Snoop Filter容量不够,导致出现Back Invalidation出现Cache Miss。

检查CPU是否出现Snoop Filter Back Invalidation需要查看以下PMU事件计数:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
{
"Unit": "CHA",
"EventCode": "0x3D",
"UMask": "0x01",
"PortMask": "0x00",
"FCMask": "0x00",
"UMaskExt": "0x00",
"EventName": "UNC_CHA_SF_EVICTION.M_STATE",
"BriefDescription": "Snoop filter capacity evictions for M-state entries.",
"PublicDescription": "Counts snoop filter capacity evictions for entries
tracking modified lines in the cores cache. Snoop filter capacity evictions
occur when the snoop filter is full and evicts an existing entry to track
a new entry.
Does not count clean evictions such as when a cores cache replaces a
tracked cacheline with a new cacheline.",
"Counter": "0,1,2,3",
"MSRValue": "0x00",
"ELLC": "0",
"Filter": "na",
"ExtSel": "0",
"Deprecated": "0",
"FILTER_VALUE": "0"
},
{
"Unit": "CHA",
"EventCode": "0x3D",
"UMask": "0x02",
"PortMask": "0x00",
"FCMask": "0x00",
"UMaskExt": "0x00",
"EventName": "UNC_CHA_SF_EVICTION.E_STATE",
"BriefDescription": "Snoop filter capacity evictions for E-state entries.",
"PublicDescription": "Counts snoop filter capacity evictions for entries
tracking modified lines in the cores cache. Snoop filter capacity evictions
occur when the snoop filter is full and evicts an existing entry to track
a new entry.
Does not count clean evictions such as when a cores cache replaces a
tracked cacheline with a new cacheline.",
"Counter": "0,1,2,3",
"MSRValue": "0x00",
"ELLC": "0",
"Filter": "na",
"ExtSel": "0",
"Deprecated": "0",
"FILTER_VALUE": "0"
},
{
"Unit": "CHA",
"EventCode": "0x3D",
"UMask": "0x04",
"PortMask": "0x00",
"FCMask": "0x00",
"UMaskExt": "0x00",
"EventName": "UNC_CHA_SF_EVICTION.S_STATE",
"BriefDescription": "Snoop filter capacity evictions for S-state entries.",
"PublicDescription": "Counts snoop filter capacity evictions for entries
tracking modified lines in the cores cache. Snoop filter capacity evictions
occur when the snoop filter is full and evicts an existing entry to track
a new entry.
Does not count clean evictions such as when a cores cache replaces a
tracked cacheline with a new cacheline.",
"Counter": "0,1,2,3",
"MSRValue": "0x00",
"ELLC": "0",
"Filter": "na",
"ExtSel": "0",
"Deprecated": "0",
"FILTER_VALUE": "0"
},
© 2020 DecodeZ All Rights Reserved. 本站访客数人次 本站总访问量
Theme by hiero