From patchwork Fri Jun 15 19:43:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138756 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1249976lji; Fri, 15 Jun 2018 12:50:44 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJqDRpYZkCrJiIgjftI9K1Q0IrPYgS+2Irv+jquEViyNLIiX+7DAOHXnT8RieSGZcJ0XWOJ X-Received: by 2002:a37:a705:: with SMTP id q5-v6mr2589447qke.154.1529092244445; Fri, 15 Jun 2018 12:50:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529092244; cv=none; d=google.com; s=arc-20160816; b=njqIpnOksMkGppdU1TdEZJ/Xv0t7FeyHBT6W0iMck6pip3dSmQwMIPCqajD4UrTKyv 8rbSeWxWj+BV+Q+Vj5q/IADVuuH8b26IZkKPsNm05XdD4Snex4iliRtv2vSmjxhCEFtN bLC+FLNzkhJVTtgTeey/RE+qvuMygaVLLpmZXpoI82T9c+H+9JaXPfd/Lx/+lAWuLFCz Ff4A/1odAeJKdJAefv/nymYSxZAKTpbPOTUyzmolnHjLzDpaZDXQR5wN+OREA2IXdGnF /9jJc8AHKBiEzEgCuJbfL/QDryTgWti0OE4wW+hh9MLxflkDNMTos73eIW8CSIruOxdP hHbA== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=jwAP7X29dbyxdynmu1epQ4EzxJvbPBd/BBvpAfZSEjM=; b=lN9EHr8dJm79qzPYxqdzZYMoMvfPbJB4vm+xmmGYqWcyAKewcVM1CYPA0+8jkvmx6q YgxR5mLjP1rrcdThyKlYyMEfe7XNqpobM/tKZxNtRyf7/Tq50RB6ZYx/sET9vxcfHd4O 733PmEvlyuB5hqGUG8CtrWxKzF447oVSO+iL3ZFATLGhBR6nqh6r0poMwEJTQmOVrOQT Vf9SNybPuJnKbmCLzHywflOhyW/4W+GU35aNAlzfIu3dV6i25GTYZsOy7bctYGcOQwu+ eZxCjpyYW6zQNefFbHW0GOcVH6n6USaUod2kwuTNvimt5/d4zKeFwa5f+uzGFexNC7e7 pbrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=jjtozDVc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 47-v6si2039463qvj.156.2018.06.15.12.50.44 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 15 Jun 2018 12:50:44 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=jjtozDVc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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]:48985 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTuk7-0005Hq-TV for patch@linaro.org; Fri, 15 Jun 2018 15:50:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51523) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTudn-0000Gc-Fy for qemu-devel@nongnu.org; Fri, 15 Jun 2018 15:44:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fTudm-0002SK-Fl for qemu-devel@nongnu.org; Fri, 15 Jun 2018 15:44:11 -0400 Received: from mail-pg0-x236.google.com ([2607:f8b0:400e:c05::236]:34014) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fTudm-0002Rx-9G for qemu-devel@nongnu.org; Fri, 15 Jun 2018 15:44:10 -0400 Received: by mail-pg0-x236.google.com with SMTP id q4-v6so4861902pgr.1 for ; Fri, 15 Jun 2018 12:44:10 -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=jwAP7X29dbyxdynmu1epQ4EzxJvbPBd/BBvpAfZSEjM=; b=jjtozDVcnQuWI1QWST27zefaVlCW4yA6dlmxEfBck0I8YvGAOlaDznS94tT4p+lkzH +WxNlw5NquuSMfOAkzK3BlSvwoOZ98SHI264qzoF8zqExfcM5p9dQP9+GCOjrU8XElGR pZ8uCehNaIL2Br9A8rZxIdOF/uNwkDlJjzeZQ= 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=jwAP7X29dbyxdynmu1epQ4EzxJvbPBd/BBvpAfZSEjM=; b=jT0sZ2b3qvjUK/8UsYDce3gud/BPaXUNZhg1ewzaVOWfb6BQYt26M6QuiepphplEEg n6RX1wg2IzV2K3f7eWnQCxnh1aJq4B+snNFxpl+iV3PomnCimk6RDNXzEvhnuaiNJzeq TrgSKz787M72HVrcV1Pn8QPoQpwhsqnITI/iIEGitOxP5gizo/b90j6cTFCK+cwNEd5c MRwY/KzrGDMnN+HxUfqc7j1e1MKEZTmPEfOEkKYhdGNCP2HTm3c7qOVIp2fHswq6Bmv8 RtaOp343D5ZPgECxVjMY0J3u58NEP5Je9pEpFZ9G9NNMazbz40NrGp4oCPRXeQNYY/bS fokw== X-Gm-Message-State: APt69E1Ssikr3ELbAsMJ+L4HHzaziFvP5w4FgvCP/KQK5O1oS9SAka6u E9TAHtBuegZBiLrfTF4KUrHBjHDjOx8= X-Received: by 2002:a62:7db:: with SMTP id 88-v6mr3371988pfh.178.1529091849009; Fri, 15 Jun 2018 12:44:09 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id 29-v6sm14038360pfj.14.2018.06.15.12.44.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Jun 2018 12:44:08 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 15 Jun 2018 09:43:40 -1000 Message-Id: <20180615194354.12489-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180615194354.12489-1-richard.henderson@linaro.org> References: <20180615194354.12489-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::236 Subject: [Qemu-devel] [PULL v2 05/19] tcg: move tb_ctx.tb_phys_invalidate_count to tcg_ctx X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, "Emilio G. Cota" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Thereby making it per-TCGContext. Once we remove tb_lock, this will avoid an atomic increment every time a TB is invalidated. Reviewed-by: Richard Henderson Reviewed-by: Alex Bennée Signed-off-by: Emilio G. Cota Signed-off-by: Richard Henderson --- include/exec/tb-context.h | 1 - tcg/tcg.h | 3 +++ accel/tcg/translate-all.c | 5 +++-- tcg/tcg.c | 14 ++++++++++++++ 4 files changed, 20 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/include/exec/tb-context.h b/include/exec/tb-context.h index d8472c88fb..8c9b49c98e 100644 --- a/include/exec/tb-context.h +++ b/include/exec/tb-context.h @@ -37,7 +37,6 @@ struct TBContext { /* statistics */ unsigned tb_flush_count; - int tb_phys_invalidate_count; }; extern TBContext tb_ctx; diff --git a/tcg/tcg.h b/tcg/tcg.h index 1e6df1906f..e49b289ba1 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -695,6 +695,8 @@ 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 */ @@ -868,6 +870,7 @@ 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 ef841c82cc..a9f2bfb468 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1069,7 +1069,8 @@ void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr) /* suppress any remaining jumps to this TB */ tb_jmp_unlink(tb); - tb_ctx.tb_phys_invalidate_count++; + atomic_set(&tcg_ctx->tb_phys_invalidate_count, + tcg_ctx->tb_phys_invalidate_count + 1); } #ifdef CONFIG_SOFTMMU @@ -1855,7 +1856,7 @@ void dump_exec_info(FILE *f, fprintf_function cpu_fprintf) cpu_fprintf(f, "\nStatistics:\n"); cpu_fprintf(f, "TB flush count %u\n", atomic_read(&tb_ctx.tb_flush_count)); - cpu_fprintf(f, "TB invalidate count %d\n", tb_ctx.tb_phys_invalidate_count); + cpu_fprintf(f, "TB invalidate count %zu\n", tcg_tb_phys_invalidate_count()); cpu_fprintf(f, "TLB flush count %zu\n", tlb_flush_count()); tcg_dump_info(f, cpu_fprintf); } diff --git a/tcg/tcg.c b/tcg/tcg.c index 62e3391020..1d1dfd7f7c 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -791,6 +791,20 @@ size_t tcg_code_capacity(void) return capacity; } +size_t tcg_tb_phys_invalidate_count(void) +{ + unsigned int n_ctxs = atomic_read(&n_tcg_ctxs); + unsigned int i; + size_t total = 0; + + for (i = 0; i < n_ctxs; i++) { + const TCGContext *s = atomic_read(&tcg_ctxs[i]); + + total += atomic_read(&s->tb_phys_invalidate_count); + } + return total; +} + /* pool based memory allocation */ void *tcg_malloc_internal(TCGContext *s, int size) {