All of lore.kernel.org
 help / color / mirror / Atom feed
From: Igor Mammedov <imammedo@redhat.com>
To: qemu-devel@nongnu.org
Cc: David Gibson <david@gibson.dropbear.id.au>,
	Alexander Graf <agraf@suse.de>,
	qemu-ppc@nongnu.org
Subject: [Qemu-devel] [PATCH for-2.11 6/6] ppc: drop caching ObjectClass from PowerPCCPUAlias
Date: Thu, 24 Aug 2017 10:21:51 +0200	[thread overview]
Message-ID: <1503562911-2776-7-git-send-email-imammedo@redhat.com> (raw)
In-Reply-To: <1503562911-2776-1-git-send-email-imammedo@redhat.com>

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>
---
 target/ppc/cpu-models.h     |  1 -
 target/ppc/kvm.c            |  1 -
 target/ppc/translate_init.c | 26 ++------------------------
 3 files changed, 2 insertions(+), 26 deletions(-)

diff --git a/target/ppc/cpu-models.h b/target/ppc/cpu-models.h
index d748c68..e9c6015 100644
--- a/target/ppc/cpu-models.h
+++ b/target/ppc/cpu-models.h
@@ -31,7 +31,6 @@
 typedef struct PowerPCCPUAlias {
     const char *alias;
     const char *model;
-    ObjectClass *oc;
 } PowerPCCPUAlias;
 
 extern PowerPCCPUAlias ppc_cpu_aliases[];
diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
index 3f21190..995c2da 100644
--- a/target/ppc/kvm.c
+++ b/target/ppc/kvm.c
@@ -2488,7 +2488,6 @@ static int kvm_ppc_register_host_cpu_type(void)
             if (suffix) {
                 *suffix = 0;
             }
-            ppc_cpu_aliases[i].oc = oc;
             break;
         }
     }
diff --git a/target/ppc/translate_init.c b/target/ppc/translate_init.c
index ca9f1e3..c06f34b 100644
--- a/target/ppc/translate_init.c
+++ b/target/ppc/translate_init.c
@@ -10177,28 +10177,6 @@ PowerPCCPUClass *ppc_cpu_class_by_pvr_mask(uint32_t pvr)
     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)
 {
     char *cpu_model, *typename;
@@ -10310,7 +10288,7 @@ static void ppc_cpu_list_entry(gpointer data, gpointer user_data)
                       name, pcc->pvr);
     for (i = 0; ppc_cpu_aliases[i].alias != NULL; 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) {
             continue;
@@ -10390,7 +10368,7 @@ CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp)
         CpuDefinitionInfoList *entry;
         CpuDefinitionInfo *info;
 
-        oc = ppc_cpu_class_by_alias(alias);
+        oc = ppc_cpu_class_by_name(alias->model);
         if (oc == NULL) {
             continue;
         }
-- 
2.7.4

  parent reply	other threads:[~2017-08-24  8:22 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-24  8:21 [Qemu-devel] [PATCH for-2.11 0/6] ppc: cpu_model handling cleanups Igor Mammedov
2017-08-24  8:21 ` [Qemu-devel] [PATCH for-2.11 1/6] ppc: use macros to make cpu type name from string literal Igor Mammedov
2017-08-25  1:30   ` David Gibson
2017-08-25  7:28     ` Igor Mammedov
2017-08-25 13:24       ` David Gibson
2017-08-24  8:21 ` [Qemu-devel] [PATCH for-2.11 2/6] ppc: make cpu_model translation to type consistent Igor Mammedov
2017-08-25  1:38   ` David Gibson
2017-08-25  7:27     ` Igor Mammedov
2017-08-25  9:45       ` David Gibson
2017-08-25 11:40         ` Igor Mammedov
2017-08-25 13:28           ` David Gibson
2017-08-25 14:34             ` Igor Mammedov
2017-08-29  7:26               ` David Gibson
2017-08-24  8:21 ` [Qemu-devel] [PATCH for-2.11 3/6] ppc: make cpu alias point only to real cpu models Igor Mammedov
2017-08-25  1:40   ` David Gibson
2017-08-24  8:21 ` [Qemu-devel] [PATCH for-2.11 4/6] ppc: replace inter-function cyclic dependency/recurssion with 2 simple lookups Igor Mammedov
2017-08-25  4:12   ` David Gibson
2017-08-25  7:34     ` Igor Mammedov
2017-08-30  3:05       ` David Gibson
2017-08-30  6:16         ` Igor Mammedov
2017-08-24  8:21 ` [Qemu-devel] [PATCH for-2.11 5/6] ppc: simplify cpu model lookup by PVR Igor Mammedov
2017-08-25  4:16   ` David Gibson
2017-08-25  7:40     ` Igor Mammedov
2017-08-25  9:32       ` David Gibson
2017-08-25 11:41         ` Igor Mammedov
2017-08-30 10:50         ` Igor Mammedov
2017-08-31  5:54           ` David Gibson
2017-08-24  8:21 ` Igor Mammedov [this message]
2017-08-25  4:22   ` [Qemu-devel] [PATCH for-2.11 6/6] ppc: drop caching ObjectClass from PowerPCCPUAlias David Gibson
2017-08-25  7:49     ` Igor Mammedov
2017-08-29  7:30       ` David Gibson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1503562911-2776-7-git-send-email-imammedo@redhat.com \
    --to=imammedo@redhat.com \
    --cc=agraf@suse.de \
    --cc=david@gibson.dropbear.id.au \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.