Remove dependency on kallsyms for splice_to_pipe (kernel 4.2+)
[lttng-modules.git] / lttng-tp-mempool.h
1 /* SPDX-License-Identifier: (GPL-2.0 or LGPL-2.1)
2 *
3 * lttng-tp-mempool.h
4 *
5 * Copyright (C) 2018 Julien Desfossez <jdesfossez@efficios.com>
6 */
7
8 #ifndef LTTNG_TP_MEMPOOL_H
9 #define LTTNG_TP_MEMPOOL_H
10
11 #include <linux/percpu.h>
12
13 #define LTTNG_TP_MEMPOOL_NR_BUF_PER_CPU 4
14 #define LTTNG_TP_MEMPOOL_BUF_SIZE 4096
15
16 /*
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
19 * per-cpu.
20 *
21 * Returns 0 on success, a negative value on error.
22 */
23 int lttng_tp_mempool_init(void);
24
25 /*
26 * Destroy the pool and free all the memory allocated.
27 */
28 void lttng_tp_mempool_destroy(void);
29
30 /*
31 * Ask for a buffer on the current cpu.
32 *
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.
36 *
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.
40 *
41 * Return a pointer to a buffer on success, NULL on error.
42 */
43 void *lttng_tp_mempool_alloc(size_t size);
44
45 /*
46 * Release the memory reserved. Same concurrency limitations as the allocation.
47 */
48 void lttng_tp_mempool_free(void *ptr);
49
50 #endif /* LTTNG_TP_MEMPOOL_H */
This page took 0.031497 seconds and 4 git commands to generate.