From patchwork Thu Jun 20 15:22:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 805983 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp345922wrt; Thu, 20 Jun 2024 08:23:58 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWXpEK3Plzv7DmyhjIRGfCRwdVreDMjjiAZiY6xNV6FedOaFxZqPnwmOCG04jgXpQog0CF5kHIeBEuT4lsLrAjY X-Google-Smtp-Source: AGHT+IHC6+9XkjqvA//TZqEcYUNZxQgIqpeyQHA4GNzqcB7SOP1S8MGia4WD4cUCgPPiHhQ3d1HK X-Received: by 2002:a05:620a:448b:b0:794:cdc3:949a with SMTP id af79cd13be357-79bb3ef2243mr583117885a.78.1718897038403; Thu, 20 Jun 2024 08:23:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718897038; cv=none; d=google.com; s=arc-20160816; b=p+ZOsa5ZwQmPA9CaminxhgAqU+7fFHP8prEn+Kf0R4+KydhgUAyE1vn0LdclTrxf2Q 1sxvgoMh0xMWhdW/PaO6W+CgpY6+XA7CvghJ633tsCNMP/21uQCZVG1ZUR3DFeVcwsG6 8dbovAUmFbxz3GDqAGmVKOTy1QMKorJ/PCEbf1tQJLQ5q25R7X2uXU3axLGVzQfEYMvV eI1KQJCteWfBJlpIpmMTaxNY6U+7VGZpRhuYzHEa5vlsqXGlA0ThRhSDGQI7RtSah+JN bGoJx5ZEzMYLl/wXL9I3gQsfkQc6J+NPXTWgBWfxVyxdu9AWP3FDf2Uf2NmI0npmMic/ 1eoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=mk0X1Wnynj7dOIA6noc/XZNsTzvKKxUiDNUzj/HAsA8=; fh=CEeBJ9j+7gfqc88m1EJETjZ6l8ELDB2GcQ0qugDAp+o=; b=iXTK2YrrUG7xA6llj8+Uiq3HNQbYxvOBvnvmIxUzFA4OkN78JWxDQGhhwzbPKWY7rE BzcglbjEZ1nRGYGpUb6Qsbsl6sYHf4F5mww6jLbg+YHZr/xvlYYMxDARXUhPasy6MCi9 zPatfxk6viCPCnpuh65Wkhaga0uJzLr4K6BCpFMJH55wn9TNknCViOwgM9QwMe/bnS23 LDbQ8y2wmOb4hDlj2eRx/V0dcikFffuLKwKD8Z/uXhgit4ovPFK8EZGCJJQcLbEnYmTd NVCJzneYS+XZ0ZySVLxOAaBRdOc5DszxBXoXNR4KeRnR34cXeXykevm/D3LMpZAEpAA8 CNoA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZzvT2ZFa; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-79bb9a4a778si417742785a.747.2024.06.20.08.23.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 20 Jun 2024 08:23:58 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZzvT2ZFa; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sKJcb-00067Q-Tz; Thu, 20 Jun 2024 11:22:45 -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 1sKJcZ-00064R-Q1 for qemu-devel@nongnu.org; Thu, 20 Jun 2024 11:22:43 -0400 Received: from mail-ed1-x534.google.com ([2a00:1450:4864:20::534]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sKJcX-00082h-B7 for qemu-devel@nongnu.org; Thu, 20 Jun 2024 11:22:43 -0400 Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-57d1679ee83so1032100a12.2 for ; Thu, 20 Jun 2024 08:22:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718896960; x=1719501760; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mk0X1Wnynj7dOIA6noc/XZNsTzvKKxUiDNUzj/HAsA8=; b=ZzvT2ZFaSIK0esGkPGcp/rGrJMYSL1ju0zZyVgnEZDZxEykadTO9B4Whacak2AuT99 EeXn0/T8Ql3WS5h8tRongY7fc50CI2/+dxlgsz/qOP1seRnDIlL/71TIlYrxX2dwGHxo vrywgIuvMZ55iqy8uhL8VuHmSLNBB/Y38NmFbIKZAormTyIprZfov271xShdCLqJl1kA aOXvSGJVC84pVvcPPTPnvApRMxtYb2ZX1Mdte1OvApq74fh9iJtJidJWhHMFQO6heH9r 4wJJjyKJxcKwUdzdzmkI9n7BagHL/YItf079DQo11cH8vy1w3roOtikMEYiUdCuI8j74 siHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718896960; x=1719501760; 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=mk0X1Wnynj7dOIA6noc/XZNsTzvKKxUiDNUzj/HAsA8=; b=sMTaQdA7yWi2Ew+v33sWPNWA3ypVZIB9rShZ/GBK3ku0CWr53rwplA9X195nDDbozk m4HFKx+x3+LHQLS5GUWqfQANb+f9m6iCXLG4MtxIxjNlIBOtf0OaDv+qErL5F6Qf7JQ7 1ncWHrcKFZJTInzBgJgF0zkWGXnEQfXC9XwS1o/MnW5ZJVgMtO2e+dE/2rlIOLNqDolo RQhywpqW6hnJbuTYeXTwIdkSH+SdK9gYz3k6laos1F/mmW5DVv7kMfkymCId8wyITTLf 8ok3rtD+r+jK+c//ap9g2EsSafbzE8b038Dr0LiKAuxt01IwhKXdUeoPaB9tY5BBq8NQ Oojg== X-Gm-Message-State: AOJu0Yze3G1MRhcYXQzSKQxI7TFgGsX7AFilMXMl0cgC/RosHBKTw64/ GKDsOZrRJKNpGQwn8njD4HimS91kMIn6GSoctJ/OLbN052LBIgro6iwbe/kdiG0= X-Received: by 2002:a50:d595:0:b0:57c:5874:4f74 with SMTP id 4fb4d7f45d1cf-57d07ed24b8mr3437569a12.28.1718896959461; Thu, 20 Jun 2024 08:22:39 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57cb72da156sm9758038a12.22.2024.06.20.08.22.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jun 2024 08:22:36 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 3BD7D5FA0E; Thu, 20 Jun 2024 16:22:22 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Maydell , kvm@vger.kernel.org, qemu-ppc@nongnu.org, Christian Borntraeger , Paolo Bonzini , Jamie Iles , David Hildenbrand , =?utf-8?q?Alex_Benn=C3=A9e?= , Pierrick Bouvier , Mark Burton , Daniel Henrique Barboza , qemu-arm@nongnu.org, Laurent Vivier , Alexander Graf , Ilya Leoshkevich , Richard Henderson , Marco Liebel , Halil Pasic , Thomas Huth , qemu-s390x@nongnu.org, Cameron Esfahani , Alexandre Iooss , Nicholas Piggin , Roman Bolshakov , "Dr. David Alan Gilbert" , Marcelo Tosatti , Mahmoud Mandour , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Max Chou , Frank Chang Subject: [PATCH v2 12/12] accel/tcg: Avoid unnecessary call overhead from qemu_plugin_vcpu_mem_cb Date: Thu, 20 Jun 2024 16:22:20 +0100 Message-Id: <20240620152220.2192768-13-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240620152220.2192768-1-alex.bennee@linaro.org> References: <20240620152220.2192768-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::534; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x534.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Max Chou If there are not any QEMU plugin memory callback functions, checking before calling the qemu_plugin_vcpu_mem_cb function can reduce the function call overhead. Signed-off-by: Max Chou Reviewed-by: Richard Henderson Reviewed-by: Frank Chang Message-Id: <20240613175122.1299212-2-max.chou@sifive.com> Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alwalid Salama --- accel/tcg/ldst_common.c.inc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/accel/tcg/ldst_common.c.inc b/accel/tcg/ldst_common.c.inc index c82048e377..87ceb95487 100644 --- a/accel/tcg/ldst_common.c.inc +++ b/accel/tcg/ldst_common.c.inc @@ -125,7 +125,9 @@ void helper_st_i128(CPUArchState *env, uint64_t addr, Int128 val, MemOpIdx oi) static void plugin_load_cb(CPUArchState *env, abi_ptr addr, MemOpIdx oi) { - qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, oi, QEMU_PLUGIN_MEM_R); + if (cpu_plugin_mem_cbs_enabled(env_cpu(env))) { + qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, oi, QEMU_PLUGIN_MEM_R); + } } uint8_t cpu_ldb_mmu(CPUArchState *env, abi_ptr addr, MemOpIdx oi, uintptr_t ra) @@ -188,7 +190,9 @@ Int128 cpu_ld16_mmu(CPUArchState *env, abi_ptr addr, static void plugin_store_cb(CPUArchState *env, abi_ptr addr, MemOpIdx oi) { - qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, oi, QEMU_PLUGIN_MEM_W); + if (cpu_plugin_mem_cbs_enabled(env_cpu(env))) { + qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, oi, QEMU_PLUGIN_MEM_W); + } } void cpu_stb_mmu(CPUArchState *env, abi_ptr addr, uint8_t val,