From: Will Deacon <will@kernel.org>
To: Kuan-Wei Chiu <visitorckw@gmail.com>, nicolinc@nvidia.com
Cc: joro@8bytes.org, akpm@linux-foundation.org, robin.murphy@arm.com,
cychu@google.com, hhchung@google.com, amitamishra@google.com,
marscheng@google.com, linux-arm-kernel@lists.infradead.org,
iommu@lists.linux.dev, linux-kernel@vger.kernel.org,
jserv@ccns.ncku.edu.tw, eleanor15x@gmail.com
Subject: Re: [PATCH 1/2] iommu/arm-smmu-v3: Replace sort_nonatomic() with sort()
Date: Sun, 2 Aug 2026 10:23:48 +0100 [thread overview]
Message-ID: <am8MpGR14HAg58Gd@willie-the-truck> (raw)
In-Reply-To: <20260730181216.2709088-2-visitorckw@gmail.com>
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@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
next prev parent reply other threads:[~2026-08-02 9:24 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-30 18:12 [PATCH 0/2] lib/sort: Clean up sort_nonatomic() and sort_r_nonatomic() Kuan-Wei Chiu
2026-07-30 18:12 ` [PATCH 1/2] iommu/arm-smmu-v3: Replace sort_nonatomic() with sort() Kuan-Wei Chiu
2026-08-02 9:23 ` Will Deacon [this message]
2026-08-02 17:45 ` Nicolin Chen
2026-08-03 12:35 ` Robin Murphy
2026-08-03 13:37 ` Pranjal Shrivastava
2026-07-30 18:12 ` [PATCH 2/2] Revert "lib/sort.c: add _nonatomic() variants with cond_resched()" Kuan-Wei Chiu
2026-07-30 19:32 ` [PATCH 0/2] lib/sort: Clean up sort_nonatomic() and sort_r_nonatomic() Kuan-Wei Chiu
2026-08-06 17:11 ` Will Deacon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=am8MpGR14HAg58Gd@willie-the-truck \
--to=will@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=amitamishra@google.com \
--cc=cychu@google.com \
--cc=eleanor15x@gmail.com \
--cc=hhchung@google.com \
--cc=iommu@lists.linux.dev \
--cc=joro@8bytes.org \
--cc=jserv@ccns.ncku.edu.tw \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marscheng@google.com \
--cc=nicolinc@nvidia.com \
--cc=robin.murphy@arm.com \
--cc=visitorckw@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox