From: Kamil Wiatrowski Date: Fri, 4 Sep 2020 13:45:46 +0000 (+0100) Subject: intel_pmu 2.0 - remove type from type instance X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2cd896a6c92629398fdffc559bdb5b578e107361;p=thirdparty%2Fcollectd.git intel_pmu 2.0 - remove type from type instance Remove type from type_instance for uncore events. Change-Id: Ia003fdb4bdadceab8a52efde0e311335fc047e89 Signed-off-by: Kamil Wiatrowski --- diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod index c2e1c42f4..a7461becc 100644 --- a/src/collectd.conf.pod +++ b/src/collectd.conf.pod @@ -3937,8 +3937,8 @@ either dispatch as aggregated value in a single metric or dispatch as individual values. If DispatchMultiPmu is set to 'false' uncore events are reported as single metric, even for multi PMU. The total value is obtained by summing all counters across all the units (e.g. CHAs). If DispatchMultiPmu is -set to 'true' all cloned PMUs are dispatched separately with 'type' value of -PMU added to Collectd's I. +set to 'true' all cloned PMUs are dispatched separately with PMU name added to +Collectd's I. =back diff --git a/src/intel_pmu.c b/src/intel_pmu.c index 00358d9af..a592f255a 100644 --- a/src/intel_pmu.c +++ b/src/intel_pmu.c @@ -225,7 +225,7 @@ static int pmu_config(oconfig_item_t *ci) { ret = cf_util_get_string_buffer(child, g_ctx.event_list_fn, sizeof(g_ctx.event_list_fn)); } else if (strcasecmp("HardwareEvents", child->key) == 0) { - intel_pmu_entity_t *ent = calloc(1, sizeof(*g_ctx.entl)); + intel_pmu_entity_t *ent = calloc(1, sizeof(*ent)); if (ent == NULL) { ERROR(PMU_PLUGIN ": Failed to allocate pmu ent."); ret = -ENOMEM; @@ -267,8 +267,7 @@ static int pmu_config(oconfig_item_t *ci) { } static void pmu_submit_counters(const char *cgroup, const char *event, - const char *pmu_name, - const uint32_t *event_type, bool multi_pmu, + const char *pmu_name, bool multi_pmu, counter_t scaled, counter_t raw, counter_t enabled, counter_t running) { value_list_t vl = VALUE_LIST_INIT; @@ -286,14 +285,9 @@ static void pmu_submit_counters(const char *cgroup, const char *event, pmu_name); else sstrncpy(vl.plugin_instance, cgroup, sizeof(vl.plugin_instance)); + sstrncpy(vl.type, "pmu_counter", sizeof(vl.type)); - if (event_type) - ssnprintf(vl.type_instance, sizeof(vl.type_instance), "%s:type=%d", event, - *event_type); - else if (multi_pmu) - ssnprintf(vl.type_instance, sizeof(vl.type_instance), "%s:total", event); - else - sstrncpy(vl.type_instance, event, sizeof(vl.type_instance)); + sstrncpy(vl.type_instance, event, sizeof(vl.type_instance)); DEBUG(PMU_PLUGIN ": %s/%s = %llu (%llu * %llu / %llu)", vl.type_instance, vl.plugin_instance, scaled, raw, enabled, running); @@ -417,7 +411,7 @@ static void pmu_dispatch_data(intel_pmu_entity_t *ent) { if (event_enabled_cgroup > 0) /* dispatch per core group values */ - pmu_submit_counters(cgroup->desc, e->event, pmu_name, event_type, + pmu_submit_counters(cgroup->desc, e->event, pmu_name, e->extra.multi_pmu, cgroup_value, cgroup_value_raw, cgroup_time_enabled, cgroup_time_running); } @@ -652,7 +646,7 @@ static int pmu_split_cores(intel_pmu_entity_t *ent) { intel_pmu_entity_t *prev = ent; for (size_t i = CGROUPS_PER_ENT; i < ent->cores.num_cgroups; i += CGROUPS_PER_ENT) { - intel_pmu_entity_t *entc = calloc(1, sizeof(*g_ctx.entl)); + intel_pmu_entity_t *entc = calloc(1, sizeof(*entc)); if (entc == NULL) { ERROR(PMU_PLUGIN ": pmu_split_cores: Failed to allocate pmu ent."); return -ENOMEM; @@ -887,7 +881,7 @@ static int pmu_shutdown(void) { } void module_register(void) { - plugin_register_init(PMU_PLUGIN, pmu_init); plugin_register_complex_config(PMU_PLUGIN, pmu_config); + plugin_register_init(PMU_PLUGIN, pmu_init); plugin_register_shutdown(PMU_PLUGIN, pmu_shutdown); } diff --git a/src/intel_pmu_test.c b/src/intel_pmu_test.c index e5d696e0b..c1a953b8a 100644 --- a/src/intel_pmu_test.c +++ b/src/intel_pmu_test.c @@ -29,7 +29,6 @@ #include "testing.h" // Helper functions -// static int ctx_entl_size = 0; intel_pmu_ctx_t *stub_pmu_init() { intel_pmu_ctx_t *pmu_ctx = calloc(1, sizeof(*pmu_ctx));