mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2025-04-17 00:07:37 +07:00
perf trace: Extract evsel contructor from perf_evlist__add_pgfault
Prep work for next patches, where we'll need access to the created evsels, to possibly configure callchains. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/n/tip-2pcgsgnkgellhlcao4aub8tu@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
70a2cba972
commit
0ae537cb35
@ -2381,8 +2381,7 @@ static bool perf_evlist__add_vfs_getname(struct perf_evlist *evlist)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int perf_evlist__add_pgfault(struct perf_evlist *evlist,
|
static struct perf_evsel *perf_evsel__new_pgfault(u64 config)
|
||||||
u64 config)
|
|
||||||
{
|
{
|
||||||
struct perf_evsel *evsel;
|
struct perf_evsel *evsel;
|
||||||
struct perf_event_attr attr = {
|
struct perf_event_attr attr = {
|
||||||
@ -2396,13 +2395,10 @@ static int perf_evlist__add_pgfault(struct perf_evlist *evlist,
|
|||||||
event_attr_init(&attr);
|
event_attr_init(&attr);
|
||||||
|
|
||||||
evsel = perf_evsel__new(&attr);
|
evsel = perf_evsel__new(&attr);
|
||||||
if (!evsel)
|
if (evsel)
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
evsel->handler = trace__pgfault;
|
evsel->handler = trace__pgfault;
|
||||||
perf_evlist__add(evlist, evsel);
|
|
||||||
|
|
||||||
return 0;
|
return evsel;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void trace__handle_event(struct trace *trace, union perf_event *event, struct perf_sample *sample)
|
static void trace__handle_event(struct trace *trace, union perf_event *event, struct perf_sample *sample)
|
||||||
@ -2504,7 +2500,7 @@ static int trace__set_ev_qualifier_filter(struct trace *trace)
|
|||||||
static int trace__run(struct trace *trace, int argc, const char **argv)
|
static int trace__run(struct trace *trace, int argc, const char **argv)
|
||||||
{
|
{
|
||||||
struct perf_evlist *evlist = trace->evlist;
|
struct perf_evlist *evlist = trace->evlist;
|
||||||
struct perf_evsel *evsel;
|
struct perf_evsel *evsel, *pgfault_maj = NULL, *pgfault_min = NULL;
|
||||||
int err = -1, i;
|
int err = -1, i;
|
||||||
unsigned long before;
|
unsigned long before;
|
||||||
const bool forks = argc > 0;
|
const bool forks = argc > 0;
|
||||||
@ -2518,14 +2514,19 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
|
|||||||
if (trace->trace_syscalls)
|
if (trace->trace_syscalls)
|
||||||
trace->vfs_getname = perf_evlist__add_vfs_getname(evlist);
|
trace->vfs_getname = perf_evlist__add_vfs_getname(evlist);
|
||||||
|
|
||||||
if ((trace->trace_pgfaults & TRACE_PFMAJ) &&
|
if ((trace->trace_pgfaults & TRACE_PFMAJ)) {
|
||||||
perf_evlist__add_pgfault(evlist, PERF_COUNT_SW_PAGE_FAULTS_MAJ)) {
|
pgfault_maj = perf_evsel__new_pgfault(PERF_COUNT_SW_PAGE_FAULTS_MAJ);
|
||||||
|
if (pgfault_maj == NULL)
|
||||||
goto out_error_mem;
|
goto out_error_mem;
|
||||||
|
perf_evlist__add(evlist, pgfault_maj);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((trace->trace_pgfaults & TRACE_PFMIN) &&
|
if ((trace->trace_pgfaults & TRACE_PFMIN)) {
|
||||||
perf_evlist__add_pgfault(evlist, PERF_COUNT_SW_PAGE_FAULTS_MIN))
|
pgfault_min = perf_evsel__new_pgfault(PERF_COUNT_SW_PAGE_FAULTS_MIN);
|
||||||
|
if (pgfault_min == NULL)
|
||||||
goto out_error_mem;
|
goto out_error_mem;
|
||||||
|
perf_evlist__add(evlist, pgfault_min);
|
||||||
|
}
|
||||||
|
|
||||||
if (trace->sched &&
|
if (trace->sched &&
|
||||||
perf_evlist__add_newtp(evlist, "sched", "sched_stat_runtime",
|
perf_evlist__add_newtp(evlist, "sched", "sched_stat_runtime",
|
||||||
|
Loading…
Reference in New Issue
Block a user