From: Harry van Haaren <harry.van.haaren@intel.com>
To: dev@dpdk.org
Cc: Harry van Haaren <harry.van.haaren@intel.com>
Subject: [dpdk-dev] [PATCH 2/3] service: add reset all attributes for service
Date: Wed, 4 Oct 2017 11:54:50 +0100 [thread overview]
Message-ID: <1507114491-144338-3-git-send-email-harry.van.haaren@intel.com> (raw)
In-Reply-To: <1507114491-144338-1-git-send-email-harry.van.haaren@intel.com>
This commit introduces a new API, allowing the application to
reset attributes of a service like the cycle count. Given this
functionality is now exposed to the user, remove the resetting
of stats during a dump() call.
Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
---
lib/librte_eal/bsdapp/eal/rte_eal_version.map | 1 +
lib/librte_eal/common/include/rte_service.h | 10 ++++++++++
lib/librte_eal/common/rte_service.c | 24 ++++++++++++++++++------
lib/librte_eal/linuxapp/eal/rte_eal_version.map | 1 +
test/test/test_service_cores.c | 11 +++++++++++
5 files changed, 41 insertions(+), 6 deletions(-)
diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
index 8c9c5f6..e654283 100644
--- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
@@ -213,6 +213,7 @@ EXPERIMENTAL {
rte_eal_hotplug_add;
rte_eal_hotplug_remove;
rte_service_attr_get;
+ rte_service_attr_reset_all;
rte_service_component_register;
rte_service_component_unregister;
rte_service_component_runstate_set;
diff --git a/lib/librte_eal/common/include/rte_service.h b/lib/librte_eal/common/include/rte_service.h
index 9267a0e..bf7b50b 100644
--- a/lib/librte_eal/common/include/rte_service.h
+++ b/lib/librte_eal/common/include/rte_service.h
@@ -377,6 +377,16 @@ int32_t rte_service_dump(FILE *f, uint32_t id);
int32_t rte_service_attr_get(uint32_t id, uint32_t attr_id,
uint32_t *attr_value);
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Reset all attributes of a service.
+ * @retval 0 Successfully reset attributes
+ * -EINVAL Invalid service id provided
+ */
+int32_t rte_service_attr_reset_all(uint32_t id);
+
#ifdef __cplusplus
}
#endif
diff --git a/lib/librte_eal/common/rte_service.c b/lib/librte_eal/common/rte_service.c
index 4935804..3f274f4 100644
--- a/lib/librte_eal/common/rte_service.c
+++ b/lib/librte_eal/common/rte_service.c
@@ -674,15 +674,27 @@ rte_service_dump_one(FILE *f, struct rte_service_spec_impl *s,
if (s->calls != 0)
calls = s->calls;
+ if (reset) {
+ s->cycles_spent = 0;
+ s->calls = 0;
+ return;
+ }
+
fprintf(f, " %s: stats %d\tcalls %"PRIu64"\tcycles %"
PRIu64"\tavg: %"PRIu64"\n",
s->spec.name, service_stats_enabled(s), s->calls,
s->cycles_spent, s->cycles_spent / calls);
+}
- if (reset) {
- s->cycles_spent = 0;
- s->calls = 0;
- }
+int32_t
+rte_service_attr_reset_all(uint32_t id)
+{
+ struct rte_service_spec_impl *s;
+ SERVICE_VALID_GET_OR_ERR_RET(id, s, -EINVAL);
+
+ int reset = 1;
+ rte_service_dump_one(NULL, s, 0, reset);
+ return 0;
}
static void
@@ -730,7 +742,7 @@ int32_t rte_service_dump(FILE *f, uint32_t id)
for (i = 0; i < RTE_SERVICE_NUM_MAX; i++) {
if (!service_valid(i))
continue;
- uint32_t reset = 1;
+ uint32_t reset = 0;
rte_service_dump_one(f, &rte_services[i], total_cycles, reset);
}
@@ -739,7 +751,7 @@ int32_t rte_service_dump(FILE *f, uint32_t id)
if (lcore_config[i].core_role != ROLE_SERVICE)
continue;
- uint32_t reset = 1;
+ uint32_t reset = 0;
service_dump_calls_per_lcore(f, i, reset);
}
diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
index c2fad10..e5a0f04 100644
--- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
@@ -218,6 +218,7 @@ EXPERIMENTAL {
rte_eal_hotplug_add;
rte_eal_hotplug_remove;
rte_service_attr_get;
+ rte_service_attr_reset_all;
rte_service_component_register;
rte_service_component_unregister;
rte_service_component_runstate_set;
diff --git a/test/test/test_service_cores.c b/test/test/test_service_cores.c
index 7d2e42d..dd3bf75 100644
--- a/test/test/test_service_cores.c
+++ b/test/test/test_service_cores.c
@@ -270,6 +270,9 @@ service_name(void)
static int
service_attr_get(void)
{
+ /* ensure all services unregistered so cycle counts are zero */
+ unregister_all();
+
struct rte_service_spec service;
memset(&service, 0, sizeof(struct rte_service_spec));
service.callback = dummy_cb;
@@ -323,6 +326,14 @@ service_attr_get(void)
rte_service_lcore_stop(slcore_id);
+ TEST_ASSERT_EQUAL(0, rte_service_attr_reset_all(id),
+ "Valid attr_reset_all() return success");
+
+ TEST_ASSERT_EQUAL(0, rte_service_attr_get(id, attr_id, &attr_value),
+ "Valid attr_get() call didn't return success");
+ TEST_ASSERT_EQUAL(0, attr_value,
+ "attr_get() call didn't set correct cycles (zero)");
+
return unregister_all();
}
--
2.7.4
next prev parent reply other threads:[~2017-10-04 10:54 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-04 10:54 [dpdk-dev] [PATCH 0/3] service: add attribute get and reset Harry van Haaren
2017-10-04 10:54 ` [dpdk-dev] [PATCH 1/3] service: add attribute get function Harry van Haaren
2018-01-12 10:27 ` [dpdk-dev] [PATCH v2 " Harry van Haaren
2018-01-12 10:27 ` [dpdk-dev] [PATCH v2 2/3] service: add reset all attributes for service Harry van Haaren
2018-01-12 10:27 ` [dpdk-dev] [PATCH v2 3/3] service: add attribute for number of invocations Harry van Haaren
2018-01-12 11:49 ` [dpdk-dev] [PATCH v2 1/3] service: add attribute get function Thomas Monjalon
2017-10-04 10:54 ` Harry van Haaren [this message]
2017-10-04 10:54 ` [dpdk-dev] [PATCH 3/3] service: add attribute for number of invokations Harry van Haaren
2018-01-11 22:42 ` [dpdk-dev] [PATCH 0/3] service: add attribute get and reset Thomas Monjalon
2018-01-12 10:01 ` Van Haaren, Harry
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=1507114491-144338-3-git-send-email-harry.van.haaren@intel.com \
--to=harry.van.haaren@intel.com \
--cc=dev@dpdk.org \
/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).