From patchwork Wed Oct 31 12:21:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 149792 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp6730991ljp; Wed, 31 Oct 2018 05:31:48 -0700 (PDT) X-Google-Smtp-Source: AJdET5eceyae2u4wGWSk3vXa45Ig3SE/1CyWtafW2EoEGJ+C9BV60i7mjFu0FBhmd+HXK5uuijJa X-Received: by 2002:ac8:43d0:: with SMTP id w16mr2445391qtn.78.1540989108882; Wed, 31 Oct 2018 05:31:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540989108; cv=none; d=google.com; s=arc-20160816; b=UvivyyFp8oGpih1r+B8CNkp6x7G3l5xeMaRyYW0rgEChG9I7EyqJOnm7XblK703rBT jUDG80TLnbPBhLpXfOxbLXcfS1IK+JG+3R7ISYw9oJAdAWmjQSb/U4TV4FjdBnnh684L EnB7/Vle55G3ivR7rHTn8G9el8osMOtW+Ujk+DX1qFqSFdEEk3EkuTWW5EZStfiIkFY3 F2BI6CiSxQCVtbM43dZ+qjN5g3nAofsL9KhxDU1fnd51ooz1LTdMmnIIfROgDyuWth+w aqJstl+uungtlJp/IN8hZqQ4ubsTsOVFPkiklA3fQBdPmQ3Emdg40PgTaU4zRioqtgnT EBXg== 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:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=53nfMiSkZwljDj68THvPmRulJ3ECsiiCe4M0EwMJzgw=; b=Q6MTFHM6CigYe3ahSVXFsBOKQtZiAWObO9a1pAiF3pNDidvUEUY2d2HQ8bFjVJPwiW AtOkRfaeSARMroTEEbfShvvaqGSzUWQB5lJ+9/k20R5V7W+mQnKiLcfaP0ChgDXSqHGB rcaE3ifx4kUfpKVgkFcB/Rd/NJQSjHmmqWemkNR4NjDsY/SoM21S/orELx34/B7gV+ly q1YeykkVEO31Oo+OSiIHOGSn5A5x4iZK7TS1ilXDyohO2NkwcfsHjnvvk+ME2YkN5Ycr UkUwVVZEToV3bvHudf0hkLwIV8ykg1U6VLErB3hNs6MbzueKfWU03/yuohqzMt6WQEdI 3mzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=DMfWpcbE; 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 k11si7299428qvc.180.2018.10.31.05.31.48 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 31 Oct 2018 05:31:48 -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=DMfWpcbE; 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]:59195 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHpf2-0002tj-4y for patch@linaro.org; Wed, 31 Oct 2018 08:31:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48981) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHpVi-0000rR-1n for qemu-devel@nongnu.org; Wed, 31 Oct 2018 08:22:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHpVg-0001wE-Oy for qemu-devel@nongnu.org; Wed, 31 Oct 2018 08:22:09 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:46760) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gHpVg-0001E1-FO for qemu-devel@nongnu.org; Wed, 31 Oct 2018 08:22:08 -0400 Received: by mail-wr1-x443.google.com with SMTP id 74-v6so8040162wrb.13 for ; Wed, 31 Oct 2018 05:21:28 -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; bh=53nfMiSkZwljDj68THvPmRulJ3ECsiiCe4M0EwMJzgw=; b=DMfWpcbEGs82S2ksUj/yGHfxBJAdbHYxBQZtaGiE7OxYBMY3N08KKfxSkiVzbh8tzs iVUQR+sfX412HSH3YyssjEATcso/TIZTopM0Lft6WA+6Hkyy/VbCCJqSdMwYdNHha/Cu 6QVVS6tQT5J6UbcR0bkmmn2OyVk12ZOuzZvM0= 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; bh=53nfMiSkZwljDj68THvPmRulJ3ECsiiCe4M0EwMJzgw=; b=mV72KL6Va2wOfa0Q655mWrC2rYOvFZ2wtL8T+z5mbfiVoBAc4k31nvWZP2U2s+++vG QSR+QqIny1hZZ7eFDWQJt8kVZKZHgjIXYBjiiHofeU5kZkG5sKyyPrzEMf/OTg5PvDu4 e3vaYXS+kJKawnqc16HsuapomP2/tGsoqDqOWdG9t+S2BOQUCgiv6jqLBtrriehltB4U IgPNHKve6FocnpynvxUQhzw7NsyzSiOTX4ZMV/5yqBPe6qJA+Bib78TOUZS2aH/fzJaa FQ+MIL9UKyV236CMScbpTYMkxTyASl0caGI6aRSr9rH6uDr/vO14WM1F+moUYnCuSRXw J9Sg== X-Gm-Message-State: AGRZ1gITIucxdL/xtg4hguNGkXkIN/BW1JusbmvAPc5zLVRsLKd/TujN ewRCHQzk6+3K68gS5y6ARERKaqRzpSs= X-Received: by 2002:adf:f941:: with SMTP id q1-v6mr2503043wrr.151.1540988487757; Wed, 31 Oct 2018 05:21:27 -0700 (PDT) Received: from cloudburst.twiddle.net.lan (79-69-241-110.dynamic.dsl.as9105.com. [79.69.241.110]) by smtp.gmail.com with ESMTPSA id v2-v6sm13450362wru.17.2018.10.31.05.21.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 31 Oct 2018 05:21:27 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 31 Oct 2018 12:21:17 +0000 Message-Id: <20181031122119.1669-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181031122119.1669-1-richard.henderson@linaro.org> References: <20181031122119.1669-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::443 Subject: [Qemu-devel] [PULL 08/10] cputlb: Count "partial" and "elided" tlb flushes 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 Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Our only statistic so far was "full" tlb flushes, where all mmu_idx are flushed at the same time. Now count "partial" tlb flushes where sets of mmu_idx are flushed, but the set is not maximal. Account one per mmu_idx flushed, as that is the unit of work performed. We don't actually count elided flushes yet, but go ahead and change the interface presented to the monitor all at once. Tested-by: Emilio G. Cota Reviewed-by: Emilio G. Cota Signed-off-by: Richard Henderson --- include/exec/cpu-defs.h | 12 ++++++++++-- include/exec/cputlb.h | 2 +- accel/tcg/cputlb.c | 18 +++++++++++++----- accel/tcg/translate-all.c | 8 ++++++-- 4 files changed, 30 insertions(+), 10 deletions(-) -- 2.17.2 diff --git a/include/exec/cpu-defs.h b/include/exec/cpu-defs.h index 181c0dbfa4..c7b501d627 100644 --- a/include/exec/cpu-defs.h +++ b/include/exec/cpu-defs.h @@ -166,6 +166,15 @@ typedef struct CPUTLBCommon { * mmu_idx may be discarded. Protected by tlb_c.lock. */ uint16_t pending_flush; + + /* + * Statistics. These are not lock protected, but are read and + * written atomically. This allows the monitor to print a snapshot + * of the stats without interfering with the cpu. + */ + size_t full_flush_count; + size_t part_flush_count; + size_t elide_flush_count; } CPUTLBCommon; /* @@ -179,8 +188,7 @@ typedef struct CPUTLBCommon { CPUTLBEntry tlb_table[NB_MMU_MODES][CPU_TLB_SIZE]; \ CPUTLBEntry tlb_v_table[NB_MMU_MODES][CPU_VTLB_SIZE]; \ CPUIOTLBEntry iotlb[NB_MMU_MODES][CPU_TLB_SIZE]; \ - CPUIOTLBEntry iotlb_v[NB_MMU_MODES][CPU_VTLB_SIZE]; \ - size_t tlb_flush_count; + CPUIOTLBEntry iotlb_v[NB_MMU_MODES][CPU_VTLB_SIZE]; #else diff --git a/include/exec/cputlb.h b/include/exec/cputlb.h index c91db211bc..5373188be3 100644 --- a/include/exec/cputlb.h +++ b/include/exec/cputlb.h @@ -23,6 +23,6 @@ /* cputlb.c */ void tlb_protect_code(ram_addr_t ram_addr); void tlb_unprotect_code(ram_addr_t ram_addr); -size_t tlb_flush_count(void); +void tlb_flush_counts(size_t *full, size_t *part, size_t *elide); #endif #endif diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 1f7764de94..e60628c350 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -100,17 +100,21 @@ static void flush_all_helper(CPUState *src, run_on_cpu_func fn, } } -size_t tlb_flush_count(void) +void tlb_flush_counts(size_t *pfull, size_t *ppart, size_t *pelide) { CPUState *cpu; - size_t count = 0; + size_t full = 0, part = 0, elide = 0; CPU_FOREACH(cpu) { CPUArchState *env = cpu->env_ptr; - count += atomic_read(&env->tlb_flush_count); + full += atomic_read(&env->tlb_c.full_flush_count); + part += atomic_read(&env->tlb_c.part_flush_count); + elide += atomic_read(&env->tlb_c.elide_flush_count); } - return count; + *pfull = full; + *ppart = part; + *pelide = elide; } static void tlb_flush_one_mmuidx_locked(CPUArchState *env, int mmu_idx) @@ -145,7 +149,11 @@ static void tlb_flush_by_mmuidx_async_work(CPUState *cpu, run_on_cpu_data data) cpu_tb_jmp_cache_clear(cpu); if (mmu_idx_bitmask == ALL_MMUIDX_BITS) { - atomic_set(&env->tlb_flush_count, env->tlb_flush_count + 1); + atomic_set(&env->tlb_c.full_flush_count, + env->tlb_c.full_flush_count + 1); + } else { + atomic_set(&env->tlb_c.part_flush_count, + env->tlb_c.part_flush_count + ctpop16(mmu_idx_bitmask)); } } diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 356dcd0948..639f0b2728 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -2290,7 +2290,7 @@ void dump_exec_info(FILE *f, fprintf_function cpu_fprintf) { struct tb_tree_stats tst = {}; struct qht_stats hst; - size_t nb_tbs; + size_t nb_tbs, flush_full, flush_part, flush_elide; tcg_tb_foreach(tb_tree_stats_iter, &tst); nb_tbs = tst.nb_tbs; @@ -2326,7 +2326,11 @@ void dump_exec_info(FILE *f, fprintf_function cpu_fprintf) cpu_fprintf(f, "TB flush count %u\n", atomic_read(&tb_ctx.tb_flush_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()); + + tlb_flush_counts(&flush_full, &flush_part, &flush_elide); + cpu_fprintf(f, "TLB full flushes %zu\n", flush_full); + cpu_fprintf(f, "TLB partial flushes %zu\n", flush_part); + cpu_fprintf(f, "TLB elided flushes %zu\n", flush_elide); tcg_dump_info(f, cpu_fprintf); }