From nobody Thu May 15 06:09:42 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1513254872653169.57508882403124; Thu, 14 Dec 2017 04:34:32 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7E57080B22; Thu, 14 Dec 2017 12:34:27 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 578A571910; Thu, 14 Dec 2017 12:34:27 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 1650C1801214; Thu, 14 Dec 2017 12:34:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vBECYPR1011160 for ; Thu, 14 Dec 2017 07:34:25 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0AE0560A9D; Thu, 14 Dec 2017 12:34:25 +0000 (UTC) Received: from inaba.usersys.redhat.com (ovpn-204-182.brq.redhat.com [10.40.204.182]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3DB137D927 for ; Thu, 14 Dec 2017 12:34:22 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Thu, 14 Dec 2017 13:34:01 +0100 Message-Id: <20171214123401.28950-6-abologna@redhat.com> In-Reply-To: <20171214123401.28950-1-abologna@redhat.com> References: <20171214123401.28950-1-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 5/5] util: Don't report CPU frequency for ARM hosts X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 14 Dec 2017 12:34:28 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Some ARM platforms, such as the original Raspberry Pi, report the CPU frequency in the BogoMIPS field of /proc/cpuinfo, so libvirt parsed that field and returned it through its API. However, not only many more boards don't report any value there, but several - including ARMv8-based server hardware, and even the more recent Raspberry Pi 3 - use this field as originally intended: to report the BogoMIPS value instead of the CPU frequency. Since we have no way of detecting how the field is being used, it's better to report no information at all rather than something ludicrous like "your shiny 96-core aarch64 virtualization host's CPUs are running at a whopping 100 MHz". Signed-off-by: Andrea Bolognani Reviewed-by: John Ferlan --- src/util/virhostcpu.c | 6 ++++-- tests/virhostcpudata/linux-aarch64-rhel74-moonshot.expected | 2 +- tests/virhostcpudata/linux-armv6l-raspberrypi.expected | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c index 9c9f362de..1c9ee5921 100644 --- a/src/util/virhostcpu.c +++ b/src/util/virhostcpu.c @@ -590,12 +590,14 @@ virHostCPUParseFrequency(FILE *cpuinfo, const char *prefix =3D NULL; char line[1024]; =20 + /* No sensible way to retrieve CPU frequency */ + if (ARCH_IS_ARM(arch)) + return 0; + if (ARCH_IS_X86(arch)) prefix =3D "cpu MHz"; else if (ARCH_IS_PPC(arch)) prefix =3D "clock"; - else if (ARCH_IS_ARM(arch)) - prefix =3D "BogoMIPS"; =20 if (!prefix) { VIR_WARN("%s is not supported by the %s parser", diff --git a/tests/virhostcpudata/linux-aarch64-rhel74-moonshot.expected b/= tests/virhostcpudata/linux-aarch64-rhel74-moonshot.expected index 24ff0ea0b..6776aa6c2 100644 --- a/tests/virhostcpudata/linux-aarch64-rhel74-moonshot.expected +++ b/tests/virhostcpudata/linux-aarch64-rhel74-moonshot.expected @@ -1 +1 @@ -CPUs: 8/8, MHz: 100, Nodes: 1, Sockets: 1, Cores: 8, Threads: 1 +CPUs: 8/8, MHz: 0, Nodes: 1, Sockets: 1, Cores: 8, Threads: 1 diff --git a/tests/virhostcpudata/linux-armv6l-raspberrypi.expected b/tests= /virhostcpudata/linux-armv6l-raspberrypi.expected index 146bd073e..1c4c713d5 100644 --- a/tests/virhostcpudata/linux-armv6l-raspberrypi.expected +++ b/tests/virhostcpudata/linux-armv6l-raspberrypi.expected @@ -1 +1 @@ -CPUs: 1/1, MHz: 697, Nodes: 1, Sockets: 1, Cores: 1, Threads: 1 +CPUs: 1/1, MHz: 0, Nodes: 1, Sockets: 1, Cores: 1, Threads: 1 --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list