aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThanos Makatos <thanos.makatos@nutanix.com>2022-02-24 21:57:52 +0000
committerGitHub <noreply@github.com>2022-02-24 21:57:52 +0000
commit440652c74404f4e682ad35a2fed64258d3496815 (patch)
treec3d62cb0f449643ec27831815b8e42fabf887bbc
parenta23ef2792820141f4ecce63ec8bf80ea320b259c (diff)
downloadlibvfio-user-440652c74404f4e682ad35a2fed64258d3496815.zip
libvfio-user-440652c74404f4e682ad35a2fed64258d3496815.tar.gz
libvfio-user-440652c74404f4e682ad35a2fed64258d3496815.tar.bz2
additional logging around dirty pages (#650)
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com> Reviewed-by: John Levon <john.levon@nutanix.com>
-rw-r--r--lib/dma.c24
-rw-r--r--lib/libvfio-user.c6
2 files changed, 30 insertions, 0 deletions
diff --git a/lib/dma.c b/lib/dma.c
index cf63177..26c5758 100644
--- a/lib/dma.c
+++ b/lib/dma.c
@@ -523,6 +523,8 @@ dma_controller_dirty_page_logging_start(dma_controller_t *dma, size_t pgsize)
dma_mark_dirty_sgs(dma);
+ vfu_log(dma->vfu_ctx, LOG_DEBUG, "dirty pages: started logging");
+
return 0;
}
@@ -542,7 +544,26 @@ dma_controller_dirty_page_logging_stop(dma_controller_t *dma)
dma->regions[i].dirty_bitmap = NULL;
}
dma->dirty_pgsize = 0;
+
+ vfu_log(dma->vfu_ctx, LOG_DEBUG, "dirty pages: stopped logging");
+}
+
+
+#ifdef DEBUG
+static void
+log_dirty_bitmap(vfu_ctx_t *vfu_ctx, dma_memory_region_t *region,
+ char *bitmap, size_t size)
+{
+ size_t i;
+ size_t count;
+ for (i = 0, count = 0; i < size; i++) {
+ count += __builtin_popcount(bitmap[i]);
+ }
+ vfu_log(vfu_ctx, LOG_DEBUG, "dirty pages: get [%p, %p), %zu dirty pages",
+ region->info.iova.iov_base, iov_end(&region->info.iova),
+ count);
}
+#endif
int
dma_controller_dirty_page_get(dma_controller_t *dma, vfu_dma_addr_t addr,
@@ -600,6 +621,9 @@ dma_controller_dirty_page_get(dma_controller_t *dma, vfu_dma_addr_t addr,
* vfu_map_sg/vfu_unmap_sg().
*/
memcpy(bitmap, region->dirty_bitmap, size);
+#ifdef DEBUG
+ log_dirty_bitmap(dma->vfu_ctx, region, bitmap, size);
+#endif
memset(region->dirty_bitmap, 0, size);
dma_mark_dirty_sgs(dma);
diff --git a/lib/libvfio-user.c b/lib/libvfio-user.c
index 3f67992..89b3bc8 100644
--- a/lib/libvfio-user.c
+++ b/lib/libvfio-user.c
@@ -942,7 +942,13 @@ handle_dirty_pages_get(vfu_ctx_t *vfu_ctx, vfu_msg_t *msg)
msg->out_size = 0;
return ERROR_INT(ret);
}
+ } else {
+ vfu_log(vfu_ctx, LOG_ERR,
+ "dirty pages: get [%#lx, %#lx): buffer too small (%u < %lu)",
+ range_in->iova, range_in->iova + range_in->size,
+ dirty_pages_in->argsz, argsz);
}
+
return 0;
}