forked from luck/tmp_suning_uos_patched
perf pmu: Push configuration down to PMU driver
This patch adds a PMU callback and the required mechanic so that drivers can process the command line configuration elements found in evsel::config_terms. Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org> Acked-by: Jiri Olsa <jolsa@kernel.org> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/1474041004-13956-6-git-send-email-mathieu.poirier@linaro.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
a818c563ae
commit
859442bd3f
|
@ -86,6 +86,7 @@ libperf-y += term.o
|
|||
libperf-y += help-unknown-cmd.o
|
||||
libperf-y += mem-events.o
|
||||
libperf-y += vsprintf.o
|
||||
libperf-y += drv_configs.o
|
||||
|
||||
libperf-$(CONFIG_LIBBPF) += bpf-loader.o
|
||||
libperf-$(CONFIG_BPF_PROLOGUE) += bpf-prologue.o
|
||||
|
|
77
tools/perf/util/drv_configs.c
Normal file
77
tools/perf/util/drv_configs.c
Normal file
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* drv_configs.h: Interface to apply PMU specific configuration
|
||||
* Copyright (c) 2016-2018, Linaro Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "drv_configs.h"
|
||||
#include "evlist.h"
|
||||
#include "evsel.h"
|
||||
#include "pmu.h"
|
||||
|
||||
static int
|
||||
perf_evsel__apply_drv_configs(struct perf_evsel *evsel,
|
||||
struct perf_evsel_config_term **err_term)
|
||||
{
|
||||
bool found = false;
|
||||
int err = 0;
|
||||
struct perf_evsel_config_term *term;
|
||||
struct perf_pmu *pmu = NULL;
|
||||
|
||||
while ((pmu = perf_pmu__scan(pmu)) != NULL)
|
||||
if (pmu->type == evsel->attr.type) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
|
||||
list_for_each_entry(term, &evsel->config_terms, list) {
|
||||
if (term->type != PERF_EVSEL__CONFIG_TERM_DRV_CFG)
|
||||
continue;
|
||||
|
||||
/*
|
||||
* We have a configuration term, report an error if we
|
||||
* can't find the PMU or if the PMU driver doesn't support
|
||||
* cmd line driver configuration.
|
||||
*/
|
||||
if (!found || !pmu->set_drv_config) {
|
||||
err = -EINVAL;
|
||||
*err_term = term;
|
||||
break;
|
||||
}
|
||||
|
||||
err = pmu->set_drv_config(term);
|
||||
if (err) {
|
||||
*err_term = term;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
int perf_evlist__apply_drv_configs(struct perf_evlist *evlist,
|
||||
struct perf_evsel **err_evsel,
|
||||
struct perf_evsel_config_term **err_term)
|
||||
{
|
||||
struct perf_evsel *evsel;
|
||||
int err = 0;
|
||||
|
||||
evlist__for_each_entry(evlist, evsel) {
|
||||
err = perf_evsel__apply_drv_configs(evsel, err_term);
|
||||
if (err) {
|
||||
*err_evsel = evsel;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
26
tools/perf/util/drv_configs.h
Normal file
26
tools/perf/util/drv_configs.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* drv_configs.h: Interface to apply PMU specific configuration
|
||||
* Copyright (c) 2016-2018, Linaro Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __PERF_DRV_CONFIGS_H
|
||||
#define __PERF_DRV_CONFIGS_H
|
||||
|
||||
#include "drv_configs.h"
|
||||
#include "evlist.h"
|
||||
#include "evsel.h"
|
||||
|
||||
int perf_evlist__apply_drv_configs(struct perf_evlist *evlist,
|
||||
struct perf_evsel **err_evsel,
|
||||
struct perf_evsel_config_term **term);
|
||||
#endif
|
|
@ -4,6 +4,7 @@
|
|||
#include <linux/bitmap.h>
|
||||
#include <linux/perf_event.h>
|
||||
#include <stdbool.h>
|
||||
#include "evsel.h"
|
||||
#include "parse-events.h"
|
||||
|
||||
enum {
|
||||
|
@ -25,6 +26,7 @@ struct perf_pmu {
|
|||
struct list_head format; /* HEAD struct perf_pmu_format -> list */
|
||||
struct list_head aliases; /* HEAD struct perf_pmu_alias -> list */
|
||||
struct list_head list; /* ELEM */
|
||||
int (*set_drv_config) (struct perf_evsel_config_term *term);
|
||||
};
|
||||
|
||||
struct perf_pmu_info {
|
||||
|
|
Loading…
Reference in New Issue
Block a user