2017-07-25 14:03:11 +00:00
|
|
|
/*
|
|
|
|
* virresctrl.h:
|
|
|
|
*
|
|
|
|
* 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
|
2017-07-25 14:03:11 +00:00
|
|
|
|
2019-06-18 16:13:08 +00:00
|
|
|
#include "internal.h"
|
2017-07-25 14:03:11 +00:00
|
|
|
|
2019-10-04 16:14:10 +00:00
|
|
|
#include "virobject.h"
|
2019-06-18 16:13:08 +00:00
|
|
|
#include "virbitmap.h"
|
|
|
|
#include "virenum.h"
|
2017-07-25 14:03:11 +00:00
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
VIR_CACHE_TYPE_BOTH,
|
|
|
|
VIR_CACHE_TYPE_CODE,
|
|
|
|
VIR_CACHE_TYPE_DATA,
|
|
|
|
|
|
|
|
VIR_CACHE_TYPE_LAST
|
|
|
|
} virCacheType;
|
|
|
|
|
|
|
|
VIR_ENUM_DECL(virCache);
|
2018-02-08 14:55:09 +00:00
|
|
|
VIR_ENUM_DECL(virCacheKernel);
|
2017-07-25 14:03:11 +00:00
|
|
|
|
2018-09-20 10:10:50 +00:00
|
|
|
typedef enum {
|
|
|
|
VIR_RESCTRL_MONITOR_TYPE_UNSUPPORT,
|
|
|
|
VIR_RESCTRL_MONITOR_TYPE_CACHE,
|
|
|
|
VIR_RESCTRL_MONITOR_TYPE_MEMBW,
|
|
|
|
|
|
|
|
VIR_RESCTRL_MONITOR_TYPE_LAST
|
|
|
|
} virResctrlMonitorType;
|
|
|
|
|
|
|
|
VIR_ENUM_DECL(virResctrlMonitorPrefix);
|
|
|
|
|
2017-07-25 14:03:11 +00:00
|
|
|
|
2017-11-20 09:23:04 +00:00
|
|
|
typedef struct _virResctrlInfoPerCache virResctrlInfoPerCache;
|
|
|
|
struct _virResctrlInfoPerCache {
|
2017-07-25 14:03:11 +00:00
|
|
|
/* Smallest possible increase of the allocation size in bytes */
|
|
|
|
unsigned long long granularity;
|
|
|
|
/* Minimal allocatable size in bytes (if different from granularity) */
|
|
|
|
unsigned long long min;
|
|
|
|
/* Type of the allocation */
|
|
|
|
virCacheType scope;
|
|
|
|
/* Maximum number of simultaneous allocations */
|
|
|
|
unsigned int max_allocation;
|
|
|
|
};
|
|
|
|
|
2018-07-30 03:12:41 +00:00
|
|
|
typedef struct _virResctrlInfoMemBWPerNode virResctrlInfoMemBWPerNode;
|
|
|
|
struct _virResctrlInfoMemBWPerNode {
|
|
|
|
/* Smallest possible increase of the allocation bandwidth in percentage */
|
|
|
|
unsigned int granularity;
|
|
|
|
/* Minimal allocatable bandwidth in percentage */
|
|
|
|
unsigned int min;
|
|
|
|
/* Maximum number of simultaneous allocations */
|
|
|
|
unsigned int max_allocation;
|
|
|
|
};
|
|
|
|
|
2018-09-20 10:10:50 +00:00
|
|
|
typedef struct _virResctrlInfoMon virResctrlInfoMon;
|
|
|
|
struct _virResctrlInfoMon {
|
|
|
|
/* Maximum number of simultaneous monitors */
|
|
|
|
unsigned int max_monitor;
|
|
|
|
/* null-terminal string list for monitor features */
|
|
|
|
char **features;
|
|
|
|
/* Number of monitor features */
|
|
|
|
size_t nfeatures;
|
|
|
|
/* Monitor type */
|
|
|
|
virResctrlMonitorType type;
|
|
|
|
/* This adjustable value affects the final reuse of resources used by
|
|
|
|
* monitor. After the action of removing a monitor, the kernel may not
|
|
|
|
* release all hardware resources that monitor used immediately if the
|
|
|
|
* cache occupancy value associated with 'removed' monitor is above this
|
|
|
|
* threshold. Once the cache occupancy is below this threshold, the
|
|
|
|
* underlying hardware resource will be reclaimed and be put into the
|
|
|
|
* resource pool for next reusing.*/
|
|
|
|
unsigned int cache_reuse_threshold;
|
|
|
|
/* The cache 'level' that has the monitor capability */
|
|
|
|
unsigned int cache_level;
|
|
|
|
};
|
|
|
|
|
2017-11-20 10:12:06 +00:00
|
|
|
typedef struct _virResctrlInfo virResctrlInfo;
|
2017-07-25 14:03:11 +00:00
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
virResctrlInfo *
|
2017-11-20 10:12:06 +00:00
|
|
|
virResctrlInfoNew(void);
|
|
|
|
|
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virResctrlInfoGetCache(virResctrlInfo *resctrl,
|
2017-11-20 10:12:06 +00:00
|
|
|
unsigned int level,
|
|
|
|
unsigned long long size,
|
|
|
|
size_t *ncontrols,
|
2021-03-11 07:16:13 +00:00
|
|
|
virResctrlInfoPerCache ***controls);
|
2017-11-20 10:12:06 +00:00
|
|
|
|
2018-07-30 03:12:41 +00:00
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virResctrlInfoGetMemoryBandwidth(virResctrlInfo *resctrl,
|
2018-07-30 03:12:41 +00:00
|
|
|
unsigned int level,
|
2021-03-11 07:16:13 +00:00
|
|
|
virResctrlInfoMemBWPerNode *control);
|
2017-10-16 15:17:32 +00:00
|
|
|
/* Alloc-related things */
|
|
|
|
typedef struct _virResctrlAlloc virResctrlAlloc;
|
|
|
|
|
2019-10-04 16:14:10 +00:00
|
|
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virResctrlAlloc, virObjectUnref);
|
|
|
|
|
|
|
|
|
2018-07-30 03:12:25 +00:00
|
|
|
typedef int virResctrlAllocForeachCacheCallback(unsigned int level,
|
|
|
|
virCacheType type,
|
|
|
|
unsigned int cache,
|
|
|
|
unsigned long long size,
|
|
|
|
void *opaque);
|
2017-10-16 15:17:32 +00:00
|
|
|
|
2018-07-30 03:12:33 +00:00
|
|
|
typedef int virResctrlAllocForeachMemoryCallback(unsigned int id,
|
|
|
|
unsigned int size,
|
|
|
|
void *opaque);
|
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
virResctrlAlloc *
|
2017-10-16 15:17:32 +00:00
|
|
|
virResctrlAllocNew(void);
|
|
|
|
|
|
|
|
bool
|
2021-03-11 07:16:13 +00:00
|
|
|
virResctrlAllocIsEmpty(virResctrlAlloc *alloc);
|
2017-10-16 15:17:32 +00:00
|
|
|
|
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virResctrlAllocSetCacheSize(virResctrlAlloc *alloc,
|
2018-07-30 03:12:25 +00:00
|
|
|
unsigned int level,
|
|
|
|
virCacheType type,
|
|
|
|
unsigned int cache,
|
|
|
|
unsigned long long size);
|
2017-10-16 15:17:32 +00:00
|
|
|
|
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virResctrlAllocForeachCache(virResctrlAlloc *alloc,
|
2018-07-30 03:12:25 +00:00
|
|
|
virResctrlAllocForeachCacheCallback cb,
|
|
|
|
void *opaque);
|
2017-10-16 15:17:32 +00:00
|
|
|
|
2018-07-30 03:12:34 +00:00
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virResctrlAllocSetMemoryBandwidth(virResctrlAlloc *alloc,
|
2018-07-30 03:12:34 +00:00
|
|
|
unsigned int id,
|
|
|
|
unsigned int memory_bandwidth);
|
|
|
|
|
2018-07-30 03:12:33 +00:00
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virResctrlAllocForeachMemory(virResctrlAlloc *alloc,
|
2018-07-30 03:12:33 +00:00
|
|
|
virResctrlAllocForeachMemoryCallback cb,
|
|
|
|
void *opaque);
|
|
|
|
|
2017-10-16 15:17:32 +00:00
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virResctrlAllocSetID(virResctrlAlloc *alloc,
|
2017-10-16 15:17:32 +00:00
|
|
|
const char *id);
|
|
|
|
const char *
|
2021-03-11 07:16:13 +00:00
|
|
|
virResctrlAllocGetID(virResctrlAlloc *alloc);
|
2017-10-16 15:17:32 +00:00
|
|
|
|
|
|
|
char *
|
2021-03-11 07:16:13 +00:00
|
|
|
virResctrlAllocFormat(virResctrlAlloc *alloc);
|
2017-10-16 15:17:32 +00:00
|
|
|
|
2018-01-30 22:57:42 +00:00
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virResctrlAllocDeterminePath(virResctrlAlloc *alloc,
|
2018-01-30 22:57:42 +00:00
|
|
|
const char *machinename);
|
|
|
|
|
2017-10-16 15:17:32 +00:00
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virResctrlAllocCreate(virResctrlInfo *r_info,
|
|
|
|
virResctrlAlloc *alloc,
|
2017-10-16 15:17:32 +00:00
|
|
|
const char *machinename);
|
|
|
|
|
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virResctrlAllocAddPID(virResctrlAlloc *alloc,
|
2017-10-16 15:17:32 +00:00
|
|
|
pid_t pid);
|
|
|
|
|
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virResctrlAllocRemove(virResctrlAlloc *alloc);
|
2017-10-16 15:17:32 +00:00
|
|
|
|
2018-09-20 10:10:50 +00:00
|
|
|
void
|
2021-03-11 07:16:13 +00:00
|
|
|
virResctrlInfoMonFree(virResctrlInfoMon *mon);
|
2018-09-20 10:10:50 +00:00
|
|
|
|
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virResctrlInfoGetMonitorPrefix(virResctrlInfo *resctrl,
|
2018-09-20 10:10:50 +00:00
|
|
|
const char *prefix,
|
2021-03-11 07:16:13 +00:00
|
|
|
virResctrlInfoMon **monitor);
|
2018-11-12 13:31:33 +00:00
|
|
|
|
|
|
|
/* Monitor-related things */
|
|
|
|
|
|
|
|
typedef struct _virResctrlMonitor virResctrlMonitor;
|
|
|
|
|
2018-11-12 13:31:41 +00:00
|
|
|
typedef struct _virResctrlMonitorStats virResctrlMonitorStats;
|
|
|
|
struct _virResctrlMonitorStats {
|
2019-06-11 03:31:13 +00:00
|
|
|
/* The system assigned cache ID associated with statistical record */
|
|
|
|
unsigned int id;
|
|
|
|
/* @features is a NULL terminal string list tracking the statistical record
|
|
|
|
* name.*/
|
|
|
|
char **features;
|
|
|
|
/* @vals store the statistical record values and @val[0] is the value for
|
|
|
|
* @features[0], @val[1] for@features[1] ... respectively */
|
2020-01-02 10:45:04 +00:00
|
|
|
unsigned long long *vals;
|
2019-06-11 03:31:13 +00:00
|
|
|
/* The length of @vals array */
|
|
|
|
size_t nvals;
|
2018-11-12 13:31:41 +00:00
|
|
|
};
|
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
virResctrlMonitor *
|
2018-11-12 13:31:33 +00:00
|
|
|
virResctrlMonitorNew(void);
|
2018-11-12 13:31:35 +00:00
|
|
|
|
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virResctrlMonitorDeterminePath(virResctrlMonitor *monitor,
|
2018-11-12 13:31:35 +00:00
|
|
|
const char *machinename);
|
2018-11-12 13:31:37 +00:00
|
|
|
|
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virResctrlMonitorAddPID(virResctrlMonitor *monitor,
|
2018-11-12 13:31:37 +00:00
|
|
|
pid_t pid);
|
2018-11-12 13:31:39 +00:00
|
|
|
|
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virResctrlMonitorCreate(virResctrlMonitor *monitor,
|
2018-11-12 13:31:39 +00:00
|
|
|
const char *machinename);
|
2018-11-12 13:31:41 +00:00
|
|
|
|
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virResctrlMonitorSetID(virResctrlMonitor *monitor,
|
2018-11-12 13:31:41 +00:00
|
|
|
const char *id);
|
|
|
|
|
|
|
|
const char *
|
2021-03-11 07:16:13 +00:00
|
|
|
virResctrlMonitorGetID(virResctrlMonitor *monitor);
|
2018-11-12 13:31:41 +00:00
|
|
|
|
|
|
|
void
|
2021-03-11 07:16:13 +00:00
|
|
|
virResctrlMonitorSetAlloc(virResctrlMonitor *monitor,
|
|
|
|
virResctrlAlloc *alloc);
|
2018-11-12 13:31:41 +00:00
|
|
|
|
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virResctrlMonitorRemove(virResctrlMonitor *monitor);
|
2018-11-12 13:31:41 +00:00
|
|
|
|
2019-06-11 03:31:14 +00:00
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virResctrlMonitorGetStats(virResctrlMonitor *monitor,
|
2019-06-11 03:31:14 +00:00
|
|
|
const char **resources,
|
2021-03-11 07:16:13 +00:00
|
|
|
virResctrlMonitorStats ***stats,
|
2019-06-11 03:31:14 +00:00
|
|
|
size_t *nstats);
|
|
|
|
|
2018-11-26 17:56:15 +00:00
|
|
|
void
|
2021-03-11 07:16:13 +00:00
|
|
|
virResctrlMonitorStatsFree(virResctrlMonitorStats *stats);
|