From nobody Sun May 19 01:27:08 2024 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=1696801971; cv=none; d=zohomail.com; s=zohoarc; b=l1QdAfOER6k4LsHYbNXFxmUY2Ps+G4A5SMj3BgSS63iz9pMM/AjMrdzNs9iwQ0m4lR1AC4SXxocTgQeHYvECZlfWs4ktibbkGEnloL9ze1iaIvYrXVocbaWb6LmYI2hyGLgx9fn+xCEvrSuYRar3KT7tomJKNXtvRm75L4gLFmE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696801971; 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=SxNJ2aIr/YO897r9yFbMRfDrybG097b5C3Cl1+PBpLY=; b=HMUQCjye5/kOeRH+qnGGaTL7NgLStnfc4jcdWwe7cldMSAViGu86kI5/CNwDht47Wadwr4tAM/XeamRcG4mTM+WzZihUbwUfqrZTu85QODYkCn7hT1Ip2wzUWu/h832SHzvdx/xwqPzZz4lUEE617D5s9mcbUfkGKb+V/8/Zda4= 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 1696801971030100.84793594983705; Sun, 8 Oct 2023 14:52:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qpbhD-00069Y-NI; Sun, 08 Oct 2023 17:52:19 -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 1qpbhC-00069P-Jw for qemu-devel@nongnu.org; Sun, 08 Oct 2023 17:52:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qpbhB-0000et-Ac for qemu-devel@nongnu.org; Sun, 08 Oct 2023 17:52:18 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-363-QMPaLGdLOWaDDiHPqBoVuA-1; Sun, 08 Oct 2023 17:51:55 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A3E191C06358; Sun, 8 Oct 2023 21:51:54 +0000 (UTC) Received: from cash.home.annexia.org (unknown [10.42.28.165]) by smtp.corp.redhat.com (Postfix) with ESMTP id 96133215670B; Sun, 8 Oct 2023 21:51:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696801935; 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=SxNJ2aIr/YO897r9yFbMRfDrybG097b5C3Cl1+PBpLY=; b=OlwAkGLPrU57GWeA5FWNaxENqHidYUJT5Rt6lItzXbdg8w7eUxql5AXWwwwk+AzjARDhy5 3SFyUxLcxIHs+8jhfuoCJNadQzYKdM1Rt7bPFNQaI1jMNJBd6jCoVOHfznzRaxqcOy/pfX Uh5ZZn3ck/HyrvV97N0jcTWvi4MVbAQ= X-MC-Unique: QMPaLGdLOWaDDiHPqBoVuA-1 From: "Richard W.M. Jones" To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, palmer@dabbelt.com, alistair.francis@wdc.com, bin.meng@windriver.com, liweiwei@iscas.ac.cn, dbarboza@ventanamicro.com, zhiwei_liu@linux.alibaba.com, pbonzini@redhat.com Subject: [PATCH v2] target/riscv: Use a direct cast for better performance Date: Sun, 8 Oct 2023 22:50:05 +0100 Message-ID: <20231008215147.3362612-2-rjones@redhat.com> In-Reply-To: <20231008215147.3362612-1-rjones@redhat.com> References: <20231008215147.3362612-1-rjones@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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.129.124; envelope-from=rjones@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_NONE=-0.0001, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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: 1696801972613100003 Content-Type: text/plain; charset="utf-8" RISCV_CPU(cs) uses a checked cast. When QOM cast debugging is enabled this adds about 5% total overhead when emulating RV64 on x86-64 host. Using a RISC-V guest with 16 vCPUs, 16 GB of guest RAM, virtio-blk disk. The guest has a copy of the qemu source tree. The test involves compiling the qemu source tree with 'make clean; time make -j16'. Before making this change the compile step took 449 & 447 seconds over two consecutive runs. After making this change, 428 & 422 seconds. The saving is about 5%. Thanks: Paolo Bonzini Signed-off-by: Richard W.M. Jones Reviewed-by: Daniel Henrique Barboza Reviewed-by: LIU Zhiwei --- target/riscv/cpu_helper.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index 3a02079290..479d9863ae 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -66,7 +66,11 @@ void cpu_get_tb_cpu_state(CPURISCVState *env, vaddr *pc, uint64_t *cs_base, uint32_t *pflags) { CPUState *cs =3D env_cpu(env); - RISCVCPU *cpu =3D RISCV_CPU(cs); + /* + * Using the checked cast RISCV_CPU(cs) imposes ~ 5% overhead when + * QOM cast debugging is enabled, so use a direct cast instead. + */ + RISCVCPU *cpu =3D (RISCVCPU *)cs; RISCVExtStatus fs, vs; uint32_t flags =3D 0; =20 --=20 2.41.0