[CRIU] [PATCH 2/2] criu: get rid of config-base.h

Dmitry Safonov dsafonov at virtuozzo.com
Mon Sep 26 07:51:59 PDT 2016


It contained definitions for F_{SET,GET}PIPE_SZ, which
we already have in "fcntl.h" - it's not big, can be included instead.
Also it has pipe-size specific definitions, which are used only
in page-pipe.c -- moved them to page-pipe.h.

This will simplify include for config.h from subprojects.

Cc: Cyrill Gorcunov <gorcunov at openvz.org>
Cc: Pavel Emelyanov <xemul at virtuozzo.com>
Signed-off-by: Dmitry Safonov <dsafonov at virtuozzo.com>
---
 Makefile.config            | 11 +----------
 criu/include/config-base.h | 40 ----------------------------------------
 criu/include/fcntl.h       |  7 ++++++-
 criu/include/page-pipe.h   | 21 +++++++++++++++++++++
 criu/page-pipe.c           |  2 +-
 criu/page-xfer.c           |  2 +-
 criu/pipes.c               |  2 +-
 7 files changed, 31 insertions(+), 54 deletions(-)
 delete mode 100644 criu/include/config-base.h

diff --git a/Makefile.config b/Makefile.config
index 9e132f80feb4..aa8cb4450a70 100644
--- a/Makefile.config
+++ b/Makefile.config
@@ -36,19 +36,12 @@ ifeq ($$(call try-cc,$$(FEATURE_TEST_$(1)),$$(LIBS_FEATURES),$$(DEFINES)),true)
 endif
 endef
 
-CONFIG_BASE := $(SRC_DIR)/criu/include/config-base.h
-
-$(CONFIG_BASE):
-	@true
-
 define config-header-rule
-$(CONFIG_HEADER): $(CONFIG_BASE)
+$(CONFIG_HEADER): $(SRC_DIR)/scripts/feature-tests.mak
 	$$(call msg-gen, $$@)
 	$(Q) @echo '#ifndef __CR_CONFIG_H__'				> $$@
 	$(Q) @echo '#define __CR_CONFIG_H__'				>> $$@
 	$(Q) @echo ''							>> $$@
-	$(Q) @echo '#include "config-base.h"'				>> $$@
-	$(Q) @echo ''							>> $$@
 $(call map,gen-feature-test,$(FEATURES_LIST))
 ifeq ($$(VDSO),y)
 	$(Q) @echo '#define CONFIG_VDSO'				>> $$@
@@ -62,5 +55,3 @@ endif
 endef
 
 $(eval $(config-header-rule))
-
-$(CONFIG_HEADER): $(SRC_DIR)/scripts/feature-tests.mak
diff --git a/criu/include/config-base.h b/criu/include/config-base.h
deleted file mode 100644
index 5e26859658e1..000000000000
--- a/criu/include/config-base.h
+++ /dev/null
@@ -1,40 +0,0 @@
-#ifndef __CR_CONFIG_BASE_H__
-#define __CR_CONFIG_BASE_H__
-
-#define PAGE_ALLOC_COSTLY_ORDER 3 /* from the kernel source code */
-struct kernel_pipe_buffer {
-        struct page *page;
-        unsigned int offset, len;
-        const struct pipe_buf_operations *ops;
-        unsigned int flags;
-        unsigned long private;
-};
-
-/*
- * The kernel allocates the linear chunk of memory for pipe buffers.
- * Allocation of chunks with size more than PAGE_ALLOC_COSTLY_ORDER
- * fails very often, so we need to restrict the pipe capacity to not
- * allocate big chunks.
- */
-#define PIPE_MAX_SIZE ((1 << PAGE_ALLOC_COSTLY_ORDER) * PAGE_SIZE /	\
-			sizeof(struct kernel_pipe_buffer))
-
-/* The number of pipes for one chunk */
-#define NR_PIPES_PER_CHUNK 8
-
-/*
- * These things are required to compile on CentOS-6
- */
-#ifndef F_LINUX_SPECIFIC_BASE
-# define F_LINUX_SPECIFIC_BASE 1024
-#endif
-
-#ifndef F_SETPIPE_SZ
-# define F_SETPIPE_SZ	(F_LINUX_SPECIFIC_BASE + 7)
-#endif
-
-#ifndef F_GETPIPE_SZ
-# define F_GETPIPE_SZ  (F_LINUX_SPECIFIC_BASE + 8)
-#endif
-
-#endif /* __CR_CONFIG_BASE_H__ */
diff --git a/criu/include/fcntl.h b/criu/include/fcntl.h
index 6f85c5ee6923..ce8abda3439d 100644
--- a/criu/include/fcntl.h
+++ b/criu/include/fcntl.h
@@ -19,12 +19,17 @@ struct f_owner_ex {
 #define F_GETOWNER_UIDS	17
 #endif
 
+/*
+ * These things are required to compile on CentOS-6
+ */
 #ifndef F_LINUX_SPECIFIC_BASE
-#define F_LINUX_SPECIFIC_BASE	1024
+# define F_LINUX_SPECIFIC_BASE	1024
 #endif
+
 #ifndef F_SETPIPE_SZ
 # define F_SETPIPE_SZ	(F_LINUX_SPECIFIC_BASE + 7)
 #endif
+
 #ifndef F_GETPIPE_SZ
 # define F_GETPIPE_SZ	(F_LINUX_SPECIFIC_BASE + 8)
 #endif
diff --git a/criu/include/page-pipe.h b/criu/include/page-pipe.h
index 45bd6b1a1e31..3557366a224a 100644
--- a/criu/include/page-pipe.h
+++ b/criu/include/page-pipe.h
@@ -4,6 +4,27 @@
 #include <sys/uio.h>
 #include "list.h"
 
+#define PAGE_ALLOC_COSTLY_ORDER 3 /* from the kernel source code */
+struct kernel_pipe_buffer {
+        struct page *page;
+        unsigned int offset, len;
+        const struct pipe_buf_operations *ops;
+        unsigned int flags;
+        unsigned long private;
+};
+
+/*
+ * The kernel allocates the linear chunk of memory for pipe buffers.
+ * Allocation of chunks with size more than PAGE_ALLOC_COSTLY_ORDER
+ * fails very often, so we need to restrict the pipe capacity to not
+ * allocate big chunks.
+ */
+#define PIPE_MAX_SIZE ((1 << PAGE_ALLOC_COSTLY_ORDER) * PAGE_SIZE /	\
+			sizeof(struct kernel_pipe_buffer))
+
+/* The number of pipes for one chunk */
+#define NR_PIPES_PER_CHUNK 8
+
 /*
  * page_pipe is a descriptor of task's virtual memory
  * with pipes, containing pages.
diff --git a/criu/page-pipe.c b/criu/page-pipe.c
index df028dcb33d3..2c4f85c997dd 100644
--- a/criu/page-pipe.c
+++ b/criu/page-pipe.c
@@ -1,5 +1,4 @@
 #include <unistd.h>
-#include <fcntl.h>
 
 #undef LOG_PREFIX
 #define LOG_PREFIX "page-pipe: "
@@ -7,6 +6,7 @@
 #include "config.h"
 #include "util.h"
 #include "page-pipe.h"
+#include "fcntl.h"
 
 /* can existing iov accumulate the page? */
 static inline bool iov_grow_page(struct iovec *iov, unsigned long addr)
diff --git a/criu/page-xfer.c b/criu/page-xfer.c
index 1ccab2abbe7e..38048d81d37f 100644
--- a/criu/page-xfer.c
+++ b/criu/page-xfer.c
@@ -3,7 +3,6 @@
 #include <arpa/inet.h>
 #include <linux/falloc.h>
 #include <unistd.h>
-#include <fcntl.h>
 #include <sys/types.h>
 #include <sys/wait.h>
 #include <sys/stat.h>
@@ -18,6 +17,7 @@
 #include "images/pagemap.pb-c.h"
 #include "pstree.h"
 #include "parasite-syscall.h"
+#include "fcntl.h"
 
 static int page_server_sk = -1;
 
diff --git a/criu/pipes.c b/criu/pipes.c
index 57618479307f..d6b0b308d1fe 100644
--- a/criu/pipes.c
+++ b/criu/pipes.c
@@ -1,7 +1,6 @@
 #include <unistd.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <fcntl.h>
 #include <stdlib.h>
 #include <sys/mman.h>
 
@@ -16,6 +15,7 @@
 #include "protobuf.h"
 #include "images/pipe.pb-c.h"
 #include "images/pipe-data.pb-c.h"
+#include "fcntl.h"
 
 static LIST_HEAD(pipes);
 
-- 
2.10.0



More information about the CRIU mailing list