Thread (60 messages) 60 messages, 5 authors, 2025-02-21

Re: [PATCH v6 07/14] iommufd/viommu: Add iommufd_viommu_report_event helper

From: Nicolin Chen <hidden>
Date: 2025-02-20 21:16:50
Also in: linux-arm-kernel, linux-iommu, linux-kselftest, linux-patches, lkml

On Wed, Feb 19, 2025 at 06:58:16AM +0000, Tian, Kevin wrote:
quoted
From: Jason Gunthorpe <jgg@nvidia.com>
Sent: Tuesday, February 18, 2025 11:36 PM

On Fri, Jan 24, 2025 at 04:30:36PM -0800, Nicolin Chen wrote:
quoted
+int iommufd_viommu_report_event(struct iommufd_viommu *viommu,
+				enum iommu_veventq_type type, void
*event_data,
quoted
+				size_t data_len)
+{
+	struct iommufd_veventq *veventq;
+	struct iommufd_vevent *vevent;
+	int rc = 0;
+
+	if (WARN_ON_ONCE(!data_len || !event_data))
+		return -EINVAL;
+
+	down_read(&viommu->veventqs_rwsem);
+
+	veventq = iommufd_viommu_find_veventq(viommu, type);
+	if (!veventq) {
+		rc = -EOPNOTSUPP;
+		goto out_unlock_veventqs;
+	}
+
+	if (atomic_read(&veventq->num_events) == veventq->depth) {
+		vevent = &veventq->overflow;
+		goto out_set_header;
+	}
+
+	vevent = kmalloc(struct_size(vevent, event_data, data_len),
GFP_KERNEL);
quoted
+	if (!vevent) {
+		rc = -ENOMEM;
+		goto out_unlock_veventqs;
This should record an overflow too
In that case probably we want to rename 'overflow' to 'lost_event'
which counts lost events for whatever reasons (overflow, oom, etc.)
Naming-wise, I think it may sound better to call the overflow node
just an 'exception' that concludes with lost eventsfor different
reasons.

A complication is that this 'exception' would give userspace a very
implicit reason as the node just report the number of lost events
v.s. providing the reason to each lost event.

With this, maybe the IOMMU_VEVENTQ_FLAG_OVERFLOW in the uAPI should
be just IOMMU_VEVENTQ_FLAG_EXCEPTION? Any better idea?

Thanks
Nicolin
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help