Skip to content

RFC: freedreno+util: Uncontended locks/refcnts

Rob Clark requested to merge robclark/mesa:fd/uncontended-locks into main

We have various locks that we know will only ever be contended if there is more than a single pipe_context. So add _uncontended variants for simple_mtx_lock/unlock() and use those in the common case when there is only a single context.

Likewise, there is some reference counting that we know does not need to be atomic if there is not more than a single context.

TODO is there a sufficient enough barrier that can be used after incrementing/decrementing num_ctx that this can work? I guess it must be possible as the aarch64 atomic intrinsics appear to have a fast- path which is (presumably) used when there is only a single thread.


A hair-brain idea I had.. could we make locking/refcnting trivial (ie. not atomic) in cases where we know there will be no races conditions / contention? Helps drawoverhead test 1 by ~30% if TC is disabled. Doesn't really change anything with TC enabled, as the driver-thread is not the bottleneck. But I guess reducing CPU overhead still reduces power.

Edited by Rob Clark

Merge request reports