875cc960b329a015de2af81962a4c4a6fba2563a
1 #ifndef HEALTH_INTERNAL_H
2 #define HEALTH_INTERNAL_H
5 * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
6 * Copyright (C) 2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 * SPDX-License-Identifier: GPL-2.0-only
12 #include <common/compat/time.h>
14 #include <urcu/tls-compat.h>
15 #include <urcu/uatomic.h>
16 #include <urcu/list.h>
17 #include <lttng/health.h>
18 #include <common/macros.h>
25 * These are the value added to the current state depending of the position in
26 * the thread where is either waiting on a poll() or running in the code.
28 #define HEALTH_POLL_VALUE (1UL << 0)
29 #define HEALTH_CODE_VALUE (1UL << 1)
31 #define HEALTH_IS_IN_POLL(x) ((x) & HEALTH_POLL_VALUE)
36 HEALTH_ERROR
= (1U << 0),
41 * last counter and last_time are only read and updated by the health_check
42 * thread (single updater).
45 struct timespec last_time
;
48 * current and flags are updated by multiple threads concurrently.
50 unsigned long current
; /* progress counter, updated atomically */
51 enum health_flags flags
; /* other flags, updated atomically */
52 int type
; /* Indicates the nature of the thread. */
53 /* Node of the global TLS state list. */
54 struct cds_list_head node
;
61 struct health_comm_msg
{
62 uint32_t cmd
; /* enum health_cmd */
65 struct health_comm_reply
{
66 uint64_t ret_code
; /* bitmask of threads in bad health */
69 /* Declare TLS health state. */
70 extern DECLARE_URCU_TLS(struct health_state
, health_state
);
73 * Update current counter by 1 to indicate that the thread entered or left a
74 * blocking state caused by a poll(). If the counter's value is not an even
75 * number (meaning a code execution flow), an LTTNG_ASSERT() is raised.
77 static inline void health_poll_entry(void)
79 /* Code MUST be in code execution state which is an even number. */
80 LTTNG_ASSERT(!(uatomic_read(&URCU_TLS(health_state
).current
)
81 & HEALTH_POLL_VALUE
));
83 uatomic_add(&URCU_TLS(health_state
).current
, HEALTH_POLL_VALUE
);
87 * Update current counter by 1 indicating the exit of a poll or blocking call.
88 * If the counter's value is not an odd number (a poll execution), an LTTNG_ASSERT()
91 static inline void health_poll_exit(void)
93 /* Code MUST be in poll execution state which is an odd number. */
94 LTTNG_ASSERT(uatomic_read(&URCU_TLS(health_state
).current
)
97 uatomic_add(&URCU_TLS(health_state
).current
, HEALTH_POLL_VALUE
);
101 * Update current counter by 2 indicates progress in execution of a
104 static inline void health_code_update(void)
106 uatomic_add(&URCU_TLS(health_state
).current
, HEALTH_CODE_VALUE
);
110 * Set health "error" flag.
112 static inline void health_error(void)
114 uatomic_or(&URCU_TLS(health_state
).flags
, HEALTH_ERROR
);
117 struct health_app
*health_app_create(int nr_types
);
118 void health_app_destroy(struct health_app
*ha
);
119 int health_check_state(struct health_app
*ha
, int type
);
120 void health_register(struct health_app
*ha
, int type
);
121 void health_unregister(struct health_app
*ha
);
127 #endif /* HEALTH_INTERNAL_H */
This page took 0.032941 seconds and 4 git commands to generate.