From nobody Fri May 3 03:01:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1598275774; cv=none; d=zohomail.com; s=zohoarc; b=dBEV+piOuY5CED6ZvNsmqcxUvzJLfoSwZGq3AcVpOKLVCMkOhhNqrQcGbLSFewnUCvPq1dJ6/7S/EfrSB1hl/QabcN8iD4xFTnC6C3lYM1ooPTRecA/OiENHkLj+JaXON35AE1R/OZqIVBafjwITIGdxhN9I1AAW4ZySoaW/tx0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598275774; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Wu+3jk2TDRA5SNORcW9osNfseY8UpsPSvD4I+Ob8y4A=; b=CFRsICjKU8irDpOTyITG4bFWuhlR+PdAwf/ULdR6XZl6k2FUqURhq31y9noMc2dA0tZlYIGc+K8rWjALjccTSJKpRMkL7NdSd3dZFweakXGIkF6fVSzxsVYrcA29zDsXGEVFrGutNfmadJ8oXJ2NpVh9xCBEj2NiKplK9w/Rcgk= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1598275774230917.5140528597983; Mon, 24 Aug 2020 06:29:34 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-140-bltRxL38PpuiknVrOnmvYA-1; Mon, 24 Aug 2020 09:29:30 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1D78F81F015; Mon, 24 Aug 2020 13:29:25 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E979A100EBA5; Mon, 24 Aug 2020 13:29:24 +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 B93DE6691E; Mon, 24 Aug 2020 13:29:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 07ODSAhx010562 for ; Mon, 24 Aug 2020 09:28:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id 319F82166B44; Mon, 24 Aug 2020 13:28:10 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2D31E2166BA4 for ; Mon, 24 Aug 2020 13:28:06 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6A0C5888BEB for ; Mon, 24 Aug 2020 13:28:06 +0000 (UTC) Received: from mail-qk1-f196.google.com (mail-qk1-f196.google.com [209.85.222.196]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-110-HZOw8HKjP16VfikN_HQBEg-1; Mon, 24 Aug 2020 09:28:03 -0400 Received: by mail-qk1-f196.google.com with SMTP id n129so7312914qkd.6 for ; Mon, 24 Aug 2020 06:28:03 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c7:c152:8180:e1dd:d6ac:1152]) by smtp.gmail.com with ESMTPSA id v2sm11122860qte.25.2020.08.24.06.28.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Aug 2020 06:28:02 -0700 (PDT) X-MC-Unique: bltRxL38PpuiknVrOnmvYA-1 X-MC-Unique: HZOw8HKjP16VfikN_HQBEg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Wu+3jk2TDRA5SNORcW9osNfseY8UpsPSvD4I+Ob8y4A=; b=bRKZAJa705uhvvMpyylVi0FmJRKQ0BtXVYuIu3mmLdMArVlp6y0dlYpQLP3NxUBYzv AEsv9Q/etQOFoaVkWOBxsWQPwydi6lp5G1Uoas6WO5oqVBpgWPqPNqAHwSG9jXLeK1oU CMm7OQ5DuiUu5/Jm8FMYLoH/ikoxPlNSerx+hBTWuu8JKdyMveYtufQkqYjZ9vq1PdwF 83jlJ0IA1jNYjN+9YFyLJqa9vUzdoXMoaYi2J8iGHHQKM1ZcJ6R25CdN96uFhzRqJ5NB nKzzziLjX5q+bZd43VVQwKsuz6bIQee2aPyGJnB+lo/6o96IHBwqe4lYjfGIR2FhfrrZ ASYw== X-Gm-Message-State: AOAM53185AAGSh9XHRq1ww++OrzBHQJPb+eGn4hxgXoDLwdtgbUHwaus lJCdzu6sgk4I9m1lUcddg5LrsSgCVlI= X-Google-Smtp-Source: ABdhPJwyRl6hfGCrl98r/LPwqwS/veCAWgZ6BQXo8r/H6NreVTYqBwhjiBTXSNlO2/AUp7SK9zYCNA== X-Received: by 2002:a05:620a:1122:: with SMTP id p2mr4878719qkk.45.1598275682619; Mon, 24 Aug 2020 06:28:02 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH 1/3] virhostcpu.c: modernize virHostCPUGetMicrocodeVersion() Date: Mon, 24 Aug 2020 10:27:52 -0300 Message-Id: <20200824132754.130453-2-danielhb413@gmail.com> In-Reply-To: <20200824132754.130453-1-danielhb413@gmail.com> References: <20200824132754.130453-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false; X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use g_autofree and remove the cleanup label. Signed-off-by: Daniel Henrique Barboza Reviewed-by: J=C3=A1n Tomko --- src/util/virhostcpu.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c index 6cea75536d..d7aa39c131 100644 --- a/src/util/virhostcpu.c +++ b/src/util/virhostcpu.c @@ -1241,7 +1241,7 @@ virHostCPUGetKVMMaxVCPUs(void) unsigned int virHostCPUGetMicrocodeVersion(void) { - char *outbuf =3D NULL; + g_autofree char *outbuf =3D NULL; char *cur; unsigned int version =3D 0; =20 @@ -1254,16 +1254,14 @@ virHostCPUGetMicrocodeVersion(void) /* Account for format 'microcode : XXXX'*/ if (!(cur =3D strstr(outbuf, "microcode")) || !(cur =3D strchr(cur, ':'))) - goto cleanup; + return 0; cur++; =20 /* Linux places the microcode revision in a 32-bit integer, so * ui is fine for us too. */ if (virStrToLong_ui(cur, &cur, 0, &version) < 0) - goto cleanup; + return 0; =20 - cleanup: - VIR_FREE(outbuf); return version; } =20 --=20 2.26.2 From nobody Fri May 3 03:01:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1598275732; cv=none; d=zohomail.com; s=zohoarc; b=Z0f+w7gW/LXm8D9qhTwgqsE9sRYa0eaRDYnhbfTEM0tHFfZAQ+TwwIMCQ4F/bWXWZN1bnyLYjOWff5gCEUWML4W2l9wtpHPnF9rOg9DgSY3TEEJDVsi4gKL+RFZIKeE3lJLpSChnYmqUrpQ15PtT6e5aw8DZRfOxYUXuVYwcX50= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598275732; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4dyzWR9cQvy7TRFWCYBQGYrIBUIFb3ff0sdMClfrhs4=; b=fsAvnDqbj7XU0ZBf8pkaek1MKmKsF7WIyv98f+24fer9hFGdMm7QVlxaaaiHTIWw9TOj8YLkl5bHWlBdFSwehO6T/7/6V8bFb67hrY3TfnqtAQzI+CVzc8VqmXXWgObpZgeUG4mp3KnrKcJMWhtOhJqneDdou8Iuf+7UGeNIwLo= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 159827573265355.54645607430621; Mon, 24 Aug 2020 06:28:52 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-28-O-kWrtwCPvSrxt0g4gfyfQ-1; Mon, 24 Aug 2020 09:28:49 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A1DB510887A1; Mon, 24 Aug 2020 13:28:39 +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 47E697F463; Mon, 24 Aug 2020 13:28:39 +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 DDB4918A0B66; Mon, 24 Aug 2020 13:28:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 07ODSCF2010587 for ; Mon, 24 Aug 2020 09:28:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id A21AE202279B; Mon, 24 Aug 2020 13:28:12 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9D84C20227B1 for ; Mon, 24 Aug 2020 13:28:08 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1CEFA811E8D for ; Mon, 24 Aug 2020 13:28:08 +0000 (UTC) Received: from mail-qk1-f196.google.com (mail-qk1-f196.google.com [209.85.222.196]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-302-0j0UhKTSNsmKgKhR7ZHWiw-1; Mon, 24 Aug 2020 09:28:04 -0400 Received: by mail-qk1-f196.google.com with SMTP id p4so7324284qkf.0 for ; Mon, 24 Aug 2020 06:28:04 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c7:c152:8180:e1dd:d6ac:1152]) by smtp.gmail.com with ESMTPSA id v2sm11122860qte.25.2020.08.24.06.28.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Aug 2020 06:28:03 -0700 (PDT) X-MC-Unique: O-kWrtwCPvSrxt0g4gfyfQ-1 X-MC-Unique: 0j0UhKTSNsmKgKhR7ZHWiw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4dyzWR9cQvy7TRFWCYBQGYrIBUIFb3ff0sdMClfrhs4=; b=GZ6sqTFJIBMGoM0Lga5sRMl1nhvqhPr+F1Vy+J9s8MZT2zNo9Blrujec7KTEwBukVS vG4mQlGIhrSC/cGUrT9s17/tZYZ/hcGLYt+ubixdJhmduN/c5wsm24HVfnTGKieMDAhN jl4LRbA8xBEYETTdWLC5rOomdduAt1geE5hKZY5FSprmQ+LEN3tQuaDJuXNMIQ3YgWEx zmOFI+2hBKgRvHvBfkx8WWlPaVvvYF9SaMn+RdUGxufors5F5KK9/2pGOiPcyfLluXdd v/2/LjvLSFGTg+pMQ6N0oDR7+f816u3NtTKtxsGqgAJG5IQUKd9DDab3X08wnAebircQ hNHQ== X-Gm-Message-State: AOAM532UuZAyGrZlJEv/cPKGSfrnAOjyxjik7ltqcKTFMsOJfkA7q1yw 2DuKhEQtIJcaZtJRJb521jSC00GT9u8= X-Google-Smtp-Source: ABdhPJwTPN9bU/FnPWX3LzgCNuxPgMzsmR0EhWaC9PjrC4kd2EIMgJuHrVz/Ixa3BHCCBOKYg/IsuQ== X-Received: by 2002:a05:620a:11a6:: with SMTP id c6mr4475186qkk.209.1598275684182; Mon, 24 Aug 2020 06:28:04 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH 2/3] virhostcpu.c: skip non x86 hosts in virHostCPUGetMicrocodeVersion() Date: Mon, 24 Aug 2020 10:27:53 -0300 Message-Id: <20200824132754.130453-3-danielhb413@gmail.com> In-Reply-To: <20200824132754.130453-1-danielhb413@gmail.com> References: <20200824132754.130453-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false; X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Non-x86 archs does not have a 'microcode' version like x86. This is covered already inside the function - just return 0 if no microcode is found. Regardless of that, a read of /proc/cpuinfo is always made. Each read will invoke the kernel to fill in the CPU details every time. Now let's consider a non-x86 host, like a Power 9 server with 128 CPUs. Each /proc/cpuinfo read will need to fetch data for each CPU and it won't even matter because we know beforehand that PowerPC chips don't have microcode information. We can do better for non-x86 hosts by skipping this process entirely. Signed-off-by: Daniel Henrique Barboza Reviewed-by: J=C3=A1n Tomko --- src/cpu/cpu_x86.c | 2 +- src/qemu/qemu_capabilities.c | 4 ++-- src/util/virhostcpu.c | 5 ++++- src/util/virhostcpu.h | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 1e5cd93abb..aa982589be 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -2759,7 +2759,7 @@ virCPUx86GetHost(virCPUDefPtr cpu, } =20 ret =3D x86DecodeCPUData(cpu, cpuData, models); - cpu->microcodeVersion =3D virHostCPUGetMicrocodeVersion(); + cpu->microcodeVersion =3D virHostCPUGetMicrocodeVersion(cpuData->arch); =20 /* Probing for TSC frequency makes sense only if the CPU supports * invariant TSC (Linux calls this constant_tsc in /proc/cpuinfo). */ diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index ff6ba8c9e9..da743ecbe0 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -5502,7 +5502,7 @@ virQEMUCapsNewData(const char *binary, priv->runUid, priv->runGid, priv->hostCPUSignature, - virHostCPUGetMicrocodeVersion(), + virHostCPUGetMicrocodeVersion(p= riv->hostArch), priv->kernelVersion); } =20 @@ -5636,7 +5636,7 @@ virQEMUCapsCacheLookup(virFileCachePtr cache, virQEMUCapsCachePrivPtr priv =3D virFileCacheGetPriv(cache); virQEMUCapsPtr ret =3D NULL; =20 - priv->microcodeVersion =3D virHostCPUGetMicrocodeVersion(); + priv->microcodeVersion =3D virHostCPUGetMicrocodeVersion(priv->hostArc= h); =20 ret =3D virFileCacheLookup(cache, binary); =20 diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c index d7aa39c131..aafc3a14c6 100644 --- a/src/util/virhostcpu.c +++ b/src/util/virhostcpu.c @@ -1239,12 +1239,15 @@ virHostCPUGetKVMMaxVCPUs(void) * some reason. */ unsigned int -virHostCPUGetMicrocodeVersion(void) +virHostCPUGetMicrocodeVersion(virArch hostArch) { g_autofree char *outbuf =3D NULL; char *cur; unsigned int version =3D 0; =20 + if (!ARCH_IS_X86(hostArch)) + return 0; + if (virFileReadHeaderQuiet(CPUINFO_PATH, 4096, &outbuf) < 0) { VIR_DEBUG("Failed to read microcode version from %s: %s", CPUINFO_PATH, g_strerror(errno)); diff --git a/src/util/virhostcpu.h b/src/util/virhostcpu.h index d07503857e..11cbcd72a3 100644 --- a/src/util/virhostcpu.h +++ b/src/util/virhostcpu.h @@ -75,7 +75,7 @@ virBitmapPtr virHostCPUGetSiblingsList(unsigned int cpu); =20 int virHostCPUGetOnline(unsigned int cpu, bool *online); =20 -unsigned int virHostCPUGetMicrocodeVersion(void); +unsigned int virHostCPUGetMicrocodeVersion(virArch hostArch); =20 int virHostCPUGetMSR(unsigned long index, uint64_t *msr); --=20 2.26.2 From nobody Fri May 3 03:01:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1598275731; cv=none; d=zohomail.com; s=zohoarc; b=Zs35VMMqnTHniuaNBy4lA7VrnHyQWFWXbIMcxpCbLVFgNJAYpEUjaBnsnjNJUH7SufJystsCN/t8wlKncTdhB5eHsXiELDx/2CpeugHnw1L+X3kc75oXCmJAqtVhfn885BUAgzPX4Zty0h+dCzDjrbS1Ep/feiPF1kXafQ0Sius= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598275731; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=26kVfsAK465ErgG917131GI/n7HlumMtQXSiLZYyNQ8=; b=nPAiUhi2pJ2TLcDbtJJT+FfJDuFSIVL0epqdIROy0U3XpLyBUA8ft4aK2KEtr++GHXsPP3yWjxTC/FuQa19KuEm/KHo160JdRzDPT62kLlJReGM+PiCSng85wvWV6f5OOewEqcY3LY8LGiC4z9eqk3D4D1IH1svIm89eMWLaVns= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1598275731862512.6125283668819; Mon, 24 Aug 2020 06:28:51 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-336-DL5706U4NRG3jziWzCSVgQ-1; Mon, 24 Aug 2020 09:28:48 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CA93D89A07D; Mon, 24 Aug 2020 13:28:16 +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 4BB4E1001B2B; Mon, 24 Aug 2020 13:28:16 +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 E236118A0B64; Mon, 24 Aug 2020 13:28:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 07ODSBkb010574 for ; Mon, 24 Aug 2020 09:28:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id 83AA62166B44; Mon, 24 Aug 2020 13:28:11 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7F7DB2166BA3 for ; Mon, 24 Aug 2020 13:28:11 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 661F4811E8E for ; Mon, 24 Aug 2020 13:28:11 +0000 (UTC) Received: from mail-qk1-f195.google.com (mail-qk1-f195.google.com [209.85.222.195]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-221-i0aG_4YQMZqmuKxnKaa1dA-1; Mon, 24 Aug 2020 09:28:06 -0400 Received: by mail-qk1-f195.google.com with SMTP id z3so3016053qkz.7 for ; Mon, 24 Aug 2020 06:28:06 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c7:c152:8180:e1dd:d6ac:1152]) by smtp.gmail.com with ESMTPSA id v2sm11122860qte.25.2020.08.24.06.28.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Aug 2020 06:28:05 -0700 (PDT) X-MC-Unique: DL5706U4NRG3jziWzCSVgQ-1 X-MC-Unique: i0aG_4YQMZqmuKxnKaa1dA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=26kVfsAK465ErgG917131GI/n7HlumMtQXSiLZYyNQ8=; b=uAaa3+P1hHbt+EIjLvnfaqscCKsEW9tSOY+hNzk3AahFs9iYpsKGvL1HOA79MS197F 3TvrrkyHKIQeTzSE12qK33VUylCBBFO9EIYAkb2cHlRYyLhH5Kygg0wPPU0dmZU2UFTj gMA38gWKm9JD67bRoUF30lM8b3vj7ABogjZzhlV48UR55yck1r94FeIaAxqrMcuBbV56 GVdGSg+cjksl1ZL9xGd8sLAM0l2oo1VIfCBZTGV3WgCKnfWi49NwzMkRXgYVKaJ7u30U Qpmy0rLFtA03nKX1z8M9FgtpRsUAjJHR5zcoOCVyGqea1BLSjhyAU1pMXOrxH0P9mzYt 50EA== X-Gm-Message-State: AOAM533ewyd9wxF9z1Lgq9PqXtz3viN++sFjYZjZjLPHG+MO9FU8cR8Y tq6cSpX629PD6vNozRlSKvW9oaJblOI= X-Google-Smtp-Source: ABdhPJyuVIJ8E0pDiwtuL8Ns2jukx/W34tABiFhBpuazmnkhMMgT5nl3sNWWLd/r48UuO1hwbYI6FA== X-Received: by 2002:a05:620a:13f7:: with SMTP id h23mr4758029qkl.396.1598275685718; Mon, 24 Aug 2020 06:28:05 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH 3/3] domaincapsmoc.c: mock virHostCPUGetMicrocodeVersion() Date: Mon, 24 Aug 2020 10:27:54 -0300 Message-Id: <20200824132754.130453-4-danielhb413@gmail.com> In-Reply-To: <20200824132754.130453-1-danielhb413@gmail.com> References: <20200824132754.130453-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false; X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Previous patch handled the runtime case where a non-x86 host is fetching /proc/cpuinfo data for a microcode info that we know it doesn't exist. This change alone speeded everything by a bit for non-x86, but there is at least one major culprit left. qemuxml2argvtest does several arch-specific tests, and a good chunk of them are x86 exclusive. This means that 'hostArch' will be seen as x86 for these tests, even when running in non-x86 hosts. In a Power 9 server with 128 CPUs, qemuxmlargvtest takes 298 seconds to complete in average, and 'perf record' indicates that 95% of the time is spent in virHostCPUGetMicrocodeVersion(). This patch mocks virHostCPUGetMicrocodeVersion() to always return 0 in the tests, avoiding /proc/cpuinfo reads. This will make all tests behave arch-agnostic, and the microcode value being 0 has no impact on any existing test. This is a CI speed across the board for all archs, including x86, given that we're not reading /proc/cpuinfo in the tests. For a Thinkpad T480 laptop with 8 Intel i7 CPUs, qemuxml2argvtest went from 15.50 sec to 12.50 seconds. The performance gain is even more noticeable for huge servers with lots of CPUs. For the Power 9 server mentioned above, this patch speeds qemuxml2argvtest to 9 seconds, down from 298 sec. Signed-off-by: Daniel Henrique Barboza Reviewed-by: J=C3=A1n Tomko --- src/util/virhostcpu.h | 3 ++- tests/domaincapsmock.c | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/util/virhostcpu.h b/src/util/virhostcpu.h index 11cbcd72a3..6148f9e66f 100644 --- a/src/util/virhostcpu.h +++ b/src/util/virhostcpu.h @@ -75,7 +75,8 @@ virBitmapPtr virHostCPUGetSiblingsList(unsigned int cpu); =20 int virHostCPUGetOnline(unsigned int cpu, bool *online); =20 -unsigned int virHostCPUGetMicrocodeVersion(virArch hostArch); +unsigned int +virHostCPUGetMicrocodeVersion(virArch hostArch) G_GNUC_NO_INLINE; =20 int virHostCPUGetMSR(unsigned long index, uint64_t *msr); diff --git a/tests/domaincapsmock.c b/tests/domaincapsmock.c index 90e17c19f0..d81a898dc0 100644 --- a/tests/domaincapsmock.c +++ b/tests/domaincapsmock.c @@ -34,3 +34,9 @@ virHostCPUGetKVMMaxVCPUs(void) { return INT_MAX; } + +unsigned int +virHostCPUGetMicrocodeVersion(virArch hostArch G_GNUC_UNUSED) +{ + return 0; +} --=20 2.26.2