From patchwork Mon Jun 24 10:18:36 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: 807009 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp1810877wrt; Mon, 24 Jun 2024 03:19:52 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVy8+vp/VAQWZjxTy08GqNZ2N7QbQJmgp+2LqESfrTlrKJ8kyJ2/B/RJqmh757jiGrlaRe29oLtv314CNk1lsyx X-Google-Smtp-Source: AGHT+IFDevNjL7vRrK6C/ibWd8jm+rkwjRmSkHa35cUXgl1CRH7XuG+81tzE2f5VMMQ5fSQm6WN6 X-Received: by 2002:a05:620a:4729:b0:795:eb8c:25a9 with SMTP id af79cd13be357-79be6e91b55mr496357385a.5.1719224392578; Mon, 24 Jun 2024 03:19:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719224392; cv=none; d=google.com; s=arc-20160816; b=qqqXU/+bBtWJqtGy+IbJysKFxKUZoWJ1oooNLwBEAxNpg2CVPuVV157hQ28ppgcxEP KgGr5PXKC3Bd/YCnlvZfsREFqXQJXsOKWv8eY4znZuEZmGFntsr+d5KJUZCYAvh1OOrZ ELKFvCaz/T/iv2oacYXofO2YUYKhcTo/TxLGAaLMdYbFpN3e7LemZ1Wb/7ABXBnrthQe CUK5UfaKJrrv/7zWioyGI8bfRUMZci22CTOX39kIZvNa3KPdsxQ7l62GgrFZna3DMlOm rO2l1qyReEBlf/a9p3YAOM2NxtwqPxgGE66xgqD5a8Yn4vtT6Vd1yFc1clY/SXbWuGoz CM2Q== 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=csz4agAZp6lldiHiVd/L/1KnBx9/0btPjs2vbkrKDHw=; fh=xg9KhLNlzpiEATsqcju6L9IGiSofT7BmI33e9MUc3B8=; b=y5Hp9bsfS9XZ8dRmani+KHyZvHqODYx2NcOmafdspmP2Q4q1dHnWmSLKEYWeiHi4jZ /F93VbMO/OtjfxG1evZvlOWHDPLcKcp3i0U3frzMOM4Z8n/K+oaYgcf/CwnHnQIWqnoT lT4JhJ0wppUGozHCU/aqPVvt2Y1HJiIhFUnGkBRlXj3bGxKQZ6kTWU++DqxdOXOW1h4/ rnB/MVQXRECK3OH3Hg4zg4vssXmomN2StvBuxzKnRqP1NdNDwyATvS5sPV4Z/9niLpqK UKlR878Ypz7JM40PcEJDFrfCvj6yJQRbxp5dHH/UayCenqa+kt559XFdyNAc40WXAN/J ytvQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ehrNIR6s; 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-79bce88286fsi805260585a.111.2024.06.24.03.19.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2024 03:19:52 -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=ehrNIR6s; 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 1sLgmi-0006pp-NT; Mon, 24 Jun 2024 06:18:52 -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 1sLgmh-0006ov-JX for qemu-devel@nongnu.org; Mon, 24 Jun 2024 06:18:51 -0400 Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLgme-0007hs-Mt for qemu-devel@nongnu.org; Mon, 24 Jun 2024 06:18:51 -0400 Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-a724b4f1218so133438366b.2 for ; Mon, 24 Jun 2024 03:18:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719224326; x=1719829126; 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=csz4agAZp6lldiHiVd/L/1KnBx9/0btPjs2vbkrKDHw=; b=ehrNIR6s2ugtuKX1oJKaSxMT6df7vcm/OIwEV1MmbzUDFepB1Fk3vhfNeF9p/41yt7 GjKWgxjYnyKB8xrM0rC3wY8kaqN4HeYXw1R7rEIdBU7FykjAfp10TZwH1YtxEnPQPdj3 z1vJP5RGAAIrUJE8fQz+kIRtv1KK9LkFa2Uue7pv4Jbq/UsFskd8dt1jtznnfXbGOTkS A+fE8R9nrpC6Drf/lsI83KUf6ytZf+r8a3MEQk3VyQbRcCEOfGXJiGvvkE4QrUlYsnCD P+K9Oh3V31bHkT5SDVv3hJ5/Rz9poM1EQ3up8EDE9+66gkcjVbTHcM8ZDHgoUrIQrw4d c3/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719224326; x=1719829126; 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=csz4agAZp6lldiHiVd/L/1KnBx9/0btPjs2vbkrKDHw=; b=Io4JWUhpLC0S7fPNhq2sCklsekqjmLhiZKz7e3xxOEXDh8Km7bPkKSOOSa6g6U4/vC ZeL3Egv1SlEcYVpueXptnvdsL86ddgqH6lMqaoqKT6TZbZkWFl48nIj0rl9KlGwAuU5k rUI4EjA5y6onAIJP1tA+11fmPcK8QNne2ddz12Lm9gyiP4PebTbzFAAHufDnpJaKzfmL 2OOP6CKVkW/VJM69D8YBAmmiSG6Lrn684YZcZWq0pbk8ZYwqXEy/kUvor/KlfqPiMw3o KgXhDexZc42um8lkqJ1aJnbUB8/X0RPdq2GYt02BTbJFLm/wyE9XMdjCz6/jqsJryqkw J2+Q== X-Gm-Message-State: AOJu0YwEJGnKp5HqF2eG01sE0cGx68Yo8fOedjrnXFHtDJ30/SY7scMm FoMtCdUovZr/RpB/GCGhu+UOTwcQYG6MKFV3LTwlJxsyaCw+7S91IthQcaKS7rUHgiVq/MjH2Cw S X-Received: by 2002:a17:907:8b8c:b0:a72:4b31:13aa with SMTP id a640c23a62f3a-a724b311555mr241195866b.55.1719224325881; Mon, 24 Jun 2024 03:18:45 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6fcf428c24sm400211666b.17.2024.06.24.03.18.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 03:18:41 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 7ED865FA2E; Mon, 24 Jun 2024 11:18:37 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Max Chou , Richard Henderson , Frank Chang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Alex?= =?utf-8?q?_Benn=C3=A9e?= , Paolo Bonzini Subject: [PULL 12/12] accel/tcg: Avoid unnecessary call overhead from qemu_plugin_vcpu_mem_cb Date: Mon, 24 Jun 2024 11:18:36 +0100 Message-Id: <20240624101836.193761-13-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240624101836.193761-1-alex.bennee@linaro.org> References: <20240624101836.193761-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::631; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x631.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 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+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é Signed-off-by: Alex Bennée Message-Id: <20240620152220.2192768-13-alex.bennee@linaro.org> 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,