From patchwork Sat Jul 10 15:31:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 472338 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp1363978jao; Sat, 10 Jul 2021 08:36:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwkBn5/DeFLLWvQ1Sb+N1zDJc95jlNbWYkDSSJYftmaecFlbW5DZJ1UMAyNinl2NthuSlBL X-Received: by 2002:ab0:4128:: with SMTP id j37mr42771096uad.79.1625931371572; Sat, 10 Jul 2021 08:36:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625931371; cv=none; d=google.com; s=arc-20160816; b=ocwRtvtMXQyFc6oilVZURnS2EXnbNvuG2bRBKROzjgUSFSopWnZAuhpcyFbgqbG8Yr Nv76uC6ZMiq58T3xmN9/5RXs3vcTwJWHNk1RvagneIxutnwmXbyf41XP52Hkbs96jAUy zEIM8iKbSR0MEfQpIaINeHq3pNQSw+0HTAOQz8+OAqj5vmjdpOT7v2/g71EvGPbf/8Fb VZk3ig3knP4IcIjfGRqzfAnNchaRhGEwKMsZQsnlz6eWlvby7EWTo+EZLEspZtVWcKZ4 1d3scI5J04g7BwxHQl//8c1suDJc04hCzD14vbm+TD3iNiXCQzW2c0Y0/9FWoRVXcMJZ 1K5Q== 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=wPpFfUs4h86ewu3F3iemYnJMaalb1kmHYOs+LuBl5DE=; b=p30SWnKIVIy8p29I9rcN+WL/U2zUJZYquuIesJ2v+VjI5XgFF8iI2gPj9mHnncaewv AxbcAwpFYrWPp3OM0BZpWxmwcxhdXiVIkKVPBro3RxdQfzfFJNk9Cpl+dn0PPrTYAyC1 d6B8ZrQ3U031rgp9Q61gyYtYLNOmx3EdJVRsrDiWxR2nPnZLmsYQ5+ckR5prX3ZVuI8t 4uRabYziQURg8q76vNc4QW/w0XbiQuaVsY9FNeX0GLeN5wBFo4QFjdqh7CzvhcB+BeJI fnOD8YTBBHoLQK90mOre2bi9bGHEQ/kdBa7K7ZUXk2e1lFhcRwFKGbpvUw6+YApzNmV6 mMdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PmrRTxuG; 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 n10si10499168vsp.41.2021.07.10.08.36.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 10 Jul 2021 08:36:11 -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=PmrRTxuG; 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]:53818 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m2F1W-0008GY-Ux for patch@linaro.org; Sat, 10 Jul 2021 11:36:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58542) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m2ExM-00050a-44 for qemu-devel@nongnu.org; Sat, 10 Jul 2021 11:31:52 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]:45603) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m2ExK-0002E2-BO for qemu-devel@nongnu.org; Sat, 10 Jul 2021 11:31:51 -0400 Received: by mail-pl1-x62a.google.com with SMTP id p17so6109861plf.12 for ; Sat, 10 Jul 2021 08:31:49 -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=wPpFfUs4h86ewu3F3iemYnJMaalb1kmHYOs+LuBl5DE=; b=PmrRTxuGXUAj0eFvREXvAAM5IPPizJxSXQjpBPBAGNYlL3e+0PbvknpVE7Ka7ODO/M ToK5ZeGElpMfZ6Q/MrBsbp/LIGAGlyBvgr36Iu0q5TQpoW1XyEh6GyhnQLrL1xWu6mSE VrsZUb5lqwqUokwPgOv2a6FjEkhIF609KZnu1UJjD8Z6TGlykFvgcPdBC8fTP2Bpu2Is GJRcngy1kFVO+MdflcBvsFDTCBAruG4qa3Gx7UCwKutZzN+VLIYKUEzI1uPci3BYtvku Nw0tGsvgHI8spi0WexuEWTKmtIgr7opotWYNC5becdbchE9ktBV0bxE7E0Oqo+i7XLwL Di+g== 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=wPpFfUs4h86ewu3F3iemYnJMaalb1kmHYOs+LuBl5DE=; b=BulBVXOhPot4NPvhghmU5TMDxoIyobPpkW80bcsdc7dnWCASYrVxUiIRJVqcmN6fPO 8R0KDuHaA/Hp5Pasz9tOosV2mafp9qc6tKGsX05HxOmagEiFJ6NwT7GCRjXecJejOavq awctinC2yFw3K8mG3dOIWBG1WdEt6I4AhzD1JhOUezpBdmm3HiM1CTMrwRqRt7v12DZV gUMsoDAh9mL2reFo8x2njk5lkyR2jannGKEB6kKMlQH4nBqmQ1sTJN73Q8BmMygY2OfW upPSydxWlUY278cewDfl5C+E5im/llS5WlZTDub6gXKW0gvSG0tXaI7T2HUTIQ9TVqjV 4jWA== X-Gm-Message-State: AOAM532Jt4TTPfn2dCGk3k3pWa3JkkGFc5slESOOBNaRWAR9F5w+O/2L gkOwJ1JR7pCpP9I+PWSVVLrYrMArok2tHg== X-Received: by 2002:a17:90a:1a:: with SMTP id 26mr4765510pja.187.1625931108959; Sat, 10 Jul 2021 08:31:48 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id u23sm11975374pgk.38.2021.07.10.08.31.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Jul 2021 08:31:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 05/41] tcg: Move tb_phys_invalidate_count to tb_ctx Date: Sat, 10 Jul 2021 08:31:07 -0700 Message-Id: <20210710153143.1320521-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210710153143.1320521-1-richard.henderson@linaro.org> References: <20210710153143.1320521-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Viktor Ashirov Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We can call do_tb_phys_invalidate from an iocontext, which has no per-thread tcg_ctx. Move this to tb_ctx, which is global. The actual update still takes place with a lock held, so only an atomic set is required, not an atomic increment. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/457 Tested-by: Viktor Ashirov Signed-off-by: Richard Henderson --- accel/tcg/tb-context.h | 1 + include/tcg/tcg.h | 3 --- accel/tcg/translate-all.c | 8 ++++---- tcg/region.c | 14 -------------- 4 files changed, 5 insertions(+), 21 deletions(-) -- 2.25.1 diff --git a/accel/tcg/tb-context.h b/accel/tcg/tb-context.h index cc33979113..cac62d9749 100644 --- a/accel/tcg/tb-context.h +++ b/accel/tcg/tb-context.h @@ -34,6 +34,7 @@ struct TBContext { /* statistics */ unsigned tb_flush_count; + unsigned tb_phys_invalidate_count; }; extern TBContext tb_ctx; diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index dedb86939a..25dd19d6e1 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -579,8 +579,6 @@ struct TCGContext { /* Threshold to flush the translated code buffer. */ void *code_gen_highwater; - size_t tb_phys_invalidate_count; - /* Track which vCPU triggers events */ CPUState *cpu; /* *_trans */ @@ -815,7 +813,6 @@ size_t tcg_code_capacity(void); void tcg_tb_insert(TranslationBlock *tb); void tcg_tb_remove(TranslationBlock *tb); -size_t tcg_tb_phys_invalidate_count(void); TranslationBlock *tcg_tb_lookup(uintptr_t tc_ptr); void tcg_tb_foreach(GTraverseFunc func, gpointer user_data); size_t tcg_nb_tbs(void); diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 57455d8639..4df26de858 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1219,8 +1219,8 @@ static void do_tb_phys_invalidate(TranslationBlock *tb, bool rm_from_page_list) /* suppress any remaining jumps to this TB */ tb_jmp_unlink(tb); - qatomic_set(&tcg_ctx->tb_phys_invalidate_count, - tcg_ctx->tb_phys_invalidate_count + 1); + qatomic_set(&tb_ctx.tb_phys_invalidate_count, + tb_ctx.tb_phys_invalidate_count + 1); } static void tb_phys_invalidate__locked(TranslationBlock *tb) @@ -2128,8 +2128,8 @@ void dump_exec_info(void) qemu_printf("\nStatistics:\n"); qemu_printf("TB flush count %u\n", qatomic_read(&tb_ctx.tb_flush_count)); - qemu_printf("TB invalidate count %zu\n", - tcg_tb_phys_invalidate_count()); + qemu_printf("TB invalidate count %u\n", + qatomic_read(&tb_ctx.tb_phys_invalidate_count)); tlb_flush_counts(&flush_full, &flush_part, &flush_elide); qemu_printf("TLB full flushes %zu\n", flush_full); diff --git a/tcg/region.c b/tcg/region.c index d3a3658e81..e64c3ea230 100644 --- a/tcg/region.c +++ b/tcg/region.c @@ -980,17 +980,3 @@ size_t tcg_code_capacity(void) return capacity; } - -size_t tcg_tb_phys_invalidate_count(void) -{ - unsigned int n_ctxs = qatomic_read(&tcg_cur_ctxs); - unsigned int i; - size_t total = 0; - - for (i = 0; i < n_ctxs; i++) { - const TCGContext *s = qatomic_read(&tcg_ctxs[i]); - - total += qatomic_read(&s->tb_phys_invalidate_count); - } - return total; -}