Re: [PATCH 2/3] dma-buf: dma-fence: Add dma_fence_overwrite_timestamp()

From: Tvrtko Ursulin

Date: Wed Nov 25 2026 - 11:27:07 EST



On 20/11/2026 10:01, Philipp Stanner wrote:
On Fri, 2026-11-20 at 10:38 +0100, Christian König wrote:
On 11/19/26 14:18, Philipp Stanner wrote:
A fence's timestamp is just an opportunistic data point for debugging
information etc. drm_sched, for example, uses the timestamps for its
scheduling algorithms.

In rare situations it can make sense to allow users to overwrite a
timestamp with a more accurate value. This is relatively harmless since
the timestamp has no meaning for the implementation itself.

Add dma_fence_overwrite_timestamp().

I think that this is a very bad idea since it gives the impression
that overwriting the timestamp on a fence is ok.

That was only done on the scheduled dma-fence because nobody cares
about that time in the uAPI. For all other cases that can blow up.

I would rather come up with a clean approach for the scheduler to
track the spend time per entity which would make that hack completely
superfluous.

Yes, I agree.

The *one* feature we would have needed in C is a public-private system.
With structs in APIs it's often completely undefined what the user can
and cannot touch.

That led to API ossification. Just look at drm_sched, where we now
cannot trivially change API internals anymore because external parties
conveniently use this or that.

IIRC Tvrtko already created patches for that, I'm just not sure if
they were ever committed.

I suppose it should be somewhat easy to track that data in
drm_sched_fence.

Maybe Tvrtko can point me to his ideas so I can take a look.

Not sure that I have any patches in this area. What I am trying to come up with in the background is a solution for amdgpu overaccounting due scheduler not being able to know what hw resources are shared, for example normal and high priority rings sharing the same execution units. But that is orthogonal.

For this particular bug I think we can do something different and that is to stop touching the dma-fence and just track the interesting timestamps in the drm_sched_fence itself. I can have a go in the next few days to see if using the existing job_list_list and/or the workqueue serialization makes this really simple.

Tvrtko