Date
21 - 40 of 45
MTIME update frequency
Ved Shanbhogue
On Wed, Nov 17, 2021 at 10:28:40AM -0800, Greg Favor wrote:
On Wed, Nov 17, 2021 at 9:49 AM Ved Shanbhogue <ved@...> wrote:I am not disagreeing to that.Agree. Standard protocols like IEEE 1588 may also be used to acheive fineJust to clarify what I was trying to say: Whether distributing a large regards ved |
|
Darius Rad
On Wed, Nov 17, 2021 at 04:37:21AM +0000, Anup Patel wrote:
Before we go ahead and change the MTIME resolution requirement in the platform spec, I would like to highlight following points (from past discussions) which led to mandating a fixed MTIME resolution in the platform spec:Considering the requirement that all time CSRs be synchronized to within 1 tick, setting a fixed resolution indirectly makes synchronization much more difficult for implementations that have a lower update frequency. For such implementations, since each update is more than 1 tick, it would be necessary to ensure that all time CSRs always have exactly the same value, which is considerably more difficult than within 1 tick. 2. It is common in enterprise clouds to migrate a Guest/VM across different hosts. Considering the diversity in RISC-V world, we have to support migration of Guest/VM from host A to host B where these hosts can be from different vendors. Now if host A and host B have different MTIME resolution then Guest/VM migration will not work and this problem also applies to ARM world. This is another reason why ARM SBSA mandates a fixed timer resolution. Although, ARM world standardized timer frequency quite late in the game but RISC-V world can avoid these problems by standardizing MTIME resolution quite early. Alternatively, there is also SBI para-virt call possible to detect change in MTIME resolution but this would mean additional code (along with barriers) in the path of reading time CSR (as an example, look at KVM para-virt clock used in x86 world). |
|
Ved Shanbhogue
On Wed, Nov 17, 2021 at 04:36:10PM -0500, Darius Rad wrote:
On Wed, Nov 17, 2021 at 04:37:21AM +0000, Anup Patel wrote:So an implementation that supports 100MHz clock would need to update the mtime by 10 on each tick to meet the 1ns granularity. In current spec a implementation that supports 10 MHz clock would need to update the mtime by 10 on each tick to meet the 10ns resolution. I am not sure incrementing by 1 vs. incrementing by 10 makes it much harder as it was already required for a system that implements a 10MHz clock.Before we go ahead and change the MTIME resolution requirement in the platform spec, I would like to highlight following points (from past discussions) which led to mandating a fixed MTIME resolution in the platform spec:Considering the requirement that all time CSRs be synchronized to within 1 CSRs need to have the consistent time at the observation point. The fastest way in most system to "observe" value in CSRs is through the cache or through memory. So the difference between the two CSRs should not be observable to the extent that the following test fails: Hart-X (sends a message to Hart-Y): Read time Write timestamp message to memory Hart-Y: Read timestamp message from memory (gets the data from cache or memory) Read time compare timestamp to time (the timestamp should not be in future) If this test is passes then the fact that the CSR in Hart-Y is 2 ticks behind or ahead of Hart-X is not observable. Setting the granularity to 1 ns provides the path for RISC-V implementations that want the fine resolution to acheive the goal without penalizing implementations that do not. regards ved |
|
Darius Rad
On Wed, Nov 17, 2021 at 03:50:17PM -0600, Vedvyas Shanbhogue wrote:
On Wed, Nov 17, 2021 at 04:36:10PM -0500, Darius Rad wrote:The specification says "synchronized to within one tick".On Wed, Nov 17, 2021 at 04:37:21AM +0000, Anup Patel wrote:So an implementation that supports 100MHz clock would need to update the mtime by 10 on each tick to meet the 1ns granularity. In current spec a implementation that supports 10 MHz clock would need to update the mtime by 10 on each tick to meet the 10ns resolution. I am not sure incrementing by 1 vs. incrementing by 10 makes it much harder as it was already required for a system that implements a 10MHz clock.Before we go ahead and change the MTIME resolution requirement in the platform spec, I would like to highlight following points (from past discussions) which led to mandating a fixed MTIME resolution in the platform spec:Considering the requirement that all time CSRs be synchronized to within 1 If the time CSR is incremented one tick at a time, then, for every update, as long as one update propagates to all harts before the next update, this requirement is met. Some harts may show time T and some may show T+1, but those are within one tick, which is acceptable. Now suppose there is a system that increments 10 ticks per update. If the time value in any hart lags, where some show T and some show T+10, this is not within one tick, which is not acceptable. Thus, for systems that update one tick at a time, they have a full tick to propagate updates to all harts. For systems that update multiple ticks at a time, they have *no* time to propagate updates to all harts; all updates must be instantaneous on *all* harts. CSRs need to have the consistent time at the observation point. The fastest way in most system to "observe" value in CSRs is through the cache or through memory. So the difference between the two CSRs should not be observable to the extent that the following test fails:That is perhaps a useful test, but not the only way to observe the clocks, nor is it how the accuracy is specified in the architecture. The architecture does not say the accuracy is with respect to what is observable in another hart. The time could, for example, be observed by something external to both harts and with higher precision. Setting the granularity to 1 ns provides the path for RISC-V implementations |
|
Ved Shanbhogue
On Wed, Nov 17, 2021 at 05:30:05PM -0500, Darius Rad wrote:
On Wed, Nov 17, 2021 at 03:50:17PM -0600, Vedvyas Shanbhogue wrote:I agree. But that requirement is there already for a system that implements a 10 Mhz clock and has to suport 10ns resolution. If 10ns vs. 1ns is a really sticking point could we have two values supported by the platform specification - similar to the range of update frequencies supported. We can leave it to the end user whether they want to put these two classes of systems in one migration pool.On Wed, Nov 17, 2021 at 04:36:10PM -0500, Darius Rad wrote:The specification says "synchronized to within one tick".On Wed, Nov 17, 2021 at 04:37:21AM +0000, Anup Patel wrote:So an implementation that supports 100MHz clock would need to update the mtime by 10 on each tick to meet the 1ns granularity. In current spec a implementation that supports 10 MHz clock would need to update the mtime by 10 on each tick to meet the 10ns resolution. I am not sure incrementing by 1 vs. incrementing by 10 makes it much harder as it was already required for a system that implements a 10MHz clock.Before we go ahead and change the MTIME resolution requirement in the platform spec, I would like to highlight following points (from past discussions) which led to mandating a fixed MTIME resolution in the platform spec:Considering the requirement that all time CSRs be synchronized to within 1 regards ved |
|
Ved Shanbhogue
On Wed, Nov 17, 2021 at 04:37:12PM -0600, Vedvyas Shanbhogue via lists.riscv.org wrote:
On Wed, Nov 17, 2021 at 05:30:05PM -0500, Darius Rad wrote:Did that address your concern? Should we update to supporting 1 ns resolution or not disallowing a 1 ns resolution?On Wed, Nov 17, 2021 at 03:50:17PM -0600, Vedvyas Shanbhogue wrote:I agree. But that requirement is there already for a system that implements a 10 Mhz clock and has to suport 10ns resolution. If 10ns vs. 1ns is a really sticking point could we have two values supported by the platform specification - similar to the range of update frequencies supported. We can leave it to the end user whether they want to put these two classes of systems in one migration pool.On Wed, Nov 17, 2021 at 04:36:10PM -0500, Darius Rad wrote:The specification says "synchronized to within one tick".On Wed, Nov 17, 2021 at 04:37:21AM +0000, Anup Patel wrote:So an implementation that supports 100MHz clock would need to update the mtime by 10 on each tick to meet the 1ns granularity. In current spec a implementation that supports 10 MHz clock would need to update the mtime by 10 on each tick to meet the 10ns resolution. I am not sure incrementing by 1 vs. incrementing by 10 makes it much harder as it was already required for a system that implements a 10MHz clock.Before we go ahead and change the MTIME resolution requirement in the platform spec, I would like to highlight following points (from past discussions) which led to mandating a fixed MTIME resolution in the platform spec:Considering the requirement that all time CSRs be synchronized to within 1 regards |
|
Darius Rad
On Fri, Nov 19, 2021 at 08:59:32AM -0600, Vedvyas Shanbhogue wrote:
On Wed, Nov 17, 2021 at 04:37:12PM -0600, Vedvyas Shanbhogue via lists.riscv.org wrote:No, it does not address my concern.On Wed, Nov 17, 2021 at 05:30:05PM -0500, Darius Rad wrote:Did that address your concern? Should we update to supporting 1 ns resolution or not disallowing a 1 ns resolution?On Wed, Nov 17, 2021 at 03:50:17PM -0600, Vedvyas Shanbhogue wrote:I agree. But that requirement is there already for a system that implements a 10 Mhz clock and has to suport 10ns resolution. If 10ns vs. 1ns is a really sticking point could we have two values supported by the platform specification - similar to the range of update frequencies supported. We can leave it to the end user whether they want to put these two classes of systems in one migration pool.On Wed, Nov 17, 2021 at 04:36:10PM -0500, Darius Rad wrote:The specification says "synchronized to within one tick".On Wed, Nov 17, 2021 at 04:37:21AM +0000, Anup Patel wrote:So an implementation that supports 100MHz clock would need to update the mtime by 10 on each tick to meet the 1ns granularity. In current spec a implementation that supports 10 MHz clock would need to update the mtime by 10 on each tick to meet the 10ns resolution. I am not sure incrementing by 1 vs. incrementing by 10 makes it much harder as it was already required for a system that implements a 10MHz clock.Before we go ahead and change the MTIME resolution requirement in the platform spec, I would like to highlight following points (from past discussions) which led to mandating a fixed MTIME resolution in the platform spec:Considering the requirement that all time CSRs be synchronized to within 1 As you said, that requirement was already there, and my concern applies to the requirement as is, although increasing the resolution will exacerbate the problem. When the specification mandates a specific update resolution, multihart implementations will have to choose between (1) updating one tick at a time, or (2) very stringent synchronization between all harts. I suspect implementations will be forced to choose (1), even if they otherwise would have preferred to have a different update frequency or clock. Or they will simply ignore the synchronization requirement in the ISA specification, which I think is a real possibility. The current requirement effectively forces implementations to have a 100 MHz clock. If the resolution is changed to 1 ns, that becomes a 1 GHz clock that implementations are forced to have. Either way, this violates the Platform Policy that says platforms should not mandate performance, but certainly the higher clock rate is more of a burden. |
|
Ved Shanbhogue
On Fri, Nov 19, 2021 at 10:36:18AM -0500, Darius Rad wrote:
On Fri, Nov 19, 2021 at 08:59:32AM -0600, Vedvyas Shanbhogue wrote:The current specification says that the MTIME values seen by two HARTs to be not apart by more than 1. It does say the MTIME must always increment in units of 1. I do not think the specification mandates incrementing by one on each clock tick. Presently it says the tick - the update frequency - can be 100 MHz or 10 MHz or somewhere in between. If the update frequency is 10 MHz then the MTIME increment per clock must be 10. If the update frequency is 100 Mhz then MTIME increment per clock is 1. So is your concern is that an adder that adds 10 to MTIME per clock tick is hard?On Wed, Nov 17, 2021 at 04:37:12PM -0600, Vedvyas Shanbhogue via lists.riscv.org wrote:No, it does not address my concern.On Wed, Nov 17, 2021 at 05:30:05PM -0500, Darius Rad wrote:Did that address your concern? Should we update to supporting 1 ns resolution or not disallowing a 1 ns resolution?On Wed, Nov 17, 2021 at 03:50:17PM -0600, Vedvyas Shanbhogue wrote:I agree. But that requirement is there already for a system that implements a 10 Mhz clock and has to suport 10ns resolution. If 10ns vs. 1ns is a really sticking point could we have two values supported by the platform specification - similar to the range of update frequencies supported. We can leave it to the end user whether they want to put these two classes of systems in one migration pool.On Wed, Nov 17, 2021 at 04:36:10PM -0500, Darius Rad wrote:The specification says "synchronized to within one tick".On Wed, Nov 17, 2021 at 04:37:21AM +0000, Anup Patel wrote:So an implementation that supports 100MHz clock would need to update the mtime by 10 on each tick to meet the 1ns granularity. In current spec a implementation that supports 10 MHz clock would need to update the mtime by 10 on each tick to meet the 10ns resolution. I am not sure incrementing by 1 vs. incrementing by 10 makes it much harder as it was already required for a system that implements a 10MHz clock.Before we go ahead and change the MTIME resolution requirement in the platform spec, I would like to highlight following points (from past discussions) which led to mandating a fixed MTIME resolution in the platform spec:Considering the requirement that all time CSRs be synchronized to within 1 regards ved |
|
Greg Favor
On Fri, Nov 19, 2021 at 7:36 AM Darius Rad <darius@...> wrote: The current requirement effectively forces implementations to have a 100 The resolution requirement (whether =10ns or <=10ns) doesn't force a 100 or 100+ MHz clock. Only the >=10 MHz update rate forces a 10 MHz clock - which is a pretty modest requirement for OS-A-class systems. (As a side-note, most any DDR interface or high-speed I/O interface (e.g. USB, SATA, PCIe/NVMe) will want significant clock frequencies supplied to them.) Either way, this violates Platforms shouldn't mandate specific software execution performance requirements, but a platform spec may - in the interest of ensuring functionality doesn't have horrible performance - choose to mandate certain qualitative things. For example, a
more application domain-targeted platform may choose to disallow trapping and emulating of all misaligned data accesses. (The "Embedded" platform, as a rather basic very "broad" platform, doesn't do this.) In contrast, mandating that a system has certain hardware capabilities, like a RISC-V standard interrupt controller with at least X number of priorities, or time with some minimum resolution and update rate, is ensuring a form of functionality. For example, an Automotive or Mobile platform may be unhappy if the update rate and resolution are only 10 ms / 100 Hz. Greg |
|
Greg Favor
The current specification says that the MTIME values seen by two HARTs to be not apart by more than 1. It does say the MTIME must always increment in units of 1. I do not think the specification mandates incrementing by one on each clock tick. Presently it says the tick - the update frequency - can be 100 MHz or 10 MHz or somewhere in between. If the update frequency is 10 MHz then the MTIME increment per clock must be 10. If the update frequency is 100 Mhz then MTIME increment per clock is 1. So is your concern is that an adder that adds 10 to MTIME per clock tick is hard? I largely agree. While the clock "tick" is one ulp, an update can increment time by, for example, 10 ticks. (The same is true in ARM SBSA/BSA/etc.) Greg |
|
Jonathan Behrens <behrensj@...>
On Fri, Nov 19, 2021 at 12:27 PM Greg Favor <gfavor@...> wrote:
I think the argument is that you technically violate the ISA spec if you have two cores and you increment mtime on the first core by +10 then a fraction of a nanosecond later update the second core's mtime by +10. During the tiny duration between the updates on the two cores mtime differs by 10, but the ISA requires mtime to differ by at most 1 at any given instant in time. Jonathan |
|
Ved Shanbhogue
On Fri, Nov 19, 2021 at 12:42:13PM -0500, Jonathan Behrens wrote:
On Fri, Nov 19, 2021 at 12:27 PM Greg Favor <gfavor@...> wrote:Which section of the specication should I look at for that requirement? The only requirement I could find is from ACLINT spec: "On a RISC-V platform with multiple MTIMER devices residing on the same die, all must satisfy the RISC-V architectural requirement that all the MTIME registers with respect to each other, and all the per-HART time CSRs with respect to each other, are synchronized to within one MTIME tick (or MTIME update period)." And this requires synchronized to within one MTIME updateThe current specification says that the MTIME values seen by two HARTs toI think the argument is that you technically violate the ISA spec if yoube not apart by more than 1. It does say the MTIME must always increment in period - not the value of MTIME be not different by more than one. regards ved |
|
Jonathan Behrens <behrensj@...>
On Fri, Nov 19, 2021 at 3:02 PM Ved Shanbhogue <ved@...> wrote: On Fri, Nov 19, 2021 at 12:42:13PM -0500, Jonathan Behrens wrote: The requirement seems to come from the Zicntr extension described in the base (unprivileged) spec. I'll let somebody else say whether incrementing mtime by +10 counts as 1 tick or 10 ticks.
|
|
Ved Shanbhogue
On Fri, Nov 19, 2021 at 03:27:40PM -0500, Jonathan Behrens wrote:
On Fri, Nov 19, 2021 at 3:02 PM Ved Shanbhogue <ved@...> wrote:This states synchronized to one tick of the real-time clock. It does not state it has to not differ by 1 count.On Fri, Nov 19, 2021 at 12:42:13PM -0500, Jonathan Behrens wrote:The requirement seems to come from the Zicntr extension described in theOn Fri, Nov 19, 2021 at 12:27 PM Greg Favor <gfavor@...>wrote:toThe current specification says that the MTIME values seen by two HARTsincrement inbe not apart by more than 1. It does say the MTIME must alwaysoneunits of 1. I do not think the specification mandates incrementing by- canon each clock tick. Presently it says the tick - the update frequencyis 10be 100 MHz or 10 MHz or somewhere in between. If the update frequencyfrequencyMHz then the MTIME increment per clock must be 10. If the updatethatis 100 Mhz then MTIME increment per clock is 1. So is your concern isdiffersI think the argument is that you technically violate the ISA spec if youan adder that adds 10 to MTIME per clock tick is hard? regards ved |
|
Darius Rad
On Fri, Nov 19, 2021 at 02:32:45PM -0600, Vedvyas Shanbhogue wrote:
On Fri, Nov 19, 2021 at 03:27:40PM -0500, Jonathan Behrens wrote:The ISA specification also says:On Fri, Nov 19, 2021 at 3:02 PM Ved Shanbhogue <ved@...> wrote:This states synchronized to one tick of the real-time clock. It does notOn Fri, Nov 19, 2021 at 12:42:13PM -0500, Jonathan Behrens wrote:The requirement seems to come from the Zicntr extension described in theOn Fri, Nov 19, 2021 at 12:27 PM Greg Favor <gfavor@...>wrote:toThe current specification says that the MTIME values seen by two HARTsincrement inbe not apart by more than 1. It does say the MTIME must alwaysoneunits of 1. I do not think the specification mandates incrementing by- canon each clock tick. Presently it says the tick - the update frequencyis 10be 100 MHz or 10 MHz or somewhere in between. If the update frequencyfrequencyMHz then the MTIME increment per clock must be 10. If the updatethatis 100 Mhz then MTIME increment per clock is 1. So is your concern isdiffersI think the argument is that you technically violate the ISA spec if youan adder that adds 10 to MTIME per clock tick is hard? The execution environment should provide a means of determining the period of the real-time counter (seconds/tick). If the period of the counter is in units of seconds/tick, then 1 count (1 LSB) is 1 tick. |
|
Darius Rad
On Fri, Nov 19, 2021 at 09:20:58AM -0800, Greg Favor wrote:
On Fri, Nov 19, 2021 at 7:36 AM Darius Rad <darius@...> wrote:Please read what I said. I said it *effectively* forces an implementationThe current requirement effectively forces implementations to have a 100 to have a 100 MHz clock. With the current wording in the draft specification, multihart implementations must do one of the following: 1. Provide a 100 MHz (or greater) clock and update the time register one tick at a time, within one tick per the ISA specification. 2. With a clock between 10 MHz and 100 MHz, update the time register more than one tick at a time, and provide extremely strict synchronization between all harts to ensure that all harts see exactly the same value at all times. 3. Ignore the specification, either by: a. Not guaranteeing that all harts see time within one tick (violating the ISA specification), or b. Using a different timebase for the time register (violating the current draft platform specification). It is my opinion that (2) is an unreasonably burdensome, and that implementations will be forced to choose (1) if they would like to adhere to the specification. However, I think (3) will happen in practice. Could you please refer to the portion of the Platform Policy that youEither way, this violatesPlatforms shouldn't mandate specific software execution performance relied on for that interpretation? The Policy says "a Platform shall avoid performance requirements or whether mechanisms have to be implemented in hardware (i.e. if they can be emulated through trap-and-emulate).", which seems to directly contradict what you are saying. In contrast, mandating that a system has certain hardware capabilities, |
|
Jonathan Behrens <behrensj@...>
On Fri, Nov 19, 2021 at 3:34 PM Vedvyas Shanbhogue via lists.riscv.org <ved=rivosinc.com@...> wrote: On Fri, Nov 19, 2021 at 03:27:40PM -0500, Jonathan Behrens wrote: It seems that this comes down entirely to semantics of what a "tick" means in this context. If 1 tick = 1 count = 10ns then it violates the spec, whereas if 1 tick = 10 count = 100ns then it complies. |
|
Ved Shanbhogue
On Fri, Nov 19, 2021 at 03:46:19PM -0500, Darius Rad wrote:
On Fri, Nov 19, 2021 at 02:32:45PM -0600, Vedvyas Shanbhogue wrote:I read them separately and I think the text carefully used "counter" and "clock" carefully for the first sentence and second sentence carefully. Placing the synchronization requirement on the clock and not the counter - which matches the ACLINT specification as well.On Fri, Nov 19, 2021 at 03:27:40PM -0500, Jonathan Behrens wrote:The ISA specification also says:On Fri, Nov 19, 2021 at 3:02 PM Ved Shanbhogue <ved@...> wrote:This states synchronized to one tick of the real-time clock. It does notOn Fri, Nov 19, 2021 at 12:42:13PM -0500, Jonathan Behrens wrote:The requirement seems to come from the Zicntr extension described in theOn Fri, Nov 19, 2021 at 12:27 PM Greg Favor <gfavor@...>wrote:toThe current specification says that the MTIME values seen by two HARTsincrement inbe not apart by more than 1. It does say the MTIME must alwaysoneunits of 1. I do not think the specification mandates incrementing by- canon each clock tick. Presently it says the tick - the update frequencyis 10be 100 MHz or 10 MHz or somewhere in between. If the update frequencyfrequencyMHz then the MTIME increment per clock must be 10. If the updatethatis 100 Mhz then MTIME increment per clock is 1. So is your concern isdiffersI think the argument is that you technically violate the ISA spec if youan adder that adds 10 to MTIME per clock tick is hard? Hope authors of the specification should clarify if that was the intent. regards ved |
|
Greg Favor
I took the opportunity to raise this with Andrew and Krste (who authored the text in question) as to the intended and proper reading of the following arch spec text:
Before summarizing their response, I'll note that the presence of two discoverable properties (tick period and time accuracy) might suggest that these correspond to time resolution and update frequency (which implies inaccuracy equal to the period of the update rate). And other readings of this text might suggest differently. In short, the intended meaning and proper reading of the arch text is the most literal reading of the first several sentences, i.e. one tick equals one ulp, and the counter monotonically increments (i.e. by +1) once each tick period. The resolution and update period are one and the same. Time CSRs across harts must be synchronized to within one ulp or tick period. Secondly, the last sentence's statement about accuracy is meant to refer to the bounds on deviation from the nominal frequency of the RTC source. Krste and Andrew will incorporate some extra words into the current text to make fully clear the intended literal meaning of the text (and hence cut off any alternative not-so-literal readings of the text), as well as to clarify what the accuracy sentence refers to. Coming back around to the OS-A platform specs, the distinction between resolution and update frequency obviously needs to go away. Given the need for flexibility across the range of OS-A compliant implementations, mandating any one tick period will be good for some and unacceptable for others. I suggest mandating a max tick period of 100 ns (corresponding to a relatively low 10 MHz frequency for OS-A class designs). This allows implementations to do anything from 100 ns down to 1 ns and even lower (if they are able to directly satisfy the synchronization requirement). This also ensures a reasonable upper bound on the lack of resolution/accuracy in time CSR readings. Greg P.S. As a personal aside, I find it next to impractical to distribute and/or explicitly synchronize time truly to within ~1 ns in medium to high core count implementations (particularly, but not only, because of physical design and process considerations). (And that leaves aside multi-die/socket implementations.) But the above doesn't stop anyone from figuring out how to actually do that. |
|
Greg Favor
>Based on above points, I still think mandating fixed MTIME resolution is desirable for OS-A platforms and this has nothing to do with how timebase-frequency is discovered (i.e. DT/ACPI). Note that ARM SBSA did not mandate a 1 GHz update rate; it only mandated a 1ns resolution - and explicitly acknowledged that updates may be at a lower rate using counter scaling. Greg |
|