diff --git a/Makefile.config b/Makefile.config index edd110a8c..880d97c34 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 000000000..fbf3fc4c2 --- /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 3736c2890..028da64c4 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) {