Path: blob/master/tools/perf/arch/powerpc/util/auxtrace.c
30402 views
// SPDX-License-Identifier: GPL-2.01/*2* VPA support3*/45#include <linux/kernel.h>6#include <linux/types.h>7#include <linux/string.h>89#include "../../util/evlist.h"10#include "../../util/debug.h"11#include "../../util/auxtrace.h"12#include "../../util/powerpc-vpadtl.h"13#include "../../util/record.h"14#include <internal/lib.h> // page_size1516#define KiB(x) ((x) * 1024)1718static int19powerpc_vpadtl_recording_options(struct auxtrace_record *ar __maybe_unused,20struct evlist *evlist __maybe_unused,21struct record_opts *opts)22{23opts->full_auxtrace = true;2425/*26* Set auxtrace_mmap_pages to minimum27* two pages28*/29if (!opts->auxtrace_mmap_pages) {30opts->auxtrace_mmap_pages = KiB(128) / page_size;31if (opts->mmap_pages == UINT_MAX)32opts->mmap_pages = KiB(256) / page_size;33}3435return 0;36}3738static size_t powerpc_vpadtl_info_priv_size(struct auxtrace_record *itr __maybe_unused,39struct evlist *evlist __maybe_unused)40{41return VPADTL_AUXTRACE_PRIV_SIZE;42}4344static int45powerpc_vpadtl_info_fill(struct auxtrace_record *itr __maybe_unused,46struct perf_session *session __maybe_unused,47struct perf_record_auxtrace_info *auxtrace_info,48size_t priv_size __maybe_unused)49{50auxtrace_info->type = PERF_AUXTRACE_VPA_DTL;5152return 0;53}5455static void powerpc_vpadtl_free(struct auxtrace_record *itr)56{57free(itr);58}5960static u64 powerpc_vpadtl_reference(struct auxtrace_record *itr __maybe_unused)61{62return 0;63}6465struct auxtrace_record *auxtrace_record__init(struct evlist *evlist,66int *err)67{68struct auxtrace_record *aux;69struct evsel *pos;70int found = 0;7172evlist__for_each_entry(evlist, pos) {73if (strstarts(pos->name, "vpa_dtl")) {74found = 1;75pos->needs_auxtrace_mmap = true;76break;77}78}7980if (!found)81return NULL;8283/*84* To obtain the auxtrace buffer file descriptor, the auxtrace event85* must come first.86*/87evlist__to_front(pos->evlist, pos);8889aux = zalloc(sizeof(*aux));90if (aux == NULL) {91pr_debug("aux record is NULL\n");92*err = -ENOMEM;93return NULL;94}9596aux->recording_options = powerpc_vpadtl_recording_options;97aux->info_priv_size = powerpc_vpadtl_info_priv_size;98aux->info_fill = powerpc_vpadtl_info_fill;99aux->free = powerpc_vpadtl_free;100aux->reference = powerpc_vpadtl_reference;101return aux;102}103104105