clflush 会刷新 L1i 吗?

Does clflush flush L1i?

问题来了:clflush flush L1i吗?英特尔 ISA 手册对此并不清楚:

Invalidates from every level of the cache hierarchy in the cache coherence domain the cache line that contains the linear address specified with the memory operand. If that cache line contains modified data at any level of the cache hierarchy, that data is written back to memory

我会根据

的措辞进行推测

If that cache line contains modified data at any level of the cache hierarchy, that data is written back to memory.

所以L1I没有动过。这是英特尔 CPU 的实际行为吗?

clflush 按照罐头上的说明进行操作并刷新所有缓存:指令、数据和统一缓存。(以及解码的 uop 缓存)。玛格丽特·布鲁姆 .

指令缓存永远不会变脏,因此讨论修改行时讨论数据是有道理的。只有回写数据缓存可以是脏的。请注意,clflush 的预期目的之一是将脏数据写回非易失性 DIMM,因此文档关注数据是很自然的。

您对措辞读得太多了,可能是基于一种误解,认为回写是刷新的同义词。 一个干净的缓存行(例如 I-cache)可以通过简单地删除它来刷新,不需要回写。 注意 invd and wbinvd. The invd docs use "flush" as a synonym for "invalidate". (related: )

之间的区别

来自英特尔第 2 卷 ISA 参考手册entry for clflush

The CLFLUSH instruction can be used at all privilege levels and is subject to all permission checking and faults associated with a byte load (and in addition, a CLFLUSH instruction is allowed to flush a linear address in an execute-only segment). Like a load, the CLFLUSH instruction sets the A bit but not the D bit in the page tables.

这并没有明确地说它实际上刷新了这些区域中的 I-cache,但这意味着刷新与甚至不可能进行数据访问的情况相关.

半相关:Flush iCache in x86