From nobody Thu May 2 20:49:29 2024 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 151063648378042.442328860020666; Mon, 13 Nov 2017 21:14:43 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0DB486A7CB; Tue, 14 Nov 2017 05:14:41 +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 9F691183C1; Tue, 14 Nov 2017 05:14: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 9D9081800BDA; Tue, 14 Nov 2017 05:14:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vAE5EYh5029019 for ; Tue, 14 Nov 2017 00:14:34 -0500 Received: by smtp.corp.redhat.com (Postfix) id BB4B4174AC; Tue, 14 Nov 2017 05:14:34 +0000 (UTC) Received: from mx1.redhat.com (ext-mx09.extmail.prod.ext.phx2.redhat.com [10.5.110.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B45C5183DB for ; Tue, 14 Nov 2017 05:14:32 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 67EA4FC7D2 for ; Tue, 14 Nov 2017 05:14:31 +0000 (UTC) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id vAE5E4kl022038 for ; Tue, 14 Nov 2017 00:14:31 -0500 Received: from e06smtp15.uk.ibm.com (e06smtp15.uk.ibm.com [195.75.94.111]) by mx0b-001b2d01.pphosted.com with ESMTP id 2e7rfjv33a-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 14 Nov 2017 00:14:30 -0500 Received: from localhost by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 14 Nov 2017 05:14:29 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 14 Nov 2017 05:14:26 -0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id vAE5EQGB4981242; Tue, 14 Nov 2017 05:14:26 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 15AC14C04A; Tue, 14 Nov 2017 05:09:41 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E53E04C044; Tue, 14 Nov 2017 05:09:39 +0000 (GMT) Received: from dhcp-9-109-222-174.in.ibm.com (unknown [9.79.253.174]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 14 Nov 2017 05:09:39 +0000 (GMT) From: Nitesh Konkar To: libvir-list@redhat.com Date: Tue, 14 Nov 2017 10:44:19 +0530 X-TM-AS-GCONF: 00 x-cbid: 17111405-0020-0000-0000-000003CBF3E5 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17111405-0021-0000-0000-0000426121F5 Message-Id: <20171114051419.29894-1-niteshkonkar.libvirt@gmail.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-11-14_03:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=5 phishscore=0 bulkscore=0 spamscore=0 clxscore=1034 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1711140071 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 206 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 14 Nov 2017 05:14:31 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 14 Nov 2017 05:14:31 +0000 (UTC) for IP:'148.163.158.5' DOMAIN:'mx0b-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'niteshkonkar.libvirt@gmail.com' RCPT:'' X-RedHat-Spam-Score: -1.326 (DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_SOFTFAIL) 148.163.158.5 mx0b-001b2d01.pphosted.com 148.163.158.5 mx0b-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.38 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Nitesh Konkar , Nitesh Konkar Subject: [libvirt] [PATCH] virhostcpu: Report correct topolgy info on host with deconfigured core 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 14 Nov 2017 05:14:42 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The host which has a deconfigured core is treated as though the topology is not correct and the SMT is not reliable. Which is not true, so report the t= opology correctly by detecting if the host is actually in a proper SMT mode with the deconfigured core. Signed-off-by: Nitesh Konkar --- Steps to reproduce: This is what `virsh capabilities` shows in a=20 10-core POWER8 system (8 threads per core): $ virsh capabilities | grep threads There are 10 CPUs online, given SMT is off (`ppc64_cpu --smt=3Doff`): $ cat /sys/devices/system/cpu/online=20 0,8,16,24,32,40,48,56,64,72 Now, if one core is disabled/offlined (e.g., the last one, number 72)... $ echo 0 | sudo tee /sys/devices/system/cpu/cpu72/online=20 Then this messes up with `virsh capabilities` number of cores (now 80) and = threads (now 1) : $ virsh capabilities | grep threads It goes back to normal if that CPU is enabled/onlined again: $ echo 1 | sudo tee /sys/devices/system/cpu/cpu72/online=20 1 $ virsh capabilities | grep threads src/util/virhostcpu.c | 8 ++++++-- tests/virhostcpudata/linux-ppc64-deconf-cpus.expected | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c index c485a97..5301583 100644 --- a/src/util/virhostcpu.c +++ b/src/util/virhostcpu.c @@ -524,6 +524,7 @@ virHostCPUGetInfoPopulateLinux(FILE *cpuinfo, DIR *nodedir =3D NULL; struct dirent *nodedirent =3D NULL; int nodecpus, nodecores, nodesockets, nodethreads, offline =3D 0; + int total_online_cpus =3D 0; int threads_per_subcore =3D 0; unsigned int node; int ret =3D -1; @@ -623,6 +624,8 @@ virHostCPUGetInfoPopulateLinux(FILE *cpuinfo, if (!online_cpus_map) goto cleanup; =20 + total_online_cpus =3D virBitmapCountBits(online_cpus_map); + /* OK, we've parsed clock speed out of /proc/cpuinfo. Get the * core, node, socket, thread and topology information from /sys */ @@ -746,10 +749,11 @@ virHostCPUGetInfoPopulateLinux(FILE *cpuinfo, * the nodeinfo structure isn't designed to carry the full topology so * we're going to lie about the detected topology to notify the user * to check the host capabilities for the actual topology. */ - if ((*nodes * + if (((*nodes * *sockets * *cores * - *threads) !=3D (*cpus + offline)) { + *threads) !=3D (*cpus + offline)) && + ((total_online_cpus * threads_per_subcore) !=3D (*cpus + offline))= ) { *nodes =3D 1; *sockets =3D 1; *cores =3D *cpus + offline; diff --git a/tests/virhostcpudata/linux-ppc64-deconf-cpus.expected b/tests/= virhostcpudata/linux-ppc64-deconf-cpus.expected index 113bfa8..7998a8f 100644 --- a/tests/virhostcpudata/linux-ppc64-deconf-cpus.expected +++ b/tests/virhostcpudata/linux-ppc64-deconf-cpus.expected @@ -1 +1 @@ -CPUs: 80/80, MHz: 3690, Nodes: 1, Sockets: 1, Cores: 80, Threads: 1 +CPUs: 80/96, MHz: 3690, Nodes: 4, Sockets: 1, Cores: 3, Threads: 8 --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list