From patchwork Mon Oct 7 15:28:34 2019 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: 175361 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4459836ill; Mon, 7 Oct 2019 08:50:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqwlbbvRnhhSpOgm41f0HK4FspsGsVQhxGgygfQRQPu5RCN8fkMgJzYKwx13Ac3Kc9bUy2S2 X-Received: by 2002:a37:6787:: with SMTP id b129mr24750724qkc.60.1570463456503; Mon, 07 Oct 2019 08:50:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570463456; cv=none; d=google.com; s=arc-20160816; b=ZxgxSpFm94Ov/0RuwUaKLF79N128qCKOf04SuxboT0QxTLdh7NjNIbxyGrn/S0tjHk U+rkb4B5fcZ3f6jX+egBIRELwonc2h/kn3iY5+9nUFdlRV07+TbyqRrafShLE88+N168 1Fsr8LmBD+ArWzr8CnjZhEvhRWPLsa5zbD6/af1v1YZ8dF4sbG8ngbCKf7xRGOLiHAeA DBpDF2ICpjw7zPuqx6stXA3V3n6yS5UUzhnytpMKuXjPbvTc7BCdhEcmvXGw//qjV+zU i1ve+Sf4i1I2Ps22YZvu2Y7Wal8nGDSSTk7B7wiTQebhY3F3/0eIh3nfYV54AL1xeMmV /HgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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:to:from :dkim-signature; bh=hggjK8Ae7uaAUz2uVJWEK720XDx0HS+iysTy3zwJ5bU=; b=WDI7+1SITOcyVbozknEsrpl8AX/y0W5UlJNj6Mavm6FcUI3iBLNFbHx11ZSDS1sdnL zf+SdQpiSEL+lwPdzsHt/4XOJxhTnoEljAf9/TKDvOiTX+1eAmHj4NL5kYyWWR8/FwQw dOh5zOVErTMGQiCdc1okFwb+h+wPVFWIE4DK27xEryS5Wb5Qtny+jb5KwDhn4Vl82bUh l1kytoqJI7IV096e4hB4j19WJCX77suFuTZzltDufQopBmV+XaELLM+QUn8m2MZM0zZp 8KmO7arRT2Y0yHVX91n0k4PwQOGK5Gi2lLJSXXtCdmEmdmIZbMS6Jk5blV6fwYirhcs9 /lbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=MWLw29C5; 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=fail (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 o23si12736659qto.30.2019.10.07.08.50.56 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Oct 2019 08:50:56 -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=fail header.i=@linaro.org header.s=google header.b=MWLw29C5; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:46486 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iHVHj-0003Er-Jy for patch@linaro.org; Mon, 07 Oct 2019 11:50:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48913) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iHUwL-0002bT-G8 for qemu-devel@nongnu.org; Mon, 07 Oct 2019 11:28:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iHUwJ-0005BF-QH for qemu-devel@nongnu.org; Mon, 07 Oct 2019 11:28:49 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:39100) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iHUwJ-0005An-IS for qemu-devel@nongnu.org; Mon, 07 Oct 2019 11:28:47 -0400 Received: by mail-wm1-x341.google.com with SMTP id v17so12819265wml.4 for ; Mon, 07 Oct 2019 08:28:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hggjK8Ae7uaAUz2uVJWEK720XDx0HS+iysTy3zwJ5bU=; b=MWLw29C5a2/tlUtOGDP/AnatDJmaxu0PByRmZLHFIsv+fah23hB3Q2g8z4cbTD/LpR BftdHZtbtz0OvC+5HOdflMFx5fn8Va8EgNyFEkiot5GoQdnbh8oKYTEbrwGB9lIfW7wl g0mOQerJ/niZ585wyebpDqijrjySlMafW/wsv9iruG8kpIyHV7tYD16RnUkTSRJbYFb2 CBcJ9t+4+QSM91Pr+Z42ztrGeOVGirFNyk5WtK9wIpgasjTVUKbiLPkdwSSF3+3+B11b UZqxQaZGKtJv9HtIazpiKLkoMiMBnrQX1DD1kcRAvDoCE2rwYmbucOSNqwSN0FdbTd4w 5N9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hggjK8Ae7uaAUz2uVJWEK720XDx0HS+iysTy3zwJ5bU=; b=JO8eJPixliPUkg05AWCmWZHgOzEpVmvR7JgVUBt4j4Iy83Uh3XMHPKrYG74mySmhq7 jyPJ+VQ4DuAYAIlzecNRQHA71S48lo6IY7k3Tz04IFSFvpQiaU+8OR83jnYYPhKv9nQR yNFg1KXceOU3el+6gWbR3rHROeKhcGKcCugMvNPx3pCfTsspREPqmDLrul7Q/EZEhON4 3riBfHllr8oOrq2zoNS8srwBJq/9HeJvX20PPKL7nmG3a4/fmA9ssnAqpB21o631Vp90 4CAdZco1U/vjVlRlw6MQ+4Gy5i9fvDB+HeFJ595JYe7L2AhbYhQaa5MaVATFxvheAxi1 iLdg== X-Gm-Message-State: APjAAAUX1+zLSQNlE5qJjYmnfweCPX74lYdOljyhp2AI6x0gUuNWu+UZ 5gjtM3XGb4AdTcJm14h+RgpgGQ== X-Received: by 2002:a1c:a404:: with SMTP id n4mr17163987wme.137.1570462126494; Mon, 07 Oct 2019 08:28:46 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id y13sm21402104wrg.8.2019.10.07.08.28.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2019 08:28:42 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 23B8E1FF98; Mon, 7 Oct 2019 16:28:40 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v9 08/13] tb-stats: reset the tracked TBs on a tb_flush Date: Mon, 7 Oct 2019 16:28:34 +0100 Message-Id: <20191007152839.30804-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191007152839.30804-1-alex.bennee@linaro.org> References: <20191007152839.30804-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::341 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , cota@braap.org, =?utf-8?q?Alex_Be?= =?utf-8?b?bm7DqWU=?= , Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We keep track of translations but can only do so up until the translation cache is flushed. At that point we really have no idea if we can re-create a translation because all the active tracking information has been reset. Signed-off-by: Alex Bennée --- accel/tcg/tb-stats.c | 19 +++++++++++++++++++ accel/tcg/translate-all.c | 2 +- include/exec/tb-stats.h | 8 ++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) -- 2.20.1 Reviewed-by: Richard Henderson diff --git a/accel/tcg/tb-stats.c b/accel/tcg/tb-stats.c index dabc5150f9..f08e5f2540 100644 --- a/accel/tcg/tb-stats.c +++ b/accel/tcg/tb-stats.c @@ -247,6 +247,25 @@ void do_hmp_tbstats_safe(CPUState *cpu, run_on_cpu_data icmd) g_free(cmdinfo); } +/* + * We have to reset the tbs array on a tb_flush as those + * TranslationBlocks no longer exist and we no loner know if the + * current mapping is still valid. + */ + +static void reset_tbs_array(void *p, uint32_t hash, void *userp) +{ + TBStatistics *tbs = p; + g_ptr_array_set_size(tbs->tbs, 0); +} + +void tbstats_reset_tbs(void) +{ + if (tb_ctx.tb_stats.map) { + qht_iter(&tb_ctx.tb_stats, reset_tbs_array, NULL); + } +} + void init_tb_stats_htable_if_not(void) { if (tb_stats_collection_enabled() && !tb_ctx.tb_stats.map) { diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 396e63c3e7..871d91d559 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1273,7 +1273,7 @@ static void do_tb_flush(CPUState *cpu, run_on_cpu_data tb_flush_count) qht_reset_size(&tb_ctx.htable, CODE_GEN_HTABLE_SIZE); page_flush_tb(); - + tbstats_reset_tbs(); tcg_region_reset_all(); /* XXX: flush processor icache at this point if cache flush is expensive */ diff --git a/include/exec/tb-stats.h b/include/exec/tb-stats.h index 921da38c97..c20a3e6439 100644 --- a/include/exec/tb-stats.h +++ b/include/exec/tb-stats.h @@ -125,4 +125,12 @@ struct TbstatsCommand { void do_hmp_tbstats_safe(CPUState *cpu, run_on_cpu_data icmd); +/** + * tbstats_reset_tbs: reset the linked array of TBs + * + * Reset the list of tbs for a given array. Should be called from + * safe work during tb_flush. + */ +void tbstats_reset_tbs(void); + #endif