From nobody Mon May 13 07:55:37 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=1709913067; cv=none; d=zohomail.com; s=zohoarc; b=Tm/pNLZpOR9YPQf3p8YMTrGVSZ932Ezg+Qb3XILWeo5alsufljFl/oJNBhGmO1H8Q2/IZLXDvDv+RxTcB2kl6hjFBL37ZQayP5LmVvD1AQIL7lRNuMFAhWQF7McbdlhPWFKsauIrb34UZbn5/rw5+nFnXFruOELrAudyIofn04g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709913067; 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=/w/9FSqOPL3amGiNN3TowAcU+kjsEKj/JTUHq4xTyWQ=; b=GNt5XTPtd3kxGF/TW4BtF6PqXcTgL/Ed8Zwrkf+UpmOYClzaJ2ch/ZzDB37pSChRIFh55/oSRxVEMRzwCASe3yD/7fV9i5QeV0JsJMqEnuPjHUruDd9jWpMoIdMe5o+doBsjbAX/YOGPSAWZNw+kQUFPR5KLXTSILsWHc+6QkVA= 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 1709913067520531.1594025036845; Fri, 8 Mar 2024 07:51:07 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ricSM-0000YD-4d; Fri, 08 Mar 2024 10:48:22 -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 1ricSJ-0000XJ-4e for qemu-devel@nongnu.org; Fri, 08 Mar 2024 10:48:19 -0500 Received: from mgamail.intel.com ([198.175.65.21]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ricSG-0003yV-US for qemu-devel@nongnu.org; Fri, 08 Mar 2024 10:48:18 -0500 Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Mar 2024 07:48:16 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa007.fm.intel.com with ESMTP; 08 Mar 2024 07:48:13 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709912898; x=1741448898; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=B3lny/2+b2ix8nzCQ1+R6QE1gQbpbWuXDCZWBTjqMaY=; b=lHNRpvYA4pvgTykE3fgEyShzTN0IU9Wsch0g/fZhxNPXryGbXJ3pYyoR 9uyeuoZsW1Ir8qF0VQnSZLhpKmEhtnisbLwNHnEoeHoOgKLM22qMKRQ0y lFazT5kck/wlnt8iRH9fYDGJ35L0ZA0WHV/QF1bIJ0+LppzfihXCmW0eY LYH2Lzy8dZh3/ddGCBte5CgT/x+i7g0+0/kDx38yf96kKv+cyOxyRkO/n PhowO59VrFebkxUp3NLAkHLRQiSQ2ERO+edB4666QBq8WvW2AwDiyOELi dkFfBziJME7fOvfTtfgx1m39ERIjP8Us3zZ9dp8VQhEEA5g9aWeIoaIDc g==; X-IronPort-AV: E=McAfee;i="6600,9927,11006"; a="4561012" X-IronPort-AV: E=Sophos;i="6.07,110,1708416000"; d="scan'208";a="4561012" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,110,1708416000"; d="scan'208";a="10400315" 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 v2 01/13] hw/core/machine-smp: Remove deprecated "parameter=0" SMP configurations Date: Sat, 9 Mar 2024 00:01:36 +0800 Message-Id: <20240308160148.3130837-2-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240308160148.3130837-1-zhao1.liu@linux.intel.com> References: <20240308160148.3130837-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.21; 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.572, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: 1709913068651100003 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. 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 Mon May 13 07:55:37 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=1709913089; cv=none; d=zohomail.com; s=zohoarc; b=QowQecnPXY/ym+QrXSDO5yiJyyrzBecVMZmzsgMajYxV7zvUkoFqYwSpu0hXzXXfkaiymPoJL6PK90PJu7caLCorCuBsyMffSpz+W6cVUbrpU1ImBcKyz6BmgaqYFBEreoCrNLpB9BRStvLMBVviljvJYAbgXXP7sY29DSdiKe0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709913089; 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=y7K7wbix9yENdI8+BCfR2vf6sBSZZ4HfFVYP8ncqiUs=; b=AaYgBSOxFSbKHnYH+w4dPfBqBqw/BRpiFnXq8EHPLLWH2OTBhVT1Kfbf39PUCiMXLayiQr7aytoiQ1/pcHzmQXkXVzA4430vvW33wv6vu7jSjgyN39L5mvVUAcxDXXyiiY3zNxx/uUZVLSvHABDIswPQPYQjUxf8Wza9PYsQTA4= 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 1709913089752930.2247146761573; Fri, 8 Mar 2024 07:51:29 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ricSM-0000YE-Lz; Fri, 08 Mar 2024 10:48:23 -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 1ricSL-0000Y4-1H for qemu-devel@nongnu.org; Fri, 08 Mar 2024 10:48:21 -0500 Received: from mgamail.intel.com ([198.175.65.21]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ricSJ-0003yA-7T for qemu-devel@nongnu.org; Fri, 08 Mar 2024 10:48:20 -0500 Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Mar 2024 07:48:19 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa007.fm.intel.com with ESMTP; 08 Mar 2024 07:48:16 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709912900; x=1741448900; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FUnxZMIQ+lkqlPhuVllZ5Kf+bp2ultRSFG+6HXooT8A=; b=RR3xSvWAzxC9E2mHEQXsa7ycodwvvgbR9bD5qtRNAlaFGejEMBS7HVPf SEjv6D2dVI1GFY3FZOwOAaVNAAUcoKjfSSnOzpkx670NIIiC0ZAWfuuZl kjFbB1Dk9KY3K0PdWVH2WIhkLmJ4t5HbfgPAy3vqNX1fiOa6sdONKdGG4 todS2LfPb2U/O8eSqRtMCdAwpLsp4BiWOXpkvRa+VJORZucKNjV8yV4Vr anMYGud0QmKA2m2424AyEiD1WdzGL8sGhbyCs7fkb+ss4cATQrwOYzlb/ nXzSMMwTb1qFWdk3gTyz54fLWUn8ExrtI0SwhQGOV7s7HLf/JXhiyb32S A==; X-IronPort-AV: E=McAfee;i="6600,9927,11006"; a="4561022" X-IronPort-AV: E=Sophos;i="6.07,110,1708416000"; d="scan'208";a="4561022" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,110,1708416000"; d="scan'208";a="10400318" 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 v2 02/13] hw/core/machine-smp: Deprecate unsupported "parameter=1" SMP configurations Date: Sat, 9 Mar 2024 00:01:37 +0800 Message-Id: <20240308160148.3130837-3-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240308160148.3130837-1-zhao1.liu@linux.intel.com> References: <20240308160148.3130837-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.21; 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.572, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: 1709913090712100001 Content-Type: text/plain; charset="utf-8" From: Zhao Liu Currently, 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 deprecated 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. Signed-off-by: Zhao Liu Reviewed-by: Thomas Huth --- 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..9cc22523be49 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`` (Unsupported "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 deprecated 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 Mon May 13 07:55:37 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=1709912956; cv=none; d=zohomail.com; s=zohoarc; b=CqSBbiAigDOTnoiOE4OtcYq3NaIti6XHK5rJJ21T1VPsfK83RtFBOyn/6FuTFFmeQvbTX0mqwmd6vvXWhvxbkUUbRqahziUYz813Z7itqs9XApeDjOmci3KYnUu+qzE7Vz/nl882MC51n4pemJEsC6ZtNJ97Pyrrety07ZD6aTA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709912956; h=Content-Type: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=NqN0uWYcakfDbPy0bCvUW/LS5ClCUeH0o5YveBckAW4=; b=n84jSzu1fWGlT8N4CdYW7EnWrcoEY60O5+tCsgC4LKou+ufy2uLlSQXYwcaAQIWH8AGhYp+amtDWB7wfrA+Bo3dLH0PMmB5LWJjm09FuNJii66QiBZMIuMRVQyON5WbUBl87T96DLDkhdSOr+7zdWoFj6FZTm2Zg3oHIFc+vJEo= 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 17099129568097.3749141630405575; Fri, 8 Mar 2024 07:49:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ricSQ-0000bL-N0; Fri, 08 Mar 2024 10:48:26 -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 1ricSO-0000aN-FV for qemu-devel@nongnu.org; Fri, 08 Mar 2024 10:48:24 -0500 Received: from mgamail.intel.com ([198.175.65.21]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ricSM-0003z8-Nc for qemu-devel@nongnu.org; Fri, 08 Mar 2024 10:48:24 -0500 Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Mar 2024 07:48:22 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa007.fm.intel.com with ESMTP; 08 Mar 2024 07:48:19 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709912903; x=1741448903; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZcFpjBwAuhrJzhfBzCyj7s6+EUBvYMXuJ0yqyGBK0eo=; b=NIkOAp/gLcGFkbj2Zb9EP0SEZ7U5zDDnElrT3tLNXc6DrlptKHrrSexs 8U52Ov3LzYmek/y5RvtC6kPkp+bLvgpYnuBfx+6C919IVaT9iVZhhkIFu HVj7dOFipzOSgyVrMpx7xi+2JXdjkDr+ihvneYRl4F1yMb0F4nJQCeqSg lX5b6mKg7YtX4XjaAFywSaLqzcJP9mdCkwJpX/mbtjhn8x9PpI7WZaNg8 CPi6L928cxkxMx0EHeBILJhKtFgocpF2gxG3GowNGKAbo6u1dsTxZZ7tg q5ZB5pT/YgOQzloAnRjEERvOpsJqSD7edFVrjKJbdBapolX+lqDwhAYBK A==; X-IronPort-AV: E=McAfee;i="6600,9927,11006"; a="4561030" X-IronPort-AV: E=Sophos;i="6.07,110,1708416000"; d="scan'208";a="4561030" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,110,1708416000"; d="scan'208";a="10400324" 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 v2 03/13] hw/core/machine-smp: Calculate total CPUs once in machine_parse_smp_config() Date: Sat, 9 Mar 2024 00:01:38 +0800 Message-Id: <20240308160148.3130837-4-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240308160148.3130837-1-zhao1.liu@linux.intel.com> References: <20240308160148.3130837-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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.21; 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.572, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: 1709912958057100004 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 50a5a40dbc3d..27864c950766 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->has_cores ? config->cores : 0; unsigned threads =3D config->has_threads ? config->threads : 0; unsigned maxcpus =3D config->has_maxcpus ? config->maxcpus : 0; + 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 Mon May 13 07:55:37 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=1709913150; cv=none; d=zohomail.com; s=zohoarc; b=mfzFNo8AUhQq82lUi1z5CVh/M7nmPVVPBj2W5cYrvDG6N4z/g8CfKSe7ylx/Ls4sOV/aqgBuGBivtObWemZaz/Z3xccqgJm/oBxgC1DgxVT12X+w9OuTrmWOlWIK0VA3di5DMeKPtQ1r88DL7cd8grfQ7aZ8S4KNPO60QKnGqFc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709913150; 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=/6IUsvT+gxf+diYJme5j4n456T+4R5WyegkTSS3M/Xc=; b=K7h2BL3BpkFqOmT/JRLnixiXA1SXv/O+9mNBOAR6lg9N8/7FmmfmYlZYOhUDyp2r0IsxTAm037c0PrhoUmLp/RxCuUCGghkY587Bi0VqYy9A4Vke6HZb/iv/LSWCfzig21b/NRX18Kyb27S/fO9L4/oiV7ASbEM+gzWXhumbbWw= 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 1709913150748979.2822488452891; Fri, 8 Mar 2024 07:52:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ricSR-0000bS-6i; Fri, 08 Mar 2024 10:48:27 -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 1ricSQ-0000au-Ap for qemu-devel@nongnu.org; Fri, 08 Mar 2024 10:48:26 -0500 Received: from mgamail.intel.com ([198.175.65.21]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ricSO-0003z8-OR for qemu-devel@nongnu.org; Fri, 08 Mar 2024 10:48:25 -0500 Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Mar 2024 07:48:25 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa007.fm.intel.com with ESMTP; 08 Mar 2024 07:48:21 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709912905; x=1741448905; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5zs8ZVODy/+ePQaXGpb2JhRIroLOZFAagBdrQ9Q4O6g=; b=ExFFfybvNTwqK824DLfdeLKQEbdMW0Y9eRRz1TVJaAQUkjvApEFJMZTG zhf8OARNPPVzrxSyRJMU2yg0xORXRnWfsJmNTEkQE/BXmPWolccd6zEup kFXqxs6kTBj9Nte85g+dfMzMoTSwxIY7nkCBvGEBuseDQqafggwtLcRcR ZZfzc9ep5z8JG+CCr32tSd1YPUJJ/v3evPx4P13E0DzjNi1z2VeLn3bs6 Md9GU78YGnYI1b1Me2rYii6VBMj8xqhhQxUZ0hC4FpvSFc89uTnL6ruPT B5P+A8LdnIHxosz6S9tt3ossK1sE/QKt16etSFGssvljIDktC7MZL1Nys g==; X-IronPort-AV: E=McAfee;i="6600,9927,11006"; a="4561039" X-IronPort-AV: E=Sophos;i="6.07,110,1708416000"; d="scan'208";a="4561039" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,110,1708416000"; d="scan'208";a="10400328" 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 v2 04/13] tests/unit/test-smp-parse: Drop the unsupported "dies=1" case Date: Sat, 9 Mar 2024 00:01:39 +0800 Message-Id: <20240308160148.3130837-5-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240308160148.3130837-1-zhao1.liu@linux.intel.com> References: <20240308160148.3130837-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.21; 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.572, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: 1709913150939100001 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 Mon May 13 07:55:37 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=1709912957; cv=none; d=zohomail.com; s=zohoarc; b=bTQRbm5O1F8Rb+pVbIidQxVCQHOMtlF12ySP7R+24s7K6HLFct0C1BuL8TlWbxLAj3+ACEsnXTiYlPb19gs2fuiR7ChcdO1Cx1nS+m3MebN9m0WrUBdOdh85O8qLn/0cHt2AnbwX0yXezhWxuf5jR1WZPn7RipH+/DIOm3GlVkw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709912957; 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=LSFhghX61bmaehVYf74GI5HT4+O2/ErRU3zLSW8mQm5xAffLGws1RR0UUptBjpj+M/81y25nJIh0amU6hv4xp7hokW//jte7sMWSyjb8Lhj1ESCqsh8fMImNrKKPYzLn8jj7zNQGCRaIeV7vPpPYBcu5Qyh2bunPmUh00Udc3TU= 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 1709912957451394.86073703504985; Fri, 8 Mar 2024 07:49:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ricSW-0000ca-PT; Fri, 08 Mar 2024 10:48:32 -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 1ricSU-0000by-QX for qemu-devel@nongnu.org; Fri, 08 Mar 2024 10:48:30 -0500 Received: from mgamail.intel.com ([198.175.65.21]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ricST-000417-9O for qemu-devel@nongnu.org; Fri, 08 Mar 2024 10:48:30 -0500 Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Mar 2024 07:48:27 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa007.fm.intel.com with ESMTP; 08 Mar 2024 07:48:24 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709912910; x=1741448910; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6WGcGPLsmeM9ujwFnIiG1nYtUcObQiTkGIz1UZVazz0=; b=S0HgMHGVoCHpRi0IZ+DTLdewIYp+bwaaW6KwzNn2n+nsVf1otiHZJo0F 45S/Jw4efojA6lgFHWpL32tbWQfKR9SDmVgjmHi5114+8WVv7VUBeZWLo jeRKLyDkqfLNI4Rf4metBc5GA8UcpSg3SEi94Jtapogk4Fo1xoqf71HK7 0wZ5nTtw6Nw+6g8XZRf6X/scvkZugQX1eHVjSx1HfDH9id70a+x+VhIR2 kxyMc5cDcrWfzi1Exb9TnIcc2HpXfbhArTGvtPs0Ouh6Ljbc8EtRPifbP yf48aMMQd4z0ZxLB9BkmXPV2Gm2FZfyBRQg86tQwvHQP8qAWvAHyO/UXl Q==; X-IronPort-AV: E=McAfee;i="6600,9927,11006"; a="4561053" X-IronPort-AV: E=Sophos;i="6.07,110,1708416000"; d="scan'208";a="4561053" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,110,1708416000"; d="scan'208";a="10400332" 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 v2 05/13] tests/unit/test-smp-parse: Use CPU number macros in invalid topology case Date: Sat, 9 Mar 2024 00:01:40 +0800 Message-Id: <20240308160148.3130837-6-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240308160148.3130837-1-zhao1.liu@linux.intel.com> References: <20240308160148.3130837-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.21; 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.572, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: 1709912958056100003 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 Mon May 13 07:55:37 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=1709912957; cv=none; d=zohomail.com; s=zohoarc; b=YPBe9s51IjNwRkdNVRlALqApdKJtJiG998v9fVNIWr4pywUi8wtAvN8lwlUGBNF2sdUwLJwMXRh8bjgRG3u2NGuvATMZfe/pb5/lF9UAQp5OPhvsGOdpTY9JtCnYsIqLOJ8SwYxuMhk9f87QXfsEEoy6SYnr1zZWbEPqxdfEMP8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709912957; 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=xmoMZej1/WFe+f8z4czflY5bc80xJJOsWJqKEw7DDYI=; b=ddav1nYPX2CR5dWXt3cedFsr1eUSAR8vMNY6dg5FALGHeRhF5qSSlOACDyY//Ondqs+DYvZQxTftKahLEDmhtANGBjkrMDNnRBRWBjKJEeq4WoXD39AWxVS2KPpz23ulxclpQPQsGxeDPhlAjhTvvDmj3T4gTUbmjvbjqL/Izb8= 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 1709912957200572.6307529839225; Fri, 8 Mar 2024 07:49:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ricSX-0000cw-Ei; Fri, 08 Mar 2024 10:48:33 -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 1ricSW-0000cW-Km for qemu-devel@nongnu.org; Fri, 08 Mar 2024 10:48:32 -0500 Received: from mgamail.intel.com ([198.175.65.21]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ricSU-00041N-Sz for qemu-devel@nongnu.org; Fri, 08 Mar 2024 10:48:32 -0500 Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Mar 2024 07:48:30 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa007.fm.intel.com with ESMTP; 08 Mar 2024 07:48:27 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709912912; x=1741448912; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hQQp1HLSgx+wpMrBVHO/awDehkcqUXAg5RqG126+NFg=; b=QnAozsdXK5tjqV/8Ixus5oq4CAL7K1B4xAn9yxEhbxGjT436ZIGgAlQq ayFa7mGecez1IRQ7beWEFFzFlbw+hraIJGLXBBsGPtMZs24pLpP016R4C +YrvgoyTVi5DArBcHZq08ps3nCP2mDc4nhGgGGg73bJ0cbRrgT1VZ7GjS 8Vf+4q/KYBkGKAsSDAnKyMnyFH9EVCa+5wUAYUvv2sI39B/ZfellcGNTf x4bdwHqlxtBXVGgsZBGPAR9xEKBqeU8q4gI7t52HbQ/vSPuJ4HvXMqqCR 1ytYdSy0cBbGxyVjaWRRdyCy+gp1JKPK27QJM5RioVQeKF533NIxNzX94 w==; X-IronPort-AV: E=McAfee;i="6600,9927,11006"; a="4561066" X-IronPort-AV: E=Sophos;i="6.07,110,1708416000"; d="scan'208";a="4561066" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,110,1708416000"; d="scan'208";a="10400335" 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 v2 06/13] tests/unit/test-smp-parse: Bump max_cpus to 4096 Date: Sat, 9 Mar 2024 00:01:41 +0800 Message-Id: <20240308160148.3130837-7-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240308160148.3130837-1-zhao1.liu@linux.intel.com> References: <20240308160148.3130837-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.21; 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.572, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: 1709912958252100011 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 Mon May 13 07:55:37 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=1709912956; cv=none; d=zohomail.com; s=zohoarc; b=SnaGAxzGEPOQu975ETFsgQbCvvbDBm3bcKct5bOZJKH7OTh7diuWYwCPgtH2TYtEr25EdwG3S0BOikUdRh3I3clROsSLcomg/5ti2XMNGooUM7aiFtqtsh7zZDPaUR1v6kIMLqySvRPna7GaWkLIwwH1rFpAQn7vAQM+hmZgJV0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709912956; 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=TVXhgm7qEQMo8Yf2caTN6DcQ6+O31ytXaAvt42YpnQIXP5xTjqlL4dEllgErRNEyUnT+p5eN9FcttNDCvKMJX/pwr04++75NFQ5y2ydiBhHmXI2lwkVUx8skLQsHRTTV9IAECpa4kGbAE62qaeI49m+mNogi7ktKBfGHue9oCdA= 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 1709912956032957.4902938835662; Fri, 8 Mar 2024 07:49:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ricSa-0000gR-Qd; Fri, 08 Mar 2024 10:48:36 -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 1ricSZ-0000de-JN for qemu-devel@nongnu.org; Fri, 08 Mar 2024 10:48:35 -0500 Received: from mgamail.intel.com ([198.175.65.21]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ricSX-00042e-VK for qemu-devel@nongnu.org; Fri, 08 Mar 2024 10:48:35 -0500 Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Mar 2024 07:48:33 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa007.fm.intel.com with ESMTP; 08 Mar 2024 07:48:30 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709912915; x=1741448915; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3yBYX2nAWb+HDAcrhm+cAUvXQKvQu/GD/FeL85SWXFA=; b=gx2EaxopDtGNxMw5ZBM0+DtmogfLEpZzLcjvNPSz+OmzBtuYvUTmMoye p16+yX3hzRc+RWPvGCbTo5KO4ATc0EZs6kTMovN/ax65F1zT8oXwbavHt iEOd4nfHPF4gbId/YyoqX+EyaPY9ausRyrRvvP3aIp1Kl89vf2VGdMMe0 6h1buXxGGpnAvqMGy3bdFJqi9AuzSSVo+UN7Y+flfnhIt6ES0kRQwdmrT oSWcHKcaexnkQztNpHtcSF44313pXLrUpFuXFIbWmTOP4MtIX0hGvBrEo EtJJJsOy35D+yIhvcIfPVxi3m+KXWtOZ9n22CBdrfBy2WdEpPDwVn/2ap w==; X-IronPort-AV: E=McAfee;i="6600,9927,11006"; a="4561079" X-IronPort-AV: E=Sophos;i="6.07,110,1708416000"; d="scan'208";a="4561079" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,110,1708416000"; d="scan'208";a="10400339" 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 v2 07/13] tests/unit/test-smp-parse: Make test cases aware of the book/drawer Date: Sat, 9 Mar 2024 00:01:42 +0800 Message-Id: <20240308160148.3130837-8-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240308160148.3130837-1-zhao1.liu@linux.intel.com> References: <20240308160148.3130837-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.21; 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.572, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: 1709912958081100009 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 Mon May 13 07:55:37 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=1709913031; cv=none; d=zohomail.com; s=zohoarc; b=KB/JiSdCNXR/kWqtcE2pZEjFHzUAPCmk5CgGuyzF6b8fhfEVgztDrka704ZXMkZuk8MvrSm82PA8oPvdJIk3Ufm/sM+1RbzIkOF3RMI0DMb00xYxFy7kmf83+cLuVtMWzxCCTel97Y0qdN6bzNBW9J90Zr4hx+ZsG8YWz6Hu4rs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709913031; 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=gr/6xdPIWNab0cYLcwHebcOQmx6yAp45uGPEbuoaqf+v0QbifMg/uVyB9nldx985BsR1Qf4/9zRl7/qpeXp3eZxrZih6btocBMjuJxwToXFjm8kjhBXE6UBDk1cOVq4k/UMuQchn0rBG1TwnmCB9vgq0+LHL2eExIKmwJ0ejycQ= 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 1709913031828436.116893359148; Fri, 8 Mar 2024 07:50:31 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ricSd-0000iP-EG; Fri, 08 Mar 2024 10:48: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 1ricSc-0000i1-0u for qemu-devel@nongnu.org; Fri, 08 Mar 2024 10:48:38 -0500 Received: from mgamail.intel.com ([198.175.65.21]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ricSa-00042e-6u for qemu-devel@nongnu.org; Fri, 08 Mar 2024 10:48:37 -0500 Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Mar 2024 07:48:36 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa007.fm.intel.com with ESMTP; 08 Mar 2024 07:48:33 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709912917; x=1741448917; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7vGl3GjI8paiQ3I7X/TQ3issWbN5GAsKHFxMbtWltmk=; b=VpjNh5+3G6LYzrrCLmvI27cwF/+wandby1e0BZANhPj4T6taW8kqp6Fw BPSjjO6/ae5n5uT9sLfcgVv7gd+CZy33qJyogbVaVA3uLJCDa/GMeIo7H 6v9Az55BL1/z3xNp3BoAJEEw3yJAT9cNUAWqVau8unAWloO4P+aj2Z/oy fBmOUumeOGWFVSPcDsAk+PWcrGaeOA+X3uFJgWqVbS4OEBeR8mCQpFitV 6vgUfQgjmNYcLOu2RevNiQhbxlqzdBfKNecn+CbaHACp9iQejaU6LRt4l VV6LpFqus5L9z3bzyOTdcNsgC3yQTclVjOT4TXd+QAcihpvNQCtIED6bJ A==; X-IronPort-AV: E=McAfee;i="6600,9927,11006"; a="4561089" X-IronPort-AV: E=Sophos;i="6.07,110,1708416000"; d="scan'208";a="4561089" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,110,1708416000"; d="scan'208";a="10400345" 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 v2 08/13] tests/unit/test-smp-parse: Test "books" parameter in -smp Date: Sat, 9 Mar 2024 00:01:43 +0800 Message-Id: <20240308160148.3130837-9-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240308160148.3130837-1-zhao1.liu@linux.intel.com> References: <20240308160148.3130837-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.21; 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.572, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: 1709913032696100001 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 Mon May 13 07:55:37 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=1709913004; cv=none; d=zohomail.com; s=zohoarc; b=BL148l4nSXHr2etxt7rYD7aNosfmq3WMc72WXetRrrKEnJ+pG3zc82bEED3X4/HYDYNRLO8zJbnT8pEHvzAZAmM7/AqDIFYJzJ8m7us1WHLhT8mPstEvOTYU0+1UjHE+L8ITIHeD0e/znTvOOHlgCK8tOc0AUY5KXkpIumdmNAM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709913004; 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=jrIAmdJrkjHq26cfUdn8RSIx3jd3pdX+i8S68JdsUwFx0xxWQjiOdqLNzghe31leulbGeLMVRWPDKM+b2ieV7yGUPpJi3t0qggQWTpPLZJa8AhBG2NS5M4c51AcLzFnZob2MoXOv76wazCLmomc+4WGmF9aJhUaIYSpVEoTxvTk= 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 1709913004941900.1458072780279; Fri, 8 Mar 2024 07:50:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ricSi-0000jv-8T; Fri, 08 Mar 2024 10:48: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 1ricSf-0000jF-U0 for qemu-devel@nongnu.org; Fri, 08 Mar 2024 10:48:41 -0500 Received: from mgamail.intel.com ([198.175.65.21]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ricSd-00042e-0t for qemu-devel@nongnu.org; Fri, 08 Mar 2024 10:48:41 -0500 Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Mar 2024 07:48:39 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa007.fm.intel.com with ESMTP; 08 Mar 2024 07:48:36 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709912920; x=1741448920; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wJPjIQhDPSLtPOJIxXDJGeEyfUjDSVN/nM6zcVB97uM=; b=TjYCoEGY/Xj+iePH83WbYhchfXAzGucembXcblhZuHArtAftRRdXQWKS gO9cLgtLwFKDenudeTC3EZ4a9oGsnmo5iVrFNIwNF7iQw6W3q3xYl8Paa b4nU3D5UnQB3HWKEGw9l1Rub1KzDSHuVTRjPi6PCHe3NOiDNlICdQ1Jre y1juYlXd5GINsv0EwUYXSG5ozZ8IQACqEBeXDG0N84OzE6JDdkMghlhvq PekR2r7z7KiucWktcY5Zkg2LTzj2qGkODg0xCRwM1XNi3jR/PLl5djLNr a42ibg8FfrRYwzKkjoY1BClMCf6o5iNJVubhzLPS37kPI17DfNTLwv03b g==; X-IronPort-AV: E=McAfee;i="6600,9927,11006"; a="4561100" X-IronPort-AV: E=Sophos;i="6.07,110,1708416000"; d="scan'208";a="4561100" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,110,1708416000"; d="scan'208";a="10400350" 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 v2 09/13] tests/unit/test-smp-parse: Test "drawers" parameter in -smp Date: Sat, 9 Mar 2024 00:01:44 +0800 Message-Id: <20240308160148.3130837-10-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240308160148.3130837-1-zhao1.liu@linux.intel.com> References: <20240308160148.3130837-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.21; 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.572, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: 1709913006254100001 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 Mon May 13 07:55:37 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=1709912956; cv=none; d=zohomail.com; s=zohoarc; b=aQE7gtefoA2mwaIx/PFAc5kKYFybXqws5EPT+8rtq3KHv5K4MoBiJ0k9XmR3MsqFEaN5m7EAu+z5lyn23ZrRt713bWBaNwPwAP7IIlklayuDEzSTDxdaFNsrXFXrRQ4ceNL7Zs11Q1CyD/Yn2h9JmYjNzTZwYDGLN5FKnat8VVM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709912956; 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=aDTA1VBsHppC9mZy/f6C3it3KbfCANZAj493X0hEUuo=; b=LDKxLIHrfRYZ0GwTN71DRFdF4XhCOFw5VOvLDJ+VkswpJ0HsGjmKSrW2zys+k2bCtFZ8ieuq8JqxzjptFdPFLFbWbBjWGtvERRx/e6cd6ylVrmzPKt6+RU68BrQrR++C4enFfG9Fimh2ebgfHnXr4u44WkgQIcDzIt6opmPoOqI= 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 1709912956815873.2074239234814; Fri, 8 Mar 2024 07:49:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ricSk-0000kS-GM; Fri, 08 Mar 2024 10:48:46 -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 1ricSh-0000jl-Up for qemu-devel@nongnu.org; Fri, 08 Mar 2024 10:48:43 -0500 Received: from mgamail.intel.com ([198.175.65.21]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ricSg-00042e-8O for qemu-devel@nongnu.org; Fri, 08 Mar 2024 10:48:43 -0500 Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Mar 2024 07:48:42 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa007.fm.intel.com with ESMTP; 08 Mar 2024 07:48:38 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709912923; x=1741448923; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=te3+aTecN6r7yc1A1r+3dPun+8qBEGGEYygyr2+XD6A=; b=NycHeW1S0PxqqpIfvEbsTqkv+cWhV3Bja63EgQTZmC/bnNG7RF5PwJgf q/ZPY/eonN84l64fLBlY4d/eHmC3Kf5O+4eZ9+aJxgB/6+ba9YfJhsyPe jO1S6wBaGi+Cun2gxj77apis8wqANv7ZT20gMxpy2DJ48cvZv6ll6FavM 2Lrisv5K1eR/rxkh+8MeAPXig4Nf5FN6PMCzXPj32jAU8aJAzIyPfxteV 0U0l9isOcOAtXZ9jhmh0R+IGAqq+Zz9LiwjIRiKhrU3W7HMgtTnaw4+Ve nwPokh/CmQ8J0BWSz5WggQWACrNsq0gP2X+tPdBrdfTsM5ZJa2sAnIs7L A==; X-IronPort-AV: E=McAfee;i="6600,9927,11006"; a="4561108" X-IronPort-AV: E=Sophos;i="6.07,110,1708416000"; d="scan'208";a="4561108" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,110,1708416000"; d="scan'208";a="10400355" 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 v2 10/13] tests/unit/test-smp-parse: Test "drawers" and "books" combination case Date: Sat, 9 Mar 2024 00:01:45 +0800 Message-Id: <20240308160148.3130837-11-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240308160148.3130837-1-zhao1.liu@linux.intel.com> References: <20240308160148.3130837-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.21; 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.572, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: 1709912958287100013 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 Mon May 13 07:55:37 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=1709912997; cv=none; d=zohomail.com; s=zohoarc; b=PJPVHUqreMKSXENYD6TD9HtqeFKvrxqqNKfRPpC/WbvvKbmpoilfAnoFMr7dT+Bb0RLj+ru4zBFSAKc+DXgUABCr1USDtmuQzQNJMrHyA1uKTy7e6EbA9zg+N4hHVRzZSfI6RP/XyHEtVWbEN3mbElOO8LvHaoc7I6A9KfEquBQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709912997; 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=JY32je1yHVY672UzBdpBx/lhU3syQFzvsHiuFWJlP3wvGvH96ETqRwhJLKdqb04XmF1Uvo88wz27UgKuOGmsb2s7dNg5SyL/ZGtbosS6HeVcnax7sxcz26Uy3Wa9h5XvuL28HEohhaq8gb6Btvrar/n6s2iSFQKVWVcIC84+mmE= 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 170991299788138.00424611760536; Fri, 8 Mar 2024 07:49:57 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ricSn-0000lD-8X; Fri, 08 Mar 2024 10:48: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 1ricSl-0000kn-CY for qemu-devel@nongnu.org; Fri, 08 Mar 2024 10:48:47 -0500 Received: from mgamail.intel.com ([198.175.65.21]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ricSj-000449-I1 for qemu-devel@nongnu.org; Fri, 08 Mar 2024 10:48:47 -0500 Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Mar 2024 07:48:45 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa007.fm.intel.com with ESMTP; 08 Mar 2024 07:48:41 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709912926; x=1741448926; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=98NJKETcDZW1zOOely50ceE+NQ46Hd2eboqvtOsOfq8=; b=d2zV/W56baG/x0KkC6vZ6BMdLYQukdMynbj+QGVnFR/saN/agKcTQTzX oWA82vNVFSw2K2skR91yBh770+Ff/tOpZWyv98ACZGpCuhRrzmJYD5WEs 9vxC5P7p2+66wo9nWCPcqP7Edxc79Rx31osPVwTRG+whrkqDnFiGs4SiP 0WOBUkgLCw1itQL/rwSS25vemFNo479X3lcq2XopcGGO6vnqEDGEG4Rnc t5cTdNV8d3AtjAZQXNLIw7bQr71874GK+Fc7ygTnn4guNSl8NE22gAQo7 ph91CdYCbYW1TaDTa9UEuvHYe65P31IRn/AKegkM1TyVN+wlyv6rEr7tq g==; X-IronPort-AV: E=McAfee;i="6600,9927,11006"; a="4561115" X-IronPort-AV: E=Sophos;i="6.07,110,1708416000"; d="scan'208";a="4561115" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,110,1708416000"; d="scan'208";a="10400358" 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 v2 11/13] tests/unit/test-smp-parse: Test the full 7-levels topology hierarchy Date: Sat, 9 Mar 2024 00:01:46 +0800 Message-Id: <20240308160148.3130837-12-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240308160148.3130837-1-zhao1.liu@linux.intel.com> References: <20240308160148.3130837-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.21; 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.572, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: 1709912998248100001 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 Mon May 13 07:55:37 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=1709912991; cv=none; d=zohomail.com; s=zohoarc; b=WbmZkENg+EWak6T8HHTid7ASwd0WbrAA91syk8zxrQ7MWAQktjC/DZFK2r3zlaS0l15NS4audAZ9EA/vApvLqK3+MGhYgRL3/A/21OyaLQDFost9ivTAfqso/23r1zFXn5pRhFSb3UPfn2LegYxL3wg/AA1oP6ko4gJgzXL4Mxg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709912991; 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=bPw+kK2lqzCRoOZ/BtHtkv9VaoDl9SHzkAZIFvToRXNAqE1uYJiCTfuBT9ZmYFu46rsHryDspj46yB1UX6TWEK18LeQsFuqs0Mwx5fgZZvzHYQuTsLqXdPWPEFaTepXZjGSpXTk9e85HOPOi2RjnK9RBRUow9yOUO6JXCskCUTc= 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 1709912991965605.2477468306342; Fri, 8 Mar 2024 07:49:51 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ricSp-0000ln-Mo; Fri, 08 Mar 2024 10:48: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 1ricSn-0000lF-K2 for qemu-devel@nongnu.org; Fri, 08 Mar 2024 10:48:49 -0500 Received: from mgamail.intel.com ([198.175.65.21]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ricSl-000449-Re for qemu-devel@nongnu.org; Fri, 08 Mar 2024 10:48:49 -0500 Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Mar 2024 07:48:48 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa007.fm.intel.com with ESMTP; 08 Mar 2024 07:48:44 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709912928; x=1741448928; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9CNNd6/FqGn+vADBzcQTmk8SQKEglbZAI6+rVVgSS7Q=; b=JE4ewhKX0iWNxzxw/NpsDtppS3aKErfc1yIsqkwmv+52J0Sxkl4eTbPW hZRD6RCb2riinegVsTLeW/QVEn8zBtK3gzCRCihsIsSR2XF79GA95bOU7 WmZwRKR32+mjVtE8vEZuTa2Y5IvkKXRMcPIhApEUDwtDZSFBksYp53apq ALeszjbjYtJada5So6d0OjdFSs8fuizgwOUtbcNUtaqos9eqy1zQn1AuM tFJ2WjmNwQHG9ljEbwbYtqwyuCSikUv8GmgQSxt/7bwM610P5kGMsYkx3 pLDSvQ1Zhl5ADptKa7LeWcnH7Mr2b+GeSQRHyzcAWSMjB40o3CngJUDSk A==; X-IronPort-AV: E=McAfee;i="6600,9927,11006"; a="4561121" X-IronPort-AV: E=Sophos;i="6.07,110,1708416000"; d="scan'208";a="4561121" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,110,1708416000"; d="scan'208";a="10400364" 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 v2 12/13] tests/unit/test-smp-parse: Test smp_props.has_clusters Date: Sat, 9 Mar 2024 00:01:47 +0800 Message-Id: <20240308160148.3130837-13-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240308160148.3130837-1-zhao1.liu@linux.intel.com> References: <20240308160148.3130837-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.21; 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.572, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: 1709912994177100003 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 Mon May 13 07:55:37 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=1709913037; cv=none; d=zohomail.com; s=zohoarc; b=g15GIHZ/0oyYapFY2XYeaWJHIc2GZXcfij3uJ8RwOIh34qfEN1xEL4kKApO90uSVEv4JtmvQCkQoPdntaB0Tco02qi+jujH3Bx/feM+r8IwgAoP3TxYguHYCjt3yNJZQz2J9SVoe2IeVGzRJ1GBc+zKgsEt5w5U/9sr1vPrtD5E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709913037; 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=qmwgOPgzI6+a5bLhK1DdsuqrJKKuEPSTVyIf2Awv5Rg=; b=FNSOpiTfVNBPjXGPFU0MnHKEYfMCGaUzAWCI7UDfaMKXSpt7YTkTgMuXGHyCAkXEHQhFY4N1D++9dziu/jnXWLaHPnywT1aMGqXUKSYztFARbOHYX8MQSTOqT/L3JIEkH9/MYjbDH1c6Bk5yS6EMfZN3LJf2Aby5ZegOL5o1vA8= 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 1709913037087996.2151334383155; Fri, 8 Mar 2024 07:50:37 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ricT3-000149-H0; Fri, 08 Mar 2024 10:49:05 -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 1ricT1-00013e-5v for qemu-devel@nongnu.org; Fri, 08 Mar 2024 10:49:03 -0500 Received: from mgamail.intel.com ([198.175.65.21]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ricSz-000449-BL for qemu-devel@nongnu.org; Fri, 08 Mar 2024 10:49:02 -0500 Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Mar 2024 07:48:51 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa007.fm.intel.com with ESMTP; 08 Mar 2024 07:48:47 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709912942; x=1741448942; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vf3I/tff1LAPx6iIpRAFiHDNzjYLXmXU3Gy0u0/iRyo=; b=SJOwVm7ldEGH+UZm/m+jyDHfYgfQ7kG1y1HFpXZVMP5NWEhw0uGPR3L6 OcfsevGCbFrRgx1Xi00VHXS1PSfJXQRhmZyUtsygUFnOe46Nhmda/Eqyh WCwTEoZgEPLvbOstMYRdGY/GadIvtSSD7P97M1U69xYv0cUvgR61Tal+Z 3RGlzgQ9RFTC3uMbKIIBIXuntNmGk8vSzdmXAMpRhWjoRYaA5lqw+2Ypk IMmlYil+XfJPT8bDv65YKwZ0sacHOi14aghYTJAaKT1nj542faNkHRxVg L3EgEl8x1jfMldw18AG/sphe7m0mj2mp4CukL/A1orI4irgfNYo8jzBDZ w==; X-IronPort-AV: E=McAfee;i="6600,9927,11006"; a="4561128" X-IronPort-AV: E=Sophos;i="6.07,110,1708416000"; d="scan'208";a="4561128" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,110,1708416000"; d="scan'208";a="10400367" 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 v2 13/13] tests/unit/test-smp-parse: Test "parameter=0" SMP configurations Date: Sat, 9 Mar 2024 00:01:48 +0800 Message-Id: <20240308160148.3130837-14-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240308160148.3130837-1-zhao1.liu@linux.intel.com> References: <20240308160148.3130837-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.21; 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.572, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: 1709913038451100015 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