[PATCH 1/2] iommu/arm-smmu-v3: Replace sort_nonatomic() with sort()
Will Deacon
will at kernel.org
Sun Aug 2 02:23:48 PDT 2026
On Thu, Jul 30, 2026 at 06:12:15PM +0000, Kuan-Wei Chiu wrote:
> The number of master->num_streams per master device is typically very
> small in practice. Sorting this array takes a very small amount of
> time, so there is no practical risk of triggering a soft lockup that
> would necessitate calling cond_resched() during the sort.
>
> Replace sort_nonatomic() with the standard sort(). Since this is the
> only remaining in-tree caller of sort_nonatomic(), this change paves
> the way to eventually remove the unused sort_nonatomic() API from the
> core library.
>
> Signed-off-by: Kuan-Wei Chiu <visitorckw at gmail.com>
> ---
> Build-tested only.
>
> I'm not really familiar with this driver or smmu internals.
> Based on my limited knowledge, master->num_streams should be small
> enough to safely switch from sort_nonatomic() to sort(), but I could be
> wrong.
>
> Please review carefully and let me know if there are any cases where
> num_streams could actually be large enough to cause issues.
>
> drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> index a10affb483a4..dcb6be2df95e 100644
> --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> @@ -4047,9 +4047,9 @@ static int arm_smmu_insert_master(struct arm_smmu_device *smmu,
> }
>
> /* Put the ids into order for sorted to_merge/to_unref arrays */
> - sort_nonatomic(master->streams, master->num_streams,
> - sizeof(master->streams[0]), arm_smmu_stream_id_cmp,
> - NULL);
> + sort(master->streams, master->num_streams,
> + sizeof(master->streams[0]), arm_smmu_stream_id_cmp,
> + NULL);
Makes sense to me. Nicolin, did you choose the nonatomic version
specifically?
Will
More information about the linux-arm-kernel
mailing list