From: Nicolin Chen <nicolinc@nvidia.com>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: <kevin.tian@intel.com>, <yi.l.liu@intel.com>,
<iommu@lists.linux.dev>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 2/3] iommufd/device: Make hwpt_list list_add/del symmetric
Date: Mon, 30 Jan 2023 11:38:49 -0800 [thread overview]
Message-ID: <Y9gcyX0HAjaxoBJd@Asurada-Nvidia> (raw)
In-Reply-To: <Y9gVhqCIl1xN3seC@nvidia.com>
On Mon, Jan 30, 2023 at 03:07:50PM -0400, Jason Gunthorpe wrote:
> On Mon, Jan 30, 2023 at 11:03:09AM -0800, Nicolin Chen wrote:
> > On Mon, Jan 30, 2023 at 10:59:32AM -0400, Jason Gunthorpe wrote:
> > > On Sat, Jan 28, 2023 at 01:18:10PM -0800, Nicolin Chen wrote:
> > > > Since the list_del() of hwpt_item is done in iommufd_device_detach(), move
> > > > its list_add_tail() to a similar place in iommufd_device_do_attach().
> > > >
> > > > Also move and place the mutex outside the iommufd_device_auto_get_domain()
> > > > and iommufd_device_do_attach() calls, to serialize attach/detach routines.
> > > > This adds an additional locking protection so that the following patch can
> > > > safely remove devices_lock.
> > >
> > > That should be two patches then, this is just moving one line of code
> > > from what I can tell?
> >
> > The mutex is used to protect the list. So moving the list means
> > we'd need to the mutex too. What this patch does is to enlarge
> > the protection scope a bit to cover iommufd_device_do_attach()
> > and iommufd_device_auto_get_domain().
>
> That doesn't explain why iommufd_device_auto_get_domain was changed
> around, it already had the lock
That is trying to make the code look like this:
iommufd_device_attach {
...
case IOMMUFD_OBJ_HW_PAGETABLE:
+ mutex_lock(&hwpt->ioas->mutex);
rc = iommufd_device_do_attach(idev, hwpt);
+ mutex_unlock(&hwpt->ioas->mutex);
...
case IOMMUFD_OBJ_IOAS:
...
+ mutex_lock(&ioas->mutex);
rc = iommufd_device_auto_get_domain(idev, ioas);
+ mutex_unlock(&ioas->mutex);
...
}
If you don't think that's necessary, I can make things intact
in iommufd_device_auto_get_domain().
Thanks
Nic
next prev parent reply other threads:[~2023-01-30 19:39 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-28 21:18 [PATCH v2 0/3] iommufd: Remove iommufd_hw_pagetable_has_group Nicolin Chen
2023-01-28 21:18 ` [PATCH v2 1/3] iommufd: Add devices_users to track the hw_pagetable usage by device Nicolin Chen
2023-01-29 9:23 ` Tian, Kevin
2023-01-29 9:30 ` Nicolin Chen
2023-01-29 9:39 ` Tian, Kevin
2023-01-30 2:22 ` Liu, Yi L
2023-01-30 15:02 ` Jason Gunthorpe
2023-01-30 19:27 ` Nicolin Chen
2023-01-30 19:50 ` Jason Gunthorpe
2023-01-30 20:04 ` Nicolin Chen
2023-01-30 20:35 ` Jason Gunthorpe
2023-01-30 20:53 ` Nicolin Chen
2023-02-01 7:48 ` Nicolin Chen
2023-02-02 9:12 ` Nicolin Chen
2023-02-07 4:19 ` Liu, Yi L
2023-02-01 6:57 ` Nicolin Chen
2023-02-01 7:56 ` Nicolin Chen
2023-02-01 15:53 ` Jason Gunthorpe
2023-02-01 17:46 ` Nicolin Chen
2023-02-01 18:37 ` Jason Gunthorpe
2023-02-01 19:25 ` Nicolin Chen
2023-02-01 20:00 ` Jason Gunthorpe
2023-02-01 21:18 ` Nicolin Chen
2023-02-02 7:28 ` Nicolin Chen
2023-02-02 15:03 ` Jason Gunthorpe
2023-02-07 4:27 ` Liu, Yi L
2023-01-28 21:18 ` [PATCH v2 2/3] iommufd/device: Make hwpt_list list_add/del symmetric Nicolin Chen
2023-01-29 9:24 ` Tian, Kevin
2023-01-29 9:31 ` Nicolin Chen
2023-01-30 14:59 ` Jason Gunthorpe
2023-01-30 19:03 ` Nicolin Chen
2023-01-30 19:07 ` Jason Gunthorpe
2023-01-30 19:38 ` Nicolin Chen [this message]
2023-01-28 21:18 ` [PATCH v2 3/3] iommufd/device: Change iommufd_hw_pagetable_has_group to device centric Nicolin Chen
2023-01-29 9:37 ` Tian, Kevin
2023-01-29 10:38 ` Nicolin Chen
2023-01-30 0:44 ` Tian, Kevin
2023-01-30 10:22 ` Nicolin Chen
2023-02-01 3:07 ` Tian, Kevin
2023-02-01 6:49 ` Baolu Lu
2023-02-01 6:59 ` Tian, Kevin
2023-02-01 7:20 ` Nicolin Chen
2023-02-02 6:32 ` Tian, Kevin
2023-02-02 6:36 ` Nicolin Chen
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=Y9gcyX0HAjaxoBJd@Asurada-Nvidia \
--to=nicolinc@nvidia.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@nvidia.com \
--cc=kevin.tian@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=yi.l.liu@intel.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