memzone

package
v0.0.19 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 20, 2023 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package memzone wraps RTE memzone library.

The goal of the memzone allocator is to reserve contiguous portions of physical memory. These zones are identified by a name.

The memzone descriptors are shared by all partitions and are located in a known place of physical memory. This zone is accessed using rte_eal_get_configuration(). The lookup (by name) of a memory zone can be done in any partition and returns the same physical address.

Please refer to DPDK Programmer's Guide for reference and caveats.

Index

Constants

View Source
const (
	// Allow alternative page size to be used if the requested page
	// size is unavailable. If this flag is not set, the function will
	// return error on an unavailable size request.
	PageSizeHintOnly = C.RTE_MEMZONE_SIZE_HINT_ONLY
)

Variables

This section is empty.

Functions

func Walk

func Walk(fn func(*Memzone))

Walk list of all memzones.

Types

type Memzone

type Memzone C.struct_rte_memzone

Memzone is a contiguous portion of physical memory. These zones are identified by a name.

func Lookup

func Lookup(name string) (*Memzone, error)

Lookup searches a memzone from its name.

func Reserve

func Reserve(name string, size uintptr, opts ...Option) (*Memzone, error)

Reserve a portion of physical memory.

This function reserves some memory and returns a pointer to a correctly filled memzone descriptor. If the allocation cannot be done, return NULL.

Note: Reserving memzones with size set to 0 will only attempt to allocate memzones from memory that is already available. It will not trigger any new allocations. : When reserving memzones with size set to 0, it is preferable to also set a valid socket_id. Setting socket_id to SOCKET_ID_ANY is supported, but will likely not yield expected results. Specifically, the resulting memzone may not necessarily be the biggest memzone available, but rather biggest memzone available on socket id corresponding to an lcore from which reservation was called.

func (*Memzone) Addr

func (mz *Memzone) Addr() unsafe.Pointer

Addr returns start virtual address of the memzone.

func (*Memzone) Bytes

func (mz *Memzone) Bytes() []byte

Bytes returns memzone in a form of slice of bytes.

func (*Memzone) Free

func (mz *Memzone) Free() error

Free a memzone. EINVAL (invalid parameter) may be returned.

func (*Memzone) HugePageSz

func (mz *Memzone) HugePageSz() uint64

HugePageSz returns the page size of underlying memory.

func (*Memzone) Len

func (mz *Memzone) Len() uintptr

Len returns length of the memzone.

func (*Memzone) Name

func (mz *Memzone) Name() string

Name returns name of the memzone.

func (*Memzone) SocketID

func (mz *Memzone) SocketID() int

SocketID returns NUMA socket ID of the memzone.

type Option

type Option struct {
	// contains filtered or unexported fields
}

Option may be specified during Reserve for a new memzone.

func OptAligned

func OptAligned(align uint) Option

OptAligned requests alignment for resulting memzone. Must be a power of 2.

func OptBounded

func OptBounded(bound uint) Option

OptBounded requests boundary for resulting memzone. Must be a power of 2 or zero. Zero value implies no boundary condition.

func OptFlag

func OptFlag(flag uint) Option

OptFlag add one of permitted flags for the memzone creation.

func OptSocket

func OptSocket(socket uint) Option

OptSocket specifies the socket id where the memzone would be created.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL