提交 a64c761c 编写于 作者: M Martin Kletzander

resctrl: Add functions to work with resctrl allocations

With this commit we finally have a way to read and manipulate basic resctrl
settings.  Locking is done only on exposed functions that read/write from/to
resctrlfs.  Not in functions that are exposed in virresctrlpriv.h as those are
only supposed to be used from tests.

More information about how resctrl works:

  https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/x86/intel_rdt_ui.txtSigned-off-by: NMartin Kletzander <mkletzan@redhat.com>
上级 434848d7
...@@ -167,7 +167,7 @@ UTIL_SOURCES = \ ...@@ -167,7 +167,7 @@ UTIL_SOURCES = \
util/virprocess.c util/virprocess.h \ util/virprocess.c util/virprocess.h \
util/virqemu.c util/virqemu.h \ util/virqemu.c util/virqemu.h \
util/virrandom.h util/virrandom.c \ util/virrandom.h util/virrandom.c \
util/virresctrl.h util/virresctrl.c \ util/virresctrl.h util/virresctrl.c util/virresctrlpriv.h \
util/virrotatingfile.h util/virrotatingfile.c \ util/virrotatingfile.h util/virrotatingfile.c \
util/virscsi.c util/virscsi.h \ util/virscsi.c util/virscsi.h \
util/virscsihost.c util/virscsihost.h \ util/virscsihost.c util/virscsihost.h \
......
...@@ -2552,6 +2552,16 @@ virRandomInt; ...@@ -2552,6 +2552,16 @@ virRandomInt;
# util/virresctrl.h # util/virresctrl.h
virCacheTypeFromString; virCacheTypeFromString;
virCacheTypeToString; virCacheTypeToString;
virResctrlAllocAddPID;
virResctrlAllocCreate;
virResctrlAllocForeachSize;
virResctrlAllocFormat;
virResctrlAllocGetID;
virResctrlAllocGetUnused;
virResctrlAllocNew;
virResctrlAllocRemove;
virResctrlAllocSetID;
virResctrlAllocSetSize;
virResctrlGetInfo; virResctrlGetInfo;
virResctrlInfoGetCache; virResctrlInfoGetCache;
virResctrlInfoNew; virResctrlInfoNew;
......
此差异已折叠。
...@@ -65,4 +65,53 @@ virResctrlInfoGetCache(virResctrlInfoPtr resctrl, ...@@ -65,4 +65,53 @@ virResctrlInfoGetCache(virResctrlInfoPtr resctrl,
size_t *ncontrols, size_t *ncontrols,
virResctrlInfoPerCachePtr **controls); virResctrlInfoPerCachePtr **controls);
/* Alloc-related things */
typedef struct _virResctrlAlloc virResctrlAlloc;
typedef virResctrlAlloc *virResctrlAllocPtr;
typedef int virResctrlAllocForeachSizeCallback(unsigned int level,
virCacheType type,
unsigned int cache,
unsigned long long size,
void *opaque);
virResctrlAllocPtr
virResctrlAllocNew(void);
bool
virResctrlAllocIsEmpty(virResctrlAllocPtr resctrl);
int
virResctrlAllocSetSize(virResctrlAllocPtr resctrl,
unsigned int level,
virCacheType type,
unsigned int cache,
unsigned long long size);
int
virResctrlAllocForeachSize(virResctrlAllocPtr resctrl,
virResctrlAllocForeachSizeCallback cb,
void *opaque);
int
virResctrlAllocSetID(virResctrlAllocPtr alloc,
const char *id);
const char *
virResctrlAllocGetID(virResctrlAllocPtr alloc);
char *
virResctrlAllocFormat(virResctrlAllocPtr alloc);
int
virResctrlAllocCreate(virResctrlInfoPtr r_info,
virResctrlAllocPtr alloc,
const char *machinename);
int
virResctrlAllocAddPID(virResctrlAllocPtr alloc,
pid_t pid);
int
virResctrlAllocRemove(virResctrlAllocPtr alloc);
#endif /* __VIR_RESCTRL_H__ */ #endif /* __VIR_RESCTRL_H__ */
/*
* virresctrlpriv.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/>.
*/
#ifndef __VIR_RESCTRL_PRIV_H__
# define __VIR_RESCTRL_PRIV_H__
# include "virresctrl.h"
virResctrlAllocPtr
virResctrlAllocGetUnused(virResctrlInfoPtr resctrl);
#endif /* __VIR_RESCTRL_PRIV_H__ */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册