From: Lu Baolu <baolu.lu@linux.intel.com>
To: Christoph Hellwig <hch@lst.de>
Cc: Kevin Tian <kevin.tian@intel.com>,
Ashok Raj <ashok.raj@intel.com>,
linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org,
Jason Gunthorpe <jgg@nvidia.com>,
Robin Murphy <robin.murphy@arm.com>
Subject: Re: [PATCH v2 10/11] iommu/vt-d: Use xarray for global device_domain_info
Date: Tue, 15 Feb 2022 13:54:47 +0800 [thread overview]
Message-ID: <653f7bf3-07b3-e411-82e1-7b4892124ef7@linux.intel.com> (raw)
In-Reply-To: <20220214073820.GF17411@lst.de>
Hi Christoph,
On 2/14/22 3:38 PM, Christoph Hellwig wrote:
>>
>> const struct iommu_ops intel_iommu_ops;
>> @@ -903,7 +905,8 @@ static void pgtable_walk(struct intel_iommu *iommu, unsigned long pfn, u8 bus, u
>> struct dmar_domain *domain;
>> int offset, level;
>>
>> - info = dmar_search_domain_by_dev_info(iommu->segment, bus, devfn);
>> + info = xa_load(&device_domain_array,
>> + devi_idx(iommu->segment, bus, devfn));
>> if (!info || !info->domain) {
>> pr_info("device [%02x:%02x.%d] not probed\n",
>> bus, PCI_SLOT(devfn), PCI_FUNC(devfn));
>> @@ -1742,14 +1745,14 @@ static int iommu_init_domains(struct intel_iommu *iommu)
>
> Don't we need a rcu critical section here?
>
>> - list_for_each_entry_safe(info, tmp, &device_domain_list, global) {
>> + rcu_read_lock();
>> + xa_for_each(&device_domain_array, index, info) {
>> if (info->iommu != iommu)
>> continue;
>>
>> @@ -1758,7 +1761,7 @@ static void disable_dmar_iommu(struct intel_iommu *iommu)
>>
>> __dmar_remove_one_dev_info(info);
>> }
>> - spin_unlock_irqrestore(&device_domain_lock, flags);
>> + rcu_read_unlock();
>
> __dmar_remove_one_dev_info asserts that device_domain_lock is held,
> which these two hunks remove.
>
>> spin_lock_irqsave(&device_domain_lock, flags);
>> dev_iommu_priv_set(dev, NULL);
>> - list_del(&info->global);
>> + xa_erase(&device_domain_array,
>> + devi_idx(info->segment, info->bus, info->devfn));
>> spin_unlock_irqrestore(&device_domain_lock, flags);
>>
>> kfree(info);
>
> Do we need a kfree_rcu here to allow rcu based access?
Thanks for your time and very appreciated for your comments. As replied
to Jason, I will stop 10/11 and 11/11 for now. From the current usage
scenario, the value of such refactoring is limited.
Best regards,
baolu
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
WARNING: multiple messages have this Message-ID (diff)
From: Lu Baolu <baolu.lu@linux.intel.com>
To: Christoph Hellwig <hch@lst.de>
Cc: baolu.lu@linux.intel.com, Joerg Roedel <joro@8bytes.org>,
Kevin Tian <kevin.tian@intel.com>,
Ashok Raj <ashok.raj@intel.com>, Liu Yi L <yi.l.liu@intel.com>,
Jacob Pan <jacob.jun.pan@linux.intel.com>,
Robin Murphy <robin.murphy@arm.com>,
Jason Gunthorpe <jgg@nvidia.com>,
iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 10/11] iommu/vt-d: Use xarray for global device_domain_info
Date: Tue, 15 Feb 2022 13:54:47 +0800 [thread overview]
Message-ID: <653f7bf3-07b3-e411-82e1-7b4892124ef7@linux.intel.com> (raw)
In-Reply-To: <20220214073820.GF17411@lst.de>
Hi Christoph,
On 2/14/22 3:38 PM, Christoph Hellwig wrote:
>>
>> const struct iommu_ops intel_iommu_ops;
>> @@ -903,7 +905,8 @@ static void pgtable_walk(struct intel_iommu *iommu, unsigned long pfn, u8 bus, u
>> struct dmar_domain *domain;
>> int offset, level;
>>
>> - info = dmar_search_domain_by_dev_info(iommu->segment, bus, devfn);
>> + info = xa_load(&device_domain_array,
>> + devi_idx(iommu->segment, bus, devfn));
>> if (!info || !info->domain) {
>> pr_info("device [%02x:%02x.%d] not probed\n",
>> bus, PCI_SLOT(devfn), PCI_FUNC(devfn));
>> @@ -1742,14 +1745,14 @@ static int iommu_init_domains(struct intel_iommu *iommu)
>
> Don't we need a rcu critical section here?
>
>> - list_for_each_entry_safe(info, tmp, &device_domain_list, global) {
>> + rcu_read_lock();
>> + xa_for_each(&device_domain_array, index, info) {
>> if (info->iommu != iommu)
>> continue;
>>
>> @@ -1758,7 +1761,7 @@ static void disable_dmar_iommu(struct intel_iommu *iommu)
>>
>> __dmar_remove_one_dev_info(info);
>> }
>> - spin_unlock_irqrestore(&device_domain_lock, flags);
>> + rcu_read_unlock();
>
> __dmar_remove_one_dev_info asserts that device_domain_lock is held,
> which these two hunks remove.
>
>> spin_lock_irqsave(&device_domain_lock, flags);
>> dev_iommu_priv_set(dev, NULL);
>> - list_del(&info->global);
>> + xa_erase(&device_domain_array,
>> + devi_idx(info->segment, info->bus, info->devfn));
>> spin_unlock_irqrestore(&device_domain_lock, flags);
>>
>> kfree(info);
>
> Do we need a kfree_rcu here to allow rcu based access?
Thanks for your time and very appreciated for your comments. As replied
to Jason, I will stop 10/11 and 11/11 for now. From the current usage
scenario, the value of such refactoring is limited.
Best regards,
baolu
next prev parent reply other threads:[~2022-02-15 5:56 UTC|newest]
Thread overview: 72+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-14 2:56 [PATCH v2 00/11] iommu/vt-d: Some Intel IOMMU cleanups Lu Baolu
2022-02-14 2:56 ` Lu Baolu
2022-02-14 2:56 ` [PATCH v2 01/11] iommu/vt-d: Remove intel_iommu::domains Lu Baolu
2022-02-14 2:56 ` Lu Baolu
2022-02-24 12:58 ` Jason Gunthorpe via iommu
2022-02-24 12:58 ` Jason Gunthorpe
2022-02-14 2:56 ` [PATCH v2 02/11] iommu/vt-d: Remove finding domain in dmar_insert_one_dev_info() Lu Baolu
2022-02-14 2:56 ` Lu Baolu
2022-02-24 12:59 ` Jason Gunthorpe via iommu
2022-02-24 12:59 ` Jason Gunthorpe
2022-02-14 2:56 ` [PATCH v2 03/11] iommu/vt-d: Remove iova_cache_get/put() Lu Baolu
2022-02-14 2:56 ` Lu Baolu
2022-02-24 13:00 ` Jason Gunthorpe via iommu
2022-02-24 13:00 ` Jason Gunthorpe
2022-02-14 2:56 ` [PATCH v2 04/11] iommu/vt-d: Remove domain and devinfo mempool Lu Baolu
2022-02-14 2:56 ` Lu Baolu
2022-02-24 13:01 ` Jason Gunthorpe via iommu
2022-02-24 13:01 ` Jason Gunthorpe
2022-02-14 2:56 ` [PATCH v2 05/11] iommu/vt-d: Remove DEFER_DEVICE_DOMAIN_INFO Lu Baolu
2022-02-14 2:56 ` Lu Baolu
2022-02-14 7:31 ` Christoph Hellwig
2022-02-14 7:31 ` Christoph Hellwig
2022-02-24 13:04 ` Jason Gunthorpe via iommu
2022-02-24 13:04 ` Jason Gunthorpe
2022-02-25 1:55 ` Lu Baolu
2022-02-25 1:55 ` Lu Baolu
2022-02-14 2:56 ` [PATCH v2 06/11] iommu/vt-d: Remove unnecessary includes Lu Baolu
2022-02-14 2:56 ` Lu Baolu
2022-02-14 7:32 ` Christoph Hellwig
2022-02-14 7:32 ` Christoph Hellwig
2022-02-24 13:05 ` Jason Gunthorpe via iommu
2022-02-24 13:05 ` Jason Gunthorpe
2022-02-25 1:56 ` Lu Baolu
2022-02-25 1:56 ` Lu Baolu
2022-02-14 2:57 ` [PATCH v2 07/11] iommu/vt-d: Remove unnecessary prototypes Lu Baolu
2022-02-14 2:57 ` Lu Baolu
2022-02-14 7:32 ` Christoph Hellwig
2022-02-14 7:32 ` Christoph Hellwig
2022-02-24 13:05 ` Jason Gunthorpe via iommu
2022-02-24 13:05 ` Jason Gunthorpe
2022-02-14 2:57 ` [PATCH v2 08/11] iommu/vt-d: Fix indentation of goto labels Lu Baolu
2022-02-14 2:57 ` Lu Baolu
2022-02-14 7:33 ` Christoph Hellwig
2022-02-14 7:33 ` Christoph Hellwig
2022-02-24 13:08 ` Jason Gunthorpe via iommu
2022-02-24 13:08 ` Jason Gunthorpe
2022-02-25 1:57 ` Lu Baolu
2022-02-25 1:57 ` Lu Baolu
2022-02-14 2:57 ` [PATCH v2 09/11] iommu/vt-d: Remove commented code Lu Baolu
2022-02-14 2:57 ` Lu Baolu
2022-02-14 7:34 ` Christoph Hellwig
2022-02-14 7:34 ` Christoph Hellwig
2022-02-16 3:45 ` Tian, Kevin
2022-02-16 3:45 ` Tian, Kevin
2022-02-16 7:11 ` Lu Baolu
2022-02-16 7:11 ` Lu Baolu
2022-02-24 13:09 ` Jason Gunthorpe via iommu
2022-02-24 13:09 ` Jason Gunthorpe
2022-02-25 1:53 ` Lu Baolu
2022-02-25 1:53 ` Lu Baolu
2022-02-14 2:57 ` [PATCH v2 10/11] iommu/vt-d: Use xarray for global device_domain_info Lu Baolu
2022-02-14 2:57 ` Lu Baolu
2022-02-14 7:38 ` Christoph Hellwig
2022-02-14 7:38 ` Christoph Hellwig
2022-02-15 5:54 ` Lu Baolu [this message]
2022-02-15 5:54 ` Lu Baolu
2022-02-14 14:00 ` Jason Gunthorpe via iommu
2022-02-14 14:00 ` Jason Gunthorpe
2022-02-15 5:46 ` Lu Baolu
2022-02-15 5:46 ` Lu Baolu
2022-02-14 2:57 ` [PATCH v2 11/11] iommu/vt-d: Use rculist for per-domain device list Lu Baolu
2022-02-14 2:57 ` Lu Baolu
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=653f7bf3-07b3-e411-82e1-7b4892124ef7@linux.intel.com \
--to=baolu.lu@linux.intel.com \
--cc=ashok.raj@intel.com \
--cc=hch@lst.de \
--cc=iommu@lists.linux-foundation.org \
--cc=jgg@nvidia.com \
--cc=kevin.tian@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=robin.murphy@arm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.