ARM 缓存行为:"Clean" 或 "Invalidate" 是刷新缓存内存的正确命令吗?
ARM Cache behaviour: is "Clean" or "Invalidate" the correct command to flush cache memory?
这可能是一个愚蠢的问题,但我对 ARM CMSIS 缓存操作函数的措辞有点困惑。
ARM CMSIS 公开了可以 "clean" 缓存的函数、可以 "invalidate" 缓存的函数,以及一组同时执行这两种操作的函数。
这些 实际上 做什么不清楚,arm documentation 坦率地说让我困惑:
- You can invalidate the whole data cache (flush data cache) in one operation without writing back dirty data.
- You can invalidate individual lines without writing back any dirty data (flush data cache single entry).
- You can perform cleaning on a line-by-line basis. The data is only written back through the write buffer when a dirty line is
encountered, and the cleaned line remains in the cache (clean data
cache single entry). You can clean cache lines using either their
index within the data cache, or their address within memory.
- You can clean and flush individual lines in one operation, using either their index within the data cache, or their address within
memory.
我的理解是"flushing"缓存中的数据会导致被写回主存,"invalidating"缓存中的数据会导致处理器重新读取主存上下一次尝试访问相关数据。
然而,ARM 文档似乎暗示刷新操作实际上是一个 无效 操作,我一直在想的是刷新操作实际上是一个 "clean"操作。
我想我只是严重误解了文档。有人能指出我正确的方向吗?
我专门为皮质 M7 开发,如果相关的话。
从 armv7-m ARM ARM 他们有这个文本。
The definitions of these operations are:
Clean
A cache clean operation ensures that updates made by an observer that
controls the cache are made visible to other observers that can access
memory at the point to which the operation is performed. Once the
Clean has completed, the new memory values are guaranteed to be
visible to the point to which the operation is performed, for example
to the point of unification. The cleaning of a cache entry from a
cache can overwrite memory that has been written by another observer
only if the entry contains a location that has been written to by an
observer in the shareability domain of that memory location.
Invalidate
A cache invalidate operation ensures that updates made visible by
observers that access memory at the point to which the invalidate is
defined are made visible to an observer that controls the cache. This
might result in the loss of updates to the locations affected by the
invalidate operation that have been written by observers that access
the cache. If the address of an entry on which the invalidate operates
does not have a Normal Cacheable attribute, or if the cache is
disabled, then an invalidate operation also ensures that this address
is not present in the cache.
我读到说清理会将缓存中尚未保存到下一级内存的项目写出来(像我这样的人称之为刷新)。 Invalidate不关心是否有未写入的值,它准备缓存就好像没有值要保存一样,准备接受新的地址和数据。
我就是这么读的...
这可能是一个愚蠢的问题,但我对 ARM CMSIS 缓存操作函数的措辞有点困惑。
ARM CMSIS 公开了可以 "clean" 缓存的函数、可以 "invalidate" 缓存的函数,以及一组同时执行这两种操作的函数。
这些 实际上 做什么不清楚,arm documentation 坦率地说让我困惑:
- You can invalidate the whole data cache (flush data cache) in one operation without writing back dirty data.
- You can invalidate individual lines without writing back any dirty data (flush data cache single entry).
- You can perform cleaning on a line-by-line basis. The data is only written back through the write buffer when a dirty line is encountered, and the cleaned line remains in the cache (clean data cache single entry). You can clean cache lines using either their index within the data cache, or their address within memory.
- You can clean and flush individual lines in one operation, using either their index within the data cache, or their address within memory.
我的理解是"flushing"缓存中的数据会导致被写回主存,"invalidating"缓存中的数据会导致处理器重新读取主存上下一次尝试访问相关数据。
然而,ARM 文档似乎暗示刷新操作实际上是一个 无效 操作,我一直在想的是刷新操作实际上是一个 "clean"操作。
我想我只是严重误解了文档。有人能指出我正确的方向吗?
我专门为皮质 M7 开发,如果相关的话。
从 armv7-m ARM ARM 他们有这个文本。
The definitions of these operations are:
Clean
A cache clean operation ensures that updates made by an observer that controls the cache are made visible to other observers that can access memory at the point to which the operation is performed. Once the Clean has completed, the new memory values are guaranteed to be visible to the point to which the operation is performed, for example to the point of unification. The cleaning of a cache entry from a cache can overwrite memory that has been written by another observer only if the entry contains a location that has been written to by an observer in the shareability domain of that memory location.
Invalidate
A cache invalidate operation ensures that updates made visible by observers that access memory at the point to which the invalidate is defined are made visible to an observer that controls the cache. This might result in the loss of updates to the locations affected by the invalidate operation that have been written by observers that access the cache. If the address of an entry on which the invalidate operates does not have a Normal Cacheable attribute, or if the cache is disabled, then an invalidate operation also ensures that this address is not present in the cache.
我读到说清理会将缓存中尚未保存到下一级内存的项目写出来(像我这样的人称之为刷新)。 Invalidate不关心是否有未写入的值,它准备缓存就好像没有值要保存一样,准备接受新的地址和数据。
我就是这么读的...