One additional comment on this patch:
On 13/10/2025 14:48, Christian König wrote:
At first glance it is counter intuitive to protect a constant function
pointer table by RCU, but this allows modules providing the function
table to unload by waiting for an RCU grace period.
Signed-off-by: Christian König <[email protected]>
---
drivers/dma-buf/dma-fence.c | 65 +++++++++++++++++++++++++++----------
include/linux/dma-fence.h | 18 ++++++++--
2 files changed, 62 insertions(+), 21 deletions(-)
8><
@@ -1104,11 +1127,14 @@ EXPORT_SYMBOL(dma_fence_init64);
*/
const char __rcu *dma_fence_driver_name(struct dma_fence *fence)
{
+ const struct dma_fence_ops *ops;
+
RCU_LOCKDEP_WARN(!rcu_read_lock_held(),
"RCU protection is required for safe access to returned
string");
+ ops = rcu_dereference(fence->ops);
if (!test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags))
- return fence->ops->get_driver_name(fence);
+ return ops->get_driver_name(fence);
else
return "detached-driver";
}
@@ -1136,11 +1162,14 @@ EXPORT_SYMBOL(dma_fence_driver_name);
*/
const char __rcu *dma_fence_timeline_name(struct dma_fence *fence)
{
+ const struct dma_fence_ops *ops;
+
RCU_LOCKDEP_WARN(!rcu_read_lock_held(),
"RCU protection is required for safe access to returned
string");
+ ops = rcu_dereference(fence->ops);
For the above two functions, the RCU_LOCKDEP_WARN now becomes redundant
to the one rcu_dererence() would emit. Maybe just move the string into a
comment?
Regards,
Tvrtko
if (!test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags))
- return fence->ops->get_driver_name(fence);
+ return ops->get_driver_name(fence);
else
return "signaled-timeline";
}