mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
cpu_ppc64: Avoid repeated loading of CPU map
The ppc64 CPU code still has to load and parse the CPU map everytime it needs to look at it, which can make some operations pretty slow. Other archs already switched to loading the CPU map once and keeping the parsed structure in memory. Let's switch ppc64 as well. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
f0554d88fb
commit
0cc8e87520
@ -53,6 +53,12 @@ struct _ppc64_map {
|
|||||||
struct _ppc64_model **models;
|
struct _ppc64_model **models;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static virCPUppc64Map *cpuMap;
|
||||||
|
|
||||||
|
int virCPUppc64DriverOnceInit(void);
|
||||||
|
VIR_ONCE_GLOBAL_INIT(virCPUppc64Driver);
|
||||||
|
|
||||||
|
|
||||||
/* Convert a legacy CPU definition by transforming
|
/* Convert a legacy CPU definition by transforming
|
||||||
* model names to generation names:
|
* model names to generation names:
|
||||||
* POWER7_v2.1 => POWER7
|
* POWER7_v2.1 => POWER7
|
||||||
@ -365,8 +371,8 @@ ppc64ModelParse(xmlXPathContextPtr ctxt,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static struct _ppc64_map *
|
static virCPUppc64Map *
|
||||||
ppc64LoadMap(void)
|
virCPUppc64LoadMap(void)
|
||||||
{
|
{
|
||||||
g_autoptr(virCPUppc64Map) map = NULL;
|
g_autoptr(virCPUppc64Map) map = NULL;
|
||||||
|
|
||||||
@ -378,12 +384,33 @@ ppc64LoadMap(void)
|
|||||||
return g_steal_pointer(&map);
|
return g_steal_pointer(&map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
virCPUppc64DriverOnceInit(void)
|
||||||
|
{
|
||||||
|
if (!(cpuMap = virCPUppc64LoadMap()))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static virCPUppc64Map *
|
||||||
|
virCPUppc64GetMap(void)
|
||||||
|
{
|
||||||
|
if (virCPUppc64DriverInitialize() < 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return cpuMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static virCPUCompareResult
|
static virCPUCompareResult
|
||||||
ppc64Compute(virCPUDef *host,
|
ppc64Compute(virCPUDef *host,
|
||||||
const virCPUDef *other,
|
const virCPUDef *other,
|
||||||
char **message)
|
char **message)
|
||||||
{
|
{
|
||||||
g_autoptr(virCPUppc64Map) map = NULL;
|
virCPUppc64Map *map = NULL;
|
||||||
g_autoptr(virCPUppc64Model) host_model = NULL;
|
g_autoptr(virCPUppc64Model) host_model = NULL;
|
||||||
g_autoptr(virCPUppc64Model) guest_model = NULL;
|
g_autoptr(virCPUppc64Model) guest_model = NULL;
|
||||||
g_autoptr(virCPUDef) cpu = NULL;
|
g_autoptr(virCPUDef) cpu = NULL;
|
||||||
@ -428,7 +455,7 @@ ppc64Compute(virCPUDef *host,
|
|||||||
return VIR_CPU_COMPARE_INCOMPATIBLE;
|
return VIR_CPU_COMPARE_INCOMPATIBLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(map = ppc64LoadMap()))
|
if (!(map = virCPUppc64GetMap()))
|
||||||
return VIR_CPU_COMPARE_ERROR;
|
return VIR_CPU_COMPARE_ERROR;
|
||||||
|
|
||||||
/* Host CPU information */
|
/* Host CPU information */
|
||||||
@ -526,10 +553,10 @@ ppc64DriverDecode(virCPUDef *cpu,
|
|||||||
const virCPUData *data,
|
const virCPUData *data,
|
||||||
virDomainCapsCPUModels *models)
|
virDomainCapsCPUModels *models)
|
||||||
{
|
{
|
||||||
g_autoptr(virCPUppc64Map) map = NULL;
|
virCPUppc64Map *map = NULL;
|
||||||
const virCPUppc64Model *model;
|
const virCPUppc64Model *model;
|
||||||
|
|
||||||
if (!data || !(map = ppc64LoadMap()))
|
if (!data || !(map = virCPUppc64GetMap()))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!(model = ppc64ModelFindPVR(map, data->data.ppc64.pvr[0].value))) {
|
if (!(model = ppc64ModelFindPVR(map, data->data.ppc64.pvr[0].value))) {
|
||||||
@ -656,13 +683,13 @@ virCPUppc64Baseline(virCPUDef **cpus,
|
|||||||
const char **features G_GNUC_UNUSED,
|
const char **features G_GNUC_UNUSED,
|
||||||
bool migratable G_GNUC_UNUSED)
|
bool migratable G_GNUC_UNUSED)
|
||||||
{
|
{
|
||||||
g_autoptr(virCPUppc64Map) map = NULL;
|
virCPUppc64Map *map = NULL;
|
||||||
const virCPUppc64Model *model;
|
const virCPUppc64Model *model;
|
||||||
const virCPUppc64Vendor *vendor = NULL;
|
const virCPUppc64Vendor *vendor = NULL;
|
||||||
g_autoptr(virCPUDef) cpu = NULL;
|
g_autoptr(virCPUDef) cpu = NULL;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
if (!(map = ppc64LoadMap()))
|
if (!(map = virCPUppc64GetMap()))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!(model = ppc64ModelFind(map, cpus[0]->model))) {
|
if (!(model = ppc64ModelFind(map, cpus[0]->model))) {
|
||||||
@ -737,10 +764,10 @@ virCPUppc64Baseline(virCPUDef **cpus,
|
|||||||
static int
|
static int
|
||||||
virCPUppc64DriverGetModels(char ***models)
|
virCPUppc64DriverGetModels(char ***models)
|
||||||
{
|
{
|
||||||
g_autoptr(virCPUppc64Map) map = NULL;
|
virCPUppc64Map *map = NULL;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
if (!(map = ppc64LoadMap()))
|
if (!(map = virCPUppc64GetMap()))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (models) {
|
if (models) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user