Commit 18607116 authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

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: 's avatarAndrey Vagin <avagin@openvz.org>
Acked-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 3a3f3c79
...@@ -3,10 +3,13 @@ include scripts/feature-tests.mak ...@@ -3,10 +3,13 @@ include scripts/feature-tests.mak
CONFIG := include/config.h 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 " $@ $(E) " GEN " $@
$(Q) @echo '#ifndef __CR_CONFIG_H__' > $@ $(Q) @echo '#ifndef __CR_CONFIG_H__' > $@
$(Q) @echo '#define __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) ifeq ($(call try-cc,$(TCP_REPAIR_TEST),,),y)
$(Q) @echo '#define CONFIG_HAS_TCP_REPAIR' >> $@ $(Q) @echo '#define CONFIG_HAS_TCP_REPAIR' >> $@
endif endif
......
#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
...@@ -4,12 +4,10 @@ ...@@ -4,12 +4,10 @@
#undef LOG_PREFIX #undef LOG_PREFIX
#define LOG_PREFIX "page-pipe: " #define LOG_PREFIX "page-pipe: "
#include "config.h"
#include "util.h" #include "util.h"
#include "page-pipe.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) static int page_pipe_grow(struct page_pipe *pp)
{ {
struct page_pipe_buf *ppb; struct page_pipe_buf *ppb;
...@@ -110,25 +108,6 @@ void page_pipe_reinit(struct page_pipe *pp) ...@@ -110,25 +108,6 @@ void page_pipe_reinit(struct page_pipe *pp)
BUG(); /* It can't fail, because ppb is in free_bufs */ 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, static inline int try_add_page_to(struct page_pipe *pp, struct page_pipe_buf *ppb,
unsigned long addr) unsigned long addr)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment