[2/6] service: introduce per-lcore cycles counter
Checks
Commit Message
Introduce a per-lcore counter for the total time spent on processing
services on that core.
This counter is useful when measuring individual lcore load.
Signed-off-by: Mattias Rönnblom <mattias.ronnblom@ericsson.com>
---
app/test/test_service_cores.c | 2 +-
lib/eal/common/rte_service.c | 14 ++++++++++++++
lib/eal/include/rte_service.h | 6 ++++++
3 files changed, 21 insertions(+), 1 deletion(-)
@@ -403,7 +403,7 @@ service_lcore_attr_get(void)
"lcore_attr_get() failed to get loops "
"(expected > zero)");
- lcore_attr_id++; // invalid lcore attr id
+ lcore_attr_id = 42; /* invalid lcore attr id */
TEST_ASSERT_EQUAL(-EINVAL, rte_service_lcore_attr_get(slcore_id,
lcore_attr_id, &lcore_attr_value),
"Invalid lcore attr didn't return -EINVAL");
@@ -61,6 +61,7 @@ struct core_state {
uint8_t is_service_core; /* set if core is currently a service core */
uint8_t service_active_on_lcore[RTE_SERVICE_NUM_MAX];
uint64_t loops;
+ uint64_t cycles;
uint64_t calls_per_service[RTE_SERVICE_NUM_MAX];
uint64_t cycles_per_service[RTE_SERVICE_NUM_MAX];
} __rte_cache_aligned;
@@ -372,6 +373,8 @@ service_runner_do_callback(struct rte_service_spec_impl *s,
* is needed, and not the more expensive atomic
* add.
*/
+ __atomic_store_n(&cs->cycles, cs->cycles + cycles,
+ __ATOMIC_RELAXED);
__atomic_store_n(&cs->calls_per_service[service_idx],
cs->calls_per_service[service_idx] + 1,
__ATOMIC_RELAXED);
@@ -812,6 +815,14 @@ lcore_attr_get_loops(unsigned int lcore)
return __atomic_load_n(&cs->loops, __ATOMIC_RELAXED);
}
+static uint64_t
+lcore_attr_get_cycles(unsigned int lcore)
+{
+ struct core_state *cs = &lcore_states[lcore];
+
+ return __atomic_load_n(&cs->cycles, __ATOMIC_RELAXED);
+}
+
static uint64_t
lcore_attr_get_service_calls(uint32_t service_id, unsigned int lcore)
{
@@ -896,6 +907,9 @@ rte_service_lcore_attr_get(uint32_t lcore, uint32_t attr_id,
case RTE_SERVICE_LCORE_ATTR_LOOPS:
*attr_value = lcore_attr_get_loops(lcore);
return 0;
+ case RTE_SERVICE_LCORE_ATTR_CYCLES:
+ *attr_value = lcore_attr_get_cycles(lcore);
+ return 0;
default:
return -EINVAL;
}
@@ -407,6 +407,12 @@ int32_t rte_service_attr_reset_all(uint32_t id);
*/
#define RTE_SERVICE_LCORE_ATTR_LOOPS 0
+/**
+ * Returns the total number of cycles that the lcore has spent on
+ * running services.
+ */
+#define RTE_SERVICE_LCORE_ATTR_CYCLES 1
+
/**
* Get an attribute from a service core.
*