From patchwork Thu Dec 19 08:32:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhao Liu X-Patchwork-Id: 13914774 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 44334E7718A for ; Thu, 19 Dec 2024 08:14:31 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tOBfp-00054s-Rb; Thu, 19 Dec 2024 03:14:21 -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 1tOBfn-00054K-F8 for qemu-devel@nongnu.org; Thu, 19 Dec 2024 03:14:19 -0500 Received: from mgamail.intel.com ([192.198.163.19]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tOBfl-0000IM-8P for qemu-devel@nongnu.org; Thu, 19 Dec 2024 03:14:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1734596057; x=1766132057; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=sJD1HzK00lYZY9+cHhZD1q8bcprwUdJTGT1EY0BZmJw=; b=hkXMmc6u2AmaMCClHJ8fRg6gnNvMgFJTfqb0svK9jtiS+MTEAwuMz3ys zuNcVEHVGeJkgdbWlgoGm7YVriZhDl7X8pxFdz0olPXMpcFtYBtw1Srd5 h0y+TwvGgvFLeCGlYkt/mdLX33xJA6Swp79NoReYAwFmXirmM2uM7F9vz El0CIK/9xsTSEfjPwEXmnYajU9AgS/wFxsWDO5uRPTfsIsGTdXtO70C4b MOyaS4iVMEMr+pLZRs8oIPeBXaKScTYPGyKH+UAyNdZDJ2y6gKBHahLMA fzofmQGKUZWKxQI1QVwE8PW2kScCKIUnFpFGGVQVlFUFbqzmJEG8KDiFH Q==; X-CSE-ConnectionGUID: 69V0u23IT8a3eVRwoe4u2Q== X-CSE-MsgGUID: uqDgkgB3QFaAzRLjP6A6+g== X-IronPort-AV: E=McAfee;i="6700,10204,11290"; a="34378603" X-IronPort-AV: E=Sophos;i="6.12,247,1728975600"; d="scan'208";a="34378603" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Dec 2024 00:14:15 -0800 X-CSE-ConnectionGUID: EOAUv0rrQ8ifIgUQ8s7VTg== X-CSE-MsgGUID: 6ckPH2LHT8mTQwa3lrXScw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="129097513" Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.39]) by fmviesa001.fm.intel.com with ESMTP; 19 Dec 2024 00:14:11 -0800 From: Zhao Liu To: Paolo Bonzini , =?utf-8?q?Daniel_P_=2E_Berrang?= =?utf-8?q?=C3=A9?= , Igor Mammedov , Eduardo Habkost , Marcel Apfelbaum , =?utf-8?q?Philippe_Mathieu-D?= =?utf-8?q?aud=C3=A9?= , Yanan Wang , "Michael S . Tsirkin" , Richard Henderson , Jonathan Cameron , Alireza Sanaee , Sia Jee Heng Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, Zhao Liu Subject: [PATCH v6 0/4] i386: Support SMP Cache Topology Date: Thu, 19 Dec 2024 16:32:33 +0800 Message-Id: <20241219083237.265419-1-zhao1.liu@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Received-SPF: pass client-ip=192.198.163.19; envelope-from=zhao1.liu@intel.com; helo=mgamail.intel.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Hi folks, This is my v6. since Phili has already merged the general smp cache part, v6 just includes the remaining i386-specific changes to support SMP cache topology for PC machine (currently all patches have got Reviewed-by from previous review). Compared with v5 [1], there's no change and just series just picks the unmerged patches and rebases on the master branch (based on the commit 8032c78e556c "Merge tag 'firmware-20241216-pull-request' of https://gitlab.com/kraxel/qemu into staging"). The patch 4 ("i386/cpu: add has_caches flag to check smp_cache"), which introduced a has_caches flag, is also ARM side wanted. Though now this series targets to i386, to help review, I still include the previous introduction about smp cache topology feature. Background ========== The x86 and ARM (RISCV) need to allow user to configure cache properties (current only topology): * For x86, the default cache topology model (of max/host CPU) does not always match the Host's real physical cache topology. Performance can increase when the configured virtual topology is closer to the physical topology than a default topology would be. * For ARM, QEMU can't get the cache topology information from the CPU registers, then user configuration is necessary. Additionally, the cache information is also needed for MPAM emulation (for TCG) to build the right PPTT. (Originally from Jonathan) About smp-cache =============== The API design has been discussed heavily in [3]. Now, smp-cache is implemented as a array integrated in -machine. Though -machine currently can't support JSON format, this is the one of the directions of future. An example is as follows: smp_cache=smp-cache.0.cache=l1i,smp-cache.0.topology=core,smp-cache.1.cache=l1d,smp-cache.1.topology=core,smp-cache.2.cache=l2,smp-cache.2.topology=module,smp-cache.3.cache=l3,smp-cache.3.topology=die "cache" specifies the cache that the properties will be applied on. This field is the combination of cache level and cache type. Now it supports "l1d" (L1 data cache), "l1i" (L1 instruction cache), "l2" (L2 unified cache) and "l3" (L3 unified cache). "topology" field accepts CPU topology levels including "thread", "core", "module", "cluster", "die", "socket", "book", "drawer" and a special value "default". The "default" is introduced to make it easier for libvirt to set a default parameter value without having to care about the specific machine (because currently there is no proper way for machine to expose supported topology levels and caches). If "default" is set, then the cache topology will follow the architecture's default cache topology model. If other CPU topology level is set, the cache will be shared at corresponding CPU topology level. [1]: Patch v5: https://lore.kernel.org/qemu-devel/20241101083331.340178-1-zhao1.liu@intel.com/ [2]: ARM smp-cache: https://lore.kernel.org/qemu-devel/20241010111822.345-1-alireza.sanaee@huawei.com/ [3]: API disscussion: https://lore.kernel.org/qemu-devel/8734ndj33j.fsf@pond.sub.org/ Thanks and Best Regards, Zhao --- Alireza Sanaee (1): i386/cpu: add has_caches flag to check smp_cache configuration Zhao Liu (3): i386/cpu: Support thread and module level cache topology i386/cpu: Update cache topology with machine's configuration i386/pc: Support cache topology in -machine for PC machine hw/core/machine-smp.c | 2 ++ hw/i386/pc.c | 4 +++ include/hw/boards.h | 3 ++ qemu-options.hx | 31 +++++++++++++++++- target/i386/cpu.c | 76 ++++++++++++++++++++++++++++++++++++++++--- 5 files changed, 111 insertions(+), 5 deletions(-)