[lttng-dev] [Patch LTTng-tools 4/4] Dump a named metadata only once per session
Mathieu Desnoyers
mathieu.desnoyers at efficios.com
Thu Jan 30 20:52:05 EST 2014
----- Original Message -----
> From: "Geneviève Bastien" <gbastien+lttng at versatic.net>
> To: lttng-dev at lists.lttng.org
> Sent: Friday, January 24, 2014 3:07:25 PM
> Subject: [lttng-dev] [Patch LTTng-tools 4/4] Dump a named metadata only once per session
>
> Named metadata can be used more than once in a single tracepoint, or many
(global types ?)
This is adding a linked-list (O(n)) on something that can be called
quite often. It will not scale if there are many enums in a process.
This should be changed into a hash table.
> tracepoints can use it. It must be statedumped only once in a given session.
>
> Signed-off-by: Geneviève Bastien <gbastien+lttng at versatic.net>
> ---
> src/bin/lttng-sessiond/ust-metadata.c | 39
> +++++++++++++++++++++++++++++++++++
> src/bin/lttng-sessiond/ust-registry.c | 11 ++++++++++
> src/bin/lttng-sessiond/ust-registry.h | 8 +++++++
> 3 files changed, 58 insertions(+)
>
> diff --git a/src/bin/lttng-sessiond/ust-metadata.c
> b/src/bin/lttng-sessiond/ust-metadata.c
> index 87d21fc..8b904a8 100644
> --- a/src/bin/lttng-sessiond/ust-metadata.c
> +++ b/src/bin/lttng-sessiond/ust-metadata.c
> @@ -316,6 +316,27 @@ int _lttng_one_metadata_statedump(struct
> ust_registry_session *session,
> {
> int ret = 0, i;
>
> + /* Check if the metadata was already dumped */
> + if (session->dumped_named_metadata != 0) {
> + struct ust_dumped_metadata *dumped = session->dumped_named_metadata;
> + char *metadata_name;
missing newline.
Thanks,
Mathieu
> + switch (metadata->mtype) {
> + case ustctl_mtype_enum:
> + metadata_name = metadata->u.ctf_enum.name;
> + break;
> + default:
> + return -EINVAL;
> + }
> + do {
> + if (dumped->mtype == metadata->mtype) {
> + if (strcmp(dumped->name, metadata_name) == 0) {
> + return 0;
> + }
> + }
> + dumped = dumped->next;
> + } while (dumped);
> + }
> +
> switch (metadata->mtype) {
> case ustctl_mtype_enum:
> {
> @@ -362,6 +383,24 @@ int _lttng_one_metadata_statedump(struct
> ust_registry_session *session,
> return -EINVAL;
> }
>
> + /* Flag this metadata as dumped */
> + struct ust_dumped_metadata *dumped;
> + dumped = zmalloc(sizeof(*dumped));
> + if (!dumped) {
> + ret = -ENOMEM;
> + return ret;
> + }
> + dumped->mtype = metadata->mtype;
> + switch (metadata->mtype) {
> + case ustctl_mtype_enum:
> + strncpy(dumped->name, metadata->u.ctf_enum.name, LTTNG_UST_SYM_NAME_LEN);
> + break;
> + default:
> + return -EINVAL;
> + }
> + dumped->next = session->dumped_named_metadata;
> + session->dumped_named_metadata = dumped;
> +
> return ret;
> }
>
> diff --git a/src/bin/lttng-sessiond/ust-registry.c
> b/src/bin/lttng-sessiond/ust-registry.c
> index 00e1c26..25cd31d 100644
> --- a/src/bin/lttng-sessiond/ust-registry.c
> +++ b/src/bin/lttng-sessiond/ust-registry.c
> @@ -568,6 +568,7 @@ int ust_registry_session_init(struct ust_registry_session
> **sessionp,
> session->uint64_t_alignment = uint64_t_alignment;
> session->long_alignment = long_alignment;
> session->byte_order = byte_order;
> + session->dumped_named_metadata = 0;
>
> session->channels = lttng_ht_new(0, LTTNG_HT_TYPE_U64);
> if (!session->channels) {
> @@ -630,4 +631,14 @@ void ust_registry_session_destroy(struct
> ust_registry_session *reg)
> }
>
> free(reg->metadata);
> +
> + /* Free all dumped metadata */
> + if (reg->dumped_named_metadata) {
> + struct ust_dumped_metadata *dumped;
> + do {
> + dumped = reg->dumped_named_metadata;
> + reg->dumped_named_metadata = dumped->next;
> + free(dumped);
> + } while (reg->dumped_named_metadata);
> + }
> }
> diff --git a/src/bin/lttng-sessiond/ust-registry.h
> b/src/bin/lttng-sessiond/ust-registry.h
> index 183db0f..a6c7e6e 100644
> --- a/src/bin/lttng-sessiond/ust-registry.h
> +++ b/src/bin/lttng-sessiond/ust-registry.h
> @@ -31,6 +31,12 @@
>
> struct ust_app;
>
> +struct ust_dumped_metadata {
> + enum ustctl_metadata_types mtype;
> + char name[LTTNG_UST_SYM_NAME_LEN];
> + struct ust_dumped_metadata *next;
> +};
> +
> struct ust_registry_session {
> /*
> * With multiple writers and readers, use this lock to access the registry.
> @@ -75,6 +81,8 @@ struct ust_registry_session {
> * deletes its sessions.
> */
> unsigned int metadata_closed;
> + /* The list of named metadata already dumped */
> + struct ust_dumped_metadata *dumped_named_metadata;
> };
>
> struct ust_registry_channel {
> --
> 1.8.5.3
>
>
> _______________________________________________
> lttng-dev mailing list
> lttng-dev at lists.lttng.org
> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
>
--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
More information about the lttng-dev
mailing list