1 /* SPDX-License-Identifier: (GPL-2.0 or LGPL-2.1)
5 * Copyright (C) 2018 Julien Desfossez <jdesfossez@efficios.com>
8 #ifndef LTTNG_TP_MEMPOOL_H
9 #define LTTNG_TP_MEMPOOL_H
11 #include <linux/percpu.h>
13 #define LTTNG_TP_MEMPOOL_NR_BUF_PER_CPU 4
14 #define LTTNG_TP_MEMPOOL_BUF_SIZE 4096
17 * Initialize the pool, only performed once. The pool is a set of
18 * LTTNG_TP_MEMPOOL_NR_BUF_PER_CPU buffers of size LTTNG_TP_MEMPOOL_BUF_SIZE
21 * Returns 0 on success, a negative value on error.
23 int lttng_tp_mempool_init(void);
26 * Destroy the pool and free all the memory allocated.
28 void lttng_tp_mempool_destroy(void);
31 * Ask for a buffer on the current cpu.
33 * The pool is per-cpu, but there is no exclusive access guarantee on the
34 * per-cpu free-list, the caller needs to ensure it cannot get preempted or
35 * interrupted while performing the allocation.
37 * The maximum size that can be allocated is LTTNG_TP_MEMPOOL_BUF_SIZE, and the
38 * maximum number of buffers allocated simultaneously on the same CPU is
39 * LTTNG_TP_MEMPOOL_NR_BUF_PER_CPU.
41 * Return a pointer to a buffer on success, NULL on error.
43 void *lttng_tp_mempool_alloc(size_t size
);
46 * Release the memory reserved. Same concurrency limitations as the allocation.
48 void lttng_tp_mempool_free(void *ptr
);
50 #endif /* LTTNG_TP_MEMPOOL_H */
This page took 0.0304 seconds and 4 git commands to generate.