From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f179.google.com (mail-pg1-f179.google.com [209.85.215.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B3BCA4477F9 for ; Thu, 30 Jul 2026 18:12:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785435177; cv=none; b=cfWShlQxzkPACQ/GTci8dDO0ueXuHFEYTIVQFO6WZmm9IJDP6h71zI+DQbZLWZc5mPbJZrnYsGOl568LV69/WYx0nesOI8tNpm6wbCx5HNavfRUtCNUR0Q/tG/l5fWFERmD08nG56BUfDlfR0Lr2rtJBAi2IBHIlb+EiloYpFSQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785435177; c=relaxed/simple; bh=nNTDXVztBRh+NwT9l9amUlw0+PAL2fZK5osZZO569lA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hfwaSujEFNdv5Rtd4nhHVkXVXf99R3qXyB7HHIfaq8MkX85r2MdbOhijDGGfcAKAV44I9DSpfzhxAiyTdEysVU6TPHyYi6nFei62+q6KrrTmOS+NayiOzwcWz+1Nii7sTdwOzaIFNU17fg+TcN5/ODhFgUr6ZirqiVSeaR9gbDQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=knIHOPXd; arc=none smtp.client-ip=209.85.215.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="knIHOPXd" Received: by mail-pg1-f179.google.com with SMTP id 41be03b00d2f7-c9cf07d2df6so73979a12.2 for ; Thu, 30 Jul 2026 11:12:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785435169; x=1786039969; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=JjZRp1nhDTDgCD+T8te9v5HqJu4svj9GdgkIOM/whNM=; b=knIHOPXdt5Dk90g9MnF49y6IxOlySz8IjhDnVNT98x4ke9PyjdEoiOGagbxQRcBgEn M0lHiiQh2NhHxEs3IQjkLnRXYiPPSVO7WQNwFpj7fMGmXvZnoS7yz0W+C7JQJj/tLO0N YZpeoSAEw7hxlAEYGGSRrEd9WfcL504FjNVp4qmoMsGKFnohRUsKUjh5RZNRw7foAjwX J8ZSCwd4DBmF0NvB2mwocMf4RvipKagua//5hZS57tY01BbNIt70/TGG7rnvjB4zBO87 hdlJOyEnQPc8Oml1DrUhGp2vLdZM6sSMNSScC6MidA6XM0QMYewYzciM44+UekVZW8do 1JrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785435169; x=1786039969; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=JjZRp1nhDTDgCD+T8te9v5HqJu4svj9GdgkIOM/whNM=; b=XR71ZGwEw7GJrK/vjtzv8pFApMGRy14QHuQccypKj7MCm/QVGgL7r+Pk4MY3xf79MF Iq09nsFDX1eD9cBtpeICwlTxP+atyzAddJlwdnKOpBsIgOUTecwxN/t+r886eTpxHlMo +bBrNovJJIQPsOE9AnctkVduPJYEzCvW/TCKhBapoBrXRXbY2PiIr73rldaa5If8kLEw fytXHdg2CpUSvknozBei6rv4Uzz9UFO/ZsKbZuufSB1n6TnAyRjL6iPDvd2MWfNTNYe6 24ozSBIVvam3fBvYOMm+syPCGvj9H3GQq+t/FZANYi7XeZMB8HY8Hly3aTbovTHRPVUX iieA== X-Forwarded-Encrypted: i=1; AHgh+RpQo4DEoD7aCLyTw3qerbdJfS9fSZ/0O5drbxIvrfTG47EK2+Z5Kgoy+uMEdYnyVpXrDdQYmcT8Un7WbhU=@vger.kernel.org X-Gm-Message-State: AOJu0Yx4hjCRFkepd1K1f1jWxkEBZEzEjU0ff2dU5XUkO0oTvqfSs2IG 15YjQc4efEYtIFss1yGnFJo6HpAlEKjM4m5hs8TtpvT8d84lW94ldlm0 X-Gm-Gg: AR+sD13Z8K+0djX3inlbOUcxYz2HoOlWFeATmoKhYI/dsvAFOTwiDNR1eqQ16QFidkT vgWW9zkvYGlkPoRbZ0lj2ZaIGjproHhdgfjHIAhddn3odeVpo4pVtQM2iYHJMD6z2wdENnPc0Ui Q085xqlqzJVJZ8GWhNMh0u9lXtVfjHqtxggxiAVjlfr+0AUuzaRHT41WSC6rSQlpI9q7qCNNDPe t4Ke8QszOKAiMC2Z2BuzXaxTK2bSgzdaPQsOuch9OGoWjc58qPqYXqloYA6ptT4Reb3ozY27wOS u6AArmGlTq3Wk03nwsJonFWG1PkiE09+WTIECWpDuv4BsrAIgmC5ls87YzwxP7dGLQB7J1ZTAdq 8N2g+xf7OzaN+N3yQidRIii1j2TiMy8/jJEK+C66tnEvbZj+sBEZafKey4lyO3wLBVI1Td/CHlZ ETUiEmGdThmP/v/FknR4OqwQqNlJaYdD2rKwWtGFNLn6Jy9qQZiKFDB8V44hbuObhiI/0+AxVfJ PX/4jcb4VA8aHACCzYdKiei4NaEu5d0iFAbUJmGt2QpqiAaaegh3thMhehZ5rQ= X-Received: by 2002:a05:6a21:3397:b0:3c3:9835:e75e with SMTP id adf61e73a8af0-3c9008f9f05mr3638201637.70.1785435168997; Thu, 30 Jul 2026 11:12:48 -0700 (PDT) Received: from visitorckw-work01.c.googlers.com.com (131.197.81.34.bc.googleusercontent.com. [34.81.197.131]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-31504b124e4sm21998197eec.6.2026.07.30.11.12.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jul 2026 11:12:48 -0700 (PDT) From: Kuan-Wei Chiu 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 Subject: [PATCH 1/2] iommu/arm-smmu-v3: Replace sort_nonatomic() with sort() Date: Thu, 30 Jul 2026 18:12:15 +0000 Message-ID: <20260730181216.2709088-2-visitorckw@gmail.com> X-Mailer: git-send-email 2.55.0.508.g3f0d502094-goog In-Reply-To: <20260730181216.2709088-1-visitorckw@gmail.com> References: <20260730181216.2709088-1-visitorckw@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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