2 * Copyright (C) ARM Limited 2013-2015. All rights reserved.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
14 // Use a snapshot of perf_event.h as it may be more recent than what is on the target and if not newer features won't be supported anyways
15 #include "k/perf_event.h"
24 PERF_GROUP_MMAP = 1 << 0,
25 PERF_GROUP_COMM = 1 << 1,
26 PERF_GROUP_FREQ = 1 << 2,
27 PERF_GROUP_TASK = 1 << 3,
28 PERF_GROUP_SAMPLE_ID_ALL = 1 << 4,
29 PERF_GROUP_PER_CPU = 1 << 5,
30 PERF_GROUP_LEADER = 1 << 6,
31 PERF_GROUP_CPU = 1 << 7,
42 PerfGroup(PerfBuffer *const pb);
45 bool createCpuGroup(const uint64_t currTime, Buffer *const buffer);
46 bool add(const uint64_t currTime, Buffer *const buffer, const int key, const __u32 type, const __u64 config, const __u64 sample, const __u64 sampleType, const int flags);
47 // Safe to call concurrently
48 int prepareCPU(const int cpu, Monitor *const monitor);
49 // Not safe to call concurrently. Returns the number of events enabled
50 int onlineCPU(const uint64_t currTime, const int cpu, const bool enable, Buffer *const buffer);
51 bool offlineCPU(int cpu);
56 int getEffectiveType(const int type, const int flags);
57 int doAdd(const uint64_t currTime, Buffer *const buffer, const int key, const __u32 type, const __u64 config, const __u64 sample, const __u64 sampleType, const int flags);
59 // 2* to be conservative for sched_switch, cpu_idle, hrtimer and non-CPU groups
60 struct perf_event_attr mAttrs[2*MAX_PERFORMANCE_COUNTERS];
61 PerfBuffer *const mPb;
62 int mFlags[2*MAX_PERFORMANCE_COUNTERS];
63 int mKeys[2*MAX_PERFORMANCE_COUNTERS];
64 int mFds[NR_CPUS * (2*MAX_PERFORMANCE_COUNTERS)];
65 // Offset in mAttrs, mFlags and mKeys of the group leaders for each perf type
69 // Intentionally undefined
70 PerfGroup(const PerfGroup &);
71 PerfGroup &operator=(const PerfGroup &);