SoW-2020-0003: Trace Hit Counters
[lttng-tools.git] / src / bin / lttng-sessiond / buffer-registry.h
index 7a817ec70464786c44c6d12e5e663516c63cfce1..00be7b65ef66fac15862e7538e5a14d3fe9c37cc 100644 (file)
@@ -1,18 +1,8 @@
 /*
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
  *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License, version 2 only, as
- * published by the Free Software Foundation.
+ * SPDX-License-Identifier: GPL-2.0-only
  *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
 #ifndef LTTNG_BUFFER_REGISTRY_H
@@ -25,7 +15,7 @@
 #include <common/hashtable/hashtable.h>
 
 #include "consumer.h"
-#include "ust-ctl.h"
+#include "lttng-ust-ctl.h"
 #include "ust-registry.h"
 
 struct buffer_reg_stream {
@@ -36,6 +26,14 @@ struct buffer_reg_stream {
        } obj;
 };
 
+struct buffer_reg_map_counter {
+       struct cds_list_head lnode;
+       union {
+               /* Original object data that MUST be copied over. */
+               struct lttng_ust_object_data *ust;
+       } obj;
+};
+
 struct buffer_reg_channel {
        /* This key is the same as a tracing channel key. */
        uint32_t key;
@@ -59,6 +57,25 @@ struct buffer_reg_channel {
        } obj;
 };
 
+struct buffer_reg_map {
+       /* This key is the same as a tracing map key. */
+       uint32_t key;
+       /* Per cpu counter registry object of this map registry. */
+       struct cds_list_head counters;
+       /* Total number of stream in the list. */
+       uint64_t counter_count;
+       /* Used to ensure mutual exclusion to the counter's list. */
+       pthread_mutex_t counter_list_lock;
+       /* Node for hash table usage. */
+       struct lttng_ht_node_u64 node;
+       union {
+               /* Original object data that MUST be copied over. */
+               struct lttng_ust_object_data *ust;
+       } obj;
+
+       struct ustctl_daemon_counter *daemon_counter;
+};
+
 struct buffer_reg_session {
        /* Registry per domain. */
        union {
@@ -67,6 +84,8 @@ struct buffer_reg_session {
 
        /* Contains buffer registry channel indexed by tracing channel key. */
        struct lttng_ht *channels;
+       /* Contains buffer registry map indexed by tracing map key. */
+       struct lttng_ht *maps;
 };
 
 /*
@@ -140,6 +159,17 @@ void buffer_reg_channel_remove(struct buffer_reg_session *session,
 void buffer_reg_channel_destroy(struct buffer_reg_channel *regp,
                enum lttng_domain_type domain);
 
+/* Map */
+int buffer_reg_map_create(uint64_t key, struct buffer_reg_map **regp);
+void buffer_reg_map_add(struct buffer_reg_session *session,
+               struct buffer_reg_map *map);
+struct buffer_reg_map *buffer_reg_map_find(uint64_t key,
+               struct buffer_reg_uid *reg);
+void buffer_reg_map_remove(struct buffer_reg_session *session,
+               struct buffer_reg_map *regp);
+void buffer_reg_map_destroy(struct buffer_reg_map *regp,
+               enum lttng_domain_type domain);
+
 /* Stream */
 int buffer_reg_stream_create(struct buffer_reg_stream **regp);
 void buffer_reg_stream_add(struct buffer_reg_stream *stream,
@@ -147,7 +177,18 @@ void buffer_reg_stream_add(struct buffer_reg_stream *stream,
 void buffer_reg_stream_destroy(struct buffer_reg_stream *regp,
                enum lttng_domain_type domain);
 
+/* Map counter */
+int buffer_reg_map_counter_create(struct buffer_reg_map_counter **regp);
+void buffer_reg_map_counter_add(struct buffer_reg_map_counter *map_counter,
+               struct buffer_reg_map *map);
+void buffer_reg_map_counter_destroy(struct buffer_reg_map_counter *regp,
+               enum lttng_domain_type domain);
+
 /* Global registry. */
 void buffer_reg_destroy_registries(void);
 
+int buffer_reg_uid_consumer_channel_key(
+               struct cds_list_head *buffer_reg_uid_list,
+               uint64_t chan_key, uint64_t *consumer_chan_key);
+
 #endif /* LTTNG_BUFFER_REGISTRY_H */
This page took 0.026292 seconds and 5 git commands to generate.