[CRIU] [PATCH] lazy-pages: add comments to update_lazy_iovecs
Mike Rapoport
rppt at linux.vnet.ibm.com
Wed Dec 14 09:25:06 PST 2016
This function does weird things, so better have it at least somehow
documented.
Signed-off-by: Mike Rapoport <rppt at linux.vnet.ibm.com>
---
criu/uffd.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/criu/uffd.c b/criu/uffd.c
index d71a83a..716bada 100644
--- a/criu/uffd.c
+++ b/criu/uffd.c
@@ -325,6 +325,10 @@ static MmEntry *init_mm_entry(struct lazy_pages_info *lpi)
return mm;
}
+/*
+ * Purge range (addr, addr + len) from lazy_iovecs. The range may
+ * cover several continuous IOVs.
+ */
static int update_lazy_iovecs(struct lazy_pages_info *lpi, unsigned long addr,
int len)
{
@@ -340,6 +344,13 @@ static int update_lazy_iovecs(struct lazy_pages_info *lpi, unsigned long addr,
if (addr < start || addr >= end)
continue;
+ /*
+ * The range completely fits into the current IOV.
+ * If addr equals iov_base we just "drop" the
+ * beginning of the IOV. Otherwise, we make the IOV to
+ * end at addr, and add a new IOV start starts at
+ * addr + len.
+ */
if (addr + len < end) {
if (addr == start) {
lazy_iov->base += len;
@@ -361,6 +372,12 @@ static int update_lazy_iovecs(struct lazy_pages_info *lpi, unsigned long addr,
break;
}
+ /*
+ * The range spawns beyond the end of the current IOV.
+ * If addr equals iov_base we just "drop" the entire
+ * IOV. Otherwise, we cut the beginning of the IOV
+ * and continue to the next one with the updated range
+ */
if (addr == start) {
list_del(&lazy_iov->l);
xfree(lazy_iov);
--
1.9.1
More information about the CRIU
mailing list