mcache per P or per M?

瀏覽次數:176 次
跳到第一則未讀訊息

Vincent Blanchon

未讀,
2019年11月2日 清晨7:57:562019/11/2
收件者:golang-nuts
Hello,

Reading the code, I can see the structs m and p hold a mcache instance. I'm curious to understand why both of them need an instance of mcache?
Also, I see that those instances are the same ones (runtime/proc.go init the p.mcache with m.cache and vice versa), is it correct? Should we consider that mcache belongs to m or p?

Thank you for the ones that will take time to reply :)

tokers

未讀,
2019年11月3日 晚上9:48:512019/11/3
收件者:golang-nuts
Hello!

It's my own understanding and it's not necessary true.
The mcache belongs to per P, but by assigning it to M, we can mark M is binded to this P.

Ian Lance Taylor

未讀,
2019年11月4日 下午5:27:002019/11/4
收件者:Vincent Blanchon、golang-nuts
On Sat, Nov 2, 2019 at 4:58 AM Vincent Blanchon
<blanchon...@gmail.com> wrote:
>
> Reading the code, I can see the structs m and p hold a mcache instance. I'm curious to understand why both of them need an instance of mcache?
> Also, I see that those instances are the same ones (runtime/proc.go init the p.mcache with m.cache and vice versa), is it correct? Should we consider that mcache belongs to m or p?

The mcache belongs to the P.

We used to have the possibility of an M using the mcache of a P even
though it was not running on the P. That happened in the helpgc
function which was run by gchelpers. But gchelpers was removed in
https://golang.org/cl/134785, so it may be that we no longer need the
mcache field on an M.

Out of curiosity, I tried that: https://golang.org/cl/205239.

Ian

Vincent Blanchon

未讀,
2019年11月5日 凌晨12:49:002019/11/5
收件者:golang-nuts

Thank you, Ian! With the CL it is much more clear now
回覆所有人
回覆作者
轉寄
0 則新訊息