On Fri, Jul 11, 2025 at 11:00:06AM +0800, Baolu Lu wrote:
+void iommu_sva_invalidate_kva_range(unsigned long start, unsigned long end) +{
- struct iommu_mm_data *iommu_mm;
- if (!static_branch_unlikely(&iommu_sva_present))
return;
- guard(spinlock_irqsave)(&iommu_mms_lock);
- list_for_each_entry(iommu_mm, &iommu_sva_mms, mm_list_elm)
mmu_notifier_arch_invalidate_secondary_tlbs(iommu_mm->mm, start, end);
+}
This is absolutely the wrong way to use static_branch. You want them in inline functions guarding the function call, not inside the function call.
I don't think a static branch is desirable here, as we have no idea how often the condition will switch in real-world scenarios. I will remove it in the next version if there are no objections.
The point of the static branch was to make the 99% normal case where SVA has never been used have no-cost in the core MM. I think we should keep that idea
Jason