From nobody Tue Nov 26 04:40:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1709718067; cv=none; d=zohomail.com; s=zohoarc; b=EajHBSuNPK6mM3dq+SEFK+1exy8ZFAWtlw4vHmyaO4o8dZ8ocuhOb099rE13d5AiZv5PBN3+ZAoxl4QOe1X5VYaIMFawEaIG4GLq9HVEcUwydPS6gosu5p9owNXTPeK5WzOFsW0dqVC77/YxcwSbbRNK4oCtQGqIXlqKFgGfl9U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709718067; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=psuseaClIu1SsxlcQwUOGvHUWKmeNNJO6zcKWVWZIAQ=; b=OE7WWPlbcVC/FpymywdxDSIn+idqdJ2XqVXR4vZJx8Smh/Y4TYhu1tL1isqq9MkEoaJBaatVNoWy4/mEUX8oKR0zy6z0DKn+ebAcxRHc75fDRjCnzVM4smqi4BbOAopT/UuwzYyYoS7lwhecPX/bJaTxZ/O29PhqL+RY8AzOTXc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 170971806728269.78985114831607; Wed, 6 Mar 2024 01:41:07 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhnlL-0007PC-Ig; Wed, 06 Mar 2024 04:40:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhnlJ-0007OS-6t for qemu-devel@nongnu.org; Wed, 06 Mar 2024 04:40:33 -0500 Received: from mgamail.intel.com ([198.175.65.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhnlH-0001xp-Dd for qemu-devel@nongnu.org; Wed, 06 Mar 2024 04:40:32 -0500 Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2024 01:40:30 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa002.fm.intel.com with ESMTP; 06 Mar 2024 01:40:27 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709718031; x=1741254031; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IfvbKnZ8U91lJU/dyibC1pSk1jQ3WaOU4RwX+q9xdr8=; b=TzjxxhVEawjpmViczxgS9MhaeXiPHfElRnr0so1pVweptpJK3gLzI5qV QgRPWx9ZzdMpW0SrRDmcrLr3Bfl7AwjeCrAGp9kGKt2rEvHCZv16wnHfF ToofmSJSWaJna0tZBwiEQbHKmn3KULyseavjRP4NZWeHgQCC18BGIcIpg jI9r9pgayIgqkqBtETiMogJijDMN/bJMvCIpJwZO9mUEmL8Ir7MLHEoOA XVnIU0bmDZOBg4WN+mNuuJnl9ynFG8dHNRKfXAPG9OAjUdZ+iXTujqVXB LHXML8y7+ext2DqVroSf4umG2D6vloUIjaQvd5XadERCoMoRkejj3dnjA Q==; X-IronPort-AV: E=McAfee;i="6600,9927,11004"; a="14897805" X-IronPort-AV: E=Sophos;i="6.06,207,1705392000"; d="scan'208";a="14897805" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,207,1705392000"; d="scan'208";a="32854124" From: Zhao Liu To: Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Thomas Huth , Igor Mammedov , Prasad Pandit , qemu-devel@nongnu.org Cc: Xiaoling Song , Zhao Liu , devel@lists.libvirt.org, Prasad Pandit Subject: [PATCH 01/14] hw/core/machine-smp: Remove deprecated "parameter=0" SMP configurations Date: Wed, 6 Mar 2024 17:53:54 +0800 Message-Id: <20240306095407.3058909-2-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240306095407.3058909-1-zhao1.liu@linux.intel.com> References: <20240306095407.3058909-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=198.175.65.11; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.568, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1709718068801100007 Content-Type: text/plain; charset="utf-8" From: Zhao Liu The "parameter=3D0" SMP configurations have been marked as deprecated since v6.2. For these cases, -smp currently returns the warning and adjusts the zeroed parameters to 1 by default. Remove the above compatibility logic in v9.0, and return error directly if any -smp parameter is set as 0. Cc: devel@lists.libvirt.org Signed-off-by: Zhao Liu Reviewed-by: Thomas Huth Reviewed-by: Prasad Pandit --- docs/about/deprecated.rst | 16 ---------------- docs/about/removed-features.rst | 15 +++++++++++++++ hw/core/machine-smp.c | 5 +++-- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst index 36bd3e15ef06..872974640252 100644 --- a/docs/about/deprecated.rst +++ b/docs/about/deprecated.rst @@ -36,22 +36,6 @@ and will cause a warning. The replacement for the ``nodelay`` short-form boolean option is ``nodelay= =3Don`` rather than ``delay=3Doff``. =20 -``-smp`` ("parameter=3D0" SMP configurations) (since 6.2) -''''''''''''''''''''''''''''''''''''''''''''''''''''''' - -Specified CPU topology parameters must be greater than zero. - -In the SMP configuration, users should either provide a CPU topology -parameter with a reasonable value (greater than zero) or just omit it -and QEMU will compute the missing value. - -However, historically it was implicitly allowed for users to provide -a parameter with zero value, which is meaningless and could also possibly -cause unexpected results in the -smp parsing. So support for this kind of -configurations (e.g. -smp 8,sockets=3D0) is deprecated since 6.2 and will -be removed in the near future, users have to ensure that all the topology -members described with -smp are greater than zero. - Plugin argument passing through ``arg=3D`` (since 6.1) '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' =20 diff --git a/docs/about/removed-features.rst b/docs/about/removed-features.= rst index 417a0e4fa1d9..f9cf874f7b1f 100644 --- a/docs/about/removed-features.rst +++ b/docs/about/removed-features.rst @@ -489,6 +489,21 @@ The ``-singlestep`` option has been turned into an acc= elerator property, and given a name that better reflects what it actually does. Use ``-accel tcg,one-insn-per-tb=3Don`` instead. =20 +``-smp`` ("parameter=3D0" SMP configurations) (removed in 9.0) +'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + +Specified CPU topology parameters must be greater than zero. + +In the SMP configuration, users should either provide a CPU topology +parameter with a reasonable value (greater than zero) or just omit it +and QEMU will compute the missing value. + +However, historically it was implicitly allowed for users to provide +a parameter with zero value, which is meaningless and could also possibly +cause unexpected results in the -smp parsing. So support for this kind of +configurations (e.g. -smp 8,sockets=3D0) is removed since 9.0, users have +to ensure that all the topology members described with -smp are greater +than zero. =20 User-mode emulator command line arguments ----------------------------------------- diff --git a/hw/core/machine-smp.c b/hw/core/machine-smp.c index 25019c91ee36..96533886b14e 100644 --- a/hw/core/machine-smp.c +++ b/hw/core/machine-smp.c @@ -105,8 +105,9 @@ void machine_parse_smp_config(MachineState *ms, (config->has_cores && config->cores =3D=3D 0) || (config->has_threads && config->threads =3D=3D 0) || (config->has_maxcpus && config->maxcpus =3D=3D 0)) { - warn_report("Deprecated CPU topology (considered invalid): " - "CPU topology parameters must be greater than zero"); + error_setg(errp, "Invalid CPU topology: " + "CPU topology parameters must be greater than zero"); + return; } =20 /* --=20 2.34.1 From nobody Tue Nov 26 04:40:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1709718063; cv=none; d=zohomail.com; s=zohoarc; b=L9DseClCNP+P8I0BP7tr8Yq7rOgOeRydETIPeDDchGpS453vpfsMdgrlnWHfP7DXTppkgcCN+IHZ2dyGEvAUeWtrqz+0TYTGbUB9R3e2wyl6wGi4RWpjy5Ttd+xVPz14u7P17/gt5eU21w/Iq8q2PupB3bdMU+ierGTlfIl5E9c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709718063; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=llfN+CYLuOC7sGMTtmbCxfBDnfcQ4tKki4a2WwmwzcY=; b=YveR53/LDZQbJnYhXlwDlQrLlFlt5rOtWsbzC20xUSuAcME/qXmxTDbqhVG3w7G3gGkzsIyvVdcS39sVW9A4r2mZpe9JJ13PGZEXCNfIWzlpWexeG8+zVTs8jSierPoiRROb2WM/IVyOEdYvkDLylIEABVkY3VMrj25xNmwuhqY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1709718063902266.700606982595; Wed, 6 Mar 2024 01:41:03 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhnlP-0007Ph-4K; Wed, 06 Mar 2024 04:40:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhnlN-0007PD-FZ for qemu-devel@nongnu.org; Wed, 06 Mar 2024 04:40:37 -0500 Received: from mgamail.intel.com ([198.175.65.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhnlL-00020k-LV for qemu-devel@nongnu.org; Wed, 06 Mar 2024 04:40:37 -0500 Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2024 01:40:33 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa002.fm.intel.com with ESMTP; 06 Mar 2024 01:40:30 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709718036; x=1741254036; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=aeA2s9T7ZHBvx6ENH8YGd6wH3Oj/Qq+YESJhKmgsOC0=; b=M0z6+Zwp4M9LsnA985kbkwOqYqcq7lizTBCBOpzoBkRNS+YAXziITbEV r8Jmlve9AWQTufldn4LBOy2buGJB+dk2EodmaQJOB4N1xiQMd6zg0GEWC sBc705DRnjCTE7zxJGHt9J7oK0Y+R0SePhFn1APrmtj1Y2zTqmTN8rcbB W95QbLc1yMjtqSvseBGoO+mnsuOZGIKAChfukvnUNQmnF+22B+qHA2TSu 3LkWKURBBwCW9Ne89yOmHs07r5txJVf4FiBqU5TbxTXgcSSh1VB52ZsU8 rHkTkB5sRm7xVkX/c0uRQlGgn/7F4kCyF3680TC6Dkf8QxqjJD236UNjv A==; X-IronPort-AV: E=McAfee;i="6600,9927,11004"; a="14897814" X-IronPort-AV: E=Sophos;i="6.06,207,1705392000"; d="scan'208";a="14897814" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,207,1705392000"; d="scan'208";a="32854129" From: Zhao Liu To: Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Thomas Huth , Igor Mammedov , Prasad Pandit , qemu-devel@nongnu.org Cc: Xiaoling Song , Zhao Liu , devel@lists.libvirt.org Subject: [PATCH 02/14] hw/core/machine-smp: Deprecate unsupported "parameter=1" SMP configurations Date: Wed, 6 Mar 2024 17:53:55 +0800 Message-Id: <20240306095407.3058909-3-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240306095407.3058909-1-zhao1.liu@linux.intel.com> References: <20240306095407.3058909-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=198.175.65.11; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.568, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1709718065335100001 Content-Type: text/plain; charset="utf-8" From: Zhao Liu Currentlt, it was allowed for users to specify the unsupported topology parameter as "1". For example, x86 PC machine doesn't support drawer/book/cluster topology levels, but user could specify "-smp drawers=3D1,books=3D1,clusters=3D1". This is meaningless and confusing, so that the support for this kind of configurations is marked depresated since 9.0. And report warning message for such case like: qemu-system-x86_64: warning: Deprecated CPU topology (considered invalid): Unsupported clusters parameter mustn't be specified as 1 qemu-system-x86_64: warning: Deprecated CPU topology (considered invalid): Unsupported books parameter mustn't be specified as 1 qemu-system-x86_64: warning: Deprecated CPU topology (considered invalid): Unsupported drawers parameter mustn't be specified as 1 Users have to ensure that all the topology members described with -smp are supported by the target machine. Cc: devel@lists.libvirt.org Signed-off-by: Zhao Liu --- docs/about/deprecated.rst | 14 +++++++++ hw/core/machine-smp.c | 63 +++++++++++++++++++++++++++++---------- 2 files changed, 61 insertions(+), 16 deletions(-) diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst index 872974640252..2e782e83e952 100644 --- a/docs/about/deprecated.rst +++ b/docs/about/deprecated.rst @@ -47,6 +47,20 @@ as short-form boolean values, and passed to plugins as `= `arg_name=3Don``. However, short-form booleans are deprecated and full explicit ``arg_name= =3Don`` form is preferred. =20 +``-smp`` (Unsopported "parameter=3D1" SMP configurations) (since 9.0) +''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + +Specified CPU topology parameters must be supported by the machine. + +In the SMP configuration, users should provide the CPU topology parameters= that +are supported by the target machine. + +However, historically it was allowed for users to specify the unsupported +topology parameter as "1", which is meaningless. So support for this kind = of +configurations (e.g. -smp drawers=3D1,books=3D1,clusters=3D1 for x86 PC ma= chine) is +marked depresated since 9.0, users have to ensure that all the topology me= mbers +described with -smp are supported by the target machine. + QEMU Machine Protocol (QMP) commands ------------------------------------ =20 diff --git a/hw/core/machine-smp.c b/hw/core/machine-smp.c index 96533886b14e..50a5a40dbc3d 100644 --- a/hw/core/machine-smp.c +++ b/hw/core/machine-smp.c @@ -112,30 +112,61 @@ void machine_parse_smp_config(MachineState *ms, =20 /* * If not supported by the machine, a topology parameter must be - * omitted or specified equal to 1. + * omitted. */ - if (!mc->smp_props.dies_supported && dies > 1) { - error_setg(errp, "dies not supported by this machine's CPU topolog= y"); - return; - } - if (!mc->smp_props.clusters_supported && clusters > 1) { - error_setg(errp, "clusters not supported by this machine's CPU top= ology"); - return; + if (!mc->smp_props.clusters_supported && config->has_clusters) { + if (config->clusters > 1) { + error_setg(errp, "clusters not supported by this " + "machine's CPU topology"); + return; + } else { + /* Here clusters only equals 1 since we've checked zero case. = */ + warn_report("Deprecated CPU topology (considered invalid): " + "Unsupported clusters parameter mustn't be " + "specified as 1"); + } } + clusters =3D clusters > 0 ? clusters : 1; =20 + if (!mc->smp_props.dies_supported && config->has_dies) { + if (config->dies > 1) { + error_setg(errp, "dies not supported by this " + "machine's CPU topology"); + return; + } else { + /* Here dies only equals 1 since we've checked zero case. */ + warn_report("Deprecated CPU topology (considered invalid): " + "Unsupported dies parameter mustn't be " + "specified as 1"); + } + } dies =3D dies > 0 ? dies : 1; - clusters =3D clusters > 0 ? clusters : 1; =20 - if (!mc->smp_props.books_supported && books > 1) { - error_setg(errp, "books not supported by this machine's CPU topolo= gy"); - return; + if (!mc->smp_props.books_supported && config->has_books) { + if (config->books > 1) { + error_setg(errp, "books not supported by this " + "machine's CPU topology"); + return; + } else { + /* Here books only equals 1 since we've checked zero case. */ + warn_report("Deprecated CPU topology (considered invalid): " + "Unsupported books parameter mustn't be " + "specified as 1"); + } } books =3D books > 0 ? books : 1; =20 - if (!mc->smp_props.drawers_supported && drawers > 1) { - error_setg(errp, - "drawers not supported by this machine's CPU topology"); - return; + if (!mc->smp_props.drawers_supported && config->has_drawers) { + if (config->drawers > 1) { + error_setg(errp, "drawers not supported by this " + "machine's CPU topology"); + return; + } else { + /* Here drawers only equals 1 since we've checked zero case. */ + warn_report("Deprecated CPU topology (considered invalid): " + "Unsupported drawers parameter mustn't be " + "specified as 1"); + } } drawers =3D drawers > 0 ? drawers : 1; =20 --=20 2.34.1 From nobody Tue Nov 26 04:40:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1709718265; cv=none; d=zohomail.com; s=zohoarc; b=TCL68hSqYXOlb0Gf0t8EAagk/t5ClgXvpH6/M+qJ1QGHUMVMDZJFImAV/fTaSmXePZlofn1EEg64qIN5Ylm+hnL359TQ8zP7hM4NccUbEbbvWjib3zr58dvg2m7Ut7M/oirq4pbF9EiXeOAJB0KgnrUO8e7LotAeLghJwYyZukg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709718265; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=uQuqqKb3ttofAAwKxS7kS6hWX3HPb9WWuOsPAkUUxak=; b=II0kV4d0cZez1cYDzhryBg2rRXsWM8cZt52YHVqJ5nXYN4Asn8GL4Lp3YPwMTCpI8li/EvfAuqMC6ZVLndgYNihShNjtLvbmZ50N6p4fdG1U5/ANgSxxAyZE8SEr8lAntV/Q35M1mzjfj6ez4MwaNcDDzNyFsyl1P+2SojQElno= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1709718265559355.7696672064267; Wed, 6 Mar 2024 01:44:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhnlQ-0007Py-On; Wed, 06 Mar 2024 04:40:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhnlP-0007Pi-Bu for qemu-devel@nongnu.org; Wed, 06 Mar 2024 04:40:39 -0500 Received: from mgamail.intel.com ([198.175.65.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhnlN-00025v-ED for qemu-devel@nongnu.org; Wed, 06 Mar 2024 04:40:38 -0500 Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2024 01:40:36 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa002.fm.intel.com with ESMTP; 06 Mar 2024 01:40:33 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709718037; x=1741254037; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0Oqv2Y548yUJEQ3jZWHP1266B+OXZuHqGaMfM6j07uY=; b=LE6KjFnJvhCeLYt15oMiKTOmSFzo+duvXF+Y++HPKuNJuFT0BDd2oAnW xaDqjyNhGKPuikHFVh5u1b+7Z3fmNxXS0xOY/f118UkqJe6lF4FA1CJS2 BzPRXbvaH6F43ipgZU4x5XHjdQlaUmkDnwPOTzHtZ6OVcCiJPo+2jC9XV qfRQflCeXJuuoM2kVFtLMo7XFKxoRmY1hxWrcReFqMvdy4j9v/4XVRvW9 xtZx9Y4cIGfjH5QeFNoAJE5CBaTuZtzBi8m8c815ZTgfZQb2ARq3A4ZVX pTG0m2gmoS94DrMWgBXjrgeuR+BsB8aEwMDBYbG0urI3AJmcGK1JlYLpO Q==; X-IronPort-AV: E=McAfee;i="6600,9927,11004"; a="14897833" X-IronPort-AV: E=Sophos;i="6.06,207,1705392000"; d="scan'208";a="14897833" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,207,1705392000"; d="scan'208";a="32854134" From: Zhao Liu To: Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Thomas Huth , Igor Mammedov , Prasad Pandit , qemu-devel@nongnu.org Cc: Xiaoling Song , Zhao Liu , Prasad Pandit Subject: [PATCH 03/14] hw/core/machine-smp: Simplify variables' initialization in machine_parse_smp_config() Date: Wed, 6 Mar 2024 17:53:56 +0800 Message-Id: <20240306095407.3058909-4-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240306095407.3058909-1-zhao1.liu@linux.intel.com> References: <20240306095407.3058909-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=198.175.65.11; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.568, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1709718266450100001 Content-Type: text/plain; charset="utf-8" From: Zhao Liu SMPConfiguration initializes its int64_t members as 0 by default. Therefore, in machine_parse_smp_config(), initialize local topology variables with SMPConfiguration's members directly. Suggested-by: Prasad Pandit Signed-off-by: Zhao Liu --- hw/core/machine-smp.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/hw/core/machine-smp.c b/hw/core/machine-smp.c index 50a5a40dbc3d..3d9799aef039 100644 --- a/hw/core/machine-smp.c +++ b/hw/core/machine-smp.c @@ -82,15 +82,15 @@ void machine_parse_smp_config(MachineState *ms, const SMPConfiguration *config, Error **errp) { MachineClass *mc =3D MACHINE_GET_CLASS(ms); - unsigned cpus =3D config->has_cpus ? config->cpus : 0; - unsigned drawers =3D config->has_drawers ? config->drawers : 0; - unsigned books =3D config->has_books ? config->books : 0; - unsigned sockets =3D config->has_sockets ? config->sockets : 0; - unsigned dies =3D config->has_dies ? config->dies : 0; - unsigned clusters =3D config->has_clusters ? config->clusters : 0; - unsigned cores =3D config->has_cores ? config->cores : 0; - unsigned threads =3D config->has_threads ? config->threads : 0; - unsigned maxcpus =3D config->has_maxcpus ? config->maxcpus : 0; + unsigned cpus =3D config->cpus; + unsigned drawers =3D config->drawers; + unsigned books =3D config->books; + unsigned sockets =3D config->sockets; + unsigned dies =3D config->dies; + unsigned clusters =3D config->clusters; + unsigned cores =3D config->cores; + unsigned threads =3D config->threads; + unsigned maxcpus =3D config->maxcpus; =20 /* * Specified CPU topology parameters must be greater than zero, --=20 2.34.1 From nobody Tue Nov 26 04:40:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1709718092; cv=none; d=zohomail.com; s=zohoarc; b=L6bQeP7q2Z9qRc8rQ839Ms2Y4FThKfQVKXsrUAz/lvRdp/Fr8vbzz7hna7hySM8RTI+YdSOwgAOUHrSe1FlaVl1vzKJ85WA4ijsjjjotzLZnBOsmfs5EtTvEGKd8Zdb2TwbOVRW7PEOkvrphon2yQbcnkWz4yZo+vl0GMOcTNY0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709718092; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=F3mjyc8ZxfsHF2ZBSVTqjGOmSoGJuxcBXUVlTjlIPDA=; b=DEGN1pvT55rhuWELln7u+M9GJOI+sQ3HKbHwwXo5yZlRclcvqvyD7i4T9L1xRPC0JkOb05WCmBsKszxpXqyTjXwXCLptZF/SrPuD3TwkR4h4JxWlXZewapipou3nDTZXEWWDRI2Nt/i0Xl/i/Wsh2ol8aThjh6C3ReWK5hV4HZ0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 170971809205581.52753066854098; Wed, 6 Mar 2024 01:41:32 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhnlU-0007Qj-EM; Wed, 06 Mar 2024 04:40:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhnlT-0007QH-4w for qemu-devel@nongnu.org; Wed, 06 Mar 2024 04:40:43 -0500 Received: from mgamail.intel.com ([198.175.65.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhnlQ-0002EH-Df for qemu-devel@nongnu.org; Wed, 06 Mar 2024 04:40:41 -0500 Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2024 01:40:39 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa002.fm.intel.com with ESMTP; 06 Mar 2024 01:40:36 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709718040; x=1741254040; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=EwAYN36P3lzqN1glAqPGtpQAeH7zDs5xPFp9VL7Pp+Y=; b=GdQIK8mcrdr/Yx2yXM8xc2or3r1S/g+ksppSHr3GI/PfXlBF0rtzm7u1 H26wSMnuWjuzpiP0PhiBXW5Ut6yIPoe8BCs2pld9XzEXTp6MxvPXkvCBQ upL1FKkn1o5pypAtQXm0wR7gSohCAaPylErm/TDkFqeXc50dur6fNCdbO vGF2k4blKoR5uQeBGokWM0f/TQhPrV9BiWsReB1d3eQXa+6rN+fmbbYlr Yt9hDMjDnGurv6zTY82hranKq5XEZp6hJr9ciruHnuyXbAvBId3xFS5mN Eg6moHlL4QAQMgKB69UpT44e6MFZSUIxfr3MFCHm95lNnuRfUSNFYZ3d1 A==; X-IronPort-AV: E=McAfee;i="6600,9927,11004"; a="14897840" X-IronPort-AV: E=Sophos;i="6.06,207,1705392000"; d="scan'208";a="14897840" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,207,1705392000"; d="scan'208";a="32854140" From: Zhao Liu To: Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Thomas Huth , Igor Mammedov , Prasad Pandit , qemu-devel@nongnu.org Cc: Xiaoling Song , Zhao Liu Subject: [PATCH 04/14] hw/core/machine-smp: Calculate total CPUs once in machine_parse_smp_config() Date: Wed, 6 Mar 2024 17:53:57 +0800 Message-Id: <20240306095407.3058909-5-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240306095407.3058909-1-zhao1.liu@linux.intel.com> References: <20240306095407.3058909-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=198.175.65.11; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.568, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1709718092856100001 Content-Type: text/plain; charset="utf-8" From: Zhao Liu In machine_parse_smp_config(), the number of total CPUs is calculated by: drawers * books * sockets * dies * clusters * cores * threads To avoid missing the future new topology level, use a local variable to cache the calculation result so that total CPUs are only calculated once. Signed-off-by: Zhao Liu Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/core/machine-smp.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/core/machine-smp.c b/hw/core/machine-smp.c index 3d9799aef039..0e398ef02666 100644 --- a/hw/core/machine-smp.c +++ b/hw/core/machine-smp.c @@ -91,6 +91,7 @@ void machine_parse_smp_config(MachineState *ms, unsigned cores =3D config->cores; unsigned threads =3D config->threads; unsigned maxcpus =3D config->maxcpus; + unsigned total_cpus; =20 /* * Specified CPU topology parameters must be greater than zero, @@ -211,8 +212,8 @@ void machine_parse_smp_config(MachineState *ms, } } =20 - maxcpus =3D maxcpus > 0 ? maxcpus : drawers * books * sockets * dies * - clusters * cores * threads; + total_cpus =3D drawers * books * sockets * dies * clusters * cores * t= hreads; + maxcpus =3D maxcpus > 0 ? maxcpus : total_cpus; cpus =3D cpus > 0 ? cpus : maxcpus; =20 ms->smp.cpus =3D cpus; @@ -228,8 +229,7 @@ void machine_parse_smp_config(MachineState *ms, mc->smp_props.has_clusters =3D config->has_clusters; =20 /* sanity-check of the computed topology */ - if (drawers * books * sockets * dies * clusters * cores * threads !=3D - maxcpus) { + if (total_cpus !=3D maxcpus) { g_autofree char *topo_msg =3D cpu_hierarchy_to_string(ms); error_setg(errp, "Invalid CPU topology: " "product of the hierarchy must match maxcpus: " --=20 2.34.1 From nobody Tue Nov 26 04:40:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1709718070; cv=none; d=zohomail.com; s=zohoarc; b=J66ZaRTsoHmuEMO246bs9qz1nbjwW34D7GttA3AEncvxKUJI3693dYee9kw2mhhtcCj9ZMfgAkippi/IFbu+GKLxscG09maOLvPPOBCCl6g21o6FLPWdhtwUwdjMAO4jGf3z/uCUAJamC1OehAj82o+k3HwFIEDh385C8cfKywU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709718070; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=WVDxExtSxwQsghEdiAEoc4m7SbITVwEWIcxol7gOF+s=; b=I1WGdVquIfif276y9PL2ZQuwoijZy/+pwWAYDLjFNAiu1r0lQhfIA/Rx2frdKaoyTSFNf1xDbpaJaABJGkjnLa1l0Xk3KIt/jPbAbt0NleMeTfA5QDKu293eFICva6aZKQYtBjrpvnMg9MtIaRaKeDNpAWgS0UjPNMVF2z/235U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1709718070019762.6895229722535; Wed, 6 Mar 2024 01:41:10 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhnlX-0007RP-BV; Wed, 06 Mar 2024 04:40:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhnlU-0007Qw-SQ for qemu-devel@nongnu.org; Wed, 06 Mar 2024 04:40:44 -0500 Received: from mgamail.intel.com ([198.175.65.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhnlS-0002EH-NR for qemu-devel@nongnu.org; Wed, 06 Mar 2024 04:40:43 -0500 Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2024 01:40:42 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa002.fm.intel.com with ESMTP; 06 Mar 2024 01:40:39 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709718043; x=1741254043; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NpfwA5T3qrlUwyebkr7jEf0KUNOVvZ9NryO2DTdXNt4=; b=Yhw37+7Cjfs7WZJzrwPW0A/6EeD/minCws0WYDVPcMgjRLGc5JK7rqew eBFrLAn8TJ47Fbh/6pBO4XUARuy92gZltQBDQfoAyCQi+zLCfKnZriAO/ knsqh5QYgLTOsOZ9S7qlr9vARL/ifDGJ5VD7uRjOpJwQwSfs0psJk8AGf VXdWoI4r9lLkqL7qTGTWNzantdBa1RmeGgltaIuFJjybYK6fskMFlTd22 uZK6OA3NsScgJOm1cjvwgJoxHWfKl+3MLO8X/tStYfPaFRS65omz+kFsl Tt+UXykDSCBgx2PasxDgC8ff3yF+FUB6vrz96yemUsDSeBQt0VQTfkfu5 g==; X-IronPort-AV: E=McAfee;i="6600,9927,11004"; a="14897848" X-IronPort-AV: E=Sophos;i="6.06,207,1705392000"; d="scan'208";a="14897848" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,207,1705392000"; d="scan'208";a="32854146" From: Zhao Liu To: Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Thomas Huth , Igor Mammedov , Prasad Pandit , qemu-devel@nongnu.org Cc: Xiaoling Song , Zhao Liu Subject: [PATCH 05/14] tests/unit/test-smp-parse: Drop the unsupported "dies=1" case Date: Wed, 6 Mar 2024 17:53:58 +0800 Message-Id: <20240306095407.3058909-6-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240306095407.3058909-1-zhao1.liu@linux.intel.com> References: <20240306095407.3058909-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=198.175.65.11; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.568, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1709718070627100009 Content-Type: text/plain; charset="utf-8" From: Zhao Liu Unsupported "parameter=3D1" SMP configurations is marked as deprecated, so drop the related test case. Signed-off-by: Zhao Liu Reviewed-by: Thomas Huth --- tests/unit/test-smp-parse.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/unit/test-smp-parse.c b/tests/unit/test-smp-parse.c index 24972666a74d..1874bea08609 100644 --- a/tests/unit/test-smp-parse.c +++ b/tests/unit/test-smp-parse.c @@ -607,11 +607,6 @@ static void test_generic_valid(const void *opaque) unsupported_params_init(mc, &data); =20 smp_parse_test(ms, &data, true); - - /* Unsupported parameters can be provided with their values as 1 */ - data.config.has_dies =3D true; - data.config.dies =3D 1; - smp_parse_test(ms, &data, true); } =20 object_unref(obj); --=20 2.34.1 From nobody Tue Nov 26 04:40:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1709718272; cv=none; d=zohomail.com; s=zohoarc; b=Zw0+htep8Mlf9Ai/rXY0wcMW+KtQXpZpILiwWI4vdjJjBnIFCf6yKJRdsFyZRXdsIbTwsFfVHvA65g3nyK+5xWw3guzOhr+yVtqGzyW9v+xC5/6dBe7rGZsNxMo9YpYdJt6UmELXvhwC6ExVOYFHgfQ57bmqQeSnPJcQxTc9dA4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709718272; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=yJPuDdHYw7dErutDsepZvyXTIZmQKL7Sm4aDkm6dSXo=; b=kTTBZbqqgpfv62MsrKUAnMYux2QkD7KoKtNaVlv31jUi+k25LEsF9DAM7kDOGMu/5tM2xUat0PdZC8RG5kmNr9zlM81GOi/LmfQG3OPAp0iBBQQgOn5Qstws4XdcEXOktbTu1AJHcUTB7SoZJTnY/L5A4OxEunEE5vmP7ZSeTGY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1709718272358272.04196910775977; Wed, 6 Mar 2024 01:44:32 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhnlZ-0007Sd-Gz; Wed, 06 Mar 2024 04:40:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhnlY-0007Ri-5q for qemu-devel@nongnu.org; Wed, 06 Mar 2024 04:40:48 -0500 Received: from mgamail.intel.com ([198.175.65.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhnlV-0002EH-GL for qemu-devel@nongnu.org; Wed, 06 Mar 2024 04:40:47 -0500 Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2024 01:40:45 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa002.fm.intel.com with ESMTP; 06 Mar 2024 01:40:42 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709718045; x=1741254045; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6WGcGPLsmeM9ujwFnIiG1nYtUcObQiTkGIz1UZVazz0=; b=mAOU7EqSsZgXZAlQVW4BGtNRlf9SOLa8dSeN8Zn6Qk8BzxQZwEO007pz dI/XiYk4W26078hOB016wkeeQt4nNf4MuVgLTs6g4jt00RbZ3A8shwGZA 4DcIFzBD+mDn05XKC6FmUhkzIN5myfqeVb1teLeU/NM/+wubi91JLelye 0rRSEwdqkoniShaqboO55hQRh//gcjoA/J3HFKID0zmiVkhqTsfWEF/Vw 74VKKVFlBwXCdF7dWl0vtw7h+TYUv7eduX2qBScVW6XnXeJ5Ha/1W8fam a8BmPSUW+/Cjrt0GYPhonjv2vjeViHSn2q+AWMe06oQUjUvSMVR7+MSKe Q==; X-IronPort-AV: E=McAfee;i="6600,9927,11004"; a="14897863" X-IronPort-AV: E=Sophos;i="6.06,207,1705392000"; d="scan'208";a="14897863" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,207,1705392000"; d="scan'208";a="32854149" From: Zhao Liu To: Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Thomas Huth , Igor Mammedov , Prasad Pandit , qemu-devel@nongnu.org Cc: Xiaoling Song , Zhao Liu Subject: [PATCH 06/14] tests/unit/test-smp-parse: Use CPU number macros in invalid topology case Date: Wed, 6 Mar 2024 17:53:59 +0800 Message-Id: <20240306095407.3058909-7-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240306095407.3058909-1-zhao1.liu@linux.intel.com> References: <20240306095407.3058909-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=198.175.65.11; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.568, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1709718274434100003 Content-Type: text/plain; charset="utf-8" From: Zhao Liu Use MAX_CPUS/MIN_CPUS macros in invalid topology case. This gives us the flexibility to change the maximum and minimum CPU limits. Signed-off-by: Zhao Liu Tested-by: Xiaoling Song Reviewed-by: Thomas Huth --- tests/unit/test-smp-parse.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/tests/unit/test-smp-parse.c b/tests/unit/test-smp-parse.c index 1874bea08609..84e342277452 100644 --- a/tests/unit/test-smp-parse.c +++ b/tests/unit/test-smp-parse.c @@ -323,15 +323,21 @@ static const struct SMPTestData data_generic_invalid[= ] =3D { "sockets (2) * cores (4) * threads (2) " "=3D=3D maxcpus (16) < smp_cpus (18)", }, { - /* config: -smp 1 - * should tweak the supported min CPUs to 2 for testing */ - .config =3D SMP_CONFIG_GENERIC(T, 1, F, 0, F, 0, F, 0, F, 0), + /* + * config: -smp 1 + * The test machine should tweak the supported min CPUs to + * 2 (MIN_CPUS + 1) for testing. + */ + .config =3D SMP_CONFIG_GENERIC(T, MIN_CPUS, F, 0, F, 0, F, 0, F, 0= ), .expect_error =3D "Invalid SMP CPUs 1. The min CPUs supported " "by machine '" SMP_MACHINE_NAME "' is 2", }, { - /* config: -smp 512 - * should tweak the supported max CPUs to 511 for testing */ - .config =3D SMP_CONFIG_GENERIC(T, 512, F, 0, F, 0, F, 0, F, 0), + /* + * config: -smp 512 + * The test machine should tweak the supported max CPUs to + * 511 (MAX_CPUS - 1) for testing. + */ + .config =3D SMP_CONFIG_GENERIC(T, MAX_CPUS, F, 0, F, 0, F, 0, F, 0= ), .expect_error =3D "Invalid SMP CPUs 512. The max CPUs supported " "by machine '" SMP_MACHINE_NAME "' is 511", }, @@ -575,8 +581,8 @@ static void machine_generic_invalid_class_init(ObjectCl= ass *oc, void *data) MachineClass *mc =3D MACHINE_CLASS(oc); =20 /* Force invalid min CPUs and max CPUs */ - mc->min_cpus =3D 2; - mc->max_cpus =3D 511; + mc->min_cpus =3D MIN_CPUS + 1; + mc->max_cpus =3D MAX_CPUS - 1; } =20 static void machine_with_dies_class_init(ObjectClass *oc, void *data) --=20 2.34.1 From nobody Tue Nov 26 04:40:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1709718244; cv=none; d=zohomail.com; s=zohoarc; b=Is322rS0lGqJv0Y3GFIOPZrYnmDgzELzEdA7gPV+ZPcSfHIfyOHJOwBaZG/JW4cFSTWCC43iHLqrTjA09KNueqjfjsJFyQ4Eo9fEXrnOHNW0ihK5LO/Hg7UoJ8Fux5uV7aUDLaQwarMkB8SIHF0MBIuasNyWSY1K7gxXlBCUDj4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709718244; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=l9LlCXOQ9FZxauUaGFCbWME8oTzZK/9FbEOSp+/dY9k=; b=BV/0L292o1fqFXKvKJKREV/kKjJSKWVINFwG7rIlsleDmEf92Njna4zCACdDUeXB/9NvgpRawVLeo0qEEn6H4JVsuUfEtmu6lmwSB7gKfXsaKIkfFl/VQWKe/yeMOtOrNPgeBVJt8enUJRkYw2YHgPpBPVgogfiAzLrYshbq5fY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1709718244853975.1774804397133; Wed, 6 Mar 2024 01:44:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhnlc-0007Wo-4R; Wed, 06 Mar 2024 04:40:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhnla-0007V0-80 for qemu-devel@nongnu.org; Wed, 06 Mar 2024 04:40:50 -0500 Received: from mgamail.intel.com ([198.175.65.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhnlY-0002EH-Hm for qemu-devel@nongnu.org; Wed, 06 Mar 2024 04:40:49 -0500 Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2024 01:40:47 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa002.fm.intel.com with ESMTP; 06 Mar 2024 01:40:45 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709718048; x=1741254048; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qD3+/mxiUeFA8qjNfSYQGL/xmY6O+NdeVswkRvGf0gA=; b=jWvNhnilNV9RjQck4crAI+c4aDQO/Otm7QdmI8bEN6oqSpy2DhAUME9B 202003Q5tsML8R6E+UU8qS1l+dWXR5onXOddrIf5xDyP85S0Vu8hYNnI3 zpWJTOxrgg/0H6yFAtW2rejqkC2dL+mDUF5EMAKVxw37hzUu65f277aWk bxrBq7ks5zVbB+/XZn9RAqEVcGOcSrxNcyQUwfysDcZ4BlgDnYTYKmIlq 97ID9V0ZuXt6SV8b60QcD/HJztem//ZtxmS3eFZjSJE7NvwwjFYm79hGC pDX8aI1OP3YdKvI/tTbp9Dhv6UjajPNmDgzYwq0+ZNcUTxJ/ep/oCbe7j Q==; X-IronPort-AV: E=McAfee;i="6600,9927,11004"; a="14897877" X-IronPort-AV: E=Sophos;i="6.06,207,1705392000"; d="scan'208";a="14897877" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,207,1705392000"; d="scan'208";a="32854153" From: Zhao Liu To: Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Thomas Huth , Igor Mammedov , Prasad Pandit , qemu-devel@nongnu.org Cc: Xiaoling Song , Zhao Liu Subject: [PATCH 07/14] tests/unit/test-smp-parse: Bump max_cpus to 4096 Date: Wed, 6 Mar 2024 17:54:00 +0800 Message-Id: <20240306095407.3058909-8-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240306095407.3058909-1-zhao1.liu@linux.intel.com> References: <20240306095407.3058909-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=198.175.65.11; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.568, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1709718246351100001 Content-Type: text/plain; charset="utf-8" From: Zhao Liu The q35 machine is trying to support up to 4096 vCPUs [1], so it's necessary to bump max_cpus in test-smp-parse to 4096 to cover the topological needs of future machines. [1]: https://lore.kernel.org/qemu-devel/20240228143351.3967-1-anisinha@redh= at.com/ Signed-off-by: Zhao Liu Tested-by: Xiaoling Song Reviewed-by: Thomas Huth --- tests/unit/test-smp-parse.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/unit/test-smp-parse.c b/tests/unit/test-smp-parse.c index 84e342277452..2eb9533bc505 100644 --- a/tests/unit/test-smp-parse.c +++ b/tests/unit/test-smp-parse.c @@ -20,8 +20,8 @@ #define T true #define F false =20 -#define MIN_CPUS 1 /* set the min CPUs supported by the machine as 1 */ -#define MAX_CPUS 512 /* set the max CPUs supported by the machine as 512 */ +#define MIN_CPUS 1 /* set the min CPUs supported by the machine as 1 */ +#define MAX_CPUS 4096 /* set the max CPUs supported by the machine as 4096= */ =20 #define SMP_MACHINE_NAME "TEST-SMP" =20 @@ -333,13 +333,13 @@ static const struct SMPTestData data_generic_invalid[= ] =3D { "by machine '" SMP_MACHINE_NAME "' is 2", }, { /* - * config: -smp 512 + * config: -smp 4096 * The test machine should tweak the supported max CPUs to - * 511 (MAX_CPUS - 1) for testing. + * 4095 (MAX_CPUS - 1) for testing. */ - .config =3D SMP_CONFIG_GENERIC(T, MAX_CPUS, F, 0, F, 0, F, 0, F, 0= ), - .expect_error =3D "Invalid SMP CPUs 512. The max CPUs supported " - "by machine '" SMP_MACHINE_NAME "' is 511", + .config =3D SMP_CONFIG_GENERIC(T, 4096, F, 0, F, 0, F, 0, F, 0), + .expect_error =3D "Invalid SMP CPUs 4096. The max CPUs supported " + "by machine '" SMP_MACHINE_NAME "' is 4095", }, }; =20 --=20 2.34.1 From nobody Tue Nov 26 04:40:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1709718130; cv=none; d=zohomail.com; s=zohoarc; b=c++Q3H99qyn366k30IA4WOeTn4GO32QwWdnajc8JU/QiPkLaUAWdrFvJR5MSTXviEAPhI0+3TPdk3cHrlVBNJfg1aMJ2f1REyZqJUI43ksiEC+JAKnez3themDboRAnde3DbXVqn2f/KhsjEogJ7D0YJDm6jrFtYkgdVLjAgcxg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709718130; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=lt7oKSiiuxn2KgExI1UlL2mwVUNq2P1L5Zp2eG6j8zg=; b=iiIIuPT2MLn9y6TyumkIkPE/MkhgsTkPcFzLfvI+Acm+pfS/zJifyCiBkp1BAekfFzoAinYfAEqJezmD++dkzta14To7QkCvrHEyA00WsQoybM0/saIA8dUsHezH6ToHOgv+q9TGZNSqGGCndQ829KGzT/9g94ylVSe31vAy6FA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1709718130496628.0696441087224; Wed, 6 Mar 2024 01:42:10 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhnlf-0007XT-9r; Wed, 06 Mar 2024 04:40:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhnld-0007XF-HL for qemu-devel@nongnu.org; Wed, 06 Mar 2024 04:40:54 -0500 Received: from mgamail.intel.com ([198.175.65.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhnlb-0002K2-SV for qemu-devel@nongnu.org; Wed, 06 Mar 2024 04:40:53 -0500 Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2024 01:40:50 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa002.fm.intel.com with ESMTP; 06 Mar 2024 01:40:48 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709718052; x=1741254052; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3yBYX2nAWb+HDAcrhm+cAUvXQKvQu/GD/FeL85SWXFA=; b=mM0eyEXMJiQMEfiFJyypkGcieEI/xhfZGQE+lmtgMAAWv3dHwCkj8fWS cxdTMSAmesbyrVYDaJi+yWCMH9i1cHZ8cidflOlBkULp5jEd15dXjIO87 yNwB4MgrOzk8EAyu7aduHHHuNAzHmv9fr9xmGRH7GbkQ8nH0Xw5qgNcUS WNtURN8EPVivpikqpFYaHM+QtA5LBV9fy8TWlR4QP2QR7Pqgw62mhY8eJ Ys3yNEBp5fgHRmmKhxQzjtmfAnIEaDuQE2TZf1Gb+fgohU/VIin6O2Jzq n1ue0hX7O75E8EYfYGz6ecTbYeXGrJ2/TdgxhhQ9Hto8O7gAAMTV5/9/0 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,11004"; a="14897891" X-IronPort-AV: E=Sophos;i="6.06,207,1705392000"; d="scan'208";a="14897891" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,207,1705392000"; d="scan'208";a="32854159" From: Zhao Liu To: Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Thomas Huth , Igor Mammedov , Prasad Pandit , qemu-devel@nongnu.org Cc: Xiaoling Song , Zhao Liu Subject: [PATCH 08/14] tests/unit/test-smp-parse: Make test cases aware of the book/drawer Date: Wed, 6 Mar 2024 17:54:01 +0800 Message-Id: <20240306095407.3058909-9-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240306095407.3058909-1-zhao1.liu@linux.intel.com> References: <20240306095407.3058909-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=198.175.65.11; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.568, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1709718130839100001 Content-Type: text/plain; charset="utf-8" From: Zhao Liu Currently, -smp supports 2 more new levels: book and drawer. It is necessary to consider the effects of book and drawer in the test cases to ensure that the calculations are correct. This is also the preparation to add new book and drawer test cases. Signed-off-by: Zhao Liu Tested-by: Xiaoling Song Reviewed-by: Thomas Huth --- tests/unit/test-smp-parse.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/tests/unit/test-smp-parse.c b/tests/unit/test-smp-parse.c index 2eb9533bc505..f656bbb6da27 100644 --- a/tests/unit/test-smp-parse.c +++ b/tests/unit/test-smp-parse.c @@ -384,6 +384,8 @@ static char *smp_config_to_string(const SMPConfiguratio= n *config) return g_strdup_printf( "(SMPConfiguration) {\n" " .has_cpus =3D %5s, cpus =3D %" PRId64 ",\n" + " .has_drawers =3D %5s, drawers =3D %" PRId64 ",\n" + " .has_books =3D %5s, books =3D %" PRId64 ",\n" " .has_sockets =3D %5s, sockets =3D %" PRId64 ",\n" " .has_dies =3D %5s, dies =3D %" PRId64 ",\n" " .has_clusters =3D %5s, clusters =3D %" PRId64 ",\n" @@ -392,6 +394,8 @@ static char *smp_config_to_string(const SMPConfiguratio= n *config) " .has_maxcpus =3D %5s, maxcpus =3D %" PRId64 ",\n" "}", config->has_cpus ? "true" : "false", config->cpus, + config->has_drawers ? "true" : "false", config->drawers, + config->has_books ? "true" : "false", config->books, config->has_sockets ? "true" : "false", config->sockets, config->has_dies ? "true" : "false", config->dies, config->has_clusters ? "true" : "false", config->clusters, @@ -404,10 +408,10 @@ static char *smp_config_to_string(const SMPConfigurat= ion *config) static unsigned int cpu_topology_get_threads_per_socket(const CpuTopology = *topo) { /* Check the divisor to avoid invalid topology examples causing SIGFPE= . */ - if (!topo->sockets) { + if (!topo->drawers || !topo->books || !topo->sockets) { return 0; } else { - return topo->max_cpus / topo->sockets; + return topo->max_cpus / topo->drawers / topo->books / topo->socket= s; } } =20 @@ -429,6 +433,8 @@ static char *cpu_topology_to_string(const CpuTopology *= topo, return g_strdup_printf( "(CpuTopology) {\n" " .cpus =3D %u,\n" + " .drawers =3D %u,\n" + " .books =3D %u,\n" " .sockets =3D %u,\n" " .dies =3D %u,\n" " .clusters =3D %u,\n" @@ -438,7 +444,8 @@ static char *cpu_topology_to_string(const CpuTopology *= topo, " .threads_per_socket =3D %u,\n" " .cores_per_socket =3D %u,\n" "}", - topo->cpus, topo->sockets, topo->dies, topo->clusters, + topo->cpus, topo->drawers, topo->books, + topo->sockets, topo->dies, topo->clusters, topo->cores, topo->threads, topo->max_cpus, threads_per_socket, cores_per_socket); } @@ -473,6 +480,8 @@ static void check_parse(MachineState *ms, const SMPConf= iguration *config, if (is_valid) { if ((err =3D=3D NULL) && (ms->smp.cpus =3D=3D expect_topo->cpus) && + (ms->smp.drawers =3D=3D expect_topo->drawers) && + (ms->smp.books =3D=3D expect_topo->books) && (ms->smp.sockets =3D=3D expect_topo->sockets) && (ms->smp.dies =3D=3D expect_topo->dies) && (ms->smp.clusters =3D=3D expect_topo->clusters) && @@ -564,6 +573,16 @@ static void unsupported_params_init(const MachineClass= *mc, SMPTestData *data) data->expect_prefer_sockets.clusters =3D 1; data->expect_prefer_cores.clusters =3D 1; } + + if (!mc->smp_props.books_supported) { + data->expect_prefer_sockets.books =3D 1; + data->expect_prefer_cores.books =3D 1; + } + + if (!mc->smp_props.drawers_supported) { + data->expect_prefer_sockets.drawers =3D 1; + data->expect_prefer_cores.drawers =3D 1; + } } =20 static void machine_base_class_init(ObjectClass *oc, void *data) --=20 2.34.1 From nobody Tue Nov 26 04:40:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1709718116; cv=none; d=zohomail.com; s=zohoarc; b=L9WdgSjgz3YZU9qnbDDOiNl/cuGDAC4kJ5o4H/WPS5nTR5vDyQvaPA3h7m3KCDFz0hZxr8mTaXOEOrFM2oawoNatmpmMKUMt4afE7h4PLBA088ivCsFsBros1SBEBdTWIdH2EBulx7G/SB0cn3i4866td+yq3F6ROICdiVVnMlY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709718116; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=B1IGfP9L1NckCIu8WhZHQ2WL/+LNPADLwN0MCsP9GKA=; b=S/yYsrKFJ3UgAlhjMVjWVW9sUd78npDqrK7yKxl/Ag8z+krLhcYI6nJ/toFTJbfJu0O82pH0PONoJ94UB9oupoIBeb+yzS32pBR/DPXWzYyMzLt5n1mNWV9t+1ysNS3IkjE5j4EGiriT4ppHj3zX01+pVFNLMQR03E3B3QbqJUg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1709718116824725.9798597831275; Wed, 6 Mar 2024 01:41:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhnlh-0007Xw-Sy; Wed, 06 Mar 2024 04:40:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhnlg-0007Xl-Fg for qemu-devel@nongnu.org; Wed, 06 Mar 2024 04:40:56 -0500 Received: from mgamail.intel.com ([198.175.65.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhnle-0002K2-ID for qemu-devel@nongnu.org; Wed, 06 Mar 2024 04:40:56 -0500 Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2024 01:40:53 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa002.fm.intel.com with ESMTP; 06 Mar 2024 01:40:51 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709718054; x=1741254054; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7vGl3GjI8paiQ3I7X/TQ3issWbN5GAsKHFxMbtWltmk=; b=FbJGJCg3j3uTWu3FQO9ccb4cASIy24TuCUAKg0cH6NAT2XhhPUKJ1hIb Sqzo+CbRw5A7hKyY+lHGOW3vtGpsMMwxz+fxA79auqqI2ZcbASYtaYMGC +5+Jnz2KBt3vkId+15O2TNXp/tEEa1CmygFXkFyWx+us1rU5sqo/mpbXg gLixgJNAIQZhLIOBIveTTOY7Ppxi/ZOnDi0b6myz1Ig7vthaH93MZPCz+ FONgN+QWFEH8lAzDdK4+fuAihqp3WG4oY9Mpx7TTyVQwYsv0U+IzO/hhN /fLHnUD7Flr57Dw5Lnob2rKEFzBXWaK0Rp4iVOV+PObIy78yXKt5D4ObE A==; X-IronPort-AV: E=McAfee;i="6600,9927,11004"; a="14897906" X-IronPort-AV: E=Sophos;i="6.06,207,1705392000"; d="scan'208";a="14897906" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,207,1705392000"; d="scan'208";a="32854163" From: Zhao Liu To: Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Thomas Huth , Igor Mammedov , Prasad Pandit , qemu-devel@nongnu.org Cc: Xiaoling Song , Zhao Liu Subject: [PATCH 09/14] tests/unit/test-smp-parse: Test "books" parameter in -smp Date: Wed, 6 Mar 2024 17:54:02 +0800 Message-Id: <20240306095407.3058909-10-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240306095407.3058909-1-zhao1.liu@linux.intel.com> References: <20240306095407.3058909-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=198.175.65.11; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.568, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1709718118804100003 Content-Type: text/plain; charset="utf-8" From: Zhao Liu Although book was introduced to -smp along with drawer by s390 machine, as a general topology level in QEMU that may be reused by other arches in the future, it is desirable to cover this parameter's parsing in a separate case. Signed-off-by: Zhao Liu Tested-by: Xiaoling Song Reviewed-by: Thomas Huth --- tests/unit/test-smp-parse.c | 105 ++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) diff --git a/tests/unit/test-smp-parse.c b/tests/unit/test-smp-parse.c index f656bbb6da27..090238ab23f8 100644 --- a/tests/unit/test-smp-parse.c +++ b/tests/unit/test-smp-parse.c @@ -75,6 +75,22 @@ .has_maxcpus =3D hf, .maxcpus =3D f, \ } =20 +/* + * Currently a 5-level topology hierarchy is supported on s390 ccw machines + * -drawers/books/sockets/cores/threads + */ +#define SMP_CONFIG_WITH_BOOKS_DRAWERS(ha, a, hb, b, hc, c, hd, \ + d, he, e, hf, f, hg, g) \ + { \ + .has_cpus =3D ha, .cpus =3D a, \ + .has_drawers =3D hb, .drawers =3D b, \ + .has_books =3D hc, .books =3D c, \ + .has_sockets =3D hd, .sockets =3D d, \ + .has_cores =3D he, .cores =3D e, \ + .has_threads =3D hf, .threads =3D f, \ + .has_maxcpus =3D hg, .maxcpus =3D g, \ + } + /** * @config - the given SMP configuration * @expect_prefer_sockets - the expected parsing result for the @@ -308,6 +324,11 @@ static const struct SMPTestData data_generic_invalid[]= =3D { /* config: -smp 2,clusters=3D2 */ .config =3D SMP_CONFIG_WITH_CLUSTERS(T, 2, F, 0, T, 2, F, 0, F, 0,= F, 0), .expect_error =3D "clusters not supported by this machine's CPU to= pology", + }, { + /* config: -smp 2,books=3D2 */ + .config =3D SMP_CONFIG_WITH_BOOKS_DRAWERS(T, 2, F, 0, T, 2, F, + 0, F, 0, F, 0, F, 0), + .expect_error =3D "books not supported by this machine's CPU topol= ogy", }, { /* config: -smp 8,sockets=3D2,cores=3D4,threads=3D2,maxcpus=3D8 */ .config =3D SMP_CONFIG_GENERIC(T, 8, T, 2, T, 4, T, 2, T, 8), @@ -379,6 +400,26 @@ static const struct SMPTestData data_with_clusters_inv= alid[] =3D { }, }; =20 +static const struct SMPTestData data_with_books_invalid[] =3D { + { + /* config: -smp 16,books=3D2,sockets=3D2,cores=3D4,threads=3D2,max= cpus=3D16 */ + .config =3D SMP_CONFIG_WITH_BOOKS_DRAWERS(T, 16, F, 1, T, 2, T, + 2, T, 4, T, 2, T, 16), + .expect_error =3D "Invalid CPU topology: " + "product of the hierarchy must match maxcpus: " + "books (2) * sockets (2) * cores (4) * threads (2)= " + "!=3D maxcpus (16)", + }, { + /* config: -smp 34,books=3D2,sockets=3D2,cores=3D4,threads=3D2,max= cpus=3D32 */ + .config =3D SMP_CONFIG_WITH_BOOKS_DRAWERS(T, 34, F, 1, T, 2, T, + 2, T, 4, T, 2, T, 32), + .expect_error =3D "Invalid CPU topology: " + "maxcpus must be equal to or greater than smp: " + "books (2) * sockets (2) * cores (4) * threads (2)= " + "=3D=3D maxcpus (32) < smp_cpus (34)", + }, +}; + static char *smp_config_to_string(const SMPConfiguration *config) { return g_strdup_printf( @@ -618,6 +659,13 @@ static void machine_with_clusters_class_init(ObjectCla= ss *oc, void *data) mc->smp_props.clusters_supported =3D true; } =20 +static void machine_with_books_class_init(ObjectClass *oc, void *data) +{ + MachineClass *mc =3D MACHINE_CLASS(oc); + + mc->smp_props.books_supported =3D true; +} + static void test_generic_valid(const void *opaque) { const char *machine_type =3D opaque; @@ -756,6 +804,56 @@ static void test_with_clusters(const void *opaque) object_unref(obj); } =20 +static void test_with_books(const void *opaque) +{ + const char *machine_type =3D opaque; + Object *obj =3D object_new(machine_type); + MachineState *ms =3D MACHINE(obj); + MachineClass *mc =3D MACHINE_GET_CLASS(obj); + SMPTestData data =3D {}; + unsigned int num_books =3D 2; + int i; + + for (i =3D 0; i < ARRAY_SIZE(data_generic_valid); i++) { + data =3D data_generic_valid[i]; + unsupported_params_init(mc, &data); + + /* when books parameter is omitted, it will be set as 1 */ + data.expect_prefer_sockets.books =3D 1; + data.expect_prefer_cores.books =3D 1; + + smp_parse_test(ms, &data, true); + + /* when books parameter is specified */ + data.config.has_books =3D true; + data.config.books =3D num_books; + if (data.config.has_cpus) { + data.config.cpus *=3D num_books; + } + if (data.config.has_maxcpus) { + data.config.maxcpus *=3D num_books; + } + + data.expect_prefer_sockets.books =3D num_books; + data.expect_prefer_sockets.cpus *=3D num_books; + data.expect_prefer_sockets.max_cpus *=3D num_books; + data.expect_prefer_cores.books =3D num_books; + data.expect_prefer_cores.cpus *=3D num_books; + data.expect_prefer_cores.max_cpus *=3D num_books; + + smp_parse_test(ms, &data, true); + } + + for (i =3D 0; i < ARRAY_SIZE(data_with_books_invalid); i++) { + data =3D data_with_books_invalid[i]; + unsupported_params_init(mc, &data); + + smp_parse_test(ms, &data, false); + } + + object_unref(obj); +} + /* Type info of the tested machine */ static const TypeInfo smp_machine_types[] =3D { { @@ -780,6 +878,10 @@ static const TypeInfo smp_machine_types[] =3D { .name =3D MACHINE_TYPE_NAME("smp-with-clusters"), .parent =3D TYPE_MACHINE, .class_init =3D machine_with_clusters_class_init, + }, { + .name =3D MACHINE_TYPE_NAME("smp-with-books"), + .parent =3D TYPE_MACHINE, + .class_init =3D machine_with_books_class_init, } }; =20 @@ -803,6 +905,9 @@ int main(int argc, char *argv[]) g_test_add_data_func("/test-smp-parse/with_clusters", MACHINE_TYPE_NAME("smp-with-clusters"), test_with_clusters); + g_test_add_data_func("/test-smp-parse/with_books", + MACHINE_TYPE_NAME("smp-with-books"), + test_with_books); =20 g_test_run(); =20 --=20 2.34.1 From nobody Tue Nov 26 04:40:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1709718088; cv=none; d=zohomail.com; s=zohoarc; b=RcAsSNK7s/h8y4NXFXbFeC9EB8cIjjbzq6q/m9LOAlkMYJaMdAKA58pMXtISCGukLfKMehVBdkpFAjH48ywc8jZvlshA3p7shwDTaiBT7UCtC2+CTeG55Ou0poMno+/O3bMxvswKpljHebnYTQ+fCND4ghjFSo3TmgQPonR0tEo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709718088; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=VTIiVu7iYclqmBI/t4Eodf8ui0lb6p7tsmfx5fT/YVc=; b=A7veES/vkWT0S0NUSCTksbS3MonNjmD83rXzn5vNP+8ChZRqRG2YHbuPRdDS3ljSYElzb/ATCoiq/y+WKtlCTQPkRTRZgqaMSjNE3wwcZPOSqpYrWzkhlmhGschGEMiE+YgV7RxSZ/UqvYeRjiGyFFNDzUtWsScdOav69X3EhCI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1709718088236810.7999669107259; Wed, 6 Mar 2024 01:41:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhnll-0007YQ-NL; Wed, 06 Mar 2024 04:41:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhnlj-0007YI-E2 for qemu-devel@nongnu.org; Wed, 06 Mar 2024 04:41:00 -0500 Received: from mgamail.intel.com ([198.175.65.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhnlh-0002K2-F4 for qemu-devel@nongnu.org; Wed, 06 Mar 2024 04:40:59 -0500 Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2024 01:40:56 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa002.fm.intel.com with ESMTP; 06 Mar 2024 01:40:54 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709718057; x=1741254057; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wJPjIQhDPSLtPOJIxXDJGeEyfUjDSVN/nM6zcVB97uM=; b=Q4n32BCqpib2IPMAAqaimYWNhQWxRf89OJbJ6/MOJNMieI7yXkd4n8je VfDxLe2EX6JVr92nr9EYBYSKVW20KfhiGqAkb7mMefCX6EaB/HaOpt8Ce byTMAsm+QXplZij5QXz4TBEe8HxOx0hVX4fr0fteFjTFPyk0wClHR3X7O UargV/oq3GR9RbkQGuTqP8mthG1jrmnd7APcjhipUZt1OxBd+w+jcjo1V QjXNnqEn13hyjN98XxL6euLgNh2TpOfboWHRontT5BhpCDgCr/AmmhRSa zNm+6n5j1vBdaN1rgb5wmJV2G4UvPA4Hj0yvYK1rrgOftF5Vg9NSjWKti g==; X-IronPort-AV: E=McAfee;i="6600,9927,11004"; a="14897921" X-IronPort-AV: E=Sophos;i="6.06,207,1705392000"; d="scan'208";a="14897921" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,207,1705392000"; d="scan'208";a="32854168" From: Zhao Liu To: Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Thomas Huth , Igor Mammedov , Prasad Pandit , qemu-devel@nongnu.org Cc: Xiaoling Song , Zhao Liu Subject: [PATCH 10/14] tests/unit/test-smp-parse: Test "drawers" parameter in -smp Date: Wed, 6 Mar 2024 17:54:03 +0800 Message-Id: <20240306095407.3058909-11-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240306095407.3058909-1-zhao1.liu@linux.intel.com> References: <20240306095407.3058909-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=198.175.65.11; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.568, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1709718088716100001 Content-Type: text/plain; charset="utf-8" From: Zhao Liu Although drawer was introduced to -smp along with book by s390 machine, as a general topology level in QEMU that may be reused by other arches in the future, it is desirable to cover this parameter's parsing in a separate case. Signed-off-by: Zhao Liu Tested-by: Xiaoling Song Reviewed-by: Thomas Huth --- tests/unit/test-smp-parse.c | 89 +++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/tests/unit/test-smp-parse.c b/tests/unit/test-smp-parse.c index 090238ab23f8..aea1b2e73a55 100644 --- a/tests/unit/test-smp-parse.c +++ b/tests/unit/test-smp-parse.c @@ -329,6 +329,11 @@ static const struct SMPTestData data_generic_invalid[]= =3D { .config =3D SMP_CONFIG_WITH_BOOKS_DRAWERS(T, 2, F, 0, T, 2, F, 0, F, 0, F, 0, F, 0), .expect_error =3D "books not supported by this machine's CPU topol= ogy", + }, { + /* config: -smp 2,drawers=3D2 */ + .config =3D SMP_CONFIG_WITH_BOOKS_DRAWERS(T, 2, T, 2, F, 0, F, + 0, F, 0, F, 0, F, 0), + .expect_error =3D "drawers not supported by this machine's CPU top= ology", }, { /* config: -smp 8,sockets=3D2,cores=3D4,threads=3D2,maxcpus=3D8 */ .config =3D SMP_CONFIG_GENERIC(T, 8, T, 2, T, 4, T, 2, T, 8), @@ -420,6 +425,26 @@ static const struct SMPTestData data_with_books_invali= d[] =3D { }, }; =20 +static const struct SMPTestData data_with_drawers_invalid[] =3D { + { + /* config: -smp 16,drawers=3D2,sockets=3D2,cores=3D4,threads=3D2,m= axcpus=3D16 */ + .config =3D SMP_CONFIG_WITH_BOOKS_DRAWERS(T, 16, T, 2, F, 1, T, + 2, T, 4, T, 2, T, 16), + .expect_error =3D "Invalid CPU topology: " + "product of the hierarchy must match maxcpus: " + "drawers (2) * sockets (2) * cores (4) * threads (= 2) " + "!=3D maxcpus (16)", + }, { + /* config: -smp 34,drawers=3D2,sockets=3D2,cores=3D4,threads=3D2,m= axcpus=3D32 */ + .config =3D SMP_CONFIG_WITH_BOOKS_DRAWERS(T, 34, T, 2, F, 1, T, + 2, T, 4, T, 2, T, 32), + .expect_error =3D "Invalid CPU topology: " + "maxcpus must be equal to or greater than smp: " + "drawers (2) * sockets (2) * cores (4) * threads (= 2) " + "=3D=3D maxcpus (32) < smp_cpus (34)", + }, +}; + static char *smp_config_to_string(const SMPConfiguration *config) { return g_strdup_printf( @@ -666,6 +691,13 @@ static void machine_with_books_class_init(ObjectClass = *oc, void *data) mc->smp_props.books_supported =3D true; } =20 +static void machine_with_drawers_class_init(ObjectClass *oc, void *data) +{ + MachineClass *mc =3D MACHINE_CLASS(oc); + + mc->smp_props.drawers_supported =3D true; +} + static void test_generic_valid(const void *opaque) { const char *machine_type =3D opaque; @@ -854,6 +886,56 @@ static void test_with_books(const void *opaque) object_unref(obj); } =20 +static void test_with_drawers(const void *opaque) +{ + const char *machine_type =3D opaque; + Object *obj =3D object_new(machine_type); + MachineState *ms =3D MACHINE(obj); + MachineClass *mc =3D MACHINE_GET_CLASS(obj); + SMPTestData data =3D {}; + unsigned int num_drawers =3D 2; + int i; + + for (i =3D 0; i < ARRAY_SIZE(data_generic_valid); i++) { + data =3D data_generic_valid[i]; + unsupported_params_init(mc, &data); + + /* when drawers parameter is omitted, it will be set as 1 */ + data.expect_prefer_sockets.drawers =3D 1; + data.expect_prefer_cores.drawers =3D 1; + + smp_parse_test(ms, &data, true); + + /* when drawers parameter is specified */ + data.config.has_drawers =3D true; + data.config.drawers =3D num_drawers; + if (data.config.has_cpus) { + data.config.cpus *=3D num_drawers; + } + if (data.config.has_maxcpus) { + data.config.maxcpus *=3D num_drawers; + } + + data.expect_prefer_sockets.drawers =3D num_drawers; + data.expect_prefer_sockets.cpus *=3D num_drawers; + data.expect_prefer_sockets.max_cpus *=3D num_drawers; + data.expect_prefer_cores.drawers =3D num_drawers; + data.expect_prefer_cores.cpus *=3D num_drawers; + data.expect_prefer_cores.max_cpus *=3D num_drawers; + + smp_parse_test(ms, &data, true); + } + + for (i =3D 0; i < ARRAY_SIZE(data_with_drawers_invalid); i++) { + data =3D data_with_drawers_invalid[i]; + unsupported_params_init(mc, &data); + + smp_parse_test(ms, &data, false); + } + + object_unref(obj); +} + /* Type info of the tested machine */ static const TypeInfo smp_machine_types[] =3D { { @@ -882,6 +964,10 @@ static const TypeInfo smp_machine_types[] =3D { .name =3D MACHINE_TYPE_NAME("smp-with-books"), .parent =3D TYPE_MACHINE, .class_init =3D machine_with_books_class_init, + }, { + .name =3D MACHINE_TYPE_NAME("smp-with-drawers"), + .parent =3D TYPE_MACHINE, + .class_init =3D machine_with_drawers_class_init, } }; =20 @@ -908,6 +994,9 @@ int main(int argc, char *argv[]) g_test_add_data_func("/test-smp-parse/with_books", MACHINE_TYPE_NAME("smp-with-books"), test_with_books); + g_test_add_data_func("/test-smp-parse/with_drawers", + MACHINE_TYPE_NAME("smp-with-drawers"), + test_with_drawers); =20 g_test_run(); =20 --=20 2.34.1 From nobody Tue Nov 26 04:40:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1709718247; cv=none; d=zohomail.com; s=zohoarc; b=Ju9ityjJeHSBYmkC3lMsoAKXyS91MJcrYW6DnXt4XOCSgZmWzAPhquP3l3E8mCCh6pJ8tE0yHAC7pXeqGFoJyDob3XAryDb9jvwAsfHuoGmT8MzlvyeHsHtjeZ4f3iEBr0mPd3MJ0Z0wM6yT4z4rf3jII+zy4F1L6TLFTai9TDk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709718247; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=IgTtxUYKCaLcBOj/Aq+Q9jLBPeE2hdTmNJLJ9McGsUY=; b=N6PmBhpef0QKHz9QbF6bjn2ygzNIZm354Atw7CZ/GlZRDAjZgr4T6ORZiKedCoOIJXW0xWMUEmObPXLAY1F8KN85V5TmOYpph4fVmV4mL0OZzaeJRYh3WaS8OtKc2nLisyrGnO5/JJazHq3ES/NFhB6+ViGGDxcDWnuwAea04ow= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 170971824701046.23545653924987; Wed, 6 Mar 2024 01:44:07 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhnlo-0007bl-8D; Wed, 06 Mar 2024 04:41:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhnlm-0007Yg-Ip for qemu-devel@nongnu.org; Wed, 06 Mar 2024 04:41:02 -0500 Received: from mgamail.intel.com ([198.175.65.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhnlk-0002K2-M8 for qemu-devel@nongnu.org; Wed, 06 Mar 2024 04:41:02 -0500 Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2024 01:41:00 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa002.fm.intel.com with ESMTP; 06 Mar 2024 01:40:57 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709718061; x=1741254061; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=rraLgOEmHua+mvXN56GiEb4WBRb2OqKXWSN7c0wTjoc=; b=lc+jGJCueT5oFH6DcQMqpPndpDs+4KGjX+tDvy1FFQo+2O4ak177gt/e TCg/S/B/Ez3cAofT7bWqpMqUDTZzUm8TOAbLa6aYKv2yX34ImhebwMiMe dwPw1fLqXLyupwCHoFiHES3CM7Xgz+mCc3NK/WMSlgZ+bnOIrJzJXyRnx zK/wsEi+MU6w3dAy+opdyrw8FU6dv9OQx7Zb4tyTVZw17fbW4XUwo1blF pwNg25K6qlDgeMtw6Fd2pZ+y4VSi/xEB7caHP5NQSvxLbT+PK36KpS4lx V71q5eWn7q/ADOXguOPBw0FG2RfrrVAVeSwmQdgLLMUFH+E1Qe+pft/22 w==; X-IronPort-AV: E=McAfee;i="6600,9927,11004"; a="14897931" X-IronPort-AV: E=Sophos;i="6.06,207,1705392000"; d="scan'208";a="14897931" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,207,1705392000"; d="scan'208";a="32854174" From: Zhao Liu To: Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Thomas Huth , Igor Mammedov , Prasad Pandit , qemu-devel@nongnu.org Cc: Xiaoling Song , Zhao Liu Subject: [PATCH 11/14] tests/unit/test-smp-parse: Test "drawers" and "books" combination case Date: Wed, 6 Mar 2024 17:54:04 +0800 Message-Id: <20240306095407.3058909-12-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240306095407.3058909-1-zhao1.liu@linux.intel.com> References: <20240306095407.3058909-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=198.175.65.11; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.568, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1709718248418100005 Content-Type: text/plain; charset="utf-8" From: Zhao Liu Since s390 machine supports both "drawers" and "books" in -smp, add the "drawers" and "books" combination test case to match the actual topology usage scenario. Signed-off-by: Zhao Liu Tested-by: Xiaoling Song Reviewed-by: Thomas Huth --- tests/unit/test-smp-parse.c | 103 ++++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) diff --git a/tests/unit/test-smp-parse.c b/tests/unit/test-smp-parse.c index aea1b2e73a55..0cf611519865 100644 --- a/tests/unit/test-smp-parse.c +++ b/tests/unit/test-smp-parse.c @@ -445,6 +445,33 @@ static const struct SMPTestData data_with_drawers_inva= lid[] =3D { }, }; =20 +static const struct SMPTestData data_with_drawers_books_invalid[] =3D { + { + /* + * config: -smp 200,drawers=3D2,books=3D2,sockets=3D2,cores=3D4,\ + * threads=3D2,maxcpus=3D200 + */ + .config =3D SMP_CONFIG_WITH_BOOKS_DRAWERS(T, 200, T, 3, T, 5, T, + 2, T, 4, T, 2, T, 200), + .expect_error =3D "Invalid CPU topology: " + "product of the hierarchy must match maxcpus: " + "drawers (3) * books (5) * sockets (2) * " + "cores (4) * threads (2) !=3D maxcpus (200)", + }, { + /* + * config: -smp 242,drawers=3D2,books=3D2,sockets=3D2,cores=3D4,\ + * threads=3D2,maxcpus=3D240 + */ + .config =3D SMP_CONFIG_WITH_BOOKS_DRAWERS(T, 242, T, 3, T, 5, T, + 2, T, 4, T, 2, T, 240), + .expect_error =3D "Invalid CPU topology: " + "maxcpus must be equal to or greater than smp: " + "drawers (3) * books (5) * sockets (2) * " + "cores (4) * threads (2) " + "=3D=3D maxcpus (240) < smp_cpus (242)", + }, +}; + static char *smp_config_to_string(const SMPConfiguration *config) { return g_strdup_printf( @@ -698,6 +725,14 @@ static void machine_with_drawers_class_init(ObjectClas= s *oc, void *data) mc->smp_props.drawers_supported =3D true; } =20 +static void machine_with_drawers_books_class_init(ObjectClass *oc, void *d= ata) +{ + MachineClass *mc =3D MACHINE_CLASS(oc); + + mc->smp_props.drawers_supported =3D true; + mc->smp_props.books_supported =3D true; +} + static void test_generic_valid(const void *opaque) { const char *machine_type =3D opaque; @@ -936,6 +971,67 @@ static void test_with_drawers(const void *opaque) object_unref(obj); } =20 +static void test_with_drawers_books(const void *opaque) +{ + const char *machine_type =3D opaque; + Object *obj =3D object_new(machine_type); + MachineState *ms =3D MACHINE(obj); + MachineClass *mc =3D MACHINE_GET_CLASS(obj); + SMPTestData data =3D {}; + unsigned int num_drawers =3D 5, num_books =3D 3; + int i; + + for (i =3D 0; i < ARRAY_SIZE(data_generic_valid); i++) { + data =3D data_generic_valid[i]; + unsupported_params_init(mc, &data); + + /* + * when drawers and books parameters are omitted, they will + * be both set as 1. + */ + data.expect_prefer_sockets.drawers =3D 1; + data.expect_prefer_sockets.books =3D 1; + data.expect_prefer_cores.drawers =3D 1; + data.expect_prefer_cores.books =3D 1; + + smp_parse_test(ms, &data, true); + + /* when drawers and books parameters are both specified */ + data.config.has_drawers =3D true; + data.config.drawers =3D num_drawers; + data.config.has_books =3D true; + data.config.books =3D num_books; + + if (data.config.has_cpus) { + data.config.cpus *=3D num_drawers * num_books; + } + if (data.config.has_maxcpus) { + data.config.maxcpus *=3D num_drawers * num_books; + } + + data.expect_prefer_sockets.drawers =3D num_drawers; + data.expect_prefer_sockets.books =3D num_books; + data.expect_prefer_sockets.cpus *=3D num_drawers * num_books; + data.expect_prefer_sockets.max_cpus *=3D num_drawers * num_books; + + data.expect_prefer_cores.drawers =3D num_drawers; + data.expect_prefer_cores.books =3D num_books; + data.expect_prefer_cores.cpus *=3D num_drawers * num_books; + data.expect_prefer_cores.max_cpus *=3D num_drawers * num_books; + + smp_parse_test(ms, &data, true); + } + + for (i =3D 0; i < ARRAY_SIZE(data_with_drawers_books_invalid); i++) { + data =3D data_with_drawers_books_invalid[i]; + unsupported_params_init(mc, &data); + + smp_parse_test(ms, &data, false); + } + + object_unref(obj); +} + /* Type info of the tested machine */ static const TypeInfo smp_machine_types[] =3D { { @@ -968,6 +1064,10 @@ static const TypeInfo smp_machine_types[] =3D { .name =3D MACHINE_TYPE_NAME("smp-with-drawers"), .parent =3D TYPE_MACHINE, .class_init =3D machine_with_drawers_class_init, + }, { + .name =3D MACHINE_TYPE_NAME("smp-with-drawers-books"), + .parent =3D TYPE_MACHINE, + .class_init =3D machine_with_drawers_books_class_init, } }; =20 @@ -997,6 +1097,9 @@ int main(int argc, char *argv[]) g_test_add_data_func("/test-smp-parse/with_drawers", MACHINE_TYPE_NAME("smp-with-drawers"), test_with_drawers); + g_test_add_data_func("/test-smp-parse/with_drawers_books", + MACHINE_TYPE_NAME("smp-with-drawers-books"), + test_with_drawers_books); =20 g_test_run(); =20 --=20 2.34.1 From nobody Tue Nov 26 04:40:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1709718135; cv=none; d=zohomail.com; s=zohoarc; b=FwEyiT5QUm+wS6SOq1mkSraBPsg2llN07T+fCQtPfHUFi9junBBcMxOYoVomzYMizO6gaK5r1GJkBRnRjfc9Sevck2pPzHiESl4IvoMbhKkQOr5Hysy6WMSxaIkdmT9um2JMK5b018DNE5zUjXw7QpsHFMZ1svdefZihFnN4g7g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709718135; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ZnJ5FdG5JC10DYh8lVwY+VkdNObAhfiXAEoTpXo026w=; b=AbjZR4z45XsowBfBlczJi7lABkQLXF1VsNIKpD6b5U5jw8lfiZDMDRThMS2d6Zls+ka6BygDIhyYH2cTyzAj2bXYwLk4D/qszVr5ISeMo+7V+HS4LUucGbyZfu6nb6zWjF+bQTVXnOqIVtcwt4BSmV1K1lBa2YxPkCcrdVKXvZ0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1709718134990590.394762400021; Wed, 6 Mar 2024 01:42:14 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhnlq-0007cU-H9; Wed, 06 Mar 2024 04:41:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhnlp-0007cJ-Jz for qemu-devel@nongnu.org; Wed, 06 Mar 2024 04:41:05 -0500 Received: from mgamail.intel.com ([198.175.65.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhnln-0002K2-IN for qemu-devel@nongnu.org; Wed, 06 Mar 2024 04:41:05 -0500 Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2024 01:41:03 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa002.fm.intel.com with ESMTP; 06 Mar 2024 01:41:00 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709718063; x=1741254063; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=98NJKETcDZW1zOOely50ceE+NQ46Hd2eboqvtOsOfq8=; b=XZDUzoMWaT8MmGVFXhxmC8fy8gyDxnJ84KINerku0RciMO87DFyC2ro2 JDVp+xzRyx06QdaSo7VhsHR1t9+moxW9PqB0tETwOYmwW6cq9n86QVZV+ IT1zmI1t+lwM46sgbvZxe4fwzob1lPv9GoKTwYfipc179/ZMtDEczMSBK naNDTRGASmxQfq8MGt5Bj7wnEY5iWYnWKef0IzG3VYiNFvgiSUDaNt8OE JVN1R2FqZvE3kODnOqXBmoYNjmVNLUOCeBywtaC+DBYaIFk3uSXqHF54d ATXrRPXVPUqNZaOkoRUBSKhWgaZSrGH/YWilEnmtA+Jn3ynOKt7xU3RC/ g==; X-IronPort-AV: E=McAfee;i="6600,9927,11004"; a="14897939" X-IronPort-AV: E=Sophos;i="6.06,207,1705392000"; d="scan'208";a="14897939" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,207,1705392000"; d="scan'208";a="32854185" From: Zhao Liu To: Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Thomas Huth , Igor Mammedov , Prasad Pandit , qemu-devel@nongnu.org Cc: Xiaoling Song , Zhao Liu Subject: [PATCH 12/14] tests/unit/test-smp-parse: Test the full 7-levels topology hierarchy Date: Wed, 6 Mar 2024 17:54:05 +0800 Message-Id: <20240306095407.3058909-13-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240306095407.3058909-1-zhao1.liu@linux.intel.com> References: <20240306095407.3058909-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=198.175.65.11; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.568, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1709718136887100003 Content-Type: text/plain; charset="utf-8" From: Zhao Liu Currently, -smp supports up to 7-levels topology hierarchy: -drawers/books/sockets/dies/clusters/cores/threads. Though no machine supports all these 7 levels yet, these 7 levels have the strict containment relationship and together form the generic CPU topology representation of QEMU. Also, note that the maxcpus is calculated by multiplying all 7 levels: maxcpus =3D drawers * books * sockets * dies * clusters * cores * threads. To cover this code path, it is necessary to test the full topology case (with all 7 levels). This also helps to avoid introducing new issues by further expanding the CPU topology in the future. Signed-off-by: Zhao Liu Tested-by: Xiaoling Song Acked-by: Thomas Huth --- tests/unit/test-smp-parse.c | 143 ++++++++++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+) diff --git a/tests/unit/test-smp-parse.c b/tests/unit/test-smp-parse.c index 0cf611519865..75581691713c 100644 --- a/tests/unit/test-smp-parse.c +++ b/tests/unit/test-smp-parse.c @@ -91,6 +91,24 @@ .has_maxcpus =3D hg, .maxcpus =3D g, \ } =20 +/* + * Currently QEMU supports up to a 7-level topology hierarchy, which is the + * QEMU's unified abstract representation of CPU topology. + * -drawers/books/sockets/dies/clusters/cores/threads + */ +#define SMP_CONFIG_WITH_FULL_TOPO(a, b, c, d, e, f, g, h, i) \ + { \ + .has_cpus =3D true, .cpus =3D a, \ + .has_drawers =3D true, .drawers =3D b, \ + .has_books =3D true, .books =3D c, \ + .has_sockets =3D true, .sockets =3D d, \ + .has_dies =3D true, .dies =3D e, \ + .has_clusters =3D true, .clusters =3D f, \ + .has_cores =3D true, .cores =3D g, \ + .has_threads =3D true, .threads =3D h, \ + .has_maxcpus =3D true, .maxcpus =3D i, \ + } + /** * @config - the given SMP configuration * @expect_prefer_sockets - the expected parsing result for the @@ -472,6 +490,40 @@ static const struct SMPTestData data_with_drawers_book= s_invalid[] =3D { }, }; =20 +static const struct SMPTestData data_full_topo_invalid[] =3D { + { + /* + * config: -smp 200,drawers=3D3,books=3D5,sockets=3D2,dies=3D4,\ + * clusters=3D2,cores=3D7,threads=3D2,maxcpus=3D200 + */ + .config =3D SMP_CONFIG_WITH_FULL_TOPO(200, 3, 5, 2, 4, 2, 7, 2, 20= 0), + .expect_error =3D "Invalid CPU topology: " + "product of the hierarchy must match maxcpus: " + "drawers (3) * books (5) * sockets (2) * dies (4) = * " + "clusters (2) * cores (7) * threads (2) " + "!=3D maxcpus (200)", + }, { + /* + * config: -smp 3361,drawers=3D3,books=3D5,sockets=3D2,dies=3D4,\ + * clusters=3D2,cores=3D7,threads=3D2,maxcpus=3D3360 + */ + .config =3D SMP_CONFIG_WITH_FULL_TOPO(3361, 3, 5, 2, 4, 2, 7, 2, 3= 360), + .expect_error =3D "Invalid CPU topology: " + "maxcpus must be equal to or greater than smp: " + "drawers (3) * books (5) * sockets (2) * dies (4) = * " + "clusters (2) * cores (7) * threads (2) " + "=3D=3D maxcpus (3360) < smp_cpus (3361)", + }, { + /* + * config: -smp 1,drawers=3D3,books=3D5,sockets=3D2,dies=3D4,\ + * clusters=3D2,cores=3D7,threads=3D3,maxcpus=3D5040 + */ + .config =3D SMP_CONFIG_WITH_FULL_TOPO(3361, 3, 5, 2, 4, 2, 7, 3, 5= 040), + .expect_error =3D "Invalid SMP CPUs 5040. The max CPUs supported " + "by machine '" SMP_MACHINE_NAME "' is 4096", + }, +}; + static char *smp_config_to_string(const SMPConfiguration *config) { return g_strdup_printf( @@ -733,6 +785,16 @@ static void machine_with_drawers_books_class_init(Obje= ctClass *oc, void *data) mc->smp_props.books_supported =3D true; } =20 +static void machine_full_topo_class_init(ObjectClass *oc, void *data) +{ + MachineClass *mc =3D MACHINE_CLASS(oc); + + mc->smp_props.drawers_supported =3D true; + mc->smp_props.books_supported =3D true; + mc->smp_props.dies_supported =3D true; + mc->smp_props.clusters_supported =3D true; +} + static void test_generic_valid(const void *opaque) { const char *machine_type =3D opaque; @@ -1032,6 +1094,80 @@ static void test_with_drawers_books(const void *opaq= ue) object_unref(obj); } =20 +static void test_full_topo(const void *opaque) +{ + const char *machine_type =3D opaque; + Object *obj =3D object_new(machine_type); + MachineState *ms =3D MACHINE(obj); + MachineClass *mc =3D MACHINE_GET_CLASS(obj); + SMPTestData data =3D {}; + unsigned int drawers =3D 5, books =3D 3, dies =3D 2, clusters =3D 7, m= ultiplier; + int i; + + multiplier =3D drawers * books * dies * clusters; + for (i =3D 0; i < ARRAY_SIZE(data_generic_valid); i++) { + data =3D data_generic_valid[i]; + unsupported_params_init(mc, &data); + + /* + * when drawers, books, dies and clusters parameters are omitted, + * they will be set as 1. + */ + data.expect_prefer_sockets.drawers =3D 1; + data.expect_prefer_sockets.books =3D 1; + data.expect_prefer_sockets.dies =3D 1; + data.expect_prefer_sockets.clusters =3D 1; + data.expect_prefer_cores.drawers =3D 1; + data.expect_prefer_cores.books =3D 1; + data.expect_prefer_cores.dies =3D 1; + data.expect_prefer_cores.clusters =3D 1; + + smp_parse_test(ms, &data, true); + + /* when drawers, books, dies and clusters parameters are specified= . */ + data.config.has_drawers =3D true; + data.config.drawers =3D drawers; + data.config.has_books =3D true; + data.config.books =3D books; + data.config.has_dies =3D true; + data.config.dies =3D dies; + data.config.has_clusters =3D true; + data.config.clusters =3D clusters; + + if (data.config.has_cpus) { + data.config.cpus *=3D multiplier; + } + if (data.config.has_maxcpus) { + data.config.maxcpus *=3D multiplier; + } + + data.expect_prefer_sockets.drawers =3D drawers; + data.expect_prefer_sockets.books =3D books; + data.expect_prefer_sockets.dies =3D dies; + data.expect_prefer_sockets.clusters =3D clusters; + data.expect_prefer_sockets.cpus *=3D multiplier; + data.expect_prefer_sockets.max_cpus *=3D multiplier; + + data.expect_prefer_cores.drawers =3D drawers; + data.expect_prefer_cores.books =3D books; + data.expect_prefer_cores.dies =3D dies; + data.expect_prefer_cores.clusters =3D clusters; + data.expect_prefer_cores.cpus *=3D multiplier; + data.expect_prefer_cores.max_cpus *=3D multiplier; + + smp_parse_test(ms, &data, true); + } + + for (i =3D 0; i < ARRAY_SIZE(data_full_topo_invalid); i++) { + data =3D data_full_topo_invalid[i]; + unsupported_params_init(mc, &data); + + smp_parse_test(ms, &data, false); + } + + object_unref(obj); +} + /* Type info of the tested machine */ static const TypeInfo smp_machine_types[] =3D { { @@ -1068,6 +1204,10 @@ static const TypeInfo smp_machine_types[] =3D { .name =3D MACHINE_TYPE_NAME("smp-with-drawers-books"), .parent =3D TYPE_MACHINE, .class_init =3D machine_with_drawers_books_class_init, + }, { + .name =3D MACHINE_TYPE_NAME("smp-full-topo"), + .parent =3D TYPE_MACHINE, + .class_init =3D machine_full_topo_class_init, } }; =20 @@ -1100,6 +1240,9 @@ int main(int argc, char *argv[]) g_test_add_data_func("/test-smp-parse/with_drawers_books", MACHINE_TYPE_NAME("smp-with-drawers-books"), test_with_drawers_books); + g_test_add_data_func("/test-smp-parse/full", + MACHINE_TYPE_NAME("smp-full-topo"), + test_full_topo); =20 g_test_run(); =20 --=20 2.34.1 From nobody Tue Nov 26 04:40:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1709718118; cv=none; d=zohomail.com; s=zohoarc; b=S1AuiVvKaA9Q/2LYCiVWvg3xVhRDW7NLeE8NQA56la1cstKPOzsJTIdGdjbzrpjddVOuCJ/wu1A8OayME8B4fj2eiAX+p7dJ2H8B+EViYRPkkWYK5UTrW5x2UKthKkUwx6i9W80SDQ9lDjoF+yY9Kd51PPUkMA04Q/9MELbtqvw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709718118; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=81w26MIDFs/9G5X5bRx4Vqwq+xTuBgQjeWOXJDILFPk=; b=HOrwNJ4Ja51dZByQ9fb+xexWz2j5SniZXYdLASqluEYWaocDvwDNP+yTkz+VzixoQENuI8JpgcKgj4XefKbeJY9GXQTDVLMlr5Q9ssf+2DTBhzMbC1ccoKdoax5ckg4Gor4Zp2EClggskMZhdmQ3Yk6+8O3jO5KxZaoLiI8UEGo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1709718118746855.9484586782967; Wed, 6 Mar 2024 01:41:58 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhnm3-0007yQ-8z; Wed, 06 Mar 2024 04:41:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhnm2-0007x7-E8 for qemu-devel@nongnu.org; Wed, 06 Mar 2024 04:41:18 -0500 Received: from mgamail.intel.com ([198.175.65.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhnm0-0002K2-Hc for qemu-devel@nongnu.org; Wed, 06 Mar 2024 04:41:18 -0500 Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2024 01:41:06 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa002.fm.intel.com with ESMTP; 06 Mar 2024 01:41:03 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709718076; x=1741254076; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9CNNd6/FqGn+vADBzcQTmk8SQKEglbZAI6+rVVgSS7Q=; b=hSvmgKdqcKMfdF5h4ZtCnBMn88TGye5DK3jzA0X+PljNRVNDLqLYLOLn gLueLEDrUJ5tnKwAvW0qwHUeqFhgBrf+8FGUv9ppvCMXuCSxWmOZuvsje 1TOW0+HARleM48kfWDnqxhFGk1OtVIoIAKiiMiahOek/AyFvhMEvC8IOt u+txbMPh7Ykuknc32iUB4R/3cQaTklZBdf03rWXwfg/eS9DJhTH5xaSPY zAeBvBthFd0gcFEbPiVVAbzbHwQM8eq95Wvz9ek2+U1BpOwlQrpWt/7wP 2A34UerHtLpbodzOkWTqrEgMgylags8NCOt5IQuYHBOcK3wC9TGzAHpGv w==; X-IronPort-AV: E=McAfee;i="6600,9927,11004"; a="14897952" X-IronPort-AV: E=Sophos;i="6.06,207,1705392000"; d="scan'208";a="14897952" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,207,1705392000"; d="scan'208";a="32854199" From: Zhao Liu To: Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Thomas Huth , Igor Mammedov , Prasad Pandit , qemu-devel@nongnu.org Cc: Xiaoling Song , Zhao Liu Subject: [PATCH 13/14] tests/unit/test-smp-parse: Test smp_props.has_clusters Date: Wed, 6 Mar 2024 17:54:06 +0800 Message-Id: <20240306095407.3058909-14-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240306095407.3058909-1-zhao1.liu@linux.intel.com> References: <20240306095407.3058909-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=198.175.65.11; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.568, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1709718120808100007 Content-Type: text/plain; charset="utf-8" From: Zhao Liu The smp_props.has_clusters in MachineClass is not a user configured field, and it indicates if user specifies "clusters" in -smp. After -smp parsing, other module could aware if the cluster level is configured by user. This is used when the machine has only 1 cluster since there's only 1 cluster by default. Add the check to cover this field. Signed-off-by: Zhao Liu Tested-by: Xiaoling Song Acked-by: Thomas Huth --- tests/unit/test-smp-parse.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/tests/unit/test-smp-parse.c b/tests/unit/test-smp-parse.c index 75581691713c..d39cfdc19bfe 100644 --- a/tests/unit/test-smp-parse.c +++ b/tests/unit/test-smp-parse.c @@ -573,7 +573,8 @@ static unsigned int cpu_topology_get_cores_per_socket(c= onst CpuTopology *topo) =20 static char *cpu_topology_to_string(const CpuTopology *topo, unsigned int threads_per_socket, - unsigned int cores_per_socket) + unsigned int cores_per_socket, + bool has_clusters) { return g_strdup_printf( "(CpuTopology) {\n" @@ -588,17 +589,20 @@ static char *cpu_topology_to_string(const CpuTopology= *topo, " .max_cpus =3D %u,\n" " .threads_per_socket =3D %u,\n" " .cores_per_socket =3D %u,\n" + " .has_clusters =3D %s,\n" "}", topo->cpus, topo->drawers, topo->books, topo->sockets, topo->dies, topo->clusters, topo->cores, topo->threads, topo->max_cpus, - threads_per_socket, cores_per_socket); + threads_per_socket, cores_per_socket, + has_clusters ? "true" : "false"); } =20 static void check_parse(MachineState *ms, const SMPConfiguration *config, const CpuTopology *expect_topo, const char *expect= _err, bool is_valid) { + MachineClass *mc =3D MACHINE_GET_CLASS(ms); g_autofree char *config_str =3D smp_config_to_string(config); g_autofree char *expect_topo_str =3D NULL, *output_topo_str =3D NULL; unsigned int expect_threads_per_socket, expect_cores_per_socket; @@ -611,15 +615,18 @@ static void check_parse(MachineState *ms, const SMPCo= nfiguration *config, cpu_topology_get_cores_per_socket(expect_topo); expect_topo_str =3D cpu_topology_to_string(expect_topo, expect_threads_per_socket, - expect_cores_per_socket); + expect_cores_per_socket, + config->has_clusters); =20 /* call the generic parser */ machine_parse_smp_config(ms, config, &err); =20 ms_threads_per_socket =3D machine_topo_get_threads_per_socket(ms); ms_cores_per_socket =3D machine_topo_get_cores_per_socket(ms); - output_topo_str =3D cpu_topology_to_string(&ms->smp, ms_threads_per_so= cket, - ms_cores_per_socket); + output_topo_str =3D cpu_topology_to_string(&ms->smp, + ms_threads_per_socket, + ms_cores_per_socket, + mc->smp_props.has_clusters); =20 /* when the configuration is supposed to be valid */ if (is_valid) { @@ -634,7 +641,8 @@ static void check_parse(MachineState *ms, const SMPConf= iguration *config, (ms->smp.threads =3D=3D expect_topo->threads) && (ms->smp.max_cpus =3D=3D expect_topo->max_cpus) && (ms_threads_per_socket =3D=3D expect_threads_per_socket) && - (ms_cores_per_socket =3D=3D expect_cores_per_socket)) { + (ms_cores_per_socket =3D=3D expect_cores_per_socket) && + (mc->smp_props.has_clusters =3D=3D config->has_clusters)) { return; } =20 --=20 2.34.1 From nobody Tue Nov 26 04:40:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1709718194; cv=none; d=zohomail.com; s=zohoarc; b=DvUuP6bc7sq64rqbhSUcwU4FwZtsifvFXK8/E7K7lPklVBeZ9Z9E3dxvZzyK/Hx9bJ2/iIFNpaa5MvsIJjXG7ZuP8VufaDDJSn1/O+mRJEMQm0daNefb4rpYAvvOQAI7F6oxPN2463ws2mtCq4+PWHOcn/YfrLisn9Yt9Mx/b2Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709718194; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=mchNf8yY1VhQRGXhH53JRB2L2hcph8i6oaxNUqyb8FE=; b=TE4IkGzUal2fquJaWeKqw7IjbEyZ3YKtFb79/E0nu+PqnNIX7f77jQXjwn27MwhyfewV9zQPk9kGSaSFpYq2oc5mcXGepXCzMjd9DdUXh3ZTW6IXX03kV80cJFfWxThdLu9oQo9Y+sPweounYYkwTlvvyDSfg0Hu/6/4XFkhtfQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1709718194886559.7897696832383; Wed, 6 Mar 2024 01:43:14 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhnm8-00085o-TP; Wed, 06 Mar 2024 04:41:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhnm7-00085T-1m for qemu-devel@nongnu.org; Wed, 06 Mar 2024 04:41:23 -0500 Received: from mgamail.intel.com ([198.175.65.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhnm4-0002dF-7X for qemu-devel@nongnu.org; Wed, 06 Mar 2024 04:41:22 -0500 Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2024 01:41:09 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa002.fm.intel.com with ESMTP; 06 Mar 2024 01:41:06 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709718080; x=1741254080; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=AyRMlDMPyeK2zIKXag691XL6Lf4SeMfVoV8Ojv6fvFk=; b=gJReOePo5eCcVs/hZ3hpWiIoTGyTxLMiti5eoKhGyZsZEi0nYEl9aySW I8fcsbsM47eJ0osypxoz/+8owA/b9VvkEWz6aB+LzEP9OT4CqkfCtZAxI KTgyZYLWmoQ6oxwK0Cqlxmss6fJScx47jz2FLzwkEwl+4u/jZ5LVvaZb+ 6XNDrPemJ4sFaiOHa93OqYQjKIaK8cGJIrDK2XpGff0RbNK3JP+sBvO37 Oz9x5sKVfXA8gJ0or9iyfnIY4LwTW68neQWCQSl1CCuHSZFMseAV1Rg4T M4+1vmL8+aBwLeyfO+UTfqjje72oZvClFDUIJzqQa2GPPzCQDyMYXhxiN A==; X-IronPort-AV: E=McAfee;i="6600,9927,11004"; a="14897959" X-IronPort-AV: E=Sophos;i="6.06,207,1705392000"; d="scan'208";a="14897959" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,207,1705392000"; d="scan'208";a="32854209" From: Zhao Liu To: Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Thomas Huth , Igor Mammedov , Prasad Pandit , qemu-devel@nongnu.org Cc: Xiaoling Song , Zhao Liu Subject: [PATCH 14/14] tests/unit/test-smp-parse: Test "parameter=0" SMP configurations Date: Wed, 6 Mar 2024 17:54:07 +0800 Message-Id: <20240306095407.3058909-15-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240306095407.3058909-1-zhao1.liu@linux.intel.com> References: <20240306095407.3058909-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=198.175.65.11; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.568, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1709718195082100001 Content-Type: text/plain; charset="utf-8" From: Zhao Liu The support for "parameter=3D0" SMP configurations is removed, and QEMU returns error for those cases. So add the related test cases to ensure parameters can't accept 0. Signed-off-by: Zhao Liu Reviewed-by: Thomas Huth --- tests/unit/test-smp-parse.c | 92 +++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/tests/unit/test-smp-parse.c b/tests/unit/test-smp-parse.c index d39cfdc19bfe..8994337e12c7 100644 --- a/tests/unit/test-smp-parse.c +++ b/tests/unit/test-smp-parse.c @@ -524,6 +524,91 @@ static const struct SMPTestData data_full_topo_invalid= [] =3D { }, }; =20 +static const struct SMPTestData data_zero_topo_invalid[] =3D { + { + /* + * Test "cpus=3D0". + * config: -smp 0,drawers=3D1,books=3D1,sockets=3D1,dies=3D1,\ + * clusters=3D1,cores=3D1,threads=3D1,maxcpus=3D1 + */ + .config =3D SMP_CONFIG_WITH_FULL_TOPO(0, 1, 1, 1, 1, 1, 1, 1, 1), + .expect_error =3D "Invalid CPU topology: CPU topology parameters m= ust " + "be greater than zero", + }, { + /* + * Test "drawers=3D0". + * config: -smp 1,drawers=3D0,books=3D1,sockets=3D1,dies=3D1,\ + * clusters=3D1,cores=3D1,threads=3D1,maxcpus=3D1 + */ + .config =3D SMP_CONFIG_WITH_FULL_TOPO(1, 0, 1, 1, 1, 1, 1, 1, 1), + .expect_error =3D "Invalid CPU topology: CPU topology parameters m= ust " + "be greater than zero", + }, { + /* + * Test "books=3D0". + * config: -smp 1,drawers=3D1,books=3D0,sockets=3D1,dies=3D1,\ + * clusters=3D1,cores=3D1,threads=3D1,maxcpus=3D1 + */ + .config =3D SMP_CONFIG_WITH_FULL_TOPO(1, 1, 0, 1, 1, 1, 1, 1, 1), + .expect_error =3D "Invalid CPU topology: CPU topology parameters m= ust " + "be greater than zero", + }, { + /* + * Test "sockets=3D0". + * config: -smp 1,drawers=3D1,books=3D1,sockets=3D0,dies=3D1,\ + * clusters=3D1,cores=3D1,threads=3D1,maxcpus=3D1 + */ + .config =3D SMP_CONFIG_WITH_FULL_TOPO(1, 1, 1, 0, 1, 1, 1, 1, 1), + .expect_error =3D "Invalid CPU topology: CPU topology parameters m= ust " + "be greater than zero", + }, { + /* + * Test "dies=3D0". + * config: -smp 1,drawers=3D1,books=3D1,sockets=3D1,dies=3D0,\ + * clusters=3D1,cores=3D1,threads=3D1,maxcpus=3D1 + */ + .config =3D SMP_CONFIG_WITH_FULL_TOPO(1, 1, 1, 1, 0, 1, 1, 1, 1), + .expect_error =3D "Invalid CPU topology: CPU topology parameters m= ust " + "be greater than zero", + }, { + /* + * Test "clusters=3D0". + * config: -smp 1,drawers=3D1,books=3D1,sockets=3D1,dies=3D1,\ + * clusters=3D0,cores=3D1,threads=3D1,maxcpus=3D1 + */ + .config =3D SMP_CONFIG_WITH_FULL_TOPO(1, 1, 1, 1, 1, 0, 1, 1, 1), + .expect_error =3D "Invalid CPU topology: CPU topology parameters m= ust " + "be greater than zero", + }, { + /* + * Test "cores=3D0". + * config: -smp 1,drawers=3D1,books=3D1,sockets=3D1,dies=3D1,\ + * clusters=3D1,cores=3D0,threads=3D1,maxcpus=3D1 + */ + .config =3D SMP_CONFIG_WITH_FULL_TOPO(1, 1, 1, 1, 1, 1, 0, 1, 1), + .expect_error =3D "Invalid CPU topology: CPU topology parameters m= ust " + "be greater than zero", + }, { + /* + * Test "threads=3D0". + * config: -smp 1,drawers=3D1,books=3D1,sockets=3D1,dies=3D1,\ + * clusters=3D1,cores=3D1,threads=3D0,maxcpus=3D1 + */ + .config =3D SMP_CONFIG_WITH_FULL_TOPO(1, 1, 1, 1, 1, 1, 1, 0, 1), + .expect_error =3D "Invalid CPU topology: CPU topology parameters m= ust " + "be greater than zero", + }, { + /* + * Test "maxcpus=3D0". + * config: -smp 1,drawers=3D1,books=3D1,sockets=3D1,dies=3D1,\ + * clusters=3D1,cores=3D1,threads=3D1,maxcpus=3D0 + */ + .config =3D SMP_CONFIG_WITH_FULL_TOPO(1, 1, 1, 1, 1, 1, 1, 1, 0), + .expect_error =3D "Invalid CPU topology: CPU topology parameters m= ust " + "be greater than zero", + }, +}; + static char *smp_config_to_string(const SMPConfiguration *config) { return g_strdup_printf( @@ -1173,6 +1258,13 @@ static void test_full_topo(const void *opaque) smp_parse_test(ms, &data, false); } =20 + for (i =3D 0; i < ARRAY_SIZE(data_zero_topo_invalid); i++) { + data =3D data_zero_topo_invalid[i]; + unsupported_params_init(mc, &data); + + smp_parse_test(ms, &data, false); + } + object_unref(obj); } =20 --=20 2.34.1