--
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+unsubscribe@groups.riscv.org.
To post to this group, send email to isa...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/isa-dev/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/isa-dev/fea83558-920d-4d62-a584-b7df5bac24aa%40groups.riscv.org.
I would be concerned about lock and unlock either opening side channels
or being useful as a denial-of-service, so those would probably need to
be privileged instructions. Further, these will require two register
operands, a base address and a length, because the cacheline size is
absolutely not part of the RISC-V user ISA and should never be allowed
to be an implicit operand to any instruction.
-- Jacob
--
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 post to this group, send email to isa...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/isa-dev/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/isa-dev/593B5B61.4060507%40gmail.com.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/isa-dev/CA%2B%2B6G0CjZpwKyLAjG3K1uFy%3DP9FfZH4NXNidNbSy1bmQwMenyg%40mail.gmail.com.
Bruce Hoult wrote:
> Cache control instructions normally only require a register containing
> an address and an operation code (preload, flush, lock, unlock), so
> don't take up much instruction encoding space.
>
chuanhua.chang wrote:
I agree with Bruce that only a base address register operand is enough. Length operand can reduce the number of executed cache maintenance instructions, but it is not necessary. A programmer can just use a cache maintenance instruction for every address with size increment smaller than the smallest cache line size (e.g., every 4 bytes or 8 bytes) to cover the address range.
That would make prefetch hugely inefficient.
--
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 post to this group, send email to isa...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/isa-dev/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/isa-dev/CAMU%2BEkwuenFdD7_p2R1abjdX4bjNDCtGOSLrTmwL-NFJrXcFXg%40mail.gmail.com.
If I understand correctly, FENCE already provides flush semantics.
-- Jacob
--
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 post to this group, send email to isa...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/isa-dev/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/isa-dev/4bb3414e-4dfc-42ec-8ae2-33f9c86a445f%40groups.riscv.org.
Nice discussion!However, I would like to diverge into another question in terms of isa management:
If we do want to put these cache instruction into RISC-V, where should we put it?While these instruction could have custom encoding and architecture, an unified approach could help software programmers a lot.Should we open up a new extension chapter?Po-wei
Bruce Hoult <br...@hoult.org> 於 2017年6月12日 下午8:49 寫道:
On Mon, Jun 12, 2017 at 6:30 AM, Jacob Bachmeyer <jcb6...@gmail.com> wrote:chuanhua.chang wrote:
I agree with Bruce that only a base address register operand is enough. Length operand can reduce the number of executed cache maintenance instructions, but it is not necessary. A programmer can just use a cache maintenance instruction for every address with size increment smaller than the smallest cache line size (e.g., every 4 bytes or 8 bytes) to cover the address range.
That would make prefetch hugely inefficient.Not really. We have to do that on ARM now anyway, as there exist big.LITTLE implementations with different line sizes and no way to know whether you've been migrated since you queried the line size. The OS has to ensure that the smallest lines size in the system is returned.If the hint instructions will cause any actual memory traffic then doing two or four times more of them than strictly necessary is *way* down in the noise. Even if no memory traffic is caused, stepping by 32 when you could have stepped by 64 or 128 is not a big deal, and far better than stepping by 1 or 4.p.s. I wasn't arguing for making the line size implicit, so one can't really "agree with Bruce" there. I was just pointing out that if there is a reason to not have cache control instructions, neither encoding space nor complexity for cacheless designs is one of them.I would strongly support encoding a size somehow in either the instruction itself, or in the lower bits of the address. Only a few bits are needed for reasonable variation in line sizes. We've had caches for four decades now, and while line sizes have varied it looks to me more like they change in a cycle rather than slowly growing to infinity. Even three bits would cover the range from 4 bytes to 1024 bytes, which should be pretty future-proof.
--
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+unsubscribe@groups.riscv.org.
To post to this group, send email to isa...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/isa-dev/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/isa-dev/CAMU%2BEkwuenFdD7_p2R1abjdX4bjNDCtGOSLrTmwL-NFJrXcFXg%40mail.gmail.com.
--
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+unsubscribe@groups.riscv.org.
To post to this group, send email to isa...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/isa-dev/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/isa-dev/74A942A7-C48B-4A09-8D1A-B15E578C520D%40gmail.com.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/isa-dev/a4d87fde-91c2-4a57-a828-d6fb2ef671a5%40groups.riscv.org.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/isa-dev/234D2BE5-05AC-4E94-9EB1-A609185A2873%40roalogic.com.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/isa-dev/E8129CA2-DE09-4928-88A7-E135271F1C9A%40roalogic.com.
Yeah. It's a fine microarchitectural decision, especially for a uniprocessor that doesn't otherwise need to snoop caches.Once you bite the bullet and have coherence for other reasons, probably to support multiple cores or fast DMA, it makes sense to implement FENCE.I differently--e.g. flush only the I$ and snoop the D$ upon I$ misses; or snoop the I$, too, and flush only the pipeline. But for the smallest and simplest implementations with Harvard caches, flushing it all is the way to go.
On Fri, Jun 16, 2017 at 4:09 AM Richard Herveille <richard.herveille@roalogic.com> wrote:
Yes, agreed.RISC-V only specifies the ISA, how that is implemented is up to the designer.In my embedded core, FENCE_I writes-back all dirty data cache lines (although 'all' wouldn't be necessary) and flushes the entire instruction cache (here 'entire' wouldn't be necessary and a flush wouldn't be necessary either). However design goal is small size and simple.
Richard
Sent from my iPhone
It's interesting as to whether FENCE.I has to be expensive and it very much depends on the microarchitecture.
FENCE.I doesn't necessarily mean flush icache however some implementations may pessimistically flush icache as a simple implementation approach. A simple implementation may also need to flush dcache to the next cache tier if it can't cross populate icache from dcache.
FENCE.I is technically an explicit fence that indicates successive instruction fetches should see previous stores. It is a type of memory fence.
To "sync icache and dcache" on x86 one just needs to execute a JMP instruction, I think since i486. JMP is technically an "implicit" FENCE.I on x86 according to the architecture manual so it obviously has to be relatively cheap, but clearly this requires some microarchitecture gymnastics.
A sophisticated implementation only needs to invalidate icache lines that are dirty in dcache and the icache could cross populate from dcache. In fact the icache may even snoop dcache writes for addresses of lines that are in icache and preemptively populate icache for modified code, with a fence just invalidating instruction prefetch queues. Architectures without an explicit instruction memory fence need to resort to this kind of thing and it's likely necessary for good JIT performance.
So FENCE.I should not be considered an icache flush, rather instruction memory FENCE w,x ; successive instruction fetches see previous stores (using the memory fence notation with 'x' for instruction fetches vs 'r' for loads).
Apparently icache dcache coherency is even cross cores on some architectures. Magic. See http://blog.onlinedisassembler.com/blog/?p=133
Sent from my iPhone
Actually FENCE_I does that. And yes, it's an expensive instruction.
Richard
Sent from my iPhone
For an implementation with a write-back data cache and no coherence module to maintain cache coherence, do you mean that a FENCE instruction has to write-back (flush) all dirty cache lines in the data cache to memory?--
If this is true, this is a very expensive operation.
Chuanhua
On Saturday, June 10, 2017 at 10:37:38 AM UTC+8, Jacob Bachmeyer wrote:
If I understand correctly, FENCE already provides flush semantics.
-- Jacob
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+unsubscribe@groups.riscv.org.
To post to this group, send email to isa...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/isa-dev/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/isa-dev/4bb3414e-4dfc-42ec-8ae2-33f9c86a445f%40groups.riscv.org.
--
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+unsubscribe@groups.riscv.org.
To post to this group, send email to isa...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/isa-dev/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/isa-dev/234D2BE5-05AC-4E94-9EB1-A609185A2873%40roalogic.com.
--
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+unsubscribe@groups.riscv.org.
To post to this group, send email to isa...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/isa-dev/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/isa-dev/E8129CA2-DE09-4928-88A7-E135271F1C9A%40roalogic.com.
--
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+unsubscribe@groups.riscv.org.
To post to this group, send email to isa...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/isa-dev/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/isa-dev/CA%2B%2B6G0DvnYNP4hxWJedz5_gERLey%2B7EFErDw6gRLNdgL1FrF0g%40mail.gmail.com.
This is why a ranged FENCE.I makes sense -- you don't have to flush the whole icache, just the memory range that was modified.I advocate to make both FENCE and FENCE.I to be R-type instructions, so rs1 and rs2 can specify a memory range. If rs1=rs2=r0, then the range corresponds to 'all memory'.Once the FENCE instructions are R-type, we can debate the use of rd, such as a successful completion code (allowing FENCE to be interrupted and forcing software to do a resume) or an address to indicate progress if the memory range was incompletely checked for the fence, or some other useful value.GuyOn Fri, Jun 16, 2017 at 10:00 AM, Andrew Waterman <and...@sifive.com> wrote:
Yeah. It's a fine microarchitectural decision, especially for a uniprocessor that doesn't otherwise need to snoop caches.Once you bite the bullet and have coherence for other reasons, probably to support multiple cores or fast DMA, it makes sense to implement FENCE.I differently--e.g. flush only the I$ and snoop the D$ upon I$ misses; or snoop the I$, too, and flush only the pipeline. But for the smallest and simplest implementations with Harvard caches, flushing it all is the way to go.
To unsubscribe from this group and stop receiving emails from it, send an email to isa-dev+u...@groups.riscv.org.
To post to this group, send email to isa...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/isa-dev/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/isa-dev/4bb3414e-4dfc-42ec-8ae2-33f9c86a445f%40groups.riscv.org.
--
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 post to this group, send email to isa...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/isa-dev/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/isa-dev/234D2BE5-05AC-4E94-9EB1-A609185A2873%40roalogic.com.
--
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 post to this group, send email to isa...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/isa-dev/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/isa-dev/E8129CA2-DE09-4928-88A7-E135271F1C9A%40roalogic.com.
--
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 post to this group, send email to isa...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/isa-dev/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/isa-dev/CA%2B%2B6G0DvnYNP4hxWJedz5_gERLey%2B7EFErDw6gRLNdgL1FrF0g%40mail.gmail.com.
--
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 post to this group, send email to isa...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/isa-dev/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/isa-dev/CALo5CZze7yXdmR2kfB1TLp1KFFCw-0vmB1%3DhhaK0yMBbV_W2ZQ%40mail.gmail.com.
--
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 post to this group, send email to isa...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/isa-dev/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/isa-dev/CA%2B%2B6G0D%3DcrRSnytyFrU%2B3B4GXdeQ1Misa8ozgCUpKpbBCo_oMQ%40mail.gmail.com.