Move internal APIs to internal header
[lttng-modules.git] / src / lttng-counter-client-percpu-32-modular.c
CommitLineData
a101fa10
MD
1/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
2 *
3 * lttng-counter-client-percpu-32-modular.c
4 *
5 * LTTng lib counter client. Per-cpu 32-bit counters in overflow
6 * arithmetic.
7 *
8 * Copyright (C) 2020 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
9 */
10
11#include <linux/module.h>
12#include <lttng/tracer.h>
e8c0bbd3
MD
13#include <lttng/events.h>
14#include <lttng/events-internal.h>
a101fa10
MD
15#include <counter/counter.h>
16#include <counter/counter-api.h>
17
18static const struct lib_counter_config client_config = {
19 .alloc = COUNTER_ALLOC_PER_CPU,
20 .sync = COUNTER_SYNC_PER_CPU,
21 .arithmetic = COUNTER_ARITHMETIC_MODULAR,
22 .counter_size = COUNTER_SIZE_32_BIT,
23};
24
25static struct lib_counter *counter_create(size_t nr_dimensions,
26 const size_t *max_nr_elem,
27 int64_t global_sum_step)
28{
29 return lttng_counter_create(&client_config, nr_dimensions, max_nr_elem,
30 global_sum_step);
31}
32
33static void counter_destroy(struct lib_counter *counter)
34{
35 return lttng_counter_destroy(counter);
36}
37
38static int counter_add(struct lib_counter *counter, const size_t *dimension_indexes, int64_t v)
39{
40 return lttng_counter_add(&client_config, counter, dimension_indexes, v);
41}
42
43static int counter_read(struct lib_counter *counter, const size_t *dimension_indexes, int cpu,
44 int64_t *value, bool *overflow, bool *underflow)
45{
46 return lttng_counter_read(&client_config, counter, dimension_indexes, cpu, value,
47 overflow, underflow);
48}
49
50static int counter_aggregate(struct lib_counter *counter, const size_t *dimension_indexes,
51 int64_t *value, bool *overflow, bool *underflow)
52{
53 return lttng_counter_aggregate(&client_config, counter, dimension_indexes, value,
54 overflow, underflow);
55}
56
57static int counter_clear(struct lib_counter *counter, const size_t *dimension_indexes)
58{
59 return lttng_counter_clear(&client_config, counter, dimension_indexes);
60}
61
62static struct lttng_counter_transport lttng_counter_transport = {
63 .name = "counter-per-cpu-32-modular",
64 .owner = THIS_MODULE,
65 .ops = {
66 .counter_create = counter_create,
67 .counter_destroy = counter_destroy,
68 .counter_add = counter_add,
69 .counter_read = counter_read,
70 .counter_aggregate = counter_aggregate,
71 .counter_clear = counter_clear,
72 },
73};
74
75static int __init lttng_counter_client_init(void)
76{
77 /*
78 * This vmalloc sync all also takes care of the lib counter
79 * vmalloc'd module pages when it is built as a module into LTTng.
80 */
81 wrapper_vmalloc_sync_mappings();
82 lttng_counter_transport_register(&lttng_counter_transport);
83 return 0;
84}
85
86module_init(lttng_counter_client_init);
87
88static void __exit lttng_counter_client_exit(void)
89{
90 lttng_counter_transport_unregister(&lttng_counter_transport);
91}
92
93module_exit(lttng_counter_client_exit);
94
95MODULE_LICENSE("GPL and additional rights");
96MODULE_AUTHOR("Mathieu Desnoyers <mathieu.desnoyers@efficios.com>");
97MODULE_DESCRIPTION("LTTng counter per-cpu 32-bit overflow client");
98MODULE_VERSION(__stringify(LTTNG_MODULES_MAJOR_VERSION) "."
99 __stringify(LTTNG_MODULES_MINOR_VERSION) "."
100 __stringify(LTTNG_MODULES_PATCHLEVEL_VERSION)
101 LTTNG_MODULES_EXTRAVERSION);
This page took 0.029524 seconds and 4 git commands to generate.