From patchwork Thu Jan 9 02:49:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 182757 Delivered-To: patch@linaro.org Received: by 2002:ac9:44c4:0:0:0:0:0 with SMTP id t4csp3319146och; Sun, 12 Jan 2020 08:07:14 -0800 (PST) X-Google-Smtp-Source: APXvYqzkHbcopU3bl/199rxQCXApWqsJiewJWk6XodPmUVCNKVh9Q5Jxk16lep7UcAwd+tZFoZIC X-Received: by 2002:a05:6402:12d2:: with SMTP id k18mr13057653edx.253.1578845024471; Sun, 12 Jan 2020 08:03:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578845024; cv=none; d=google.com; s=arc-20160816; b=0Wum1xwUWOuus0DJ9azT+MT1WlIdwRX8oKuk+r/8W9ms7XhjbZItY8S7MOtCZvNqiU wqUzy3bhzUancB1NJP/B1eUmJVtS0iQ/NiSub2o5quC7t+NNELxwkZ39OZghaKICoe2c 52tEMxsMdPuPOgINtrkC//qZT9RwLSqdxJ6/yqEWr4zLnbgOW18fpeKh1Lb9CJxWW0bP hBbC34t/UP26Cua+JmFCv8rqBQXAzaJEAJdzcn1Ol89zvvgFf6szC1RAKG0bSbN/Rt3U 2ioQeWPvO2GI70SC15I7faXY/ovuZnRNXc0nN1sfNjS3uRSJ8+tRNiEIGPPypvPVNXpJ CCgw== 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=7oSKIrC5QlsP+UfXWHE34ZSkgxpGtuY2yzIIDI3pxVg=; b=QaJnluYUcfi+SU8Yl0/VbTvzBT6eTcDGgC+3ktphFi36+gZsLKNSu3bwEMaQPS7mPt rIZhH1V170+yPzoPjZdHkHhpz5lrwmWCB7uRekwvLkRH0EGRW5Gcx/9vGIYAvgcRx6hr hiYjHkzFw5w77mTxQpmKyTUswj77xQ8rSLfg+BatO/CuLvLDP/v+jyi51FmWDLschoMN MsalnVV2EaKlxywjkHB5Hl6Yos6KLBBHcUPdFU5Of5FMU9E0HeyCB/IFdMlncF/Q8aK3 fO0yOeC66x9zkL0b+QyPht7R97Hi/GZO+XFZ6yyA7X/1Jui2QrU6v5guBeCFefkPebXR BZ8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lOyB9FK9; 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 y21si4210265eje.473.2020.01.12.08.03.44 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 12 Jan 2020 08:03:44 -0800 (PST) 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=lOyB9FK9; 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]:54112 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipO0A-0005oU-P2 for patch@linaro.org; Wed, 08 Jan 2020 21:56:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54010) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipNtB-0003Bi-6P for qemu-devel@nongnu.org; Wed, 08 Jan 2020 21:49:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ipNt9-0006aC-DX for qemu-devel@nongnu.org; Wed, 08 Jan 2020 21:49:36 -0500 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:35631) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ipNt9-0006Xc-3X for qemu-devel@nongnu.org; Wed, 08 Jan 2020 21:49:35 -0500 Received: by mail-pf1-x444.google.com with SMTP id i23so2618404pfo.2 for ; Wed, 08 Jan 2020 18:49:35 -0800 (PST) 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=7oSKIrC5QlsP+UfXWHE34ZSkgxpGtuY2yzIIDI3pxVg=; b=lOyB9FK9E2skyDHYPmTW/uGY8BzETIK6d+v7I7syXPz7KdzDUd4OgXo2UA1OMycb8G S7duWDwInokskO2azizjWsi9ui/BjBnqSmqyMwMugbNIhrxeGfUZUZNszB+j/BNCwwmP 5YO56UtDNSIKD0mVEoRCOZf/JUWA3UHhkk9DYF4W9dRuSTy7xNA/urIn3WxzsGL2PAjO itTGFacu4PLcGnMPDWrmmiPAuFrMhLhn2q8YW0y5vh+1wxkPQXQzfFzlS3v9RQY5MJQD EYjkI1Mo87RgKjFpal4l0BeXDdTt0BhxRUYi+aj6aDKKgkifBPVuDcCHPEI7Wxvqjn3G /uzA== 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=7oSKIrC5QlsP+UfXWHE34ZSkgxpGtuY2yzIIDI3pxVg=; b=h8jH9Yh4aoHNnKyv0hvjMocfDw+NDuYY7kq9XlxoNzNL/jVYmasAb45frlSxm6HNf2 ybeJZ+9aQYm2Tr/lcQ670qZJpqcjCZcp2mjTA5JTDWo1WeQZ03AYaTaS+CexU3ooaPdm TWL7fkrrFyMRD8DzEgJ0001ii4XSqVZlIcLpvoTnj00oOB1lVQ8rE0/UcDlBcMrDeSnB EHCwsJxORqelpWe8Nf2RNIH4zQrwayMjMuCN1F7AGoN7oaKAirOgt/3YJxJVXPqUCmqX XNL24XU1OTPLoANvUXBF8poJlw9NaGCdJiD0ame0MpyZWFioxuauBe5w3XiMpSJI1MZQ lxzA== X-Gm-Message-State: APjAAAWp1whNkRvW8/I/NuLwbLaRXv1Pj+q3ZeaU6W0am1v/YUt//CPV n/k/DkJWcZDMBdUoj/uGgbouRV+1ClgFhQ== X-Received: by 2002:a63:534d:: with SMTP id t13mr8329975pgl.89.1578538173727; Wed, 08 Jan 2020 18:49:33 -0800 (PST) Received: from localhost.localdomain (alanje.lnk.telstra.net. [120.151.179.201]) by smtp.gmail.com with ESMTPSA id b4sm5337844pfd.18.2020.01.08.18.49.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jan 2020 18:49:33 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 9/9] cputlb: Hoist timestamp outside of loops over tlbs Date: Thu, 9 Jan 2020 13:49:07 +1100 Message-Id: <20200109024907.2730-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200109024907.2730-1-richard.henderson@linaro.org> References: <20200109024907.2730-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:4864:20::444 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: alistair.francis@wdc.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Do not call get_clock_realtime() in tlb_mmu_resize_locked, but hoist outside of any loop over a set of tlbs. This is only two (indirect) callers, tlb_flush_by_mmuidx_async_work and tlb_flush_page_locked, so not onerous. Signed-off-by: Richard Henderson --- accel/tcg/cputlb.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) -- 2.20.1 diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 761e9d44d7..9f6cb36921 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -137,12 +137,12 @@ static void tlb_window_reset(CPUTLBDesc *desc, int64_t ns, * high), since otherwise we are likely to have a significant amount of * conflict misses. */ -static void tlb_mmu_resize_locked(CPUTLBDesc *desc, CPUTLBDescFast *fast) +static void tlb_mmu_resize_locked(CPUTLBDesc *desc, CPUTLBDescFast *fast, + int64_t now) { size_t old_size = tlb_n_entries(fast); size_t rate; size_t new_size = old_size; - 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; @@ -222,12 +222,13 @@ static void tlb_mmu_flush_locked(CPUTLBDesc *desc, CPUTLBDescFast *fast) memset(desc->vtable, -1, sizeof(desc->vtable)); } -static void tlb_flush_one_mmuidx_locked(CPUArchState *env, int mmu_idx) +static void tlb_flush_one_mmuidx_locked(CPUArchState *env, int mmu_idx, + int64_t now) { CPUTLBDesc *desc = &env_tlb(env)->d[mmu_idx]; CPUTLBDescFast *fast = &env_tlb(env)->f[mmu_idx]; - tlb_mmu_resize_locked(desc, fast); + tlb_mmu_resize_locked(desc, fast, now); tlb_mmu_flush_locked(desc, fast); } @@ -310,6 +311,7 @@ static void tlb_flush_by_mmuidx_async_work(CPUState *cpu, run_on_cpu_data data) CPUArchState *env = cpu->env_ptr; uint16_t asked = data.host_int; uint16_t all_dirty, work, to_clean; + int64_t now = get_clock_realtime(); assert_cpu_is_self(cpu); @@ -324,7 +326,7 @@ static void tlb_flush_by_mmuidx_async_work(CPUState *cpu, run_on_cpu_data data) for (work = to_clean; work != 0; work &= work - 1) { int mmu_idx = ctz32(work); - tlb_flush_one_mmuidx_locked(env, mmu_idx); + tlb_flush_one_mmuidx_locked(env, mmu_idx, now); } qemu_spin_unlock(&env_tlb(env)->c.lock); @@ -446,7 +448,7 @@ static void tlb_flush_page_locked(CPUArchState *env, int midx, tlb_debug("forcing full flush midx %d (" TARGET_FMT_lx "/" TARGET_FMT_lx ")\n", midx, lp_addr, lp_mask); - tlb_flush_one_mmuidx_locked(env, midx); + tlb_flush_one_mmuidx_locked(env, midx, get_clock_realtime()); } else { if (tlb_flush_entry_locked(tlb_entry(env, midx, page), page)) { tlb_n_used_entries_dec(env, midx);