From: Yi Liu <yi.l.liu@intel.com>
To: jgg@nvidia.com, kevin.tian@intel.com
Cc: nicolinc@nvidia.com, yi.l.liu@intel.com,
baolu.lu@linux.intel.com, iommu@lists.linux.dev
Subject: [PATCH 2/2] iommufd: Balance veventq->num_events inc/dec
Date: Mon, 24 Mar 2025 05:00:34 -0700 [thread overview]
Message-ID: <20250324120034.5940-3-yi.l.liu@intel.com> (raw)
In-Reply-To: <20250324120034.5940-1-yi.l.liu@intel.com>
iommufd_veventq_fops_read() decrements veventq->num_events when a vevent
is read out. However, the report path ony increments veventq->num_events
for normal events. To be balanced, make the read path decrement num_events
only for normal vevents.
Fixes: e36ba5ab808e ("iommufd: Add IOMMUFD_OBJ_VEVENTQ and IOMMUFD_CMD_VEVENTQ_ALLOC")
Signed-off-by: Yi Liu <yi.l.liu@intel.com>
---
drivers/iommu/iommufd/eventq.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/iommu/iommufd/eventq.c b/drivers/iommu/iommufd/eventq.c
index 4c43ace8c725..f39cf0797347 100644
--- a/drivers/iommu/iommufd/eventq.c
+++ b/drivers/iommu/iommufd/eventq.c
@@ -385,7 +385,8 @@ static ssize_t iommufd_veventq_fops_read(struct file *filep, char __user *buf,
break;
}
spin_lock(&eventq->lock);
- veventq->num_events--;
+ if (!vevent_for_lost_events_header(cur))
+ veventq->num_events--;
spin_unlock(&eventq->lock);
done += cur->data_len;
kfree(cur);
--
2.34.1
next prev parent reply other threads:[~2025-03-24 12:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-24 12:00 [PATCH 0/2] Two fixes to vevent path Yi Liu
2025-03-24 12:00 ` [PATCH 1/2] iommufd: Initialize the flags of vevent in iommufd_viommu_report_event() Yi Liu
2025-03-24 14:04 ` Nicolin Chen
2025-03-24 12:00 ` Yi Liu [this message]
2025-03-24 14:07 ` [PATCH 2/2] iommufd: Balance veventq->num_events inc/dec Nicolin Chen
2025-03-25 13:35 ` [PATCH 0/2] Two fixes to vevent path Jason Gunthorpe
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=20250324120034.5940-3-yi.l.liu@intel.com \
--to=yi.l.liu@intel.com \
--cc=baolu.lu@linux.intel.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@nvidia.com \
--cc=kevin.tian@intel.com \
--cc=nicolinc@nvidia.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