From nobody Wed Apr 24 19:48:07 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 ARC-Seal: i=1; a=rsa-sha256; t=1562869764; cv=none; d=zoho.com; s=zohoarc; b=T0iLNBUrDh45L2t9mIQsKbdA9lKodCdocTIldjErgmxQLjgPBFGDPGPgZi/MEQbCiAL3jMIUCfjhuD+B4JjhHcIYmXXwFXPsxxWUJivM2Dnbaos7PwkRBVIBU6yXUcFd2r2Tq6MJZyf6P16BbX6OKrqOXIXcIoxL9g0TqAyDUz0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562869764; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=KRxHv3qK911uzXfzKNci4Yg3HlJthyNZ9EZVmPWvYPs=; b=f2KOehNWFBdJLaPcJ3oOkn7kSk6XEe9S7C72iZ07ztEGwwzKYyS1Sku70psfYcivwg1KM0wdCJvHCYyPcOCDIz7OLcIE97hMnldDiWbZbnZ2bbMGOH3fRa6fxXO4s5jWyJlahDmwg5kaCQJ8g/d0mXRl2HC9PkK+dIDIrPK5rH4= ARC-Authentication-Results: i=1; mx.zoho.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 1562869764394534.554772240928; Thu, 11 Jul 2019 11:29:24 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EAE9030C0DCC; Thu, 11 Jul 2019 18:29:21 +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 0BE8919C7F; Thu, 11 Jul 2019 18:29:20 +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 0B4DB4EBC8; Thu, 11 Jul 2019 18:29:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6BITFvk021202 for ; Thu, 11 Jul 2019 14:29:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id DF77A5C232; Thu, 11 Jul 2019 18:29:15 +0000 (UTC) Received: from mx1.redhat.com (ext-mx13.extmail.prod.ext.phx2.redhat.com [10.5.110.42]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DA1AE5C1B4 for ; Thu, 11 Jul 2019 18:29:12 +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 F031C3082133 for ; Thu, 11 Jul 2019 18:29:03 +0000 (UTC) Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x6BGorAx106212 for ; Thu, 11 Jul 2019 12:51:07 -0400 Received: from ppma01dal.us.ibm.com (83.d6.3fa9.ip4.static.sl-reverse.com [169.63.214.131]) by mx0a-001b2d01.pphosted.com with ESMTP id 2tp7cmvp4s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 11 Jul 2019 12:50:59 -0400 Received: from pps.filterd (ppma01dal.us.ibm.com [127.0.0.1]) by ppma01dal.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id x6BGjNKN012615 for ; Thu, 11 Jul 2019 16:47:30 GMT Received: from b01cxnp23034.gho.pok.ibm.com (b01cxnp23034.gho.pok.ibm.com [9.57.198.29]) by ppma01dal.us.ibm.com with ESMTP id 2tjk97nea6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 11 Jul 2019 16:47:30 +0000 Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x6BGlT9l53805538 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Jul 2019 16:47:29 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3B909AE05C; Thu, 11 Jul 2019 16:47:29 +0000 (GMT) Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 02402AE060; Thu, 11 Jul 2019 16:47:28 +0000 (GMT) Received: from astrid.austin.ibm.com (unknown [9.41.179.165]) by b01ledav005.gho.pok.ibm.com (Postfix) with ESMTP; Thu, 11 Jul 2019 16:47:28 +0000 (GMT) From: Scott Cheloha To: libvir-list@redhat.com Date: Thu, 11 Jul 2019 11:46:30 -0500 Message-Id: <20190711164630.12730-1-cheloha@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-07-11_04:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1907110185 X-Greylist: Delayed for 01:37:56 by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Thu, 11 Jul 2019 18:29:04 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Thu, 11 Jul 2019 18:29:04 +0000 (UTC) for IP:'148.163.158.5' DOMAIN:'mx0b-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'cheloha@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: 0.002 (SPF_HELO_NONE, SPF_NONE) 148.163.158.5 mx0b-001b2d01.pphosted.com 148.163.158.5 mx0b-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.42 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Scott Cheloha Subject: [libvirt] [PATCH] virsh emulatorpin, vcpupin: omit offline CPUs from affinity map 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Thu, 11 Jul 2019 18:29:23 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Each host CPU is not necessarily online. Including CPUs that are known to be offline in the default affinity map doesn't make much sense. We can try to omit those CPUs if the host supports CPU bitmaps, i.e. virHostCPUHasBitmap() is true. Otherwise we can return a full map as we do now. For example, given the following lscpu(1): Architecture: ppc64le Byte Order: Little Endian CPU(s): 128 On-line CPU(s) list: 0,8,16,24,32,40,48,56,64,72,80,88,96,104,112,120 Off-line CPU(s) list: 1-7,9-15,17-23,25-31,33-39,41-47,49-55,57-63,65-71,7= 3-79,81-87,89-95,97-103,105-111,113-119,121-127 Thread(s) per core: 1 Core(s) per socket: 4 Socket(s): 4 NUMA node(s): 4 Model: 2.1 (pvr 004b 0201) Model name: POWER8E (raw), altivec supported CPU max MHz: 4322.0000 CPU min MHz: 2061.0000 L1d cache: 64K L1i cache: 32K L2 cache: 512K L3 cache: 8192K NUMA node0 CPU(s): 0,8,16,24 NUMA node1 CPU(s): 32,40,48,56 NUMA node16 CPU(s): 64,72,80,88 NUMA node17 CPU(s): 96,104,112,120 the current behavior for a guest with no VCPU configuration is: $ virsh vcpupin myvm ---------------------------------- 0: 0-127 but this patch instead you get: VCPU CPU Affinity ---------------------------------- 0 0,8,16,24,32,40,48,56,64,72,80,88,96,104,112,120 which is more consistent with the lscpu(1) output. Fixes: ibm bz174632 (rhbz#1434276) Signed-off-by: Scott Cheloha --- I'm unsure whether it's better to automatically fall back to the full map if virHostCPUGetOnlineBitmap() fails, or to fail loudly as I do in this patch. Preferences? src/conf/domain_conf.c | 8 ++++++++ src/qemu/qemu_driver.c | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 3323c9a5b1..0ea6f69574 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1989,6 +1989,7 @@ virDomainDefGetVcpuPinInfoHelper(virDomainDefPtr def, int maxvcpus =3D virDomainDefGetVcpusMax(def); size_t i; VIR_AUTOPTR(virBitmap) allcpumap =3D NULL; + VIR_AUTOPTR(virBitmap) onlinemap =3D NULL; =20 if (hostcpus < 0) return -1; @@ -1998,6 +1999,11 @@ virDomainDefGetVcpuPinInfoHelper(virDomainDefPtr def, =20 virBitmapSetAll(allcpumap); =20 + if (virHostCPUHasBitmap()) { + if (!(onlinemap =3D virHostCPUGetOnlineBitmap())) + return -1; + } + for (i =3D 0; i < maxvcpus && i < ncpumaps; i++) { virDomainVcpuDefPtr vcpu =3D virDomainDefGetVcpu(def, i); virBitmapPtr bitmap =3D NULL; @@ -2009,6 +2015,8 @@ virDomainDefGetVcpuPinInfoHelper(virDomainDefPtr def, bitmap =3D autoCpuset; else if (def->cpumask) bitmap =3D def->cpumask; + else if (onlinemap) + bitmap =3D onlinemap; else bitmap =3D allcpumap; =20 diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 5a75f23981..2c59513929 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -5377,6 +5377,10 @@ qemuDomainGetEmulatorPinInfo(virDomainPtr dom, } else if (vm->def->placement_mode =3D=3D VIR_DOMAIN_CPU_PLACEMENT_MOD= E_AUTO && autoCpuset) { cpumask =3D autoCpuset; + } else if (virHostCPUHasBitmap()) { + if (!(bitmap =3D virHostCPUGetOnlineBitmap())) + goto cleanup; + cpumask =3D bitmap; } else { if (!(bitmap =3D virBitmapNew(hostcpus))) goto cleanup; --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list