page-pipe: move tunable constants into config.h

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@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Andrey Vagin 2014-02-14 16:43:21 +04:00 committed by Pavel Emelyanov
parent 3a3f3c79e4
commit 18607116fa
3 changed files with 31 additions and 23 deletions

View file

@ -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

26
include/config-base.h Normal file
View file

@ -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

View file

@ -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)
{