[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1720790333-456232-2-git-send-email-steven.sistare@oracle.com>
Date: Fri, 12 Jul 2024 06:18:47 -0700
From: Steve Sistare <steven.sistare@...cle.com>
To: virtualization@...ts.linux-foundation.org, linux-kernel@...r.kernel.org
Cc: "Michael S. Tsirkin" <mst@...hat.com>, Jason Wang <jasowang@...hat.com>,
Si-Wei Liu <si-wei.liu@...cle.com>,
Eugenio Perez Martin <eperezma@...hat.com>,
Xuan Zhuo <xuanzhuo@...ux.alibaba.com>,
Dragos Tatulea <dtatulea@...dia.com>,
Steve Sistare <steven.sistare@...cle.com>
Subject: [PATCH V2 1/7] vhost-vdpa: count pinned memory
Remember the count of pinned memory for the device.
Signed-off-by: Steve Sistare <steven.sistare@...cle.com>
---
drivers/vhost/vdpa.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
index 63a53680a85c..963f3704bc39 100644
--- a/drivers/vhost/vdpa.c
+++ b/drivers/vhost/vdpa.c
@@ -60,6 +60,7 @@ struct vhost_vdpa {
struct vdpa_iova_range range;
u32 batch_asid;
bool suspended;
+ long pinned_vm;
};
static DEFINE_IDA(vhost_vdpa_ida);
@@ -926,6 +927,7 @@ static void vhost_vdpa_pa_unmap(struct vhost_vdpa *v, struct vhost_iotlb *iotlb,
unpin_user_page(page);
}
atomic64_sub(PFN_DOWN(map->size), &dev->mm->pinned_vm);
+ v->pinned_vm -= PFN_DOWN(map->size);
vhost_vdpa_general_unmap(v, map, asid);
vhost_iotlb_map_free(iotlb, map);
}
@@ -1009,9 +1011,10 @@ static int vhost_vdpa_map(struct vhost_vdpa *v, struct vhost_iotlb *iotlb,
return r;
}
- if (!vdpa->use_va)
+ if (!vdpa->use_va) {
atomic64_add(PFN_DOWN(size), &dev->mm->pinned_vm);
-
+ v->pinned_vm += PFN_DOWN(size);
+ }
return 0;
}
--
2.39.3
Powered by blists - more mailing lists