2016-03-28 13:30:28 +00:00
|
|
|
/*
|
|
|
|
* virperf.h: methods for managing perf events
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library. If not, see
|
|
|
|
* <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2019-06-18 16:13:08 +00:00
|
|
|
#pragma once
|
2016-03-28 13:30:28 +00:00
|
|
|
|
2019-06-18 16:13:08 +00:00
|
|
|
#include "virutil.h"
|
|
|
|
#include "virautoclean.h"
|
|
|
|
#include "virenum.h"
|
2016-03-28 13:30:28 +00:00
|
|
|
|
2016-08-02 18:43:35 +00:00
|
|
|
/* Some Intel processor families introduced some RDT (Resource Director
|
|
|
|
* Technology) features to monitor or control shared resource based on
|
|
|
|
* the perf framework in the linux kernel. */
|
2016-03-28 13:30:28 +00:00
|
|
|
typedef enum {
|
2016-08-02 18:43:35 +00:00
|
|
|
VIR_PERF_EVENT_CMT, /* Cache Monitoring Technology */
|
|
|
|
VIR_PERF_EVENT_MBMT, /* Memory Bandwidth Monitoring Total */
|
|
|
|
VIR_PERF_EVENT_MBML, /* Memory Bandwidth Monitor Limit for controller */
|
2016-03-28 13:30:28 +00:00
|
|
|
|
2016-10-07 11:55:51 +00:00
|
|
|
VIR_PERF_EVENT_CPU_CYCLES, /* Count of CPU Cycles (total/elapsed) */
|
2016-07-16 08:15:12 +00:00
|
|
|
VIR_PERF_EVENT_INSTRUCTIONS, /* Count of instructions for application */
|
|
|
|
VIR_PERF_EVENT_CACHE_REFERENCES, /* Cache hits by applications */
|
|
|
|
VIR_PERF_EVENT_CACHE_MISSES, /* Cache misses by applications */
|
2016-12-07 10:57:36 +00:00
|
|
|
VIR_PERF_EVENT_BRANCH_INSTRUCTIONS, /* Count of branch instructions
|
|
|
|
for applications */
|
2016-12-11 13:30:11 +00:00
|
|
|
VIR_PERF_EVENT_BRANCH_MISSES, /* Count of branch misses for applications */
|
2016-12-13 16:01:38 +00:00
|
|
|
VIR_PERF_EVENT_BUS_CYCLES, /* Count of bus cycles for applications*/
|
2016-12-13 16:01:39 +00:00
|
|
|
VIR_PERF_EVENT_STALLED_CYCLES_FRONTEND, /* Count of stalled cpu cycles in
|
|
|
|
the frontend of the instruction
|
|
|
|
processor pipeline */
|
2016-12-13 16:01:40 +00:00
|
|
|
VIR_PERF_EVENT_STALLED_CYCLES_BACKEND, /* Count of stalled cpu cycles in
|
|
|
|
the backend of the instruction
|
|
|
|
processor pipeline */
|
2016-12-13 16:01:41 +00:00
|
|
|
VIR_PERF_EVENT_REF_CPU_CYCLES, /* Count of ref cpu cycles */
|
2017-02-23 14:55:30 +00:00
|
|
|
VIR_PERF_EVENT_CPU_CLOCK, /* Count of cpu clock time*/
|
2017-02-23 14:55:31 +00:00
|
|
|
VIR_PERF_EVENT_TASK_CLOCK, /* Count of task clock time*/
|
2017-02-23 14:55:32 +00:00
|
|
|
VIR_PERF_EVENT_PAGE_FAULTS, /* Count of total page faults */
|
2017-02-23 14:55:33 +00:00
|
|
|
VIR_PERF_EVENT_CONTEXT_SWITCHES, /* Count of context switches */
|
2017-02-23 14:55:34 +00:00
|
|
|
VIR_PERF_EVENT_CPU_MIGRATIONS, /* Count of cpu migrations */
|
2017-02-23 14:55:35 +00:00
|
|
|
VIR_PERF_EVENT_PAGE_FAULTS_MIN, /* Count of minor page faults */
|
2017-02-23 14:55:36 +00:00
|
|
|
VIR_PERF_EVENT_PAGE_FAULTS_MAJ, /* Count of major page faults */
|
2017-02-23 14:55:37 +00:00
|
|
|
VIR_PERF_EVENT_ALIGNMENT_FAULTS, /* Count of alignment faults */
|
2017-02-23 14:55:38 +00:00
|
|
|
VIR_PERF_EVENT_EMULATION_FAULTS, /* Count of emulation faults */
|
2016-07-16 08:15:12 +00:00
|
|
|
|
2016-03-28 13:30:28 +00:00
|
|
|
VIR_PERF_EVENT_LAST
|
|
|
|
} virPerfEventType;
|
|
|
|
|
|
|
|
VIR_ENUM_DECL(virPerfEvent);
|
|
|
|
|
2018-07-28 18:01:41 +00:00
|
|
|
struct _virPerf;
|
|
|
|
typedef struct _virPerf virPerf;
|
|
|
|
typedef virPerf *virPerfPtr;
|
2016-03-28 13:30:28 +00:00
|
|
|
|
|
|
|
virPerfPtr virPerfNew(void);
|
|
|
|
|
|
|
|
void virPerfFree(virPerfPtr perf);
|
|
|
|
|
|
|
|
int virPerfEventEnable(virPerfPtr perf,
|
|
|
|
virPerfEventType type,
|
|
|
|
pid_t pid);
|
|
|
|
|
|
|
|
int virPerfEventDisable(virPerfPtr perf,
|
|
|
|
virPerfEventType type);
|
|
|
|
|
|
|
|
bool virPerfEventIsEnabled(virPerfPtr perf,
|
|
|
|
virPerfEventType type);
|
|
|
|
|
|
|
|
int virPerfReadEvent(virPerfPtr perf,
|
|
|
|
virPerfEventType type,
|
|
|
|
uint64_t *value);
|
|
|
|
|
2019-02-07 17:18:52 +00:00
|
|
|
VIR_DEFINE_AUTOPTR_FUNC(virPerf, virPerfFree);
|