From a982ea5165736566760cc0fc3fa65b2482188fed Mon Sep 17 00:00:00 2001 From: Tuukka Tikkanen Date: Mon, 5 Jan 2015 09:53:48 +0200 Subject: idlestat: Remove unused functions The functions used to calculate core/cluster c-state statistics from individual cpu statistics are no longer used and can be removed. Signed-off-by: Tuukka Tikkanen --- idlestat.c | 234 ------------------------------------------------------------- idlestat.h | 1 - topology.h | 4 -- 3 files changed, 239 deletions(-) diff --git a/idlestat.c b/idlestat.c index a9dc12a..c65c33d 100644 --- a/idlestat.c +++ b/idlestat.c @@ -204,113 +204,6 @@ static int display_wakeup(struct report_ops *ops, void *arg, void *baseline, cha return 0; } -static struct cpuidle_data *intersection(struct cpuidle_data *data1, - struct cpuidle_data *data2) -{ - double begin, end; - struct cpuidle_data *data; - - assert(data1 != NULL); - assert(data2 != NULL); - - begin = MAX(data1->begin, data2->begin); - end = MIN(data1->end, data2->end); - - if (begin >= end) - return NULL; - - data = calloc(sizeof(*data), 1); - if (!data) - return ptrerror(__func__); - - data->begin = begin; - data->end = end; - data->duration = end - begin; - data->duration *= USEC_PER_SEC; - - return data; -} - -static struct cpuidle_cstate *inter(struct cpuidle_cstate *c1, - struct cpuidle_cstate *c2) -{ - int i, j; - struct cpuidle_data *interval; - struct cpuidle_cstate *result; - struct cpuidle_data *data = NULL; - size_t index; - - /* - * Watch out! These may create aliases that end up stored - * permanently! (e.g. if nrcpus == 1) - * TODO: This is obviously a bug. - */ - if (!c1) - return c2; - if (!c2) - return c1; - - result = calloc(sizeof(*result), 1); - if (!result) - return ptrerror(__func__); - - result->inter_result = 1; - - for (i = 0, index = 0; i < c1->nrdata; i++) { - - for (j = index; j < c2->nrdata; j++) { - struct cpuidle_data *tmp; - - /* intervals are ordered, no need to go further */ - if (c1->data[i].end < c2->data[j].begin) - break; - - /* primary loop begins where we ended */ - if (c1->data[i].begin > c2->data[j].end) - index = j; - - interval = intersection(&c1->data[i], &c2->data[j]); - if (!interval) - continue; - if (is_err(interval)) { - free(data); - free(result); - return ptrerror(NULL); - } - - result->min_time = MIN(result->min_time, - interval->duration); - - result->max_time = MAX(result->max_time, - interval->duration); - - result->avg_time = AVG(result->avg_time, - interval->duration, - result->nrdata + 1); - - result->duration += interval->duration; - - result->nrdata++; - - tmp = realloc(data, sizeof(*data) * result->nrdata); - if (!tmp) { - free(data); - free(result); - return ptrerror(__func__); - } - data = tmp; - - /* Newly allocated area will be 100% overwritten */ - data[result->nrdata - 1] = *interval; - - free(interval); - } - } - - result->data = data; - return result; -} - static char *cpuidle_cstate_name(int cpu, int state) { char *fpath, *name; @@ -1025,133 +918,6 @@ struct cpuidle_datas *idlestat_load(const char *filename) return ptrerror(NULL); } -struct cpuidle_cstates *core_cluster_data(struct cpu_core *s_core) -{ - struct cpuidle_cstate *c1, *cstates, *tmp; - struct cpuidle_cstates *result; - struct cpu_cpu *s_cpu; - int i; - int cstate_max = -1; - - if (!s_core->is_ht) - list_for_each_entry(s_cpu, &s_core->cpu_head, list_cpu) - return s_cpu->cstates; - - result = calloc(sizeof(*result), 1); - if (!result) - return NULL; - - /* hack but negligible overhead */ - list_for_each_entry(s_cpu, &s_core->cpu_head, list_cpu) - cstate_max = MAX(cstate_max, s_cpu->cstates->cstate_max); - result->cstate_max = cstate_max; - - for (i = 0; i < cstate_max + 1; i++) { - cstates = NULL; - list_for_each_entry(s_cpu, &s_core->cpu_head, list_cpu) { - c1 = &s_cpu->cstates->cstate[i]; - - tmp = inter(cstates, c1); - if (cstates && cstates != tmp && - cstates->inter_result) { - free(cstates->data); - free(cstates); - } - cstates = tmp; - - if (!cstates) - continue; - if (is_err(cstates)) { - release_cstate_info(result, 1); - return ptrerror(NULL); - } - } - /* copy state name from first cpu */ - s_cpu = list_first_entry(&s_core->cpu_head, struct cpu_cpu, - list_cpu); - cstates->name = strdup(s_cpu->cstates->cstate[i].name); - - result->cstate[i] = *cstates; - result->cstate[i].inter_result = 0; - - /* - * Free cstates if it has been allocated by inter() - * Do not free things pointed to by members of cstates - * even if you free cstates itself. - */ - if (cstates && cstates->inter_result) { - free(cstates); - } else { - fprintf(stderr, "Warning: %s aliased cstates at %p\n", - __func__, cstates); - } - } - - return result; -} - -struct cpuidle_cstates *physical_cluster_data(struct cpu_physical *s_phy) -{ - struct cpuidle_cstate *c1, *cstates, *tmp; - struct cpuidle_cstates *result; - struct cpu_core *s_core; - int i; - int cstate_max = -1; - - result = calloc(sizeof(*result), 1); - if (!result) - return NULL; - - /* hack but negligible overhead */ - list_for_each_entry(s_core, &s_phy->core_head, list_core) - cstate_max = MAX(cstate_max, s_core->cstates->cstate_max); - result->cstate_max = cstate_max; - - for (i = 0; i < cstate_max + 1; i++) { - cstates = NULL; - list_for_each_entry(s_core, &s_phy->core_head, list_core) { - c1 = &s_core->cstates->cstate[i]; - - tmp = inter(cstates, c1); - if (cstates && cstates != tmp && - cstates->inter_result) { - free(cstates->data); - free(cstates); - } - cstates = tmp; - - if (!cstates) - continue; - if (is_err(cstates)) { - release_cstate_info(result, 1); - return ptrerror(NULL); - } - } - /* copy state name from first core (if any) */ - s_core = list_first_entry(&s_phy->core_head, struct cpu_core, - list_core); - cstates->name = s_core->cstates->cstate[i].name ? - strdup(s_core->cstates->cstate[i].name) : NULL; - - result->cstate[i] = *cstates; - result->cstate[i].inter_result = 0; - - /* - * Free cstates if it has been allocated by inter() - * Do not free things pointed to by members of cstates - * even if you free cstates itself. - */ - if (cstates && cstates->inter_result) { - free(cstates); - } else { - fprintf(stderr, "Warning: %s aliased cstates at %p\n", - __func__, cstates); - } - } - - return result; -} - static void help(const char *cmd) { fprintf(stderr, diff --git a/idlestat.h b/idlestat.h index 70beeab..6c7b6d0 100644 --- a/idlestat.h +++ b/idlestat.h @@ -63,7 +63,6 @@ struct cpuidle_cstate { double min_time; double duration; int target_residency; /* -1 if not available */ - int inter_result; /* 1 if created by a call to inter() */ }; struct wakeup_irq { diff --git a/topology.h b/topology.h index e06f1dc..aa84a5b 100644 --- a/topology.h +++ b/topology.h @@ -77,10 +77,6 @@ extern void assign_baseline_in_topo(struct cpuidle_datas *datas); extern int release_cpu_topo_cstates(struct cpu_topology *topo); extern int dump_cpu_topo_info(struct report_ops *ops, void *report_data, int (*dump)(struct report_ops *, void *, void *, char *, void *), struct cpu_topology *topo, int cstate); -extern struct cpuidle_cstates *core_cluster_data(struct cpu_core *s_core); -extern struct cpuidle_cstates * - physical_cluster_data(struct cpu_physical *s_phy); - extern struct cpu_physical *cpu_to_cluster(int cpuid, struct cpu_topology *topo); extern struct cpu_core *cpu_to_core(int cpuid, struct cpu_topology *topo); -- cgit v1.2.3