From nobody Sun May 5 21:29:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1528304229141858.2830350308782; Wed, 6 Jun 2018 09:57:09 -0700 (PDT) Received: from localhost ([::1]:53599 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQbkC-0005SZ-CP for importer@patchew.org; Wed, 06 Jun 2018 12:57:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39182) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQbig-0004bv-9y for qemu-devel@nongnu.org; Wed, 06 Jun 2018 12:55:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQbic-0003we-Tu for qemu-devel@nongnu.org; Wed, 06 Jun 2018 12:55:34 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:60848 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fQbic-0003wO-N9 for qemu-devel@nongnu.org; Wed, 06 Jun 2018 12:55:30 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3B4C411F7A9; Wed, 6 Jun 2018 16:55:30 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5DECC2017D15; Wed, 6 Jun 2018 16:55:29 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Date: Wed, 6 Jun 2018 17:55:25 +0100 Message-Id: <20180606165527.17365-2-berrange@redhat.com> In-Reply-To: <20180606165527.17365-1-berrange@redhat.com> References: <20180606165527.17365-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Wed, 06 Jun 2018 16:55:30 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Wed, 06 Jun 2018 16:55:30 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'berrange@redhat.com' RCPT:'' Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 1/3] i386: improve alignment of CPU model listing X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Eduardo Habkost , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Since the addition of the -IBRS CPU model variants, the descriptions shown by '-cpu help' are not well aligned, as several model names overflow the space allowed. Right aligning the CPU model names is also not attractive, because it obscures the common name prefixes of many models. The CPU model name field needs to be 4 characters larger, and be left aligned instead. Signed-off-by: Daniel P. Berrang=C3=A9 --- target/i386/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 94260412e2..aa4d9949b4 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -3206,7 +3206,7 @@ static void x86_cpu_list_entry(gpointer data, gpointe= r user_data) desc =3D cc->cpu_def->model_id; } =20 - (*s->cpu_fprintf)(s->file, "x86 %16s %-48s\n", + (*s->cpu_fprintf)(s->file, "x86 %-20s %-48s\n", name, desc); g_free(name); } --=20 2.17.0 From nobody Sun May 5 21:29:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1528304229051819.9906166679633; Wed, 6 Jun 2018 09:57:09 -0700 (PDT) Received: from localhost ([::1]:53598 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQbkC-0005SX-2h for importer@patchew.org; Wed, 06 Jun 2018 12:57:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39185) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQbig-0004bx-Am for qemu-devel@nongnu.org; Wed, 06 Jun 2018 12:55:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQbie-0003xF-4i for qemu-devel@nongnu.org; Wed, 06 Jun 2018 12:55:34 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:53804 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fQbid-0003wv-QJ for qemu-devel@nongnu.org; Wed, 06 Jun 2018 12:55:31 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4D77B4023155; Wed, 6 Jun 2018 16:55:31 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 70F622024CCB; Wed, 6 Jun 2018 16:55:30 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Date: Wed, 6 Jun 2018 17:55:26 +0100 Message-Id: <20180606165527.17365-3-berrange@redhat.com> In-Reply-To: <20180606165527.17365-1-berrange@redhat.com> References: <20180606165527.17365-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 06 Jun 2018 16:55:31 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 06 Jun 2018 16:55:31 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'berrange@redhat.com' RCPT:'' Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 2/3] i386: improve sorting of CPU model names X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Eduardo Habkost , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The current list of CPU model names output by "-cpu help" is sorted alphabetically based on the internal QOM class name. The text that is displayed, however, uses the CPU model name, which is equivalent to the QOM class name, minus a suffix. Unfortunately that suffix has an effect on the sort ordering, for example, causing the various Broadwell variants to appear reversed: x86 486 x86 Broadwell-IBRS Intel Core Processor (Broadwell, IBRS) x86 Broadwell-noTSX-IBRS Intel Core Processor (Broadwell, no TSX, IBRS x86 Broadwell-noTSX Intel Core Processor (Broadwell, no TSX) x86 Broadwell Intel Core Processor (Broadwell) x86 Conroe Intel Celeron_4x0 (Conroe/Merom Class Core 2) By sorting on the actual CPU model name text that is displayed, the result is x86 486 x86 Broadwell Intel Core Processor (Broadwell) x86 Broadwell-IBRS Intel Core Processor (Broadwell, IBRS) x86 Broadwell-noTSX Intel Core Processor (Broadwell, no TSX) x86 Broadwell-noTSX-IBRS Intel Core Processor (Broadwell, no TSX, IBRS) x86 Conroe Intel Celeron_4x0 (Conroe/Merom Class Core 2) This requires extra string allocations during sorting, but this is not a concern given the usage scenario and the number of CPU models that exist. Signed-off-by: Daniel P. Berrang=C3=A9 --- target/i386/cpu.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index aa4d9949b4..cb074082b3 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -3177,15 +3177,19 @@ static gint x86_cpu_list_compare(gconstpointer a, g= constpointer b) ObjectClass *class_b =3D (ObjectClass *)b; X86CPUClass *cc_a =3D X86_CPU_CLASS(class_a); X86CPUClass *cc_b =3D X86_CPU_CLASS(class_b); - const char *name_a, *name_b; + char *name_a, *name_b; + int ret; =20 if (cc_a->ordering !=3D cc_b->ordering) { - return cc_a->ordering - cc_b->ordering; + ret =3D cc_a->ordering - cc_b->ordering; } else { - name_a =3D object_class_get_name(class_a); - name_b =3D object_class_get_name(class_b); - return strcmp(name_a, name_b); + name_a =3D x86_cpu_class_get_model_name(cc_a); + name_b =3D x86_cpu_class_get_model_name(cc_b); + ret =3D strcmp(name_a, name_b); + g_free(name_a); + g_free(name_b); } + return ret; } =20 static GSList *get_sorted_cpu_model_list(void) --=20 2.17.0 From nobody Sun May 5 21:29:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1528304314939559.5611708859509; Wed, 6 Jun 2018 09:58:34 -0700 (PDT) Received: from localhost ([::1]:53605 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQbla-0006dp-9w for importer@patchew.org; Wed, 06 Jun 2018 12:58:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39186) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQbig-0004by-BE for qemu-devel@nongnu.org; Wed, 06 Jun 2018 12:55:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQbif-0003yg-2Q for qemu-devel@nongnu.org; Wed, 06 Jun 2018 12:55:34 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:34936 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fQbie-0003xU-Ru for qemu-devel@nongnu.org; Wed, 06 Jun 2018 12:55:33 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5E53B81ACA85; Wed, 6 Jun 2018 16:55:32 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 81C7F2024CCB; Wed, 6 Jun 2018 16:55:31 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Date: Wed, 6 Jun 2018 17:55:27 +0100 Message-Id: <20180606165527.17365-4-berrange@redhat.com> In-Reply-To: <20180606165527.17365-1-berrange@redhat.com> References: <20180606165527.17365-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 06 Jun 2018 16:55:32 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 06 Jun 2018 16:55:32 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'berrange@redhat.com' RCPT:'' Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 3/3] i386: display known CPUID features linewrapped, in alphabetical order X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Eduardo Habkost , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" When using '-cpu help' the list of CPUID features is grouped according to the internal low level CPUID grouping. The data printed results in very long lines too. This combines to make it hard for users to read the output and identify if QEMU knows about the feature they wish to use. This change gets rid of the grouping of features and treats all flags as single list. The list is sorted into alphabetical order and the printing with line wrapping at the 77th column. Signed-off-by: Daniel P. Berrang=C3=A9 --- target/i386/cpu.c | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index cb074082b3..8043e41be8 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -3157,17 +3157,21 @@ static void x86_cpu_class_check_missing_features(X8= 6CPUClass *xcc, =20 /* Print all cpuid feature names in featureset */ -static void listflags(FILE *f, fprintf_function print, const char **featur= eset) +static void listflags(FILE *f, fprintf_function print, GList *features) { - int bit; - bool first =3D true; - - for (bit =3D 0; bit < 32; bit++) { - if (featureset[bit]) { - print(f, "%s%s", first ? "" : " ", featureset[bit]); - first =3D false; + size_t len =3D 0; + GList *tmp; + + for (tmp =3D features; tmp; tmp =3D tmp->next) { + const char *name =3D tmp->data; + if ((len + strlen(name) + 1) >=3D 75) { + print(f, "\n"); + len =3D 0; } + print(f, "%s%s", len =3D=3D 0 ? " " : " ", name); + len +=3D strlen(name) + 1; } + print(f, "\n"); } =20 /* Sort alphabetically by type name, respecting X86CPUClass::ordering. */ @@ -3218,26 +3222,35 @@ static void x86_cpu_list_entry(gpointer data, gpoin= ter user_data) /* list available CPU models and flags */ void x86_cpu_list(FILE *f, fprintf_function cpu_fprintf) { - int i; + int i, j; CPUListState s =3D { .file =3D f, .cpu_fprintf =3D cpu_fprintf, }; GSList *list; + GList *names =3D NULL; =20 (*cpu_fprintf)(f, "Available CPUs:\n"); list =3D get_sorted_cpu_model_list(); g_slist_foreach(list, x86_cpu_list_entry, &s); g_slist_free(list); =20 - (*cpu_fprintf)(f, "\nRecognized CPUID flags:\n"); + names =3D NULL; for (i =3D 0; i < ARRAY_SIZE(feature_word_info); i++) { FeatureWordInfo *fw =3D &feature_word_info[i]; - - (*cpu_fprintf)(f, " "); - listflags(f, cpu_fprintf, fw->feat_names); - (*cpu_fprintf)(f, "\n"); + for (j =3D 0; j < 32; j++) { + if (fw->feat_names[j]) { + names =3D g_list_append(names, (gpointer)fw->feat_names[j]= ); + } + } } + + names =3D g_list_sort(names, (GCompareFunc)strcmp); + + (*cpu_fprintf)(f, "\nRecognized CPUID flags:\n"); + listflags(f, cpu_fprintf, names); + (*cpu_fprintf)(f, "\n"); + g_list_free(names); } =20 static void x86_cpu_definition_entry(gpointer data, gpointer user_data) --=20 2.17.0