[CRIU] [PATCH 14/16] mem/shmem: Reorder code in expand_shmem

Cyrill Gorcunov gorcunov at gmail.com
Fri Jul 5 18:38:09 MSK 2019


- more elegant entries declaration
- check for is_shmem_tracking_en early

Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>
---
 criu/shmem.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/criu/shmem.c b/criu/shmem.c
index da9242674291..478d67a69992 100644
--- a/criu/shmem.c
+++ b/criu/shmem.c
@@ -179,14 +179,15 @@ static void set_pstate(unsigned long *pstate_map, unsigned long pfn,
 
 static int expand_shmem(struct shmem_info *si, unsigned long new_size)
 {
-	unsigned long nr_pages, nr_map_items, map_size,
-				nr_new_map_items, new_map_size, old_size;
+	unsigned long nr_pages, nr_map_items, map_size;
+	unsigned long nr_new_map_items, new_map_size, old_size;
 
-	old_size = si->size;
-	si->size = new_size;
 	if (!is_shmem_tracking_en())
 		return 0;
 
+	old_size = si->size;
+	si->size = new_size;
+
 	nr_pages = DIV_ROUND_UP(old_size, PAGE_SIZE);
 	nr_map_items = BITS_TO_LONGS(nr_pages * PST_BITS);
 	map_size = nr_map_items * sizeof(*si->pstate_map);
-- 
2.20.1



More information about the CRIU mailing list