SFENCE是否会阻止存储缓冲区隐藏来自MESI的更改? [英] Does SFENCE prevent the Store Buffer hiding changes from MESI?

查看:63
本文介绍了SFENCE是否会阻止存储缓冲区隐藏来自MESI的更改?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果Core写入但其L1中不存在高速缓存行,则它将写入存储缓冲区.另一个核心请求该缓存行,MESI无法看到存储缓冲区更新,并返回未修改的缓存行.此后不久,将刷新存储缓冲区,但是第二个Core已经使用了较早的值.

If a Core writes but the cache line is not present in its L1, so it writes to the Store Buffer. Another Core requests that cache line, MESI cannot see the Store Buffer update and returns the unmodified cache line. The Store Buffer is flushed shortly after, but the second Core already uses the older value.

我看不到SFENCE如何解决此问题?是的,缓存行将尽快更新,但是Core仍然需要等待将该值写入L1,在此期间第二个Core可以请求读取?

I don't see how an SFENCE solves this problem? Yes the cache line will be updated sooner, but the Core still needs to wait to write the value to L1 and during this time the second Core can request to read?

推荐答案

不,它不会阻止核心隐藏" MESI中的商店(也许更好地称为缓存一致性域).实际上,正如对OP的评论中所指出的那样,SFENCE对已经强烈订购的普通x86存储没有影响.仅在至少其中一个是NT存储区或WC存储器存储区之间的存储区之间设置隔离栅是有用的.

No, it doesn't prevent the core from "hiding" the stores from MESI (perhaps better called something like the cache coherent domain). In fact, as pointed out in the comments to the OP, SFENCE has no effect on normal x86 stores which are already strongly ordered. It is only useful to put a fence between stores at least one of which is an NT store, or a store to WC memory, etc.

这里的隐藏"并不是真正的问题. x86具有总存储量"顺序,其中存在 most 操作观察到的单个全局存储顺序.此顺序基本上是存储 leave 存储缓冲区(提交给L1)的顺序.这不是不是他们进入缓冲区的顺序,甚至不是商店退休的顺序.因此,当存储仍在存储缓冲区中时,实际上并没有出现在整个存储顺序中,并且在缓存一致性域中是不可见的.

The "hiding" here isn't really problematic. The x86 has a "total store" order in which there is a single global order of stores that is observed by most operations. This order is basically the order at which stores leave the store buffer (are committed to L1). It is not the order at which they enter the buffer, or even the order in which the stores retire. So when a store is still in the store buffer, it effectively hasn't occurred in the total store order, and is invisible in the cache coherent domain.

这导致重新排序(在x86上)的唯一方法是,这允许稍后的加载显然传递早期的存储:执行后的加载从全局顺序"中读取(例如,L1中的命中),但是执行更早商店可能仍位于商店缓冲区中(如上所述),这意味着它尚未成为全局订单的一部分.为了防止重新排序会影响性能,但是所有其他排序都只是通过保持顺序(装入-装入和存储-存储)以及其他一些机制来防止,以便确保以后的存储在完成较早的装入之前不会提交,从而阻止了所有其他排序

The only way this causes reordering (on x86), is that this allows later loads to apparently pass earlier stores: a later load reads from the "global order" when it executes (e.g., hits in L1), but an earlier store may still be sitting in the store buffer, which (as above) means it hasn't become part of the global order yet. To prevent that reordering would be performance prohibitive, but all the other orderings are prevented just by keeping things in order (load-load, and store-store) and some other mechanism which ensures later stores don't get committed until earlier loads have completed.

如果您想解决"存储缓冲区问题,那么mfence是您的解决方案.在继续操作之前,它可以有效地刷新存储缓冲区.

If you want to "solve" the store buffer problem, then mfence is your solution. It effectively flushes the store buffer before proceeding.

这篇关于SFENCE是否会阻止存储缓冲区隐藏来自MESI的更改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆