All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tina Zhang <tina.zhang@intel.com>
To: iommu@lists.linux.dev, linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Cc: David Woodhouse <dwmw2@infradead.org>,
	Lu Baolu <baolu.lu@linux.intel.com>,
	Joerg Roedel <joro@8bytes.org>, Jason Gunthorpe <jgg@ziepe.ca>,
	Kevin Tian <kevin.tian@intel.com>,
	Tina Zhang <tina.zhang@intel.com>
Subject: [RFC PATCH 00/12] iommu/vt-d: Remove superfluous IOMMU IOTLB invalidations
Date: Tue, 17 Oct 2023 11:20:32 +0800	[thread overview]
Message-ID: <20231017032045.114868-1-tina.zhang@intel.com> (raw)

This series based on "Share sva" patch-set[1], aims to remove superfluous
IOMMU IOTLB invalidations in VT-d driver.

In the current VT-d driver, IOMMU IOTLB invalidation commands and
device-TLB commands are performed per device, which leads to superfluous
IOTLB invalidations. For example, if there are four devices behind a IOMMU
are attached to one sva domain (which could be a common case in
virtualization scenarios where one virtual IOMMU working for all the
virtual devices), four IOTLB invalidation commands and four device-IOTLB
invalidation commands will be issued. However, only one IOTLB invalidation
command and four device-IOTLB invalidation commands are necessary.
Superfluous IOMMU IOTLB invalidations impact run-time performance.

Although the goal could be built straight-forwardly in the current VT-d
driver, some refactoring works are considered necessary before landing the
one solving the problem of redundant IOTLB invalidations:

1) VT-d driver uses different structures to keep attached device info.
For default domain, it uses struct dev_pasids_info and some related fields
of struct dmar_domain. For sva domain, it uses struct intel_svm and
struct intel_svm_dev. The reason of it is because previously the sva
domain is not shared among devices behind different IOMMUs and
therefore dmar_domain and its fields cannot be used globally to keep
all attached device info. After the patch-set[1] gets acceptance, sva
domain is global to the attached devices. Thus, retiring struct
intel_svm/intel_svm_dev is the main refactoring work of this patch-set.

2) Most logic of intel_svm_set_dev_pasid() can be covered by
intel_iommu_set_dev_pasid(). Refactoring both intel_svm_set_dev_pasid()
and intel_iommu_set_dev_pasid() and let the former call the latter for
set_dev_pasid operation to avoid duplicating code.

3) Last but not least, struct mmu_notifier is proposed to iommu_domain.
This is a change to IOMMU core, which helps to centralize info required by
sva to sva domain and therefore can help cleanup the code in IOMMU drivers.

This patchset is on github per-iommu_IOTLB_invalidation branch[2].

[1]: https://lore.kernel.org/linux-iommu/20231017004802.109618-1-tina.zhang@intel.com/
[2]: https://github.com/TinaZhangZW/linux/tree/per-iommu_IOTLB_invalidation

Tina Zhang (12):
  iommu/vt-d: Retire the treatment for revoking PASIDs with pending
    pgfaults
  iommu/vt-d: Remove initialization for dynamically heap-allocated
    rcu_head
  iommu/vt-d: Retire intel_svm_bind_mm()
  iommu/vt-d: Make dev_to_intel_iommu() helper global
  iommu/vt-d: Retire struct intel_svm_dev
  iommu: Add mmu_notifier to sva domain
  iommu/vt-d: Retire struct intel_svm
  iommu/vt-d: Use RCU for dev_pasids list updates in
    set/remove_dev_pasid()
  iommu/vt-d: Refactor intel_iommu_set_dev_pasid()
  iommu/vt-d: Refactor intel_iommu_remove_dev_pasid()
  iommu/vt-d: Use intel_iommu_set_dev_pasid() for sva domain
  iommu/vt-d: Remove superfluous IOMMU IOTLB invalidations

 drivers/iommu/intel/iommu.c |  91 +++++++++----
 drivers/iommu/intel/iommu.h |  30 ++---
 drivers/iommu/intel/svm.c   | 261 ++++++++----------------------------
 include/linux/iommu.h       |   2 +
 4 files changed, 128 insertions(+), 256 deletions(-)

-- 
2.39.3


             reply	other threads:[~2023-10-17  3:21 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-17  3:20 Tina Zhang [this message]
2023-10-17  3:20 ` [RFC PATCH 01/12] iommu/vt-d: Retire the treatment for revoking PASIDs with pending pgfaults Tina Zhang
2023-10-17  3:20 ` [RFC PATCH 02/12] iommu/vt-d: Remove initialization for dynamically heap-allocated rcu_head Tina Zhang
2023-10-17  3:20 ` [RFC PATCH 03/12] iommu/vt-d: Retire intel_svm_bind_mm() Tina Zhang
2023-10-17  3:20 ` [RFC PATCH 04/12] iommu/vt-d: Make dev_to_intel_iommu() helper global Tina Zhang
2023-10-17  3:20 ` Tina Zhang
2023-10-17  3:20 ` [RFC PATCH 05/12] iommu/vt-d: Retire struct intel_svm_dev Tina Zhang
2023-10-17  3:20 ` [RFC PATCH 06/12] iommu: Add mmu_notifier to sva domain Tina Zhang
2023-10-23 18:35   ` Jason Gunthorpe
2023-11-01 11:58     ` Zhang, Tina
2023-10-17  3:20 ` [RFC PATCH 07/12] iommu/vt-d: Retire struct intel_svm Tina Zhang
2023-10-17  3:20 ` [RFC PATCH 08/12] iommu/vt-d: Use RCU for dev_pasids list updates in set/remove_dev_pasid() Tina Zhang
2023-10-17  3:20 ` [RFC PATCH 09/12] iommu/vt-d: Refactor intel_iommu_set_dev_pasid() Tina Zhang
2023-10-17  3:20 ` [RFC PATCH 10/12] iommu/vt-d: Refactor intel_iommu_remove_dev_pasid() Tina Zhang
2023-10-17  3:20 ` [RFC PATCH 11/12] iommu/vt-d: Use intel_iommu_set_dev_pasid() for sva domain Tina Zhang
2023-10-17  3:20 ` [RFC PATCH 12/12] iommu/vt-d: Remove superfluous IOMMU IOTLB invalidations Tina Zhang

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=20231017032045.114868-1-tina.zhang@intel.com \
    --to=tina.zhang@intel.com \
    --cc=baolu.lu@linux.intel.com \
    --cc=dwmw2@infradead.org \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@ziepe.ca \
    --cc=joro@8bytes.org \
    --cc=kevin.tian@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.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 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.