From: Kuan-Wei Chiu <visitorckw@gmail.com>
To: will@kernel.org, joro@8bytes.org, akpm@linux-foundation.org
Cc: robin.murphy@arm.com, nicolinc@nvidia.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, Kuan-Wei Chiu <visitorckw@gmail.com>
Subject: [PATCH 1/2] iommu/arm-smmu-v3: Replace sort_nonatomic() with sort()
Date: Thu, 30 Jul 2026 18:12:15 +0000 [thread overview]
Message-ID: <20260730181216.2709088-2-visitorckw@gmail.com> (raw)
In-Reply-To: <20260730181216.2709088-1-visitorckw@gmail.com>
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);
mutex_lock(&smmu->streams_mutex);
for (i = 0; i < fwspec->num_ids; i++) {
--
2.55.0.508.g3f0d502094-goog
next prev parent reply other threads:[~2026-07-30 18:13 UTC|newest]
Thread overview: 4+ 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 ` Kuan-Wei Chiu [this message]
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
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=20260730181216.2709088-2-visitorckw@gmail.com \
--to=visitorckw@gmail.com \
--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=will@kernel.org \
/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