{"id":807637,"url":"http://patchwork.ozlabs.org/api/1.0/patches/807637/?format=json","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/1.0/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<1504099475-241036-8-git-send-email-imammedo@redhat.com>","date":"2017-08-30T13:24:34","name":"[v2,7/8] ppc: drop caching ObjectClass from PowerPCCPUAlias","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"095243ac288243fb85fd85294aee5062a9408a47","submitter":{"id":11305,"url":"http://patchwork.ozlabs.org/api/1.0/people/11305/?format=json","name":"Igor Mammedov","email":"imammedo@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/1504099475-241036-8-git-send-email-imammedo@redhat.com/mbox/","series":[{"id":612,"url":"http://patchwork.ozlabs.org/api/1.0/series/612/?format=json","date":"2017-08-30T13:24:29","name":"ppc: cpu_model handling cleanups","version":2,"mbox":"http://patchwork.ozlabs.org/series/612/mbox/"}],"check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/807637/checks/","tags":{},"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ext-mx01.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx01.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=imammedo@redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xj5x35MyJz9sN7\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 30 Aug 2017 23:30:47 +1000 (AEST)","from localhost ([::1]:50597 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dn34v-0006e0-Fo\n\tfor incoming@patchwork.ozlabs.org; Wed, 30 Aug 2017 09:30:45 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:51002)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <imammedo@redhat.com>) id 1dn2zB-0001pl-6o\n\tfor qemu-devel@nongnu.org; Wed, 30 Aug 2017 09:24:55 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <imammedo@redhat.com>) id 1dn2zA-0003aB-Am\n\tfor qemu-devel@nongnu.org; Wed, 30 Aug 2017 09:24:49 -0400","from mx1.redhat.com ([209.132.183.28]:48842)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <imammedo@redhat.com>)\n\tid 1dn2zA-0003ZH-1v; Wed, 30 Aug 2017 09:24:48 -0400","from smtp.corp.redhat.com\n\t(int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 14FC981226;\n\tWed, 30 Aug 2017 13:24:47 +0000 (UTC)","from dell-r430-03.lab.eng.brq.redhat.com\n\t(dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 17CCA9B519;\n\tWed, 30 Aug 2017 13:24:45 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 14FC981226","From":"Igor Mammedov <imammedo@redhat.com>","To":"qemu-devel@nongnu.org","Date":"Wed, 30 Aug 2017 15:24:34 +0200","Message-Id":"<1504099475-241036-8-git-send-email-imammedo@redhat.com>","In-Reply-To":"<1504099475-241036-1-git-send-email-imammedo@redhat.com>","References":"<1504099475-241036-1-git-send-email-imammedo@redhat.com>","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.12","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.25]);\n\tWed, 30 Aug 2017 13:24:47 +0000 (UTC)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","Subject":"[Qemu-devel] [PATCH v2 7/8] ppc: drop caching ObjectClass from\n\tPowerPCCPUAlias","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"qemu-ppc@nongnu.org, Alexander Graf <agraf@suse.de>,\n\tDavid Gibson <david@gibson.dropbear.id.au>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"},"content":"Caching there practically doesn't give any benefits\nand that at slow path druring querying supported CPU list.\nBut it introduces non conventional path of where from\ncomes used CPU type name (kvm_ppc_register_host_cpu_type).\n\nTaking in account that kvm_ppc_register_host_cpu_type()\nfixes up models the aliases point to, it's sufficient to\nmake ppc_cpu_class_by_name() translate cpu alias to\ncorrect cpu type name.\nSo drop PowerPCCPUAlias::oc field + ppc_cpu_class_by_alias()\nand let ppc_cpu_class_by_name() do conversion to cpu type name,\nwhich simplifies code a little bit saving ~20LOC and trouble\nwondering why ppc_cpu_class_by_alias() is necessary.\n\nSigned-off-by: Igor Mammedov <imammedo@redhat.com>\n---\n target/ppc/cpu-models.h     |  1 -\n target/ppc/kvm.c            |  1 -\n target/ppc/translate_init.c | 26 ++------------------------\n 3 files changed, 2 insertions(+), 26 deletions(-)","diff":"diff --git a/target/ppc/cpu-models.h b/target/ppc/cpu-models.h\nindex d748c68..e9c6015 100644\n--- a/target/ppc/cpu-models.h\n+++ b/target/ppc/cpu-models.h\n@@ -31,7 +31,6 @@\n typedef struct PowerPCCPUAlias {\n     const char *alias;\n     const char *model;\n-    ObjectClass *oc;\n } PowerPCCPUAlias;\n \n extern PowerPCCPUAlias ppc_cpu_aliases[];\ndiff --git a/target/ppc/kvm.c b/target/ppc/kvm.c\nindex d185ef9..6870e6f 100644\n--- a/target/ppc/kvm.c\n+++ b/target/ppc/kvm.c\n@@ -2496,7 +2496,6 @@ static int kvm_ppc_register_host_cpu_type(void)\n             if (suffix) {\n                 *suffix = 0;\n             }\n-            ppc_cpu_aliases[i].oc = oc;\n             break;\n         }\n     }\ndiff --git a/target/ppc/translate_init.c b/target/ppc/translate_init.c\nindex a803a7f..963c4f3 100644\n--- a/target/ppc/translate_init.c\n+++ b/target/ppc/translate_init.c\n@@ -10177,28 +10177,6 @@ PowerPCCPUClass *ppc_cpu_class_by_pvr_mask(uint32_t pvr)\n     return pcc;\n }\n \n-static ObjectClass *ppc_cpu_class_by_name(const char *name);\n-\n-static ObjectClass *ppc_cpu_class_by_alias(PowerPCCPUAlias *alias)\n-{\n-    ObjectClass *invalid_class = (void*)ppc_cpu_class_by_alias;\n-\n-    /* Cache target class lookups in the alias table */\n-    if (!alias->oc) {\n-        alias->oc = ppc_cpu_class_by_name(alias->model);\n-        if (!alias->oc) {\n-            /* Fast check for non-existing aliases */\n-            alias->oc = invalid_class;\n-        }\n-    }\n-\n-    if (alias->oc == invalid_class) {\n-        return NULL;\n-    } else {\n-        return alias->oc;\n-    }\n-}\n-\n static ObjectClass *ppc_cpu_class_by_name(const char *name)\n {\n     char *cpu_model, *typename;\n@@ -10310,7 +10288,7 @@ static void ppc_cpu_list_entry(gpointer data, gpointer user_data)\n                       name, pcc->pvr);\n     for (i = 0; ppc_cpu_aliases[i].alias != NULL; i++) {\n         PowerPCCPUAlias *alias = &ppc_cpu_aliases[i];\n-        ObjectClass *alias_oc = ppc_cpu_class_by_alias(alias);\n+        ObjectClass *alias_oc = ppc_cpu_class_by_name(alias->model);\n \n         if (alias_oc != oc) {\n             continue;\n@@ -10390,7 +10368,7 @@ CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp)\n         CpuDefinitionInfoList *entry;\n         CpuDefinitionInfo *info;\n \n-        oc = ppc_cpu_class_by_alias(alias);\n+        oc = ppc_cpu_class_by_name(alias->model);\n         if (oc == NULL) {\n             continue;\n         }\n","prefixes":["v2","7/8"]}