[CRIU] [PATCHv0 2/8] pagemap-cache: add const-qualifier to pmc's vma

Eugene Batalov eabatalov89 at gmail.com
Sun Dec 6 05:15:18 PST 2015


From: Fyodor <bocharovfedor at gmail.com>

We need to perform dirty page tracking when dumping shmem but there
we have only const vmas so we need pmc to work with them. Also pmc concept
implies that it won't change its vmas so it would be natural to declared
them as const.

Signed-off-by: Fyodor Bocharov <fbocharov at yandex.ru>
Signed-off-by: Eugene Batalov <eabatalov89 at gmail.com>
---
 include/pagemap-cache.h | 6 +++---
 pagemap-cache.c         | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/include/pagemap-cache.h b/include/pagemap-cache.h
index 37291ab..e088090 100644
--- a/include/pagemap-cache.h
+++ b/include/pagemap-cache.h
@@ -15,7 +15,7 @@ typedef struct {
 	pid_t			pid;		/* which process it belongs */
 	unsigned long		start;		/* start of area */
 	unsigned long		end;		/* end of area */
-	struct list_head	*vma_head;	/* list head of VMAs we're serving */
+	const struct list_head	*vma_head;	/* list head of VMAs we're serving */
 	u64			*map;		/* local buffer */
 	size_t			map_len;	/* length of a buffer */
 	int			fd;		/* file to read PMs from */
@@ -23,8 +23,8 @@ typedef struct {
 
 #define PMC_INIT (pmc_t){ }
 
-extern int pmc_init(pmc_t *pmc, pid_t pid, struct list_head *vma_head, size_t size);
-extern u64 *pmc_get_map(pmc_t *pmc, struct vma_area *vma);
+extern int pmc_init(pmc_t *pmc, pid_t pid, const struct list_head *vma_head, size_t size);
+extern u64 *pmc_get_map(pmc_t *pmc, const struct vma_area *vma);
 extern void pmc_fini(pmc_t *pmc);
 
 #endif /* __CR_PAGEMAP_H__ */
diff --git a/pagemap-cache.c b/pagemap-cache.c
index 9ce7b91..589420a 100644
--- a/pagemap-cache.c
+++ b/pagemap-cache.c
@@ -31,7 +31,7 @@ static inline void pmc_zap(pmc_t *pmc)
 	pmc->start = pmc->end = 0;
 }
 
-int pmc_init(pmc_t *pmc, pid_t pid, struct list_head *vma_head, size_t size)
+int pmc_init(pmc_t *pmc, pid_t pid, const struct list_head *vma_head, size_t size)
 {
 	size_t map_size = max(size, (size_t)PMC_SIZE);
 	pmc_reset(pmc);
@@ -60,7 +60,7 @@ static inline u64 *__pmc_get_map(pmc_t *pmc, unsigned long addr)
 	return &pmc->map[PAGE_PFN(addr - pmc->start)];
 }
 
-static int pmc_fill_cache(pmc_t *pmc, struct vma_area *vma)
+static int pmc_fill_cache(pmc_t *pmc, const struct vma_area *vma)
 {
 	unsigned long low = vma->e->start & PMC_MASK;
 	unsigned long high = low + PMC_SIZE;
@@ -129,7 +129,7 @@ static int pmc_fill_cache(pmc_t *pmc, struct vma_area *vma)
 	return 0;
 }
 
-u64 *pmc_get_map(pmc_t *pmc, struct vma_area *vma)
+u64 *pmc_get_map(pmc_t *pmc, const struct vma_area *vma)
 {
 	/* Hit */
 	if (likely(pmc->start <= vma->e->start && pmc->end >= vma->e->end))
-- 
1.9.1



More information about the CRIU mailing list