From nobody Sun Nov 24 00:49:55 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1728729053; cv=none; d=zohomail.com; s=zohoarc; b=Oa/J/PwpmMiDTdFQrChDfl6qLsQEbwSQqKcbC2v8e0C+4P8deD+LP/DVYeEV/okIDACCVjNtUaY0Zj6CVO1PNGCTp3A8Z/n6qaEVDuWfZMom6D/oP26bmkHZRFWj/aKquUXN8+3dpufrHXfTwQGUagMNKOQ6vYh2GzRuP04pi08= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728729053; 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=OgTLLdmyJQAdjUDZ8Uv7ctD552RPylhDjNHpJplbFeU=; b=QKmi3XGC2ySHdSVygDFlfPHC1k0tCXiiJ/6xlXXz8sBoYGdszQ5AAC94EDphQ2aIHIZcZL3NthRGyv8aZpuvGZpsp4voyP9hWiTi60XUpe9LkcuwqL+0Z/5fAzMVk6DvAFzuaP8UG31QHwB24qpoDaBM9LLN1u4ltTB9YWsSR6E= 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 1728729053408269.5727974469128; Sat, 12 Oct 2024 03:30:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1szZN6-00048i-DE; Sat, 12 Oct 2024 06:29:16 -0400 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 1szZN4-000462-1w; Sat, 12 Oct 2024 06:29:14 -0400 Received: from mgamail.intel.com ([192.198.163.8]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1szZN2-0007EI-BH; Sat, 12 Oct 2024 06:29:13 -0400 Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Oct 2024 03:29:11 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by orviesa010.jf.intel.com with ESMTP; 12 Oct 2024 03:29:05 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1728728952; x=1760264952; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=i+35KcqWfRxigU2EIhaJxKdHSfXUSTicv5fw/oXO2lw=; b=Hg1adh+D2ZnAE62s5ucZGEZyNf3b1vMPZHKV7xpdzASKdpj9P4lxTJjN Y0q0ZzgxFMqMXQDA/fm7n7ZmingAL80eeSKRoOtdohZe3OLVSW/WAeGYL 9mBvSps2z7rZ9FxXeS1v8zh5ejfwYM3uiEk34bXmEdx9ibyuloK+HrUHD 8FFOkvc9Az01PJDcbqC3MVJetdMzSthP2W6OzFoNKOpXu1rdVcEOuGftM YLks3K9L/uD0DtQo+eZ4uBC5W+Bq0xBxXTR3sir0OsVOUUTOPiqILA3Xj ddyRb+vPg7+klDTyYbOjGJKHIC3qmsR5h51l0igE6GugwsKRSjPvRMVYz A==; X-CSE-ConnectionGUID: kTJweIsASxiXljiWZ6y6Zg== X-CSE-MsgGUID: ZcAUiWd8QO+rMf8ZasCQ7Q== X-IronPort-AV: E=McAfee;i="6700,10204,11222"; a="45634956" X-IronPort-AV: E=Sophos;i="6.11,198,1725346800"; d="scan'208";a="45634956" X-CSE-ConnectionGUID: iSUSYFKcSyyEaLI1013xMA== X-CSE-MsgGUID: WLmQSF1tQ+WlPwsdfAOydQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,198,1725346800"; d="scan'208";a="77050877" From: Zhao Liu To: =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Igor Mammedov , Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , "Michael S . Tsirkin" , Paolo Bonzini , Richard Henderson , Eric Blake , Markus Armbruster , Marcelo Tosatti , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Peter Maydell , Jonathan Cameron , Sia Jee Heng , Alireza Sanaee Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, qemu-riscv@nongnu.org, qemu-arm@nongnu.org, Zhenyu Wang , Dapeng Mi , Zhao Liu Subject: [PATCH v3 7/7] i386/cpu: add has_caches flag to check smp_cache configuration Date: Sat, 12 Oct 2024 18:44:29 +0800 Message-Id: <20241012104429.1048908-8-zhao1.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241012104429.1048908-1-zhao1.liu@intel.com> References: <20241012104429.1048908-1-zhao1.liu@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: pass client-ip=192.198.163.8; envelope-from=zhao1.liu@intel.com; helo=mgamail.intel.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.15, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: 1728729055042116600 Content-Type: text/plain; charset="utf-8" From: Alireza Sanaee Add has_caches flag to SMPCompatProps, which helps in avoiding extra checks for every single layer of caches in x86 (and ARM in future). Signed-off-by: Alireza Sanaee Signed-off-by: Zhao Liu Reviewed-by: Jonathan Cameron --- Note: Picked from Alireza's series with the changes: * Moved the flag to SMPCompatProps with a new name "has_caches". This way, it remains consistent with the function and style of "has_clusters" in SMPCompatProps. * Dropped my previous TODO with the new flag. --- Changes since Patch v2: * Picked a new patch frome Alireza's ARM smp-cache series. --- hw/core/machine-smp.c | 2 ++ include/hw/boards.h | 3 +++ target/i386/cpu.c | 9 ++++----- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/hw/core/machine-smp.c b/hw/core/machine-smp.c index f3edbded2e7b..16e456678cb6 100644 --- a/hw/core/machine-smp.c +++ b/hw/core/machine-smp.c @@ -367,6 +367,8 @@ bool machine_parse_smp_cache(MachineState *ms, return false; } =20 + mc->smp_props.has_caches =3D true; + return true; } =20 diff --git a/include/hw/boards.h b/include/hw/boards.h index e4a1035e3fa1..af62b09c89d1 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -153,6 +153,8 @@ typedef struct { * @modules_supported - whether modules are supported by the machine * @cache_supported - whether cache (l1d, l1i, l2 and l3) configuration are * supported by the machine + * @has_caches - whether cache properties are explicitly specified in the + * user provided smp-cache configuration */ typedef struct { bool prefer_sockets; @@ -163,6 +165,7 @@ typedef struct { bool drawers_supported; bool modules_supported; bool cache_supported[CACHE_LEVEL_AND_TYPE__MAX]; + bool has_caches; } SMPCompatProps; =20 /** diff --git a/target/i386/cpu.c b/target/i386/cpu.c index c8a04faf3764..6f711e98b527 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -7853,12 +7853,11 @@ static void x86_cpu_realizefn(DeviceState *dev, Err= or **errp) =20 #ifndef CONFIG_USER_ONLY MachineState *ms =3D MACHINE(qdev_get_machine()); + MachineClass *mc =3D MACHINE_GET_CLASS(ms); =20 - /* - * TODO: Add a SMPCompatProps.has_caches flag to avoid useless Updates - * if user didn't set smp_cache. - */ - x86_cpu_update_smp_cache_topo(ms, cpu); + if (mc->smp_props.has_caches) { + x86_cpu_update_smp_cache_topo(ms, cpu); + } =20 qemu_register_reset(x86_cpu_machine_reset_cb, cpu); =20 --=20 2.34.1