On 11/12/26 15:27, Philipp Stanner wrote: > On Thu, 2026-11-12 at 15:15 +0100, Christian König wrote: >> >> To allow drivers to more accurately calculate how much time the job spend on >> the HW. > > It's still just not a very good idea to randomly overwrite a fence's > internal value without a formal API contract. This should have done > through a dma_fence_overwrite_timestamp() which is responsible > centrally for the ordering, or, even better, through a separate > timestamp in drm_sched_fence.
In general a good idea, but if I'm not completely mistaken Tvrko came up with a complete framework to track the time each entity spend on the HW based on both scheduled and finished timestamps. We should probably make sure that this framework doesn't depend on such hacks, then switch amdgpu and others to using that instead and drop that hack. > Why do they care btw? As far as I have ever seen only amdgpu uses the > scheduled fence. What do you do with it? It is used for the gputop information. E.g. an estimation how much each submission uses the HW. > > I see why Tvrtko needs it, to do the fairness algorithm. > >> The time it was pushed the to HW queue is pretty uninteresting for the time >> spend on the HW. >> >> What you need is the time it started running and that is when a the previous >> fence completes. > > OK, I see. > >>> Is it guaranteed that this fence is signaled and, thus, has a >>> timestamp, or is it not? If it's guaranteed, the test_bit() is actually >>> unnecessary. If it is not guaranteed, then there can be misordering >>> between the two operations and it's UB and, thus, a bug. >>> >>> That said, I'm OK with your patch here being merged since you did not >>> cause that chaos / problem, but a second patch with a FIXME about the >>> issue that links this mail-thread would be good. >> >> I've considered this approach as well when we originally merged the >> change, but the timestamps are only like 90% accurate anyway so to be >> honest I don't think it really matters. > > You have considered which approach? What Tvrtko is suggesting with this patch. > What do you think of the memory ordering problem I point out? Not much of an issue, the timestamp is really only used opportunistically. > And btw above you said that this is done so that drivers can do > something "accurately" :) Well "more accurately", e.g. the accuracy increases from completely off to only slightly off :) Because of the interrupt latency and everything involved a submission which takes 3ms can report in anything from 3ms to 6ms runtime from my experience. If somebody wants this to be really accurate we would need to record the HW timestamps. That is possible, Intel does that for example, but for AMD HW nobody really cared enough so far to requests this. > > But as I said to Tvrtko, we are where we are. This here is no big deal, > but I really want to get the dma_fence memory ordering set straight and > well-documented. The usage patterns have fragmented. It's completely > unclear whether what drm_sched does here is actually legal. Mhm, Tvrtko's work might be a good reason to get the job runtime accurate at least. Regards, Christian. > > > P.
