Motr  M0
counter.h
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2015-2020 Seagate Technology LLC and/or its Affiliates
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * For any questions about this software or licensing,
18  * please email opensource@seagate.com or cortx-questions@seagate.com.
19  *
20  */
21 
22 
23 #pragma once
24 
25 #ifndef __MOTR_ADDB2_COUNTER_H__
26 #define __MOTR_ADDB2_COUNTER_H__
27 
34 #include "lib/types.h"
35 #include "lib/tlist.h"
36 #include "addb2/addb2.h"
37 
38 struct m0_tl;
39 
41  uint64_t cod_nr;
42  int64_t cod_min;
43  int64_t cod_max;
44  int64_t cod_sum;
45  uint64_t cod_ssq;
46  uint64_t cod_datum;
47 };
48 
49 enum {
51  sizeof(struct m0_addb2_counter_data) / sizeof(uint64_t)
52 };
53 
57 };
58 
59 void m0_addb2_counter_add(struct m0_addb2_counter *counter, uint64_t label,
60  int idx);
62 void m0_addb2_counter_mod(struct m0_addb2_counter *counter, int64_t val);
64  int64_t val, uint64_t datum);
65 
68  struct m0_tl *lc_list;
69 };
70 
72  struct m0_tl *list, uint64_t label, int idx);
74 
75 void m0_addb2_clock_add(struct m0_addb2_sensor *clock, uint64_t label, int idx);
76 void m0_addb2_clock_del(struct m0_addb2_sensor *clock);
77 
79 #define M0_ADDB2_TIMED_0(id, datum, ...) \
80  m0_time_t __start = m0_time_now(); \
81  m0_time_t __end; \
82  m0_time_t __duration; \
83  uint64_t __datum = (datum); \
84  uint64_t __id = (id); \
85  __VA_ARGS__; \
86  __end = m0_time_now(); \
87  __duration = (__end - __start) >> 10; \
88  if (__id != 0) \
89  M0_ADDB2_ADD(__id, __duration, __datum); \
90 
91 #define M0_ADDB2_TIMED(id, counter, datum, ...) \
92 do { \
93  struct m0_addb2_counter *__counter = (counter); \
94  M0_ADDB2_TIMED_0((id), (datum), __VA_ARGS__); \
95  if (__counter != NULL) \
96  m0_addb2_counter_mod_with(__counter, __duration, __datum); \
97 } while (0)
98 
100  uint64_t lc_id;
101  int lc_key;
102 };
103 
105  uint64_t id, uint64_t counter);
107  uint64_t val, uint64_t datum);
108 
110 #endif /* __MOTR_ADDB2_COUNTER_H__ */
111 
112 /*
113  * Local variables:
114  * c-indentation-style: "K&R"
115  * c-basic-offset: 8
116  * tab-width: 8
117  * fill-column: 80
118  * scroll-step: 1
119  * End:
120  */
121 /*
122  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
123  */
static struct m0_list list
Definition: list.c:144
Definition: idx_mock.c:52
void m0_addb2_counter_add(struct m0_addb2_counter *counter, uint64_t label, int idx)
Definition: counter.c:48
void m0_addb2_list_counter_del(struct m0_addb2_list_counter *counter)
Definition: counter.c:104
void m0_addb2_counter_mod_with(struct m0_addb2_counter *counter, int64_t val, uint64_t datum)
Definition: counter.c:71
void m0_addb2_clock_del(struct m0_addb2_sensor *clock)
Definition: counter.c:114
void m0_addb2_counter_del(struct m0_addb2_counter *counter)
Definition: counter.c:61
uint64_t cod_ssq
Definition: counter.h:45
struct m0_addb2_counter_data co_val
Definition: counter.h:56
static int counter
Definition: mutex.c:32
Definition: tlist.h:251
int m0_addb2_local_counter_init(struct m0_addb2_local_counter *lc, uint64_t id, uint64_t counter)
Definition: counter.c:119
void m0_addb2_clock_add(struct m0_addb2_sensor *clock, uint64_t label, int idx)
Definition: counter.c:109
void m0_addb2_list_counter_add(struct m0_addb2_list_counter *counter, struct m0_tl *list, uint64_t label, int idx)
Definition: counter.c:96
struct m0_addb2_sensor co_sensor
Definition: counter.h:55
struct m0_tl * lc_list
Definition: counter.h:68
void m0_addb2_counter_mod(struct m0_addb2_counter *counter, int64_t val)
Definition: counter.c:66
uint64_t cod_datum
Definition: counter.h:46
void m0_addb2_local_counter_mod(struct m0_addb2_local_counter *lc, uint64_t val, uint64_t datum)
Definition: counter.c:129
struct m0_addb2_sensor lc_sensor
Definition: counter.h:67