Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
at v4.13-rc1 54 lines 1.1 kB view raw
1#include <errno.h> 2#include <stdlib.h> 3#include "evsel.h" 4#include "counts.h" 5#include "util.h" 6 7struct perf_counts *perf_counts__new(int ncpus, int nthreads) 8{ 9 struct perf_counts *counts = zalloc(sizeof(*counts)); 10 11 if (counts) { 12 struct xyarray *values; 13 14 values = xyarray__new(ncpus, nthreads, sizeof(struct perf_counts_values)); 15 if (!values) { 16 free(counts); 17 return NULL; 18 } 19 20 counts->values = values; 21 } 22 23 return counts; 24} 25 26void perf_counts__delete(struct perf_counts *counts) 27{ 28 if (counts) { 29 xyarray__delete(counts->values); 30 free(counts); 31 } 32} 33 34static void perf_counts__reset(struct perf_counts *counts) 35{ 36 xyarray__reset(counts->values); 37} 38 39void perf_evsel__reset_counts(struct perf_evsel *evsel) 40{ 41 perf_counts__reset(evsel->counts); 42} 43 44int perf_evsel__alloc_counts(struct perf_evsel *evsel, int ncpus, int nthreads) 45{ 46 evsel->counts = perf_counts__new(ncpus, nthreads); 47 return evsel->counts != NULL ? 0 : -ENOMEM; 48} 49 50void perf_evsel__free_counts(struct perf_evsel *evsel) 51{ 52 perf_counts__delete(evsel->counts); 53 evsel->counts = NULL; 54}