From: "Van Haaren, Harry" <harry.van.haaren@intel.com>
To: "Horton, Remy" <remy.horton@intel.com>, "dev@dpdk.org" <dev@dpdk.org>
Cc: Thomas Monjalon <thomas.monjalon@6wind.com>
Subject: Re: [dpdk-dev] [PATCH v7 1/6] lib: add information metrics library
Date: Tue, 17 Jan 2017 11:01:20 +0000 [thread overview]
Message-ID: <E923DB57A917B54B9182A2E928D00FA6129E3B53@IRSMSX102.ger.corp.intel.com> (raw)
In-Reply-To: <1484583573-30163-2-git-send-email-remy.horton@intel.com>
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Remy Horton
> This patch adds a new information metric library that allows other
> modules to register named metrics and update their values. It is
> intended to be independent of ethdev, rather than mixing ethdev
> and non-ethdev information in xstats.
>
> Signed-off-by: Remy Horton <remy.horton@intel.com>
Comments inline below.
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 9645c9b..4a19497 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -596,6 +596,11 @@ F: lib/librte_jobstats/
> F: examples/l2fwd-jobstats/
> F: doc/guides/sample_app_ug/l2_forward_job_stats.rst
>
> +Metrics
> +M: Remy Horton <remy.horton@intel.com>
> +F: lib/librte_metrics/
> +F: doc/guides/sample_app_ug/keep_alive.rst
Copy paste error, Keep alive sample app guide should not be here. There is no sample app / guide for usage of the metrics library in this patchset as it is.
> +++ b/lib/librte_metrics/rte_metrics.c
> @@ -0,0 +1,310 @@
> +/*-
> + * BSD LICENSE
> + *
> + * Copyright(c) 2016 Intel Corporation. All rights reserved.
> + * All rights reserved.
Update to 2016-2017
> +/**
> + * Internal stats metadata and value entry.
> + *
> + * @internal
> + * @param name
> + * Name of metric
> + * @param value
> + * Current value for metric
> + * @param idx_next_set
> + * Index of next root element (zero for none)
> + * @param idx_next_metric
> + * Index of next metric in set (zero for none)
> + *
> + * Only the root of each set needs idx_next_set but since it has to be
> + * assumed that number of sets could equal total number of metrics,
> + * having a separate set metadata table doesn't save any memory.
> + */
> +struct rte_metrics_meta_s {
> + char name[RTE_METRICS_MAX_NAME_LEN];
> + uint64_t value[RTE_MAX_ETHPORTS];
> + uint64_t nonport_value;
> + uint16_t idx_next_set;
> + uint16_t idx_next_stat;
> +};
Nit: why the _s in rte_metrics_meta_s? Is there a reason why struct rte_metrics_meta { is not suitable? Same question for rte_metrics_data_s.
> +void
> +rte_metrics_init(void)
> +{
> + struct rte_metrics_data_s *stats;
> + const struct rte_memzone *memzone;
> +
> + if (rte_eal_process_type() != RTE_PROC_PRIMARY)
> + return;
> +
> + memzone = rte_memzone_lookup(RTE_METRICS_MEMZONE_NAME);
> + if (memzone != NULL)
> + return;
> + memzone = rte_memzone_reserve(RTE_METRICS_MEMZONE_NAME,
> + sizeof(struct rte_metrics_data_s), rte_socket_id(), 0);
In my opinion, passing socket_id to rte_metrics_init() would be a better API, than relying on the metrics initialization core to be on the correct socket.
> + if (memzone == NULL)
> + rte_exit(EXIT_FAILURE, "Unable to allocate stats memzone\n");
> + stats = memzone->addr;
> + memset(stats, 0, sizeof(struct rte_metrics_data_s));
> + rte_spinlock_init(&stats->lock);
Should this spinlock be initialized before the creation of the memzone? Creating the memzone first, and later initializing the locking-structure for it feels racey to me. The lock should probably be taken and unlocked again after init and memset.
> +}
> +
> +int
> +rte_metrics_reg_metric(const char *name)
> +{
Nit: would rte_metrics_reg_name() be a better function name?
> + const char * const list_names[] = {name};
> +
> + return rte_metrics_reg_metrics(list_names, 1);
> +}
> +
> +int
> +rte_metrics_reg_metrics(const char * const *names, uint16_t cnt_names)
> +{
Nit: would rte_metrics_reg_names() be a better function name?
> +
> +int
> +rte_metrics_update_metric(int port_id, uint16_t key, const uint64_t value)
> +{
Would rte_metrics_update_single() be a better function name? I presume updating a single metric at a time is exception case, and the (see below) more generic rte_metrics_update() would be more commonly used.
> + return rte_metrics_update_metrics(port_id, key, &value, 1);
> +}
> +
> +int
> +rte_metrics_update_metrics(int port_id,
> + uint16_t key,
> + const uint64_t *values,
> + uint32_t count)
Would rte_metrics_update() be a better function name?
> +{
> + struct rte_metrics_meta_s *entry;
> + struct rte_metrics_data_s *stats;
> + const struct rte_memzone *memzone;
> + uint16_t idx_metric;
> + uint16_t idx_value;
> + uint16_t cnt_setsize;
> +
> + if (port_id != RTE_METRICS_GLOBAL &&
> + (port_id < 0 || port_id > RTE_MAX_ETHPORTS))
> + return -EINVAL;
> +
> + rte_metrics_init();
See above comments on rte_metrics_init() taking a socket_id parameter. Here any core could call update_metrics(), and if the library was not yet initialized, the memory for metrics would end up on the socket of this core. This should be avoided by
A) adding socket_id parameter to the metrics_init() function
B) Demanding that metrics_init() is called by the application before any core uses update_metrics()
> + memzone = rte_memzone_lookup(RTE_METRICS_MEMZONE_NAME);
> + if (memzone == NULL)
> + return -EIO;
> + stats = memzone->addr;
> +
> + rte_spinlock_lock(&stats->lock);
> + idx_metric = key;
> + cnt_setsize = 1;
> + while (idx_metric < stats->cnt_stats) {
> + entry = &stats->metadata[idx_metric];
> + if (entry->idx_next_stat == 0)
> + break;
> + cnt_setsize++;
> + idx_metric++;
> + }
> + /* Check update does not cross set border */
> + if (count > cnt_setsize) {
> + rte_spinlock_unlock(&stats->lock);
> + return -ERANGE;
> + }
What is a "set border"? I think this ensures that one set of metrics cannot overwrite the index's of another metrics set - correct?
> +
> + if (port_id == RTE_METRICS_GLOBAL)
> + for (idx_value = 0; idx_value < count; idx_value++) {
> + idx_metric = key + idx_value;
> + stats->metadata[idx_metric].nonport_value =
> + values[idx_value];
> + }
> + else
> + for (idx_value = 0; idx_value < count; idx_value++) {
> + idx_metric = key + idx_value;
> + stats->metadata[idx_metric].value[port_id] =
> + values[idx_value];
> + }
> + rte_spinlock_unlock(&stats->lock);
> + return 0;
> +}
<snip>
> diff --git a/lib/librte_metrics/rte_metrics.h b/lib/librte_metrics/rte_metrics.h
> new file mode 100644
> index 0000000..fd82af9
> --- /dev/null
> +++ b/lib/librte_metrics/rte_metrics.h
> @@ -0,0 +1,223 @@
> +/*-
> + * BSD LICENSE
> + *
> + * Copyright(c) 2016 Intel Corporation. All rights reserved.
> + * All rights reserved.
Add -2017
> +
> +
> +/**
> + * Initializes metric module. This only has to be explicitly called if you
> + * intend to use rte_metrics_reg_metric() or rte_metrics_reg_metrics() from a
> + * secondary process. This function must be called from a primary process.
> + */
> +void rte_metrics_init(void);
As noted in the C function above:
- accept a socket-id
- demand an application calls it if it will use the metrics library.
<snip>
next prev parent reply other threads:[~2017-01-17 11:01 UTC|newest]
Thread overview: 115+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-24 14:58 [dpdk-dev] [RFC PATCH v1] rte: add bit-rate metrics to xstats Remy Horton
2016-08-26 13:28 ` Pattan, Reshma
2016-08-29 10:01 ` Pattan, Reshma
2016-08-29 11:19 ` Remy Horton
2016-10-28 1:04 ` [dpdk-dev] [PATCH v2 0/3] expanded statistic reporting Remy Horton
2016-10-28 1:04 ` [dpdk-dev] [RFC PATCH v2 1/3] lib: add information metrics library Remy Horton
2016-10-28 1:04 ` [dpdk-dev] [RFC PATCH v2 2/3] lib: add bitrate statistics library Remy Horton
2016-10-28 1:12 ` Stephen Hemminger
2016-10-28 7:48 ` Remy Horton
2016-10-28 7:39 ` Morten Brørup
2016-11-01 1:53 ` Remy Horton
2016-10-28 1:04 ` [dpdk-dev] [RFC PATCH v2 3/3] app/test-pmd: add support for bitrate statistics Remy Horton
2016-11-04 3:36 ` [dpdk-dev] [PATCH v3 0/3] Expanded statistics reporting Remy Horton
2016-11-04 3:36 ` [dpdk-dev] [PATCH v3 1/3] lib: add information metrics library Remy Horton
2016-11-04 16:42 ` Pattan, Reshma
2016-11-07 15:25 ` Pattan, Reshma
2016-11-08 3:19 ` Remy Horton
2016-11-04 3:36 ` [dpdk-dev] [PATCH v3 2/3] lib: add bitrate statistics library Remy Horton
2016-11-04 3:36 ` [dpdk-dev] [PATCH v3 3/3] app/test-pmd: add support for bitrate statistics Remy Horton
2016-11-15 7:15 ` [dpdk-dev] [PATCH v4 0/3] Expanded statistics reporting Remy Horton
2016-11-15 7:15 ` [dpdk-dev] [PATCH v4 1/3] lib: add information metrics library Remy Horton
2016-11-15 7:15 ` [dpdk-dev] [PATCH v4 2/3] lib: add bitrate statistics library Remy Horton
2016-11-15 15:17 ` Pattan, Reshma
2016-11-15 7:15 ` [dpdk-dev] [PATCH v4 3/3] app/test-pmd: add support for bitrate statistics Remy Horton
2016-11-18 8:00 ` [dpdk-dev] [PATCH v5 0/4] Expanded statistics reporting Remy Horton
2016-11-18 8:00 ` [dpdk-dev] [PATCH v5 1/4] lib: add information metrics library Remy Horton
2016-11-18 8:00 ` [dpdk-dev] [PATCH v5 2/4] lib: add bitrate statistics library Remy Horton
2016-11-18 8:00 ` [dpdk-dev] [PATCH v5 3/4] app/test-pmd: add support for bitrate statistics Remy Horton
2016-11-18 8:00 ` [dpdk-dev] [PATCH v5 4/4] latencystats: added new library for latency stats Remy Horton
2017-01-11 16:03 ` [dpdk-dev] [PATCH v6 0/4] Expanded statistics reporting Remy Horton
2017-01-11 16:03 ` [dpdk-dev] [PATCH v6 1/4] lib: add information metrics library Remy Horton
2017-01-12 13:22 ` Thomas Monjalon
2017-01-12 15:30 ` Remy Horton
2017-01-12 19:05 ` Thomas Monjalon
2017-01-16 10:27 ` Remy Horton
2017-01-11 16:03 ` [dpdk-dev] [PATCH v6 2/4] lib: add bitrate statistics library Remy Horton
2017-01-11 16:15 ` Stephen Hemminger
2017-01-16 13:18 ` Remy Horton
2017-01-11 16:03 ` [dpdk-dev] [PATCH v6 3/4] app/test-pmd: add support for bitrate statistics Remy Horton
2017-01-12 13:32 ` Thomas Monjalon
2017-01-11 16:03 ` [dpdk-dev] [PATCH v6 4/4] latencystats: added new library for latency stats Remy Horton
2017-01-12 13:41 ` Thomas Monjalon
2017-01-12 14:44 ` Remy Horton
2017-01-13 9:45 ` Mcnamara, John
2017-01-13 9:53 ` Thomas Monjalon
2017-01-16 16:18 ` Mcnamara, John
2017-01-11 16:58 ` [dpdk-dev] [PATCH v6 0/4] Expanded statistics reporting Thomas Monjalon
2017-01-16 16:19 ` [dpdk-dev] [PATCH v7 0/6] " Remy Horton
2017-01-16 16:19 ` [dpdk-dev] [PATCH v7 1/6] lib: add information metrics library Remy Horton
2017-01-17 11:01 ` Van Haaren, Harry [this message]
2017-01-17 13:40 ` Remy Horton
2017-01-17 14:23 ` Van Haaren, Harry
2017-01-16 16:19 ` [dpdk-dev] [PATCH v7 2/6] app/proc_info: add metrics displaying Remy Horton
2017-01-17 11:08 ` Van Haaren, Harry
2017-01-17 14:27 ` Remy Horton
2017-01-16 16:19 ` [dpdk-dev] [PATCH v7 3/6] lib: add bitrate statistics library Remy Horton
2017-01-17 11:16 ` Van Haaren, Harry
2017-01-17 15:37 ` Remy Horton
2017-01-16 16:19 ` [dpdk-dev] [PATCH v7 4/6] app/test-pmd: add bitrate statistics calculation Remy Horton
2017-01-17 11:19 ` Van Haaren, Harry
2017-01-16 16:19 ` [dpdk-dev] [PATCH v7 5/6] lib: added new library for latency stats Remy Horton
2017-01-17 4:29 ` Jerin Jacob
2017-01-17 6:48 ` Remy Horton
2017-01-17 7:35 ` Jerin Jacob
2017-01-17 11:19 ` Mcnamara, John
2017-01-17 12:34 ` Jerin Jacob
2017-01-17 14:53 ` Mcnamara, John
2017-01-17 16:25 ` Jerin Jacob
2017-01-18 20:11 ` Olivier Matz
2017-01-24 15:24 ` Olivier MATZ
2017-01-17 11:41 ` Van Haaren, Harry
2017-01-16 16:19 ` [dpdk-dev] [PATCH v7 6/6] app/test-pmd: add latency statistics calculation Remy Horton
2017-01-17 11:45 ` Van Haaren, Harry
2017-01-17 23:24 ` [dpdk-dev] [PATCH v8 0/7] Expanded statistics reporting Remy Horton
2017-01-17 23:24 ` [dpdk-dev] [PATCH v8 1/7] lib: add information metrics library Remy Horton
2017-01-17 23:24 ` [dpdk-dev] [PATCH v8 2/7] app/proc_info: add metrics displaying Remy Horton
2017-01-17 23:24 ` [dpdk-dev] [PATCH v8 3/7] lib: add bitrate statistics library Remy Horton
2017-01-17 23:24 ` [dpdk-dev] [PATCH v8 4/7] app/test-pmd: add bitrate statistics calculation Remy Horton
2017-01-17 23:24 ` [dpdk-dev] [PATCH v8 5/7] mbuf: add a timestamp to the mbuf for latencystats Remy Horton
2017-01-17 23:24 ` [dpdk-dev] [PATCH v8 6/7] lib: added new library for latency stats Remy Horton
2017-01-17 23:24 ` [dpdk-dev] [PATCH v8 7/7] app/test-pmd: add latency statistics calculation Remy Horton
2017-01-18 15:05 ` [dpdk-dev] [PATCH v9 0/7] Expanded statistics reporting Remy Horton
2017-01-18 15:05 ` [dpdk-dev] [PATCH v9 1/7] lib: add information metrics library Remy Horton
2017-01-30 15:50 ` Thomas Monjalon
2017-01-30 21:44 ` Remy Horton
2017-01-31 13:13 ` Mcnamara, John
2017-01-31 13:28 ` Bruce Richardson
2017-02-02 17:22 ` Thomas Monjalon
2017-01-18 15:05 ` [dpdk-dev] [PATCH v9 2/7] app/proc_info: add metrics displaying Remy Horton
2017-01-18 15:05 ` [dpdk-dev] [PATCH v9 3/7] lib: add bitrate statistics library Remy Horton
2017-01-18 15:05 ` [dpdk-dev] [PATCH v9 4/7] app/test-pmd: add bitrate statistics calculation Remy Horton
2017-01-18 15:05 ` [dpdk-dev] [PATCH v9 5/7] mbuf: add a timestamp to the mbuf for latencystats Remy Horton
2017-01-18 15:05 ` [dpdk-dev] [PATCH v9 6/7] lib: added new library for latency stats Remy Horton
2017-01-18 15:05 ` [dpdk-dev] [PATCH v9 7/7] app/test-pmd: add latency statistics calculation Remy Horton
2017-02-03 10:33 ` [dpdk-dev] [PATCH v10 0/7] Expanded statistics reporting Remy Horton
2017-02-03 10:33 ` [dpdk-dev] [PATCH v10 1/7] lib: add information metrics library Remy Horton
2017-02-03 10:33 ` [dpdk-dev] [PATCH v10 2/7] app/proc_info: add metrics displaying Remy Horton
2017-02-03 10:33 ` [dpdk-dev] [PATCH v10 3/7] lib: add bitrate statistics library Remy Horton
2017-02-03 10:33 ` [dpdk-dev] [PATCH v10 4/7] app/test-pmd: add bitrate statistics calculation Remy Horton
2017-02-03 10:33 ` [dpdk-dev] [PATCH v10 5/7] mbuf: add a timestamp to the mbuf for latencystats Remy Horton
2017-02-03 10:33 ` [dpdk-dev] [PATCH v10 6/7] lib: added new library for latency stats Remy Horton
2017-02-03 10:33 ` [dpdk-dev] [PATCH v10 7/7] app/test-pmd: add latency statistics calculation Remy Horton
2017-02-16 10:53 ` [dpdk-dev] [PATCH v10 0/7] Expanded statistics reporting Thomas Monjalon
2017-02-23 7:09 ` Remy Horton
2017-02-23 8:45 ` Thomas Monjalon
2017-03-09 16:25 ` [dpdk-dev] [PATCH v11 " Remy Horton
2017-03-09 16:25 ` [dpdk-dev] [PATCH v11 1/7] lib: add information metrics library Remy Horton
2017-03-09 16:25 ` [dpdk-dev] [PATCH v11 2/7] app/proc_info: add metrics displaying Remy Horton
2017-03-09 16:25 ` [dpdk-dev] [PATCH v11 3/7] lib: add bitrate statistics library Remy Horton
2017-03-09 16:25 ` [dpdk-dev] [PATCH v11 4/7] app/test-pmd: add bitrate statistics calculation Remy Horton
2017-03-09 16:25 ` [dpdk-dev] [PATCH v11 5/7] mbuf: add a timestamp to the mbuf for latencystats Remy Horton
2017-03-09 19:02 ` Stephen Hemminger
2017-03-10 9:48 ` Van Haaren, Harry
2017-03-09 16:25 ` [dpdk-dev] [PATCH v11 6/7] lib: added new library for latency stats Remy Horton
2017-03-09 16:25 ` [dpdk-dev] [PATCH v11 7/7] app/test-pmd: add latency statistics calculation Remy Horton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E923DB57A917B54B9182A2E928D00FA6129E3B53@IRSMSX102.ger.corp.intel.com \
--to=harry.van.haaren@intel.com \
--cc=dev@dpdk.org \
--cc=remy.horton@intel.com \
--cc=thomas.monjalon@6wind.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).