mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nicolin Chen <nicolinc@nvidia.com>
To: Baolu Lu <baolu.lu@linux.intel.com>
Cc: <jgg@nvidia.com>, <kevin.tian@intel.com>, <iommu@lists.linux.dev>,
	<linux-kernel@vger.kernel.org>, <joro@8bytes.org>,
	<will@kernel.org>, <robin.murphy@arm.com>
Subject: Re: [PATCH rc 2/2] iommufd/fault: Use a separate spinlock to protect fault->deliver list
Date: Tue, 14 Jan 2025 21:45:32 -0800	[thread overview]
Message-ID: <Z4dLfHIs+rW0zAcu@Asurada-Nvidia> (raw)
In-Reply-To: <1cbee44f-4fce-4e9c-8b95-cd1fa25f5921@linux.intel.com>

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@linux.intel.com>

Thanks!
Nicolin

      reply	other threads:[~2025-01-15  5:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-14 23:28 [PATCH rc 0/2] iommufd/fault: Two bug fixes prior to vEVENTQ Nicolin Chen
2025-01-14 23:28 ` [PATCH rc 1/2] iommufd/fault: Destroy response and mutex in iommufd_fault_destroy() Nicolin Chen
2025-01-15  0:54   ` Jason Gunthorpe
2025-01-15  5:17   ` Tian, Kevin
2025-01-15  5:21   ` Baolu Lu
2025-01-14 23:28 ` [PATCH rc 2/2] iommufd/fault: Use a separate spinlock to protect fault->deliver list Nicolin Chen
2025-01-15  5:24   ` Tian, Kevin
2025-01-15  5:40     ` Nicolin Chen
2025-01-15  5:24   ` Baolu Lu
2025-01-15  5:45     ` Nicolin Chen [this message]

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=Z4dLfHIs+rW0zAcu@Asurada-Nvidia \
    --to=nicolinc@nvidia.com \
    --cc=baolu.lu@linux.intel.com \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@nvidia.com \
    --cc=joro@8bytes.org \
    --cc=kevin.tian@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=will@kernel.org \
    /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

all inboxes | Powered by JetHome®