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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Feb 19, 2025 at 06:58:16AM +0000, Tian, Kevin wrote:
> > From: Jason Gunthorpe <jgg@xxxxxxxxxx>
> > Sent: Tuesday, February 18, 2025 11:36 PM
> > 
> > On Fri, Jan 24, 2025 at 04:30:36PM -0800, Nicolin Chen wrote:
> > > +int iommufd_viommu_report_event(struct iommufd_viommu *viommu,
> > > +				enum iommu_veventq_type type, void
> > *event_data,
> > > +				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);
> > > +	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




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux