From patchwork Thu Mar 28 23:03:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 161368 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp1345091jan; Thu, 28 Mar 2019 16:48:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqyqlRxmL/Xz8m9umaWlzMKZKCAGj1tywIA5O/pvC4DWuIx01WHHHIykgHQn7mqb2Q7QP306 X-Received: by 2002:a5d:860f:: with SMTP id f15mr8586592iol.225.1553816906048; Thu, 28 Mar 2019 16:48:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553816906; cv=none; d=google.com; s=arc-20160816; b=yu6t/XEUjORAhpOO6UNftc9+RcXPSGLuETy0nsUvXPlsfsf054zxo9Q1QMA1MwYSyM mNa56NwadOF+vYIt73bohsKQCSWwT/3av7Z4vh26wwPs9JKNgwP148tYfd81m+vivrth 5UO0cVCRFaIeVacgVlPi10GC1JaafZtjWfDzkh0qMPiVnb5oWzrtJA4+z2gVhu4IUjFO RHLNdlfpERfRYTu6DEJ2ZxXug0Hy7oyfV853K54HnYVZGr+62Z4e9v+cPercPss+d+Gp oxwMqwiM7M8+FvMY2a5PwGWhaVOwpwySL/ccoHI9JahAa8leOJDKlR1P9YGQM3GnXQTL Se7g== 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:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=WieJSx5BImKOVOCxOodAUYBI2M76j22iORgFgoIM8L0=; b=EpqAw8pLJ0+eHLShrol1Md6I5XsTpNaSdOrvOy++1o8s1iN+ZimMQR1bS7RUUCWqao Xt3+0NFESoNnRlYsA+XiGFYY0f2SlpOtjbb4Hqkit8HZxgDvGjyxhH1T16ZsLlh0ADag otkJvoGo+czZBMJqtkC6+1wbYBvj+qL5N+0djxLgR411czzoLp9qwvX6WSCbHouFkoIA 9DhmntzCudBuoMRUYf65KrO04/fm4wzAGQXlaObkTRXriWSEv1e5r9+RbtX++BJBXVhd 0sgzGbgUMNa9/eHugy9YIALjUU7tpRi5Q/DVQds6wtJBKe8EAvsjjQTFo17t2mLhbNw7 8I7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=H5lYJAK9; 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=fail (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 r190si232459itb.17.2019.03.28.16.48.25 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 28 Mar 2019 16:48:26 -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=fail header.i=@linaro.org header.s=google header.b=H5lYJAK9; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:43584 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h9eky-0001A7-CU for patch@linaro.org; Thu, 28 Mar 2019 19:48:24 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42735) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h9eKx-000226-Ki for qemu-devel@nongnu.org; Thu, 28 Mar 2019 19:21:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h9e4D-0002tT-26 for qemu-devel@nongnu.org; Thu, 28 Mar 2019 19:04:14 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:43143) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h9e4C-0002sp-RH for qemu-devel@nongnu.org; Thu, 28 Mar 2019 19:04:13 -0400 Received: by mail-pl1-x641.google.com with SMTP id m10so52450plt.10 for ; Thu, 28 Mar 2019 16:04:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=WieJSx5BImKOVOCxOodAUYBI2M76j22iORgFgoIM8L0=; b=H5lYJAK988WHN3PdHHk75tkWA05L9gJX9ApNjT9ZJChRmeAlIDPJeang8ZcxbLc2yw bZNe7JTn78tAO6JxgW1rP2nwlBsYi90NbXy2sTWXP+mx0kbinztJ4W6hQK5KnjulSCli vyBSJygBRDGXIjF3r+6P9d4rZe5ozgC22hWZejpp/TTE80cagGalyk5pqvB9B0nmL/Gx 0UZjDNl62ioeeBDL+FrRB3IeVU3YvgVOVpjK5tD8x8ycCIHuhJ1OMPPRPuHpuNjZfOvp vrWKj6x3jck2QqCUF4xYRwNhR7lI7VWUZJ0nZT47LxuAx/fg+UQR0sk3L1v+3qHMprTO ZCgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=WieJSx5BImKOVOCxOodAUYBI2M76j22iORgFgoIM8L0=; b=Mp0qdP8IFTxJ61daZZQPqSu8YdEih0/GvK7XPhcsuLS8LakSjgiC1pS/l9AxtPL2me AM9gzJSqXQxse9z9r/XaXaleN3Rq1nQea7d8eoU8cTsB5+gHFEajRck+o3OzL+Qdk+tm SGs3YH/5nTwYvtCcxQmg0HH82cVe2lqZdD0bXYmD2CBdbqo5/FYx9b1n5nXgraKXt7z2 AeQruDGdDbMyf002c2zovpb75qYm3zoi2kkvYw7FZF8MdtcY+52xPIlvOijonEIJMek2 yJ2rfIPLsWb7mvsi1BSen3P6lsqDMkRL/Yxkyx2xezZVU3yu8EndzsxtMHu8WbdUee2e /ZAg== X-Gm-Message-State: APjAAAX/YdTwQs4FVrQeXi+BjXiBLa6Cp4xc15AlU8H75leKkDXcxVRb NRbWx78s3AN+cTo/Gawnqlggyw76+MQ= X-Received: by 2002:a17:902:16a4:: with SMTP id h33mr8806924plh.23.1553814250305; Thu, 28 Mar 2019 16:04:10 -0700 (PDT) Received: from cloudburst.ASUS (cpe-66-75-72-255.hawaii.res.rr.com. [66.75.72.255]) by smtp.gmail.com with ESMTPSA id f1sm280911pgl.35.2019.03.28.16.04.08 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Mar 2019 16:04:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 28 Mar 2019 13:03:29 -1000 Message-Id: <20190328230404.12909-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190328230404.12909-1-richard.henderson@linaro.org> References: <20190328230404.12909-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::641 Subject: [Qemu-devel] [PATCH for-4.1 v2 01/36] tcg: Fold CPUTLBWindow into CPUTLBDesc 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- include/exec/cpu-defs.h | 17 ++++------------- accel/tcg/cputlb.c | 24 ++++++++++++------------ 2 files changed, 16 insertions(+), 25 deletions(-) -- 2.17.1 Reviewed-by: Alex Bennée diff --git a/include/exec/cpu-defs.h b/include/exec/cpu-defs.h index 8f2a848bf5..52d150aaf1 100644 --- a/include/exec/cpu-defs.h +++ b/include/exec/cpu-defs.h @@ -127,18 +127,6 @@ typedef struct CPUIOTLBEntry { MemTxAttrs attrs; } CPUIOTLBEntry; -/** - * struct CPUTLBWindow - * @begin_ns: host time (in ns) at the beginning of the time window - * @max_entries: maximum number of entries observed in the window - * - * See also: tlb_mmu_resize_locked() - */ -typedef struct CPUTLBWindow { - int64_t begin_ns; - size_t max_entries; -} CPUTLBWindow; - typedef struct CPUTLBDesc { /* * Describe a region covering all of the large pages allocated @@ -148,9 +136,12 @@ typedef struct CPUTLBDesc { */ target_ulong large_page_addr; target_ulong large_page_mask; + /* host time (in ns) at the beginning of the time window */ + int64_t window_begin_ns; + /* maximum number of entries observed in the window */ + size_t window_max_entries; /* The next index to use in the tlb victim table. */ size_t vindex; - CPUTLBWindow window; size_t n_used_entries; } CPUTLBDesc; diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 88cc8389e9..23586f9974 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -79,11 +79,11 @@ static inline size_t sizeof_tlb(CPUArchState *env, uintptr_t mmu_idx) return env->tlb_mask[mmu_idx] + (1 << CPU_TLB_ENTRY_BITS); } -static void tlb_window_reset(CPUTLBWindow *window, int64_t ns, +static void tlb_window_reset(CPUTLBDesc *desc, int64_t ns, size_t max_entries) { - window->begin_ns = ns; - window->max_entries = max_entries; + desc->window_begin_ns = ns; + desc->window_max_entries = max_entries; } static void tlb_dyn_init(CPUArchState *env) @@ -94,7 +94,7 @@ static void tlb_dyn_init(CPUArchState *env) CPUTLBDesc *desc = &env->tlb_d[i]; size_t n_entries = 1 << CPU_TLB_DYN_DEFAULT_BITS; - tlb_window_reset(&desc->window, get_clock_realtime(), 0); + tlb_window_reset(desc, get_clock_realtime(), 0); desc->n_used_entries = 0; env->tlb_mask[i] = (n_entries - 1) << CPU_TLB_ENTRY_BITS; env->tlb_table[i] = g_new(CPUTLBEntry, n_entries); @@ -151,18 +151,18 @@ static void tlb_mmu_resize_locked(CPUArchState *env, int mmu_idx) int64_t now = get_clock_realtime(); int64_t window_len_ms = 100; int64_t window_len_ns = window_len_ms * 1000 * 1000; - bool window_expired = now > desc->window.begin_ns + window_len_ns; + bool window_expired = now > desc->window_begin_ns + window_len_ns; - if (desc->n_used_entries > desc->window.max_entries) { - desc->window.max_entries = desc->n_used_entries; + if (desc->n_used_entries > desc->window_max_entries) { + desc->window_max_entries = desc->n_used_entries; } - rate = desc->window.max_entries * 100 / old_size; + rate = desc->window_max_entries * 100 / old_size; if (rate > 70) { new_size = MIN(old_size << 1, 1 << CPU_TLB_DYN_MAX_BITS); } else if (rate < 30 && window_expired) { - size_t ceil = pow2ceil(desc->window.max_entries); - size_t expected_rate = desc->window.max_entries * 100 / ceil; + size_t ceil = pow2ceil(desc->window_max_entries); + size_t expected_rate = desc->window_max_entries * 100 / ceil; /* * Avoid undersizing when the max number of entries seen is just below @@ -182,7 +182,7 @@ static void tlb_mmu_resize_locked(CPUArchState *env, int mmu_idx) if (new_size == old_size) { if (window_expired) { - tlb_window_reset(&desc->window, now, desc->n_used_entries); + tlb_window_reset(desc, now, desc->n_used_entries); } return; } @@ -190,7 +190,7 @@ static void tlb_mmu_resize_locked(CPUArchState *env, int mmu_idx) g_free(env->tlb_table[mmu_idx]); g_free(env->iotlb[mmu_idx]); - tlb_window_reset(&desc->window, now, 0); + tlb_window_reset(desc, now, 0); /* desc->n_used_entries is cleared by the caller */ env->tlb_mask[mmu_idx] = (new_size - 1) << CPU_TLB_ENTRY_BITS; env->tlb_table[mmu_idx] = g_try_new(CPUTLBEntry, new_size);