Skip to content

Commit acf5d49

Browse files
duanzhenzhongjoergroedel
authored andcommitted
iommu/vt-d: Link cache tags of same iommu unit together
Cache tag invalidation requests for a domain are accumulated until a different iommu unit is found when traversing the cache_tags linked list. But cache tags of same iommu unit can be distributed in the linked list, this make batched flush less efficient. E.g., one device backed by iommu0 is attached to a domain in between two devices attaching backed by iommu1. Group cache tags together for same iommu unit in cache_tag_assign() to maximize the performance of batched flush. Co-developed-by: Lu Baolu <[email protected]> Signed-off-by: Lu Baolu <[email protected]> Signed-off-by: Zhenzhong Duan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent cf08ca8 commit acf5d49

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

drivers/iommu/intel/cache.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ static int cache_tag_assign(struct dmar_domain *domain, u16 did,
4747
struct device_domain_info *info = dev_iommu_priv_get(dev);
4848
struct intel_iommu *iommu = info->iommu;
4949
struct cache_tag *tag, *temp;
50+
struct list_head *prev;
5051
unsigned long flags;
5152

5253
tag = kzalloc(sizeof(*tag), GFP_KERNEL);
@@ -65,6 +66,7 @@ static int cache_tag_assign(struct dmar_domain *domain, u16 did,
6566
tag->dev = iommu->iommu.dev;
6667

6768
spin_lock_irqsave(&domain->cache_lock, flags);
69+
prev = &domain->cache_tags;
6870
list_for_each_entry(temp, &domain->cache_tags, node) {
6971
if (cache_tage_match(temp, did, iommu, dev, pasid, type)) {
7072
temp->users++;
@@ -73,8 +75,15 @@ static int cache_tag_assign(struct dmar_domain *domain, u16 did,
7375
trace_cache_tag_assign(temp);
7476
return 0;
7577
}
78+
if (temp->iommu == iommu)
79+
prev = &temp->node;
7680
}
77-
list_add_tail(&tag->node, &domain->cache_tags);
81+
/*
82+
* Link cache tags of same iommu unit together, so corresponding
83+
* flush ops can be batched for iommu unit.
84+
*/
85+
list_add(&tag->node, prev);
86+
7887
spin_unlock_irqrestore(&domain->cache_lock, flags);
7988
trace_cache_tag_assign(tag);
8089

0 commit comments

Comments
 (0)