Implement lib counter
[lttng-modules.git] / include / counter / counter-types.h
1 /* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
2 *
3 * counter/counter-types.h
4 *
5 * LTTng Counters Types
6 *
7 * Copyright (C) 2020 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 */
9
10 #ifndef _LTTNG_COUNTER_TYPES_H
11 #define _LTTNG_COUNTER_TYPES_H
12
13 #include <linux/types.h>
14 #include <linux/percpu.h>
15 #include <counter/config.h>
16
17 struct lib_counter_dimension {
18 /*
19 * Max. number of indexable elements.
20 */
21 size_t max_nr_elem;
22 /*
23 * The stride for a dimension is the multiplication factor which
24 * should be applied to its index to take into account other
25 * dimensions nested inside.
26 */
27 size_t stride;
28 };
29
30 struct lib_counter_layout {
31 void *counters;
32 unsigned long *underflow_bitmap;
33 unsigned long *overflow_bitmap;
34 };
35
36 enum lib_counter_arithmetic {
37 LIB_COUNTER_ARITHMETIC_MODULAR,
38 LIB_COUNTER_ARITHMETIC_SATURATE,
39 };
40
41 struct lib_counter {
42 size_t nr_dimensions;
43 int64_t allocated_elem;
44 struct lib_counter_dimension *dimensions;
45 enum lib_counter_arithmetic arithmetic;
46 union {
47 struct {
48 int32_t max, min;
49 } limits_32_bit;
50 struct {
51 int64_t max, min;
52 } limits_64_bit;
53 } saturation;
54 union {
55 int8_t s8;
56 int16_t s16;
57 int32_t s32;
58 int64_t s64;
59 } global_sum_step; /* 0 if unused */
60 struct lib_counter_config config;
61
62 struct lib_counter_layout global_counters;
63 struct lib_counter_layout __percpu *percpu_counters;
64 };
65
66 #endif /* _LTTNG_COUNTER_TYPES_H */
This page took 0.030762 seconds and 4 git commands to generate.