virperf.h 3.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
/*
 * 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/>.
 *
 * Authors:
 *  Ren Qiaowei <qiaowei.ren@intel.com>
 */

#ifndef __VIR_PERF_H__
# define __VIR_PERF_H__

# include "virutil.h"

27 28 29
/* 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. */
30
typedef enum {
31 32 33
    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 */
34

35
    VIR_PERF_EVENT_CPU_CYCLES,       /* Count of CPU Cycles (total/elapsed) */
Q
Qiaowei Ren 已提交
36 37 38
    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 */
39 40
    VIR_PERF_EVENT_BRANCH_INSTRUCTIONS, /* Count of branch instructions
                                           for applications */
41
    VIR_PERF_EVENT_BRANCH_MISSES,  /* Count of branch misses for applications */
42
    VIR_PERF_EVENT_BUS_CYCLES,       /* Count of bus cycles for applications*/
43 44 45
    VIR_PERF_EVENT_STALLED_CYCLES_FRONTEND, /* Count of stalled cpu cycles in
                                               the frontend of the instruction
                                               processor pipeline */
46 47 48
    VIR_PERF_EVENT_STALLED_CYCLES_BACKEND, /* Count of stalled cpu cycles in
                                              the backend of the instruction
                                              processor pipeline */
49
    VIR_PERF_EVENT_REF_CPU_CYCLES,   /* Count of ref cpu cycles */
50
    VIR_PERF_EVENT_CPU_CLOCK,   /* Count of cpu clock time*/
51
    VIR_PERF_EVENT_TASK_CLOCK,   /* Count of task clock time*/
52
    VIR_PERF_EVENT_PAGE_FAULTS,   /* Count of total page faults */
53
    VIR_PERF_EVENT_CONTEXT_SWITCHES,   /* Count of context switches */
54
    VIR_PERF_EVENT_CPU_MIGRATIONS,   /* Count of cpu migrations */
55
    VIR_PERF_EVENT_PAGE_FAULTS_MIN,   /* Count of minor page faults */
56
    VIR_PERF_EVENT_PAGE_FAULTS_MAJ,   /* Count of major page faults */
Q
Qiaowei Ren 已提交
57

58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
    VIR_PERF_EVENT_LAST
} virPerfEventType;

VIR_ENUM_DECL(virPerfEvent);

struct virPerf;
typedef struct virPerf *virPerfPtr;

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);

#endif /* __VIR_PERF_H__ */