stats: Add cmap key to clear the various stats.

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
This commit is contained in:
Christine Caulfield 2017-10-31 10:54:43 +00:00 committed by Jan Friesse
parent c733e9417e
commit d9dfd41e4e
11 changed files with 123 additions and 4 deletions

View File

@ -706,6 +706,38 @@ cs_error_t cs_ipcs_get_conn_stats(int service_id, uint32_t pid, void *conn_ptr,
return CS_OK;
}
void cs_ipcs_clear_stats()
{
struct cs_ipcs_conn_context *cnx;
struct ipcs_conn_stats ipcs_stats;
qb_ipcs_connection_t *c, *prev;
int service_id;
/* Global stats are easy */
memset(&global_stats, 0, sizeof(global_stats));
for (service_id = 0; service_id < SERVICES_COUNT_MAX; service_id++) {
if (!ipcs_mapper[service_id].inst) {
continue;
}
for (c = qb_ipcs_connection_first_get(ipcs_mapper[service_id].inst);
c;
prev = c, c = qb_ipcs_connection_next_get(ipcs_mapper[service_id].inst, prev), qb_ipcs_connection_unref(prev)) {
/* Get stats with 'clear_after_read' set */
qb_ipcs_connection_stats_get(c, &ipcs_stats.conn, QB_TRUE);
/* Our own stats */
cnx = qb_ipcs_context_get(c);
if (cnx == NULL) continue;
cnx->invalid_request = 0;
cnx->overload = 0;
cnx->sent = 0;
}
}
}
static enum qb_ipc_type cs_get_ipc_type (void)
{
char *str;

View File

@ -58,3 +58,4 @@ struct ipcs_conn_stats
cs_error_t cs_ipcs_get_conn_stats(int service_id, uint32_t pid, void *conn_ptr, struct ipcs_conn_stats *ipcs_stats);
void cs_ipcs_get_global_stats(struct ipcs_global_stats *ipcs_stats);
void cs_ipcs_clear_stats(void);

View File

@ -368,12 +368,40 @@ cs_error_t stats_map_get(const char *key_name,
return CS_OK;
}
#define STATS_CLEAR "stats.clear."
#define STATS_CLEAR_KNET "stats.clear.knet"
#define STATS_CLEAR_IPC "stats.clear.ipc"
#define STATS_CLEAR_TOTEM "stats.clear.totem"
#define STATS_CLEAR_ALL "stats.clear.all"
cs_error_t stats_map_set(const char *key_name,
const void *value,
size_t value_len,
icmap_value_types_t type)
{
return CS_ERR_NOT_SUPPORTED;
int cleared = 0;
if (strncmp(key_name, STATS_CLEAR_KNET, strlen(STATS_CLEAR_KNET)) == 0) {
totempg_stats_clear(TOTEMPG_STATS_CLEAR_TRANSPORT);
cleared = 1;
}
if (strncmp(key_name, STATS_CLEAR_IPC, strlen(STATS_CLEAR_IPC)) == 0) {
cs_ipcs_clear_stats();
cleared = 1;
}
if (strncmp(key_name, STATS_CLEAR_TOTEM, strlen(STATS_CLEAR_TOTEM)) == 0) {
totempg_stats_clear(TOTEMPG_STATS_CLEAR_TOTEM);
cleared = 1;
}
if (strncmp(key_name, STATS_CLEAR_ALL, strlen(STATS_CLEAR_ALL)) == 0) {
totempg_stats_clear(TOTEMPG_STATS_CLEAR_TRANSPORT | TOTEMPG_STATS_CLEAR_TOTEM);
cs_ipcs_clear_stats();
cleared = 1;
}
if (!cleared) {
return CS_ERR_NOT_SUPPORTED;
}
return CS_OK;
}
cs_error_t stats_map_adjust_int(const char *key_name, int32_t step)
@ -388,8 +416,12 @@ cs_error_t stats_map_delete(const char *key_name)
int stats_map_is_key_ro(const char *key_name)
{
/* It's all read-only */
return 1;
/* It's all read-only apart from the 'clear' destinations */
if (strncmp(key_name, STATS_CLEAR, strlen(STATS_CLEAR)) == 0) {
return 0;
} else {
return 1;
}
}
icmap_iter_t stats_map_iter_init(const char *prefix)

View File

@ -1289,6 +1289,14 @@ int totemknet_reconfigure (
}
void totemknet_stats_clear (
void *knet_context)
{
struct totemknet_instance *instance = (struct totemknet_instance *)knet_context;
(void) knet_handle_clear_stats(instance->knet_handle, KNET_CLEARSTATS_HANDLE_AND_LINK);
}
/* For the stats module */
int totemknet_link_get_status (
knet_node_id_t node, uint8_t link_no,

View File

@ -142,4 +142,7 @@ extern int totemknet_reconfigure (
void *knet_context,
struct totem_config *totem_config);
extern void totemknet_stats_clear (
void *knet_context);
#endif /* TOTEMKNET_H_DEFINED */

View File

@ -154,6 +154,9 @@ struct transport {
int (*reconfigure) (
void *net_context,
struct totem_config *totem_config);
void (*stats_clear) (
void *net_context);
};
struct transport transport_entries[] = {
@ -222,7 +225,8 @@ struct transport transport_entries[] = {
.recv_mcast_empty = totemknet_recv_mcast_empty,
.member_add = totemknet_member_add,
.member_remove = totemknet_member_remove,
.reconfigure = totemknet_reconfigure
.reconfigure = totemknet_reconfigure,
.stats_clear = totemknet_stats_clear
}
};
@ -565,3 +569,14 @@ int totemnet_reconfigure (
return (res);
}
void totemnet_stats_clear (
void *net_context)
{
struct totemnet_instance *instance = (struct totemnet_instance *)net_context;
if (instance->transport->stats_clear) {
instance->transport->stats_clear (
instance->transport_context);
}
}

View File

@ -118,6 +118,8 @@ extern int totemnet_net_mtu_adjust (void *net_context, struct totem_config *tote
extern int totemnet_reconfigure (void *net_context, struct totem_config *totem_config);
extern void totemnet_stats_clear (void *net_context);
extern const char *totemnet_iface_print (void *net_context);
extern int totemnet_ifaces_get (

View File

@ -1526,6 +1526,15 @@ extern int totempg_reconfigure (void)
return totemsrp_reconfigure (totemsrp_context, totempg_totem_config);
}
extern void totempg_stats_clear (int flags)
{
if (flags & TOTEMPG_STATS_CLEAR_TOTEM) {
totempg_stats.msg_reserved = 0;
totempg_stats.msg_queue_avail = 0;
}
return totemsrp_stats_clear (totemsrp_context, flags);
}
void totempg_threaded_mode_enable (void)
{
totempg_threaded_mode = 1;

View File

@ -4788,3 +4788,13 @@ int totemsrp_reconfigure (void *context, struct totem_config *totem_config)
res = totemnet_reconfigure (instance->totemnet_context, totem_config);
return (res);
}
void totemsrp_stats_clear (void *context, int flags)
{
struct totemsrp_instance *instance = (struct totemsrp_instance *)context;
memset(&instance->stats, 0, sizeof(totemsrp_stats_t));
if (flags & TOTEMPG_STATS_CLEAR_TRANSPORT) {
totemnet_stats_clear (instance->totemnet_context);
}
}

View File

@ -150,4 +150,7 @@ int totemsrp_reconfigure (
void *context,
struct totem_config *totem_config);
void totemsrp_stats_clear (
void *srp_context, int flags);
#endif /* TOTEMSRP_H_DEFINED */

View File

@ -109,5 +109,9 @@ void stats_knet_add_member(knet_node_id_t nodeid, uint8_t link);
void stats_knet_del_member(knet_node_id_t nodeid, uint8_t link);
#define TOTEMPG_STATS_CLEAR_TOTEM 1
#define TOTEMPG_STATS_CLEAR_TRANSPORT 2
extern void totempg_stats_clear (int flags);
#endif /* TOTEMSTATS_H_DEFINED */