From patchwork Wed Jun 28 12:04:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Fei Wu X-Patchwork-Id: 697235 Delivered-To: patch@linaro.org Received: by 2002:adf:e885:0:0:0:0:0 with SMTP id d5csp4303540wrm; Wed, 28 Jun 2023 05:06:07 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6wspPqoHFiGJr0FfIRSCKIWbGYW4BJs2qEfKUXSqoiCW1JHTK2OFg2MGGIbjUDUJ8YGgk/ X-Received: by 2002:a05:620a:458b:b0:765:aca9:1a02 with SMTP id bp11-20020a05620a458b00b00765aca91a02mr8232990qkb.25.1687953966709; Wed, 28 Jun 2023 05:06:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687953966; cv=none; d=google.com; s=arc-20160816; b=UDHa5WMgFYLWSwN2xrsZXVjxI89RxzVAQJGLFYXhCoSp9BfDhfv30cH1G2qO4xkX4T 1pO9l5tpPp82W4tCoUYUPy3qiMn8jR9LMJXVHc8dgR9ZtCGSz2BO/JIXkf+jHd7/js8O Ip7h7Tb0XmFX0aiHHXTfHUSmMM8HfUdQdJJFOCO1kzNUrIP5LYJy7m66LKBupNbDBz/6 M/KDrKQMrriE8GIIGM1w9IARcvnbujYWOm/lQVZtVF2Y4mastVVfT6Hiy47o7fYslIHT u7k+DTxwZC+6HDj2kWjvM8cQ8kpNF8jjsUjd2xv6tZgYUqdeNWcnCWt1wjtHxCK7JxhP Z2Hg== 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=2hSx00J4GGitn2m+Xj+I/kAqn/fMM36qqnROOM+Q//g=; fh=2bFsjEJDMXw9dK5b6JC7gtC94M7Kt4e+OaavNqFP5lA=; b=qwU3+IQye9s1dLzcdZmGknY7D+cw3f1oS4W7/aW0BFcCT9fjX7uc/EOP+Xookff4As mzDkWUyelQkdgpgPPzxIPz+feCdBpxhzOYtCeEPbaCMMzYQCjWj2OOoxtS8EEcsoZ6ze 4UOF0E1GhpRxs3oPg1L6IkHZD2WZPsPRhY85safDFyH9bFmYcRV+w86zU0tZZvGLUzR4 F7qDwqonQN2NX3r/qN5JYH+6MqbiGgLGNMy1B+dsxKGQqNOlYMxpxwEE43s9R4AjZPNB kBp1BsDcFbWQ/P9U+Ni8LlmANN3IZugEkvUrDji235YnEQgl3lwKO0l0sBxx8Ljdw34G fCKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=iTtwfSYG; 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=intel.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id rj12-20020a05620a8fcc00b00763a8f6aa25si1737024qkn.542.2023.06.28.05.06.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 28 Jun 2023 05:06:06 -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=@intel.com header.s=Intel header.b=iTtwfSYG; 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=intel.com Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qETsk-0007at-Em; Wed, 28 Jun 2023 08:02:46 -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 1qETsd-0007UR-7k for qemu-devel@nongnu.org; Wed, 28 Jun 2023 08:02:42 -0400 Received: from mga01.intel.com ([192.55.52.88]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qETsX-0006hC-TT for qemu-devel@nongnu.org; Wed, 28 Jun 2023 08:02:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687953753; x=1719489753; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=iXdZiM9wHrHsHxOasbNIOEuEt1z288cTyQQ7G+fWjmI=; b=iTtwfSYGBIhtzag/LhFMXYK0Pbnqi8sRXKh6WL8oJO0Xekap4EsyxGDy lGMivJ9/6Lornf5Oih7GprWONmUFPG3AY6uvPkNfwEzp2tXWeCfBP45XT /Aqh7aLnjDxtTwI4PfIDVw1OyBpUKGzeJZBw0rhTCvjeTwz7oWW0Ne29+ E/yYk7kbXasmof7MebpIZStW9sXt9rtLM+o8Bo7706eaBG+3TD7C24ouc 5p2gH5WFH54BmkHIFmMTQqfdhQ4IVhSYUWEEMD7OW2T4hiQKycgLf9Cig KnsM4D2G8lNegXk696DBbQJyXQAhZB/cB7HZ1hvwiOXjfkMC5q4A6lapd w==; X-IronPort-AV: E=McAfee;i="6600,9927,10754"; a="392547314" X-IronPort-AV: E=Sophos;i="6.01,165,1684825200"; d="scan'208";a="392547314" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2023 05:02:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10754"; a="841047493" X-IronPort-AV: E=Sophos;i="6.01,165,1684825200"; d="scan'208";a="841047493" Received: from wufei-optiplex-7090.sh.intel.com ([10.238.200.247]) by orsmga004.jf.intel.com with ESMTP; 28 Jun 2023 05:02:21 -0700 From: Fei Wu To: richard.henderson@linaro.org, alex.bennee@linaro.org, qemu-devel@nongnu.org Cc: Fei Wu , Paolo Bonzini Subject: [PATCH v16 5/9] tb-stats: reset the tracked TBs on a tb_flush Date: Wed, 28 Jun 2023 20:04:26 +0800 Message-Id: <20230628120430.73777-6-fei2.wu@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230628120430.73777-1-fei2.wu@intel.com> References: <20230628120430.73777-1-fei2.wu@intel.com> MIME-Version: 1.0 Received-SPF: pass client-ip=192.55.52.88; envelope-from=fei2.wu@intel.com; helo=mga01.intel.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: Alex Bennée 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 Reviewed-by: Richard Henderson Signed-off-by: Fei Wu --- accel/tcg/tb-maint.c | 1 + accel/tcg/tb-stats.c | 18 ++++++++++++++++++ include/exec/tb-stats.h | 8 ++++++++ 3 files changed, 27 insertions(+) diff --git a/accel/tcg/tb-maint.c b/accel/tcg/tb-maint.c index 264bdd84b3..1ebe6fc60e 100644 --- a/accel/tcg/tb-maint.c +++ b/accel/tcg/tb-maint.c @@ -762,6 +762,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); tb_remove_all(); + tbstats_reset_tbs(); tcg_region_reset_all(); /* XXX: flush processor icache at this point if cache flush is expensive */ qatomic_inc(&tb_ctx.tb_flush_count); diff --git a/accel/tcg/tb-stats.c b/accel/tcg/tb-stats.c index c90dde37d0..7c7f700c89 100644 --- a/accel/tcg/tb-stats.c +++ b/accel/tcg/tb-stats.c @@ -103,6 +103,24 @@ void clean_tbstats(void) qht_destroy(&tb_ctx.tb_stats); } +/* + * We have to reset the tbs array on a tb_flush as those + * TranslationBlocks no longer exist. + */ + +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(void) { if (!tb_ctx.tb_stats.map && tb_stats_collection_enabled()) { diff --git a/include/exec/tb-stats.h b/include/exec/tb-stats.h index ef6e8b6388..cef177bc69 100644 --- a/include/exec/tb-stats.h +++ b/include/exec/tb-stats.h @@ -94,4 +94,12 @@ void dump_jit_profile_info(GString *buf); void clean_tbstats(void); +/** + * 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