forked from Minki/linux
iommu/iova: Put free_iova_mem() outside of spinlock iova_rbtree_lock
It is not necessary to put free_iova_mem() inside of spinlock/unlock iova_rbtree_lock which only leads to more completion for the spinlock. It has a small promote on the performance after the change. And also rename private_free_iova() as remove_iova() because the function will not free iova after that change. Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com> Reviewed-by: John Garry <john.garry@huawei.com> Acked-by: Robin Murphy <robin.murphy@arm.com> Link: https://lore.kernel.org/r/1620647582-194621-1-git-send-email-chenxiang66@hisilicon.com Signed-off-by: Joerg Roedel <jroedel@suse.de>
This commit is contained in:
parent
571f316074
commit
7978724f39
@ -412,12 +412,11 @@ private_find_iova(struct iova_domain *iovad, unsigned long pfn)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void private_free_iova(struct iova_domain *iovad, struct iova *iova)
|
static void remove_iova(struct iova_domain *iovad, struct iova *iova)
|
||||||
{
|
{
|
||||||
assert_spin_locked(&iovad->iova_rbtree_lock);
|
assert_spin_locked(&iovad->iova_rbtree_lock);
|
||||||
__cached_rbnode_delete_update(iovad, iova);
|
__cached_rbnode_delete_update(iovad, iova);
|
||||||
rb_erase(&iova->node, &iovad->rbroot);
|
rb_erase(&iova->node, &iovad->rbroot);
|
||||||
free_iova_mem(iova);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -452,8 +451,9 @@ __free_iova(struct iova_domain *iovad, struct iova *iova)
|
|||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
spin_lock_irqsave(&iovad->iova_rbtree_lock, flags);
|
spin_lock_irqsave(&iovad->iova_rbtree_lock, flags);
|
||||||
private_free_iova(iovad, iova);
|
remove_iova(iovad, iova);
|
||||||
spin_unlock_irqrestore(&iovad->iova_rbtree_lock, flags);
|
spin_unlock_irqrestore(&iovad->iova_rbtree_lock, flags);
|
||||||
|
free_iova_mem(iova);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(__free_iova);
|
EXPORT_SYMBOL_GPL(__free_iova);
|
||||||
|
|
||||||
@ -472,10 +472,13 @@ free_iova(struct iova_domain *iovad, unsigned long pfn)
|
|||||||
|
|
||||||
spin_lock_irqsave(&iovad->iova_rbtree_lock, flags);
|
spin_lock_irqsave(&iovad->iova_rbtree_lock, flags);
|
||||||
iova = private_find_iova(iovad, pfn);
|
iova = private_find_iova(iovad, pfn);
|
||||||
if (iova)
|
if (!iova) {
|
||||||
private_free_iova(iovad, iova);
|
spin_unlock_irqrestore(&iovad->iova_rbtree_lock, flags);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
remove_iova(iovad, iova);
|
||||||
spin_unlock_irqrestore(&iovad->iova_rbtree_lock, flags);
|
spin_unlock_irqrestore(&iovad->iova_rbtree_lock, flags);
|
||||||
|
free_iova_mem(iova);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(free_iova);
|
EXPORT_SYMBOL_GPL(free_iova);
|
||||||
|
|
||||||
@ -825,7 +828,8 @@ iova_magazine_free_pfns(struct iova_magazine *mag, struct iova_domain *iovad)
|
|||||||
if (WARN_ON(!iova))
|
if (WARN_ON(!iova))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
private_free_iova(iovad, iova);
|
remove_iova(iovad, iova);
|
||||||
|
free_iova_mem(iova);
|
||||||
}
|
}
|
||||||
|
|
||||||
spin_unlock_irqrestore(&iovad->iova_rbtree_lock, flags);
|
spin_unlock_irqrestore(&iovad->iova_rbtree_lock, flags);
|
||||||
|
Loading…
Reference in New Issue
Block a user