man.bsd.lv manual page server

Manual Page Search Parameters

MPIPE(9) Kernel Developer's Manual MPIPE(9)

mpipe_init, mpipe_done, mpipe_alloc_nowait, mpipe_alloc_waitok, mpipe_freemalloc pipelines

#include <sys/mpipe.h>

void
mpipe_init(malloc_pipe_t mpipe, malloc_type_t type, int bytes, int nnom, int nmax, int mpflags, void (*construct)(void *, void *), void (*deconstruct)(void *, void *), void *priv);

void
mpipe_done(malloc_pipe_t mpipe);

void *
mpipe_alloc_nowait(malloc_pipe_t mpipe);

void *
mpipe_alloc_waitok(malloc_pipe_t mpipe);

void
mpipe_free(malloc_pipe_t mpipe, void *buf);

A malloc pipeline is a linear pool of buffers of a single type. A malloc pipeline guarantees a number of outstanding allocations and provides both blocking and non-blocking behavior above the guaranteed allocation amounts. A malloc pipeline can have an upper limit, beyond which allocations sleep or fail respectively. Malloc pipelines are intended for situations where a minimum number of buffers are required to make progress.

The () function initializes a malloc pipeline mpipe. The pipeline allocates buffers of size bytes from the malloc zone type. The pipeline is prefilled with nnom buffers and has a limit of nmax buffers. The construct argument is a callback, invoked when a buffer is allocated from the system. The deconstruct argument is a callback, invoked when the malloc pipeline is destroyed or a buffer is freed to the system. Both construct and deconstruct are invoked with the buffer address as their first parameter and with priv as their second parameter. The flags argument controls allocation parameters:

Do not zero allocated buffers.
By default, MPIPE buffers are zeroed on free; this flag disables that behavior.
Allocations may use the interrupt memory reserve.

This function may block.

The () function destroys a malloc pipeline. The pipeline's destructor is invoked on each buffer and then they are returned to the system. It is an error to invoke this function on a pipeline with outstanding allocations. This function may block.

The () function allocates a buffer from the malloc pipeline. It will first allocate from the pipeline itself; if that is exhausted, it will fall back on kmalloc(9), up to the pipeline maximum. This function may not block.

The () function allocates a buffer from the malloc pipeline. It will first allocate from the pipeline; if that is exhausted, it will fall back on kmalloc(9), up to the pipeline maximum. It will sleep if it reaches the maximum, potentially releasing any tokens.

The () function frees a buffer to the malloc pipeline. If the pipeline is full, it will free directly to the kernel allocator, calling the destructor as it does. This function may block.

The MPIPE implementation is in /sys/kern/kern_mpipe.c.

memory(9)

MPIPE first appeared in DragonFly 1.0.

December 21, 2010 DragonFly-5.6.1