From nobody Fri Apr 4 04:36:39 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1740667066; cv=none; d=zohomail.com; s=zohoarc; b=jbOIh2PMfeqMK0+oaigr92ogjGDANE7eFF043fj/7Tfc36MNP0sQoW/nsWGrYh3AlbSgd4njTxKuYxMvcZH0qU5WqA0ogR7oHSJGSzqtA2yJfC9CjreRBufxbbjeH0sh4FZBwGSXit8VWYPZ00LqCbjQKq2rRTrMAbWz0w3LR5M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1740667066; 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=W2DTEL0GvEgD05Vg/aBlXWWfjE1Jq68V9IAsv0IIcfk=; b=R5VP0RA5kHtw8l6cdDBUp0ukZkhx9nSOhOrPyd1ziqJuX0D5fcCKEMzsO2kquMHiZewviSuX9CNKJd+yYz//RtXFIhp3MK+rm+F0KpSpbCnt51Yas7GbHWT6rCFJ66VHM5zWUtyezgx7VhDOi8VMzlCo17JPjHV718idcm6ZI/U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 1740667066342950.8295395097348; Thu, 27 Feb 2025 06:37:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tneln-00015D-RH; Thu, 27 Feb 2025 09:21:48 -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 1tnel2-0007ia-OG for qemu-devel@nongnu.org; Thu, 27 Feb 2025 09:21:05 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tnekz-0003qb-SA for qemu-devel@nongnu.org; Thu, 27 Feb 2025 09:21:00 -0500 Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-336-yYxRgl66P8Kpnts6Wi53Yg-1; Thu, 27 Feb 2025 09:20:55 -0500 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-5e4aecbd88fso1149299a12.1 for ; Thu, 27 Feb 2025 06:20:55 -0800 (PST) Received: from [192.168.10.48] ([176.206.102.52]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5e4c43a55besm1139424a12.72.2025.02.27.06.20.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Feb 2025 06:20:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1740666057; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=W2DTEL0GvEgD05Vg/aBlXWWfjE1Jq68V9IAsv0IIcfk=; b=TKzodS39GChu4vh3QJ7LvfEIpbaUg2OA3OZcQR2j14O2Zx9ddQWsBqVtjvHT+q/U6G37nY uX/6/hB2wOFPf5OAB/GfZoFeNwDVbq1+xjqtjvxhcCgMZnoAFI58v+y1waOgGRVF0C+nLN xtHtKckr/SgNK7buAF7lehpNj6TQIqs= X-MC-Unique: yYxRgl66P8Kpnts6Wi53Yg-1 X-Mimecast-MFC-AGG-ID: yYxRgl66P8Kpnts6Wi53Yg_1740666055 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740666054; x=1741270854; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=W2DTEL0GvEgD05Vg/aBlXWWfjE1Jq68V9IAsv0IIcfk=; b=r480jGFftfMuh8kcRv+1hLWIEOtTFBoFyj+ntGtnEWboPBjU4Qex3qUV2ZiP6SphcE 0l0CjJMaOro/PtRZuUUgWLRu2JwwUUyIm8pc3ovn3eAQmZpnmrgqucLWlbcLrmwaF+Zy KiLMNuZcxptacOv/xQzddulWRE88tN2irh0fJwGVC34drmAxY6PElILg08c2JiFgZkZ/ HFAzVDJftNJA4THzUsv4A/pzHCJBE1uJbWkZ6DJJhdmkye6UwC1+vGtuaAGyH9jacjZ8 afEfUq76o9mrzgNUTgpxAHKrU/qi1cJ+AySyPRa5jqYBd0eHZ/SXZi+E0qUcHWg4MPlh WdFg== X-Gm-Message-State: AOJu0YwW0LvxL5zG8Bpx07fo/c+wUmM0F42ZvYDqRcDR8OMp3lS8F0iw dY59Ffl5i/FPL5mT2N/UOzrTRcvC01Ic6n8M8muX+wQNZmb60H5DLcN9w+I7ZFUBZ8in48dhEwh 6OFc0F7Pbddg0c7zDbWDa2sZ+VA7CFaqdKTz+zvTTIXFbpV3ucRBhhejF6Axjz5CvLdlW1370mk 7B4EqeDhEYvLm3bvw49EbC/XG1yzDoSkwrmW+W4Z0= X-Gm-Gg: ASbGncskRBFpLrGYbqVLDUdP++aG5bGJso79kRifxa2D02o1s9QJQFFes49fYVKj7Gg NII1Z2FVMq4bR/w+FHSMhmBtgAXlLnEAcyJxZh61XKULKVSvtM1fbLyPEDJ1UIgMj01wniZQYxj O4pGRM90TEeeCyCNjhMWzwxea9UnO0jMu6WBjN7NDRsY6u4pXMdgC7gcSrhi2SpyCU6vWtj2L4/ K3uzYs/EHqVWig4u/AgYr8ReO9pMQkLM2WBwOPsMY9gTw2U2OZE/uihJRT0cImyMtnl2Alz+DMI JVAALCuwC7YfujBEOs/L X-Received: by 2002:a05:6402:2548:b0:5db:e7eb:1b34 with SMTP id 4fb4d7f45d1cf-5e0b70f07d4mr29001794a12.13.1740666053775; Thu, 27 Feb 2025 06:20:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IHNsxeGbB+ZyF929QRj/hqGtIm2BMFKVfQd0zLRSDWQNLAUaW9RIj3K1h0b5ko8JQeCbTFUbA== X-Received: by 2002:a05:6402:2548:b0:5db:e7eb:1b34 with SMTP id 4fb4d7f45d1cf-5e0b70f07d4mr29001757a12.13.1740666053283; Thu, 27 Feb 2025 06:20:53 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Zhao Liu , Yongwei Ma , Jonathan Cameron , "Michael S. Tsirkin" Subject: [PULL 27/34] i386/pc: Support cache topology in -machine for PC machine Date: Thu, 27 Feb 2025 15:19:45 +0100 Message-ID: <20250227141952.811410-28-pbonzini@redhat.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250227141952.811410-1-pbonzini@redhat.com> References: <20250227141952.811410-1-pbonzini@redhat.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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.438, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1740667068707019000 Content-Type: text/plain; charset="utf-8" From: Zhao Liu Allow user to configure l1d, l1i, l2 and l3 cache topologies for PC machine. Additionally, add the document of "-machine smp-cache" in qemu-options.hx. Signed-off-by: Zhao Liu Tested-by: Yongwei Ma Reviewed-by: Jonathan Cameron Reviewed-by: Michael S. Tsirkin Link: https://lore.kernel.org/r/20250110145115.1574345-5-zhao1.liu@intel.com Signed-off-by: Paolo Bonzini --- hw/i386/pc.c | 4 ++++ qemu-options.hx | 30 +++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index f199a8c7ad1..63a96cd23f8 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1798,6 +1798,10 @@ static void pc_machine_class_init(ObjectClass *oc, v= oid *data) mc->nvdimm_supported =3D true; mc->smp_props.dies_supported =3D true; mc->smp_props.modules_supported =3D true; + mc->smp_props.cache_supported[CACHE_LEVEL_AND_TYPE_L1D] =3D true; + mc->smp_props.cache_supported[CACHE_LEVEL_AND_TYPE_L1I] =3D true; + mc->smp_props.cache_supported[CACHE_LEVEL_AND_TYPE_L2] =3D true; + mc->smp_props.cache_supported[CACHE_LEVEL_AND_TYPE_L3] =3D true; mc->default_ram_id =3D "pc.ram"; pcmc->default_smbios_ep_type =3D SMBIOS_ENTRY_POINT_TYPE_AUTO; =20 diff --git a/qemu-options.hx b/qemu-options.hx index 61270e32067..dc694a99a30 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -42,7 +42,8 @@ DEF("machine", HAS_ARG, QEMU_OPTION_machine, \ " aux-ram-share=3Don|off allocate auxiliary guest RAM a= s shared (default: off)\n" #endif " memory-backend=3D'backend-id' specifies explicitly pr= ovided backend for main RAM (default=3Dnone)\n" - " cxl-fmw.0.targets.0=3Dfirsttarget,cxl-fmw.0.targets.1= =3Dsecondtarget,cxl-fmw.0.size=3Dsize[,cxl-fmw.0.interleave-granularity=3Dg= ranularity]\n", + " cxl-fmw.0.targets.0=3Dfirsttarget,cxl-fmw.0.targets.1= =3Dsecondtarget,cxl-fmw.0.size=3Dsize[,cxl-fmw.0.interleave-granularity=3Dg= ranularity]\n" + " smp-cache.0.cache=3Dcachename,smp-cache.0.topology=3D= topologylevel\n", QEMU_ARCH_ALL) SRST ``-machine [type=3D]name[,prop=3Dvalue[,...]]`` @@ -172,6 +173,33 @@ SRST :: =20 -machine cxl-fmw.0.targets.0=3Dcxl.0,cxl-fmw.0.targets.1=3Dcxl= .1,cxl-fmw.0.size=3D128G,cxl-fmw.0.interleave-granularity=3D512 + + ``smp-cache.0.cache=3Dcachename,smp-cache.0.topology=3Dtopologylevel`` + Define cache properties for SMP system. + + ``cache=3Dcachename`` specifies the cache that the properties will= be + applied on. This field is the combination of cache level and cache + type. It supports ``l1d`` (L1 data cache), ``l1i`` (L1 instruction + cache), ``l2`` (L2 unified cache) and ``l3`` (L3 unified cache). + + ``topology=3Dtopologylevel`` sets the cache topology level. It acc= epts + CPU topology levels including ``core``, ``module``, ``cluster``, `= `die``, + ``socket``, ``book``, ``drawer`` and a special value ``default``. = If + ``default`` is set, then the cache topology will follow the archit= ecture's + default cache topology model. If another topology level is set, th= e cache + will be shared at corresponding CPU topology level. For example, + ``topology=3Dcore`` makes the cache shared by all threads within a= core. + The omitting cache will default to using the ``default`` level. + + The default cache topology model for an i386 PC machine is as foll= ows: + ``l1d``, ``l1i``, and ``l2`` caches are per ``core``, while the ``= l3`` + cache is per ``die``. + + Example: + + :: + + -machine smp-cache.0.cache=3Dl1d,smp-cache.0.topology=3Dcore,s= mp-cache.1.cache=3Dl1i,smp-cache.1.topology=3Dcore ERST =20 DEF("M", HAS_ARG, QEMU_OPTION_M, --=20 2.48.1