[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH Kernel v21 2/8] vfio iommu: Remove atomicity of ref_count of pinn
From: |
Kirti Wankhede |
Subject: |
[PATCH Kernel v21 2/8] vfio iommu: Remove atomicity of ref_count of pinned pages |
Date: |
Sat, 16 May 2020 02:43:17 +0530 |
vfio_pfn.ref_count is always updated while holding iommu->lock, using
atomic variable is overkill.
Signed-off-by: Kirti Wankhede <address@hidden>
Reviewed-by: Neo Jia <address@hidden>
Reviewed-by: Eric Auger <address@hidden>
Reviewed-by: Cornelia Huck <address@hidden>
---
drivers/vfio/vfio_iommu_type1.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
index a0c60f895b24..fa735047b04d 100644
--- a/drivers/vfio/vfio_iommu_type1.c
+++ b/drivers/vfio/vfio_iommu_type1.c
@@ -112,7 +112,7 @@ struct vfio_pfn {
struct rb_node node;
dma_addr_t iova; /* Device address */
unsigned long pfn; /* Host pfn */
- atomic_t ref_count;
+ unsigned int ref_count;
};
struct vfio_regions {
@@ -233,7 +233,7 @@ static int vfio_add_to_pfn_list(struct vfio_dma *dma,
dma_addr_t iova,
vpfn->iova = iova;
vpfn->pfn = pfn;
- atomic_set(&vpfn->ref_count, 1);
+ vpfn->ref_count = 1;
vfio_link_pfn(dma, vpfn);
return 0;
}
@@ -251,7 +251,7 @@ static struct vfio_pfn *vfio_iova_get_vfio_pfn(struct
vfio_dma *dma,
struct vfio_pfn *vpfn = vfio_find_vpfn(dma, iova);
if (vpfn)
- atomic_inc(&vpfn->ref_count);
+ vpfn->ref_count++;
return vpfn;
}
@@ -259,7 +259,8 @@ static int vfio_iova_put_vfio_pfn(struct vfio_dma *dma,
struct vfio_pfn *vpfn)
{
int ret = 0;
- if (atomic_dec_and_test(&vpfn->ref_count)) {
+ vpfn->ref_count--;
+ if (!vpfn->ref_count) {
ret = put_pfn(vpfn->pfn, dma->prot);
vfio_remove_from_pfn_list(dma, vpfn);
}
--
2.7.0
- [PATCH Kernel v21 0/8] Add UAPIs to support migration for VFIO devices, Kirti Wankhede, 2020/05/15
- [PATCH Kernel v21 1/8] vfio: UAPI for migration interface for device state, Kirti Wankhede, 2020/05/15
- [PATCH Kernel v21 2/8] vfio iommu: Remove atomicity of ref_count of pinned pages,
Kirti Wankhede <=
- [PATCH Kernel v21 3/8] vfio iommu: Cache pgsize_bitmap in struct vfio_iommu, Kirti Wankhede, 2020/05/15
- [PATCH Kernel v21 4/8] vfio iommu: Add ioctl definition for dirty pages tracking, Kirti Wankhede, 2020/05/15
- [PATCH Kernel v21 5/8] vfio iommu: Implementation of ioctl for dirty pages tracking, Kirti Wankhede, 2020/05/15
- [PATCH Kernel v21 6/8] vfio iommu: Update UNMAP_DMA ioctl to get dirty bitmap before unmap, Kirti Wankhede, 2020/05/15
- [PATCH Kernel v21 7/8] vfio iommu: Add migration capability to report supported features, Kirti Wankhede, 2020/05/15
- [PATCH Kernel v21 8/8] vfio: Selective dirty page tracking if IOMMU backed device pins pages, Kirti Wankhede, 2020/05/15
- RE: [PATCH Kernel v21 0/8] Add UAPIs to support migration for VFIO devices, Tian, Kevin, 2020/05/15