On Nov 19, 2021, at 7:03 AM, a7866...@gmail.com <a7866...@gmail.com> wrote:
1.How did lr check whether the memory word is locked ? Is it possible to happen that one hart read dirty data while another hart writing same word ?
--
You received this message because you are subscribed to the Google Groups "RISC-V ISA Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to isa-dev+u...@groups.riscv.org.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/isa-dev/78b9097f-c7d7-4745-84e8-cdd62fb75dd1n%40groups.riscv.org.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/isa-dev/1788399B-204A-4B4D-90AD-35350C78F281%40gmail.com.
The LR makes a reservation. But it does not remove any other reservation. If it does, the implementation is vulnerable to livelock. If only the SC removes the other reservations, then the removal can be atomic with respect to success. Even then, care is required that the other reservations are removed only when the SC will otherwise be successful – though certain reasons for failure that will not repeat might still be allowed.
For similar reasons, it’s important the an LR does not acquire a cache line in the Exclusive or Modified state. LR should be happy with a Shared state. If LR requires Exclusive/Modified, LR/SC sequences are vulnerable to livelock.
Bill
From: Dan Petrisko <petr...@cs.washington.edu>
Sent: Friday, November 19, 2021 11:56 AM
To: Edwin Sutanto <esut...@gmail.com>
Cc: a7866...@gmail.com <a7866...@gmail.com>; RISC-V ISA Dev <isa...@groups.riscv.org>
Subject: Re: [isa-dev] question of lr/cs
EXTERNAL MAIL
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/isa-dev/CABXpatpNxv6kpEOAkXWGdbR9SD-qyQbJQdQoySLaCUJibNVqyg%40mail.gmail.com.
On Nov 19, 2021, at 9:13 AM, Bill Huffman <huf...@cadence.com> wrote:
The LR makes a reservation. But it does not remove any other reservation.
If it does, the implementation is vulnerable to livelock. If only the SC removes the other reservations, then the removal can be atomic with respect to success. Even then, care is required that the other reservations are removed only when the SC will otherwise be successful – though certain reasons for failure that will not repeat might still be allowed.
For similar reasons, it’s important the an LR does not acquire a cache line in the Exclusive or Modified state. LR should be happy with a Shared state. If LR requires Exclusive/Modified, LR/SC sequences are vulnerable to livelock.
From: Edwin Sutanto <esut...@gmail.com>
Sent: Friday, November 19, 2021 12:34 PM
To: Bill Huffman <huf...@cadence.com>
Cc: Dan Petrisko <petr...@cs.washington.edu>; a7866...@gmail.com <a7866...@gmail.com>; RISC-V ISA Dev <isa...@groups.riscv.org>
Subject: Re: [isa-dev] question of lr/cs
EXTERNAL MAIL
i don’t have the doc in front me
Sent from my iPhone
On Nov 19, 2021, at 9:13 AM, Bill Huffman <huf...@cadence.com> wrote:
The LR makes a reservation. But it does not remove any other reservation.
i thought the doc says an LR will remove other reservation, ie you can’t have more than 1 outstanding / nested
I realize we may be making different assumptions. The LR will remove any other reservation on the same hart. But not on a different hart. Any given hart only needs to remember a single reservation.
I was assuming the subject was different harts. You may well have been assuming the subject was the same hart.
If it does, the implementation is vulnerable to livelock. If only the SC removes the other reservations, then the removal can be atomic with respect to success. Even then, care is required that the other reservations are removed only when the SC will otherwise be successful – though certain reasons for failure that will not repeat might still be allowed.
For similar reasons, it’s important the an LR does not acquire a cache line in the Exclusive or Modified state. LR should be happy with a Shared state. If LR requires Exclusive/Modified, LR/SC sequences are vulnerable to livelock.
But the two harts’ software will keep trying if their respective SC fail, regardless you gain exclusive or non-exc
thus livelock
Yes, avoiding livelock is good. 😊
Bill
Agreed, coherence traffic will be reduced by having LR require an exclusive state – but not really by much. Where LR/SC traffic from multiple cores to the same lock location is large enough for that to matter, live-lock is an increasingly important issue.
I can see how a well-designed hardware back-off might make LR requesting exclusive OK. I think, though, that at the level the discussion was occurring, the assumption should be that LR must only request shared. The usual optimizations, such as acquiring exclusive when no other core has the line, would be appropriate.
It’s been pointed out to me that it’s also possible to have the LR unconditionally acquire an exclusive copy of a line if arriving coherence messages for that line do not take effect for some number of cycles – enough cycles for a conformant sequence to execute the corresponding SC.
I’ll back off to saying that if LR removes reservations on other harts or requests an exclusive copy of the cache line, either additional features need to be added, or livelock will become a possibility.
Bill
From: Bill Huffman
Sent: Friday, November 19, 2021 2:47 PM
To: Dan Petrisko <petr...@cs.washington.edu>
Cc: Edwin Sutanto <esut...@gmail.com>; a7866...@gmail.com <a7866...@gmail.com>; RISC-V ISA Dev <isa...@groups.riscv.org>
Subject: RE: [isa-dev] question of lr/cs
Agreed, coherence traffic will be reduced by having LR require an exclusive state – but not really by much. Where LR/SC traffic from multiple cores to the same lock location is large enough for that to matter, live-lock is an increasingly important issue.
I can see how a well-designed hardware back-off might make LR requesting exclusive OK. I think, though, that at the level the discussion was occurring, the assumption should be that LR must only request shared. The usual optimizations, such as acquiring exclusive when no other core has the line, would be appropriate.
Bill
I have more concern about how a hart using LR instruction to recognize the state of memory(shared of exclusive), not livelock.Only guarantee the task that fist used LR, the livelock will be solved.The specification introduced CAS to implement lock, and use LR/SC instruction constructed an atomic swap instruction. But I think LR/SC could direct implement lock, otherwise the atomic swap instruction constructed by LR/SC hardly to be claimed is atomic.The "cs" in question actually is sc instruction.It is my carelessness.