[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Z4dLfHIs+rW0zAcu@Asurada-Nvidia>
Date: Tue, 14 Jan 2025 21:45:32 -0800
From: Nicolin Chen <nicolinc@...dia.com>
To: Baolu Lu <baolu.lu@...ux.intel.com>
CC: <jgg@...dia.com>, <kevin.tian@...el.com>, <iommu@...ts.linux.dev>,
<linux-kernel@...r.kernel.org>, <joro@...tes.org>, <will@...nel.org>,
<robin.murphy@....com>
Subject: Re: [PATCH rc 2/2] iommufd/fault: Use a separate spinlock to protect
fault->deliver list
On Wed, Jan 15, 2025 at 01:24:53PM +0800, Baolu Lu wrote:
> On 1/15/25 07:28, Nicolin Chen wrote:
> > @@ -445,12 +445,38 @@ struct iommufd_fault {
> > /* The lists of outstanding faults protected by below mutex. */
>
> It's better to update above comment as well.
>
> > struct mutex mutex;
> > + spinlock_t lock; /* protects the deliver list */
> > struct list_head deliver;
> > struct xarray response;
Ack. I'll do:
- /* The lists of outstanding faults protected by below mutex. */
- struct mutex mutex;
+ spinlock_t lock; /* protects the deliver list */
struct list_head deliver;
+ struct mutex mutex; /* serializes response flows */
struct xarray response;
> > struct wait_queue_head wait_queue;
> > };
> > +/* Extract the first node out of the fault->deliver list */
> > +static inline struct iopf_group *
> > +iommufd_fault_deliver_extract(struct iommufd_fault *fault)
> > +{
> > + struct list_head *list = &fault->deliver;
> > + struct iopf_group *group = NULL;
> > +
> > + spin_lock(&fault->lock);
> > + if (!list_empty(list)) {
> > + group = list_first_entry(list, struct iopf_group, node);
> > + list_del(&group->node);
> > + }
> > + spin_unlock(&fault->lock);
> > + return group;
> > +}
> > +
> > +/* Restore a node back to the head in fault->deliver */
> > +static inline void iommufd_fault_deliver_restore(struct iommufd_fault *fault,
> > + struct iopf_group *group)
> > +{
> > + spin_lock(&fault->lock);
> > + list_add(&fault->deliver, &group->node);
>
> This is not right. It should be
>
> list_add(&group->node, &fault->deliver);
>
> > + spin_unlock(&fault->lock);
> > +}
Oh, right!
> Others look good to me. With above addressed,
>
> Reviewed-by: Lu Baolu <baolu.lu@...ux.intel.com>
Thanks!
Nicolin
Powered by blists - more mailing lists