[CRIU] [PATCH] page-pipe: move tunable constants into config.h

Andrey Vagin avagin at openvz.org
Thu Feb 13 03:53:48 PST 2014


PIPE_MAX_SIZE is calculated according with the kernel code.
PPB_IOV_BATCH has been taken from my mind.

Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 Makefile.config       |  5 ++++-
 include/config-base.h | 26 ++++++++++++++++++++++++++
 page-pipe.c           | 23 +----------------------
 3 files changed, 31 insertions(+), 23 deletions(-)
 create mode 100644 include/config-base.h

diff --git a/Makefile.config b/Makefile.config
index edd110a..880d97c 100644
--- a/Makefile.config
+++ b/Makefile.config
@@ -3,10 +3,13 @@ include scripts/feature-tests.mak
 
 CONFIG		:= include/config.h
 
-$(CONFIG): scripts/utilities.mak scripts/feature-tests.mak
+$(CONFIG): scripts/utilities.mak scripts/feature-tests.mak include/config-base.h
 	$(E) "  GEN     " $@
 	$(Q) @echo '#ifndef __CR_CONFIG_H__' > $@
 	$(Q) @echo '#define __CR_CONFIG_H__' >> $@
+	$(Q) @echo '' >> $@
+	$(Q) @echo '#include "config-base.h"' >> $@
+	$(Q) @echo '' >> $@
 ifeq ($(call try-cc,$(TCP_REPAIR_TEST),,),y)
 	$(Q) @echo '#define CONFIG_HAS_TCP_REPAIR' >> $@
 endif
diff --git a/include/config-base.h b/include/config-base.h
new file mode 100644
index 0000000..fbf3fc4
--- /dev/null
+++ b/include/config-base.h
@@ -0,0 +1,26 @@
+#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
+
+
+#endif
diff --git a/page-pipe.c b/page-pipe.c
index 3736c28..028da64 100644
--- a/page-pipe.c
+++ b/page-pipe.c
@@ -4,12 +4,10 @@
 #undef LOG_PREFIX
 #define LOG_PREFIX "page-pipe: "
 
+#include "config.h"
 #include "util.h"
 #include "page-pipe.h"
 
-/* The number of pipes for one chunk */
-#define NR_PIPES_PER_CHUNK 8
-
 static int page_pipe_grow(struct page_pipe *pp)
 {
 	struct page_pipe_buf *ppb;
@@ -110,25 +108,6 @@ void page_pipe_reinit(struct page_pipe *pp)
 		BUG(); /* It can't fail, because ppb is in free_bufs */
 }
 
-#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))
-#define PPB_IOV_BATCH	8
-
 static inline int try_add_page_to(struct page_pipe *pp, struct page_pipe_buf *ppb,
 		unsigned long addr)
 {
-- 
1.8.5.3



More information about the CRIU mailing list