LWBUF(9) BSD Kernel Developer's Manual LWBUF(9)NAME
lwbuf_alloc, lwbuf_free, lwbuf_page, lwbuf_kva, lwbuf_set_global — light‐
weight buffers
SYNOPSIS
#include <cpu/lwbuf.h>
struct lwbuf *
lwbuf_alloc(vm_page_t m, struct lwbuf *);
void
lwbuf_free(struct lwbuf *lwb);
vm_page_t
lwbuf_page(struct lwbuf *lwb);
vm_offset_t
lwbuf_kva(struct lwbuf *lwb);
void
lwbuf_set_global(struct lwbuf *lwb);
DESCRIPTION
The lwbuf kernel functions are used for maintaining a lightweight refer‐
ence to and accessing an arbitrary vm_page_t.
lwbuf_alloc() returns a pointer to a lightweight buffer representing m.
The lwb argument is an lwbuf structure, used to avoid allocation of an
lwbuf on the x86_64 architecture. The lwb argument is unused on the i386
architecture.
lwbuf_free() frees all resources associated with the lightweight buffer
lwb.
lwbuf_page() and lwbuf_kva() return the associated vm_page_t or
vm_offset_t of the lightweight buffer lwb.
lwbuf_set_global() ensures that a vm_offset_t previously obtained through
lwbuf_kva will be valid on all processors without subsequent calls to
lwbuf_kva. It should not be used.
IMPLEMENTATION NOTES
The implementation of lwbuf is CPU-dependent. On i386, pages taken from
per-processor pools of kernel virtual address space (KVA) are used to map
arbitrary vm_page_t objects. On x86_64 such tricks are unnecessary, the
kernel maintains a direct map of KVA covering all physical memory.
Lightweight buffers are thread and cross-processor safe with a number of
limitations. Allocated buffers are not internally cached or reference
counted. Any consumer of lightweight buffers may elect to share allo‐
cated buffers or allow them to be used in other threads or on other pro‐
cessors, but care must be taken. Buffers must be externally refcounted
or in some other manner freed only after last use.
HISTORY
A lwbuf implementation first appeared in DragonFly 2.5.
AUTHORS
The lwbuf implementation and this manpage were written by Samuel J.
Greear.
BSD March 17, 2010 BSD