From patchwork Fri Jun 11 23:41:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 458542 Delivered-To: patch@linaro.org Received: by 2002:a17:907:7409:0:0:0:0 with SMTP id gj9csp707281ejc; Fri, 11 Jun 2021 16:49:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyAc/Tl0kPmmnyKWSm47yhaHmUTkL/RubF0qifA4iCj3u6D2/3YN61f0wBzylS9Zx5/8+q7 X-Received: by 2002:a05:6602:2215:: with SMTP id n21mr5143102ion.80.1623455361117; Fri, 11 Jun 2021 16:49:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623455361; cv=none; d=google.com; s=arc-20160816; b=c8PKwheVPg0yNFJetZ9Gho0ARCLkR8Vvu5ZK4x5OSbhsr0h7teNsbWQy+p72HqqxXv FrlYEDkk1AzXlF5nWuhNox2+xjUBRTGeMMnNh3ikZSH9axIbrX9vYOxAgl79/tiqU0xo DuxfVQKg/zY5RsF3m/j2fqs5fyDgBjeyIjaRD0sMxGAPPDTdrnN8HjZL7lc95Lv/TAjW 75eQwdGXrQglKWwmo4cmS0HgROBKmIOa45Jk3Uh4D0oHag1zc5l+NXCNqjwthEz7FuKl F5ZHcQZj6YrBluDVCqLsbRSQ/bxqnhEeEEHXOmRWJwtPysq4XlYZyJeJE6fNJ0UIEUqq ArHg== 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=iYzRJ65/H4fLD/mZbc5LqELD84drbVwSLcSFgKAxf3E=; b=Gqf2/rBkiMAxyVI64UMpceXk+g17xgXGB9+Zg2Ktjh5HELFv5ZN8NqD3yIJocnkBQf WRCjP6agBi4Q8C+sbBCjVxOut9NvnLf0xt2xoIioQrWyw2K6ToQINRdXrBaO0sFQVSYy okyaSk6agjw17iBPqrSkja8vqSvzPrmBxIN/3IdXaAUks24Z1emsh6I3JxAt3ucxmsXE bMuCcPb75opNT2nkNSnCBFgFziBBhvDU2aDQNcXdrxKmCW/nl+C4Zn7sX4vSdaYvB7D/ PcN6GFGz/1sjeqkK93bdmY1T9rtRzVHKK/sabgpL6C3TpWVlkQgeh3Ecz08X979e5n0c B4Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mmEhLw68; 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 i13si9794990ilm.45.2021.06.11.16.49.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 11 Jun 2021 16:49:21 -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=mmEhLw68; 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]:43358 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lrqts-0001Mz-9d for patch@linaro.org; Fri, 11 Jun 2021 19:49:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47204) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrqml-0002gy-36 for qemu-devel@nongnu.org; Fri, 11 Jun 2021 19:41:59 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]:37558) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lrqmh-0002gM-Vq for qemu-devel@nongnu.org; Fri, 11 Jun 2021 19:41:58 -0400 Received: by mail-pl1-x62b.google.com with SMTP id h12so3599742plf.4 for ; Fri, 11 Jun 2021 16:41:55 -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=iYzRJ65/H4fLD/mZbc5LqELD84drbVwSLcSFgKAxf3E=; b=mmEhLw68a9vsbek7USdTzB4NDKKrrcGQkon4VMBgVVZYNzY6go3QKre4VkvArwmoJT hiC3HfuE5VoktDdLtfSgkdXmM1hF4w7Ev4HWwIK20G94wMPJrrliPa8tTVbttAc4Q9Es 2M5RpGYQQ2vVxIQeEapqbkeFlc1cqJDvJHmbx6cScNh/fCbuOQfJK+MB1EPbEWkKYfYG 5FphL3RnPGWRrH6/DPpoqkr1bGdY4GTUgHSAPMETSFHh1VcKHEobKpz5wVScaMlvi9QD sB9YTPEuPQsTloRsiTWSZJIUYWgY6XjLNhSjatLHWwF1b7TZ4URNSzLtscuMHkATExWl 7wIQ== 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=iYzRJ65/H4fLD/mZbc5LqELD84drbVwSLcSFgKAxf3E=; b=E5hINmK54qhge6ackav44X2grWOskyuNbaM7LEMxHvz1N+f5RRBBhvgzhwEbhUZfke uc0lW928x3lz1AYSHGEfxQPmxLA7gTIf+R0l1Uw4Fpfu4+iEyPsSUxQ64JxdQ9iDmujT yAD++Au8JHOHmcV/lWsr7ottkRjnalwFVMic7Jsr4hCKNUxjswyS8tTWN+SG+fHfiheR IHwu77GR7tuWPDokL5mwZgFqWRnsEB91QP4JgS8wTZ6uFfjVGMGcP2VSCOBTLWvoKw3t cOKmT/2vjw07W6nbP0Q4ND6rHEcNE/2A9MB42I3j3kKv0K9TyNQB9hG64oYlJUXqA/nG kZag== X-Gm-Message-State: AOAM532/TdUeYDoEBW8NHoQ0PcOiTr3ajqf+zth10Dk2PPnJ54TpuOhB 2wf7g4x/ZYpqjBQjrftLFH8zTfJv5FTsRg== X-Received: by 2002:a17:90a:4f0a:: with SMTP id p10mr11551371pjh.36.1623454914732; Fri, 11 Jun 2021 16:41:54 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id q23sm6139829pgm.31.2021.06.11.16.41.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Jun 2021 16:41:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 15/34] tcg: Introduce tcg_max_ctxs Date: Fri, 11 Jun 2021 16:41:25 -0700 Message-Id: <20210611234144.653682-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210611234144.653682-1-richard.henderson@linaro.org> References: <20210611234144.653682-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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: Luis Pires , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Finish the divorce of tcg/ from hw/, and do not take the max cpu value from MachineState; just remember what we were passed in tcg_init. Reviewed-by: Luis Pires Reviewed-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/tcg-internal.h | 3 ++- tcg/region.c | 6 +++--- tcg/tcg.c | 23 ++++++++++------------- 3 files changed, 15 insertions(+), 17 deletions(-) -- 2.25.1 diff --git a/tcg/tcg-internal.h b/tcg/tcg-internal.h index fcfeca232f..f9906523da 100644 --- a/tcg/tcg-internal.h +++ b/tcg/tcg-internal.h @@ -28,7 +28,8 @@ #define TCG_HIGHWATER 1024 extern TCGContext **tcg_ctxs; -extern unsigned int n_tcg_ctxs; +extern unsigned int tcg_cur_ctxs; +extern unsigned int tcg_max_ctxs; void tcg_region_init(size_t tb_size, int splitwx, unsigned max_cpus); bool tcg_region_alloc(TCGContext *s); diff --git a/tcg/region.c b/tcg/region.c index 877baf16f5..57069a38ff 100644 --- a/tcg/region.c +++ b/tcg/region.c @@ -347,7 +347,7 @@ void tcg_region_initial_alloc(TCGContext *s) /* Call from a safe-work context */ void tcg_region_reset_all(void) { - unsigned int n_ctxs = qatomic_read(&n_tcg_ctxs); + unsigned int n_ctxs = qatomic_read(&tcg_cur_ctxs); unsigned int i; qemu_mutex_lock(®ion.lock); @@ -934,7 +934,7 @@ void tcg_region_prologue_set(TCGContext *s) */ size_t tcg_code_size(void) { - unsigned int n_ctxs = qatomic_read(&n_tcg_ctxs); + unsigned int n_ctxs = qatomic_read(&tcg_cur_ctxs); unsigned int i; size_t total; @@ -970,7 +970,7 @@ size_t tcg_code_capacity(void) size_t tcg_tb_phys_invalidate_count(void) { - unsigned int n_ctxs = qatomic_read(&n_tcg_ctxs); + unsigned int n_ctxs = qatomic_read(&tcg_cur_ctxs); unsigned int i; size_t total = 0; diff --git a/tcg/tcg.c b/tcg/tcg.c index 5cc384e205..9880d5205e 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -43,11 +43,6 @@ #define NO_CPU_IO_DEFS #include "exec/exec-all.h" - -#if !defined(CONFIG_USER_ONLY) -#include "hw/boards.h" -#endif - #include "tcg/tcg-op.h" #if UINTPTR_MAX == UINT32_MAX @@ -155,7 +150,8 @@ static int tcg_out_ldst_finalize(TCGContext *s); #endif TCGContext **tcg_ctxs; -unsigned int n_tcg_ctxs; +unsigned int tcg_cur_ctxs; +unsigned int tcg_max_ctxs; TCGv_env cpu_env = 0; const void *tcg_code_gen_epilogue; uintptr_t tcg_splitwx_diff; @@ -475,7 +471,6 @@ void tcg_register_thread(void) #else void tcg_register_thread(void) { - MachineState *ms = MACHINE(qdev_get_machine()); TCGContext *s = g_malloc(sizeof(*s)); unsigned int i, n; @@ -491,8 +486,8 @@ void tcg_register_thread(void) } /* Claim an entry in tcg_ctxs */ - n = qatomic_fetch_inc(&n_tcg_ctxs); - g_assert(n < ms->smp.max_cpus); + n = qatomic_fetch_inc(&tcg_cur_ctxs); + g_assert(n < tcg_max_ctxs); qatomic_set(&tcg_ctxs[n], s); if (n > 0) { @@ -643,9 +638,11 @@ static void tcg_context_init(unsigned max_cpus) */ #ifdef CONFIG_USER_ONLY tcg_ctxs = &tcg_ctx; - n_tcg_ctxs = 1; + tcg_cur_ctxs = 1; + tcg_max_ctxs = 1; #else - tcg_ctxs = g_new(TCGContext *, max_cpus); + tcg_max_ctxs = max_cpus; + tcg_ctxs = g_new0(TCGContext *, max_cpus); #endif tcg_debug_assert(!tcg_regset_test_reg(s->reserved_regs, TCG_AREG0)); @@ -3937,7 +3934,7 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp *op) static inline void tcg_profile_snapshot(TCGProfile *prof, bool counters, bool table) { - unsigned int n_ctxs = qatomic_read(&n_tcg_ctxs); + unsigned int n_ctxs = qatomic_read(&tcg_cur_ctxs); unsigned int i; for (i = 0; i < n_ctxs; i++) { @@ -4000,7 +3997,7 @@ void tcg_dump_op_count(void) int64_t tcg_cpu_exec_time(void) { - unsigned int n_ctxs = qatomic_read(&n_tcg_ctxs); + unsigned int n_ctxs = qatomic_read(&tcg_cur_ctxs); unsigned int i; int64_t ret = 0;