mirror of https://gitee.com/openkylin/qemu.git
ppc: drop caching ObjectClass from PowerPCCPUAlias
Caching there practically doesn't give any benefits and that at slow path druring querying supported CPU list. But it introduces non conventional path of where from comes used CPU type name (kvm_ppc_register_host_cpu_type). Taking in account that kvm_ppc_register_host_cpu_type() fixes up models the aliases point to, it's sufficient to make ppc_cpu_class_by_name() translate cpu alias to correct cpu type name. So drop PowerPCCPUAlias::oc field + ppc_cpu_class_by_alias() and let ppc_cpu_class_by_name() do conversion to cpu type name, which simplifies code a little bit saving ~20LOC and trouble wondering why ppc_cpu_class_by_alias() is necessary. Signed-off-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
b376db7775
commit
2527cb9109
|
@ -31,7 +31,6 @@
|
||||||
typedef struct PowerPCCPUAlias {
|
typedef struct PowerPCCPUAlias {
|
||||||
const char *alias;
|
const char *alias;
|
||||||
const char *model;
|
const char *model;
|
||||||
ObjectClass *oc;
|
|
||||||
} PowerPCCPUAlias;
|
} PowerPCCPUAlias;
|
||||||
|
|
||||||
extern PowerPCCPUAlias ppc_cpu_aliases[];
|
extern PowerPCCPUAlias ppc_cpu_aliases[];
|
||||||
|
|
|
@ -2533,7 +2533,6 @@ static int kvm_ppc_register_host_cpu_type(void)
|
||||||
if (suffix) {
|
if (suffix) {
|
||||||
*suffix = 0;
|
*suffix = 0;
|
||||||
}
|
}
|
||||||
ppc_cpu_aliases[i].oc = oc;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10253,28 +10253,6 @@ PowerPCCPUClass *ppc_cpu_class_by_pvr_mask(uint32_t pvr)
|
||||||
return pcc;
|
return pcc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ObjectClass *ppc_cpu_class_by_name(const char *name);
|
|
||||||
|
|
||||||
static ObjectClass *ppc_cpu_class_by_alias(PowerPCCPUAlias *alias)
|
|
||||||
{
|
|
||||||
ObjectClass *invalid_class = (void*)ppc_cpu_class_by_alias;
|
|
||||||
|
|
||||||
/* Cache target class lookups in the alias table */
|
|
||||||
if (!alias->oc) {
|
|
||||||
alias->oc = ppc_cpu_class_by_name(alias->model);
|
|
||||||
if (!alias->oc) {
|
|
||||||
/* Fast check for non-existing aliases */
|
|
||||||
alias->oc = invalid_class;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (alias->oc == invalid_class) {
|
|
||||||
return NULL;
|
|
||||||
} else {
|
|
||||||
return alias->oc;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static ObjectClass *ppc_cpu_class_by_name(const char *name)
|
static ObjectClass *ppc_cpu_class_by_name(const char *name)
|
||||||
{
|
{
|
||||||
char *cpu_model, *typename;
|
char *cpu_model, *typename;
|
||||||
|
@ -10386,7 +10364,7 @@ static void ppc_cpu_list_entry(gpointer data, gpointer user_data)
|
||||||
name, pcc->pvr);
|
name, pcc->pvr);
|
||||||
for (i = 0; ppc_cpu_aliases[i].alias != NULL; i++) {
|
for (i = 0; ppc_cpu_aliases[i].alias != NULL; i++) {
|
||||||
PowerPCCPUAlias *alias = &ppc_cpu_aliases[i];
|
PowerPCCPUAlias *alias = &ppc_cpu_aliases[i];
|
||||||
ObjectClass *alias_oc = ppc_cpu_class_by_alias(alias);
|
ObjectClass *alias_oc = ppc_cpu_class_by_name(alias->model);
|
||||||
|
|
||||||
if (alias_oc != oc) {
|
if (alias_oc != oc) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -10466,7 +10444,7 @@ CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp)
|
||||||
CpuDefinitionInfoList *entry;
|
CpuDefinitionInfoList *entry;
|
||||||
CpuDefinitionInfo *info;
|
CpuDefinitionInfo *info;
|
||||||
|
|
||||||
oc = ppc_cpu_class_by_alias(alias);
|
oc = ppc_cpu_class_by_name(alias->model);
|
||||||
if (oc == NULL) {
|
if (oc == NULL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue