Received: by 2002:a17:504:1f11:b0:1be9:327d:8ee3 with SMTP id z17csp1432669njl; Thu, 10 Oct 2024 04:19:03 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVVOKZ3cvaPK2FsJdtqB/G7nhwt7JXiJoxQzdVvLe7rXdxRGxtlfW+AnYTMg5bcO3HxOSLsW5hQvahfrg==@linaro.org X-Google-Smtp-Source: AGHT+IFMc/w6GEIeNvzMjUFK0ZRwvKMo1eXzOI39OrTvEAxKoaBQNyKfxAS0S3fN0ssQzdlqyzSt X-Received: by 2002:a05:6214:5781:b0:6cb:3b34:55d3 with SMTP id 6a1803df08f44-6cbe4a9fd64mr33362856d6.29.1728559143191; Thu, 10 Oct 2024 04:19:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728559143; cv=none; d=google.com; s=arc-20240605; b=geiMJKZmf2mN9mAfrtwrqCpAxBJtzkxC5CX8DNy18Es45WiWfkmZ2t5vuIXdsREoXm JZhm5Wn0wETfNYS+DmDSzHwUdcpNGUkFxGVyATSBMHJEi+4bzN5SJuUx+ZopxOj+LXCX +lVl0OekqQk5l1m9zeD/CZAEU9lxQJ726xhNV5VJIHMW77nzrXeQ88idfFLouYe+2gOA FK9dd7aCaFiK9FHZ2tzzwl6dPI7zld5DU72EIKeS4Oa6ols/jOqB0rlQ9sW4QAh1NF4+ pxWdouta0xOuvx63a6VUZ6nONfRvEi9Cx1JI6Lm1MPZBdqXsv8LasvCUjRmvF1a1d/3/ CQMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:from:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to; bh=f42Sfw5vnza4r/+wGM+wIJL/UBKyD5Pjb1AGbyHpOK0=; fh=rWf9XuWQsI9arb3S/1QVkVJRzitX9+a8CSyR5OF0OEQ=; b=inhJ+vKbACyh3yQRh9uAYM21JPS3v62PzyuE6A2skbesl7OSf1fRWOe01L+fI71IUj 8EgF2aY1tPgGXE9WJ3k9YxGc7h/qlsnvFc66+ZNbm9zz8My1HHp9AIuZ1Nqomg/l4SbV A57NxHz+M9qkEyxaFQ/P5dr/KjSZH7fd61s5X+ExqbUOW7Xt24sCyvR4gsR0eSjQXirX eRVYp/Rgs47Izq6j/xCm6cYZ/UGc0aYevGjuLQMynwPfl6hks6Hg4kkTETS91r47eClJ uj1euC6Y5Iofh37GTBkNjJsdK8A7+KIxReTm6OZMYnmDpRa/WdpxOq9PmEi/SVXsMNKH ikog==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6cbe86a9d4asi11440856d6.481.2024.10.10.04.19.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Oct 2024 04:19:03 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nongnu.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1syrBn-0000On-BD; Thu, 10 Oct 2024 07:18:39 -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 1syrBl-0000OZ-R5; Thu, 10 Oct 2024 07:18:37 -0400 Received: from frasgout.his.huawei.com ([185.176.79.56]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1syrBj-0004oY-2u; Thu, 10 Oct 2024 07:18:37 -0400 Received: from mail.maildlp.com (unknown [172.18.186.31]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4XPRwC6XSVz6LD3P; Thu, 10 Oct 2024 19:14:03 +0800 (CST) Received: from frapeml500003.china.huawei.com (unknown [7.182.85.28]) by mail.maildlp.com (Postfix) with ESMTPS id 94864140391; Thu, 10 Oct 2024 19:18:24 +0800 (CST) Received: from a2303103017.china.huawei.com (10.126.168.143) by frapeml500003.china.huawei.com (7.182.85.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Thu, 10 Oct 2024 13:18:23 +0200 To: , CC: , , , , , , , , , , , , , , , , , , Subject: [RFC PATCH v3 0/6] Specifying cache topology on ARM Date: Thu, 10 Oct 2024 12:18:16 +0100 Message-ID: <20241010111822.345-1-alireza.sanaee@huawei.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.168.143] X-ClientProxiedBy: lhrpeml500001.china.huawei.com (7.191.163.213) To frapeml500003.china.huawei.com (7.182.85.28) Received-SPF: pass client-ip=185.176.79.56; envelope-from=alireza.sanaee@huawei.com; helo=frasgout.his.huawei.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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: , Reply-to: Alireza Sanaee From: Alireza Sanaee via Errors-To: qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org Sender: qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org X-TUID: lZREbN9WW/hN Specifying the cache layout in virtual machines is useful for applications and operating systems to fetch accurate information about the cache structure and make appropriate adjustments. Enforcing correct sharing information can lead to better optimizations. This patch enables the specification of cache layout through a command line parameter, building on a patch set by Intel [1,2]. It uses this set as a foundation. The ACPI/PPTT table is populated based on user-provided information and CPU topology. Example: +----------------+ +----------------+ | Socket 0 | | Socket 1 | | (L3 Cache) | | (L3 Cache) | +--------+-------+ +--------+-------+ | | +--------+--------+ +--------+--------+ | Cluster 0 | | Cluster 0 | | (L2 Cache) | | (L2 Cache) | +--------+--------+ +--------+--------+ | | +--------+--------+ +--------+--------+ +--------+--------+ +--------+----+ | Core 0 | | Core 1 | | Core 0 | | Core 1 | | (L1i, L1d) | | (L1i, L1d) | | (L1i, L1d) | | (L1i, L1d)| +--------+--------+ +--------+--------+ +--------+--------+ +--------+----+ | | | | +--------+ +--------+ +--------+ +--------+ |Thread 0| |Thread 1| |Thread 1| |Thread 0| +--------+ +--------+ +--------+ +--------+ |Thread 1| |Thread 0| |Thread 0| |Thread 1| +--------+ +--------+ +--------+ +--------+ The following command will represent the system. ./qemu-system-aarch64 \ -machine virt,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=cluseter,smp-cache.3.cache=l3,smp-cache.3.topology=socket \ -cpu max \ -m 2048 \ -smp sockets=2,clusters=1,cores=2,threads=2 \ -kernel ./Image.gz \ -append "console=ttyAMA0 root=/dev/ram rdinit=/init acpi=force" \ -initrd rootfs.cpio.gz \ -bios ./edk2-aarch64-code.fd \ -nographic Failure cases: 1) there are cases where QEMU might not have any clusters selected in the -smp option, while user specifies caches to be shared at cluster level. In this situations, qemu returns error. 2) There are other scenarios where caches exist in systems' registers but not left unspecified by users. In this case qemu returns failure. Currently only three levels of caches are supported to be specified from the command line. However, increasing the value does not require significant changes. Further, this patch assumes l2 and l3 unified caches and does not allow l(2/3)(i/d). The level terminology is thread/core/cluster/socket right now. Here is the hierarchy assumed in this patch: Socket level = Cluster level + 1 = Core level + 2 = Thread level + 3; [1] https://lore.kernel.org/kvm/20240908125920.1160236-1-zhao1.liu@intel.com/ [2] https://lore.kernel.org/qemu-devel/20240704031603.1744546-1-zhao1.liu@intel.com/ TODO: 1) Making the code to work with arbitrary levels 2) Separated data and instruction cache at L2 and L3. 3) Allow for different Data or Instruction only at a particular level. 4) Additional cache controls. e.g. size of L3 may not want to just match the underlying system, because only some of the associated host CPUs may be bound to this VM. 5) Add device tree related code to generate info related to caches. Depends-on: target/arm/tcg: refine cache descriptions with a wrapper Depends-on: Msg-id: 20240903144550.280-1-alireza.sanaee@huawei.com Depends-on: Building PPTT with root node and identical implementation flag Depends-on: Msg-id: 20240926113323.55991-1-yangyicong@huawei.com Alireza Sanaee (6): bios-tables-test: prepare to change ARM ACPI virt PPTT i386/cpu: add IsDefined flag to smp-cache property target/arm/tcg: increase cache level for cpu=max hw/acpi: add cache hierarchy node to pptt table tests/qtest/bios-table-test: testing new ARM ACPI PPTT topology Update the ACPI tables according to the acpi aml_build change, also empty bios-tables-test-allowed-diff.h. hw/acpi/aml-build.c | 310 ++++++++++++++++++++- hw/arm/virt-acpi-build.c | 137 ++++++++- hw/arm/virt.c | 5 + hw/core/machine-smp.c | 2 + hw/loongarch/acpi-build.c | 3 +- include/hw/acpi/aml-build.h | 20 +- include/hw/boards.h | 1 + target/arm/tcg/cpu64.c | 13 + tests/data/acpi/aarch64/virt/PPTT.topology | Bin 356 -> 540 bytes tests/qtest/bios-tables-test.c | 4 + 10 files changed, 487 insertions(+), 8 deletions(-) -- 2.34.1