From nobody Mon Nov 25 11:22:10 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1715759611; cv=none; d=zohomail.com; s=zohoarc; b=HNFSH/pzBAaxh0srPBES1OK52fECvLbA8RbS9I5GyS6vLlwHZc1rvrxILn26sNSUavLTVFUesKmhNPV3W+dykK0JArOMcmDYRJQ8cPx+uAh+qvNtWitNBkQhsfadqbrKGJDvQjBZ0Z2lkg7z85IeFokFJdZkvZ/7SeaNybh7R/A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715759611; h=Content-Type: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=+l6G3m8cadQ7WYYi4wJCHAd6krJgJAZNy2Yqel8DyXU=; b=ElPlz5yGFpXKtM5bxGIV8aBqfsPwPCohMFCGbpZqU0rd+RuYBrl9yEJ4Up+O9CU8QaAzH4zOcO4kYpgIqQB9zlbpSfdQu6PjfSRf7U9wQBWOEARoG6SCBpCoWu86q/JjE0q3MiCLkz+ZzzJ6icU2eGMaXcqULVsVGgNJ4SWk6/g= 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 1715759611970311.4298307009874; Wed, 15 May 2024 00:53:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s79Rl-0004BG-Q5; Wed, 15 May 2024 03:53:10 -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 1s79Rf-00047c-2B for qemu-devel@nongnu.org; Wed, 15 May 2024 03:53:03 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s79Rc-0001aT-OS for qemu-devel@nongnu.org; Wed, 15 May 2024 03:53:02 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-41fc53252ceso45478685e9.0 for ; Wed, 15 May 2024 00:53:00 -0700 (PDT) Received: from stoup.. ([149.14.240.163]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-41fccee9292sm222611855e9.37.2024.05.15.00.52.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 00:52:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1715759579; x=1716364379; 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=+l6G3m8cadQ7WYYi4wJCHAd6krJgJAZNy2Yqel8DyXU=; b=F0cFWyU5ns3IO7WNAir0D79+zuBBm4SmC8z7APXwfAcMqFILVO68TSuL6IClGYPUUA 2l7b8241YefEkmLhvjQYz/+Ol4QJVeO9zJH87EwVYf47rpDGNE8fM1OytMnrkFTU33zA dwAoOdvFFN7LwWb1rY5t/Kz/B7N3cuUGQ6Rk/mqkc8aiHQX/gdvgGbc8eAgNk06FbqzG flzlQ6wZpDIDSaYmOqw116LV0+N6x3BWidQd/GorbtN5/HryKRvT2PskM7pz2ZlXMU+B E/ofZXbwBky3LB+34zK6GChsoukJ0c4/fIU6VAAdGdRPtET3Hm6hyYqhXTNFdZ+fAEVH BzNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715759579; x=1716364379; 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=+l6G3m8cadQ7WYYi4wJCHAd6krJgJAZNy2Yqel8DyXU=; b=IVKxy2hr/V9BYk811jpzZf0xVjxLaJDAFRQlDJAV3ngFOXPec3n4ZJRtYK6W9TmAzp kd24P7RE4tgiZWIVXYRGk2M639mmcTpEvP3YC20UpgZo9TVgVR3Tx3ThN4QxdQM81LEw JlQrlvCuIu3Pa8xFGuDVhW7jYYhLa1U2UHH7ssgk8M9fXpaomrFLGdr7M3NdDNMRhRP8 ClWn6mrP1IyubDL54PM2fKcOledhmcSWfiUjGwb6c2uAN+vU1alkGQkB2zfaiLCQH1Ws ZkEuR38rMbzCrl/nS1aaYa47eUQK4NPJ4Ofufn1mRCtvDLUqT7guQg0pcTqbAQup1dUg hNeA== X-Gm-Message-State: AOJu0YwCgNMH6v0Smua9FuH/24ftzdoAqHyyk1PxEep8+kz1fGTAYcY/ jSjoXO2mWplhZYe9NOC0uIdpsWmlOL5qljKN+0VuG/v6Uk9svjAoPFIfBqKiG/4kJoLo8iZUvGk 1t4o= X-Google-Smtp-Source: AGHT+IG3/qUZoGRC/O0keLBWwyrTKOPzY6M6kMYhKO0VuoSqQmlTAYaxSMWHmDqVfpzBGSif8jElXQ== X-Received: by 2002:a05:600c:a46:b0:41f:f144:5623 with SMTP id 5b1f17b1804b1-41ff1445732mr117845125e9.14.1715759579343; Wed, 15 May 2024 00:52:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 15/34] plugins: Merge alloc_tcg_plugin_context into plugin_gen_tb_start Date: Wed, 15 May 2024 09:52:28 +0200 Message-Id: <20240515075247.68024-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240515075247.68024-1-richard.henderson@linaro.org> References: <20240515075247.68024-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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=2a00:1450:4864:20::334; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x334.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1715759612581100001 We don't need to allocate plugin context at startup, we can wait until we actually use it. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- accel/tcg/plugin-gen.c | 36 ++++++++++++++++++++---------------- tcg/tcg.c | 11 ----------- 2 files changed, 20 insertions(+), 27 deletions(-) diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index b54494712a..54b08ffc9e 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -305,28 +305,32 @@ static void plugin_gen_inject(struct qemu_plugin_tb *= plugin_tb) =20 bool plugin_gen_tb_start(CPUState *cpu, const DisasContextBase *db) { - bool ret =3D false; + struct qemu_plugin_tb *ptb; =20 - if (test_bit(QEMU_PLUGIN_EV_VCPU_TB_TRANS, cpu->plugin_state->event_ma= sk)) { - struct qemu_plugin_tb *ptb =3D tcg_ctx->plugin_tb; - - /* reset callbacks */ - if (ptb->cbs) { - g_array_set_size(ptb->cbs, 0); - } - ptb->n =3D 0; - - ret =3D true; - - ptb->mem_helper =3D false; - - tcg_gen_plugin_cb(PLUGIN_GEN_FROM_TB); + if (!test_bit(QEMU_PLUGIN_EV_VCPU_TB_TRANS, + cpu->plugin_state->event_mask)) { + return false; } =20 tcg_ctx->plugin_db =3D db; tcg_ctx->plugin_insn =3D NULL; + ptb =3D tcg_ctx->plugin_tb; =20 - return ret; + if (ptb) { + /* Reset callbacks */ + if (ptb->cbs) { + g_array_set_size(ptb->cbs, 0); + } + ptb->n =3D 0; + ptb->mem_helper =3D false; + } else { + ptb =3D g_new0(struct qemu_plugin_tb, 1); + tcg_ctx->plugin_tb =3D ptb; + ptb->insns =3D g_ptr_array_new(); + } + + tcg_gen_plugin_cb(PLUGIN_GEN_FROM_TB); + return true; } =20 void plugin_gen_insn_start(CPUState *cpu, const DisasContextBase *db) diff --git a/tcg/tcg.c b/tcg/tcg.c index 71daa5d268..34e3056380 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -761,14 +761,6 @@ QEMU_BUILD_BUG_ON((int)(offsetof(CPUNegativeOffsetStat= e, tlb.f[0]) - < MIN_TLB_MASK_TABLE_OFS); #endif =20 -static void alloc_tcg_plugin_context(TCGContext *s) -{ -#ifdef CONFIG_PLUGIN - s->plugin_tb =3D g_new0(struct qemu_plugin_tb, 1); - s->plugin_tb->insns =3D g_ptr_array_new(); -#endif -} - /* * All TCG threads except the parent (i.e. the one that called tcg_context= _init * and registered the target's TCG globals) must register with this functi= on @@ -813,7 +805,6 @@ void tcg_register_thread(void) qatomic_set(&tcg_ctxs[n], s); =20 if (n > 0) { - alloc_tcg_plugin_context(s); tcg_region_initial_alloc(s); } =20 @@ -1360,8 +1351,6 @@ static void tcg_context_init(unsigned max_cpus) indirect_reg_alloc_order[i] =3D tcg_target_reg_alloc_order[i]; } =20 - alloc_tcg_plugin_context(s); - tcg_ctx =3D s; /* * In user-mode we simply share the init context among threads, since = we --=20 2.34.1