From patchwork Mon Jan 28 15:58:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 156780 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3611500jaa; Mon, 28 Jan 2019 08:19:36 -0800 (PST) X-Google-Smtp-Source: ALg8bN6oZwzAVhTGP2m2AN9SNa+Mg0WEe2t2jaMVA8FuirHspI+RtMF/uLwcZrsoeTb3/0/Q2pN+ X-Received: by 2002:a1c:7fca:: with SMTP id a193mr17854606wmd.36.1548692376270; Mon, 28 Jan 2019 08:19:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548692376; cv=none; d=google.com; s=arc-20160816; b=zKivfzdSnAPWjLqP53XbYXifhTpJtE/G4Jj3cjR24oDuF5I2yzSOP/OIZ3R/uSZdgv yCNXYff8Q5TzraaLg41ioD2rS0brt6+Ya5fyPiCvYr2x6UXgNNbArBklxKFUFALIw7Ry Gd3JQuNUlSaMOqtsb8pEIrGfkZUxxVlR2nRH2NU0QCZ/oFkbA43It/RkQMeKm0Tq/HrH WxqBE+8rOiZ+u+ADxPe9XGZ8Um2ddNhcxs+qXMTur6OxUErDEacYFFyX4bP5v5sW1hf9 5dNPuI/mSFzf2Mk7nLoBsZOGZcInPtNIdB4cppxT94NywZk+EI5wY+x38hfslI2kW1E2 x5KA== 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; bh=AGAWWFtB255WL3QD01Pm/ADB1O2A0MpRDbzf5uqk7D0=; b=QpGfI4DtjAqbfmEXBTZ+tDygj/tYYezOeM8y8Dc5bh3ZctvP4YgcftMUOqDIJkOzAw TrefAeEsizIxFvJtNoQaKamiacRkyTgleKjojUDhPwoWNk3KwI54J1DPJMP2VN+XlHGM Urt8JookZnbtNweMS6hQNChxyqht0XRRzqVDeGLmoeiy0vSqt1H/LZtmvAUl6jOv9ZAT Hjadtz3sT1Zu9Kf1eM4bOVP+9D1ki9E6vOxiOfqbXe/1GAEdKjOF1+QAbtKDWV7FVGnt cTsGzQrAn00KegNt3Nrwni1kK8e3kUWhNkCO5PrrQjuj00NSDlqu28IknPijn2crs6t+ 9qGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Znk9xUOk; 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 v8si83631589wrd.56.2019.01.28.08.19.36 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 28 Jan 2019 08:19:36 -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=fail header.i=@linaro.org header.s=google header.b=Znk9xUOk; 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]:34420 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1go9dH-0002ff-61 for patch@linaro.org; Mon, 28 Jan 2019 11:19:35 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33602) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1go9K6-0005D3-2X for qemu-devel@nongnu.org; Mon, 28 Jan 2019 10:59:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1go9K4-0007vV-Kd for qemu-devel@nongnu.org; Mon, 28 Jan 2019 10:59:45 -0500 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]:38256) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1go9K4-0007oG-CS for qemu-devel@nongnu.org; Mon, 28 Jan 2019 10:59:44 -0500 Received: by mail-pl1-x636.google.com with SMTP id e5so7924208plb.5 for ; Mon, 28 Jan 2019 07:59:27 -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=AGAWWFtB255WL3QD01Pm/ADB1O2A0MpRDbzf5uqk7D0=; b=Znk9xUOkNSDt5PqCRG1bXq2BZ5vUMPjzxYdjhNrsfsyo5pT7kXcf8+iuGb+qmS+sQY mkGQobm8gXV85HSNh0Pdr4IG6oEvuPy7oz1rQfUQhsHC9JC79GlreEI+iMTikbQ5thq+ I5BWArl8z9IE5JJUPQWedIdMMV1neCKWYSgbg= 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=AGAWWFtB255WL3QD01Pm/ADB1O2A0MpRDbzf5uqk7D0=; b=c2NuwlPcdn3SHpKG/zczhXZwroUYKgvajj+Txcr4hsodx/owbtnDU/SoH8aJMOtTjy ze46Fl7tmogM8WqHUzs6onMvBHSimN+B1JPWph1rPx0rrZHJMgyZQbgbe0qgLulPWKIa 6H0lNzK6vwpDfIumPwNf5M9xqBJG2TCWCLxqByJlKPFbwxaLJyzngvQDEREuhW40/Fh+ IscsRILuutcl3bQbBMWF7sUqzFzntLURJHbpI13Au/IjrZ9kMc1BF3S486RHqSXqkIGl NrR0Nc/a3XKRKdFsZSSwx6QBRHewZkrDZpHZtaWXjuSinh/N5nG4Ya6uaurM+zPZyayb 6scA== X-Gm-Message-State: AJcUukcjUZtsEzejwPLEV8pwixUQZYz35JtVP5YGuG7YImFkRu3g273k 45KAv7UVaMx53izIsFpowWHCPuXS+uU= X-Received: by 2002:a17:902:b112:: with SMTP id q18mr22373102plr.255.1548691166105; Mon, 28 Jan 2019 07:59:26 -0800 (PST) Received: from cloudburst.twiddle.net (50-233-235-3-static.hfc.comcastbusiness.net. [50.233.235.3]) by smtp.gmail.com with ESMTPSA id p2sm45518687pfp.125.2019.01.28.07.59.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 28 Jan 2019 07:59:25 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 28 Jan 2019 07:58:55 -0800 Message-Id: <20190128155907.20607-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190128155907.20607-1-richard.henderson@linaro.org> References: <20190128155907.20607-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::636 Subject: [Qemu-devel] [PULL 11/23] cputlb: do not evict empty entries to the vtlb 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" Currently we evict an entry to the victim TLB when it doesn't match the current address. But it could be that there's no match because the current entry is empty (i.e. all -1's, for instance via tlb_flush). Do not evict the entry to the vtlb in that case. This change will help us keep track of the TLB's use rate, which we'll use to implement a policy for dynamic TLB sizing. Tested-by: Alex Bennée Reviewed-by: Alex Bennée Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota Message-Id: <20190116170114.26802-2-cota@braap.org> Signed-off-by: Richard Henderson --- accel/tcg/cputlb.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) -- 2.17.2 diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index af6bd8ccf9..10f1150c62 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -224,6 +224,15 @@ static inline bool tlb_hit_page_anyprot(CPUTLBEntry *tlb_entry, tlb_hit_page(tlb_entry->addr_code, page); } +/** + * tlb_entry_is_empty - return true if the entry is not in use + * @te: pointer to CPUTLBEntry + */ +static inline bool tlb_entry_is_empty(const CPUTLBEntry *te) +{ + return te->addr_read == -1 && te->addr_write == -1 && te->addr_code == -1; +} + /* Called with tlb_c.lock held */ static inline void tlb_flush_entry_locked(CPUTLBEntry *tlb_entry, target_ulong page) @@ -591,7 +600,7 @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ulong vaddr, * Only evict the old entry to the victim tlb if it's for a * different page; otherwise just overwrite the stale data. */ - if (!tlb_hit_page_anyprot(te, vaddr_page)) { + if (!tlb_hit_page_anyprot(te, vaddr_page) && !tlb_entry_is_empty(te)) { unsigned vidx = env->tlb_d[mmu_idx].vindex++ % CPU_VTLB_SIZE; CPUTLBEntry *tv = &env->tlb_v_table[mmu_idx][vidx];