From patchwork Wed Jan 23 22:56:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 156437 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1267577jaa; Wed, 23 Jan 2019 15:02:04 -0800 (PST) X-Google-Smtp-Source: ALg8bN6j+8/q7YgELT/+m8bs6caxPC/j2EniPMxsJLdzvqbmYWFxtCY/LW9c4ddDVs0L+AsYm7XM X-Received: by 2002:a1c:8d12:: with SMTP id p18mr54545wmd.31.1548284524233; Wed, 23 Jan 2019 15:02:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548284524; cv=none; d=google.com; s=arc-20160816; b=H6XuiLjcH45Fl/t/AdPw16h7D3cPk7fz57QbQbHsczyvmSIcjzggy9S24qSfq/RX3u CNQQuy9q2uspHxzIISaR6k5CN6SMk0yWWtj35TyZi70WyOWP79ymhRuvXyi1w45Mg/Tt iECdu1v5jb3Jr/QIC0ANN5FQBC9O9iO6t4LUkEeNy/Ho50Qrj8i5OntUwVeh9VOBL9Ji 0Oo4IgN9ycD6iFhgw80HYkYwt6aiWrrdxXxVvWK5K6kdF+X6sRldFaQijQnWdcqubGVV V2txe+pzUEfn11ewKnl/Bil7mrjIrwFW2XgvZ4kFLK8A3xkZS+9TDQqVkD9AUiDq9NeP TQhg== 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=Pz5aD67VE1SWnaTOHg95Pv/R7AnRFhVRALCT9fNAKYXMgCCW/CSMKUHDFhxxE1a3f7 IheHphgOzC4G6h+L6nx7/RcUQSQFnR7tULwKHbCBXJkNJItWiSlP9r1m11huyKrpLKj8 04Pou0UIWL5/wLiYNL9WYzuvNSwC77cUlHS/kVGsDVWF48ZoRgFWjXS0Cqr2EDMdZ97w LmJbNDyYJofqxQJY5qH8KEJsOvFeZ7Gn7JKbF3o0p6FarQfXZqM6iVJdY4BCic8YsAzN XWqksQc5ePqu7ZuDvtioI1jUTrohdCRfx2thCNOgMr+e+ntQkONAqZP2YVTa0B8QfsJl z0fQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="Qs/oOYay"; 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 a187si37758989wmh.184.2019.01.23.15.02.03 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 23 Jan 2019 15:02:04 -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="Qs/oOYay"; 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]:43224 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gmRX0-0000BB-He for patch@linaro.org; Wed, 23 Jan 2019 18:02:02 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40844) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gmRSJ-0005mL-N1 for qemu-devel@nongnu.org; Wed, 23 Jan 2019 17:57:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gmRSI-00046c-Op for qemu-devel@nongnu.org; Wed, 23 Jan 2019 17:57:11 -0500 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:43864) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gmRSI-00045h-Ip for qemu-devel@nongnu.org; Wed, 23 Jan 2019 17:57:10 -0500 Received: by mail-pl1-x641.google.com with SMTP id gn14so1897079plb.10 for ; Wed, 23 Jan 2019 14:57:10 -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=Qs/oOYayVKdoLK4L/1M5G4Pl8zkA7GZGyO5vngVJqdlC5o2nbh4EAePtXxomAkzZsW BBtQJPdRve8fTfl9x3OiuID9+B+vcC6b5qpoOqxQpn3V6YbwP7JK7GtsF8zrZKtqlTF1 N4gUBDDGvzdgwaIn54lfYi5XeFGrVOr8Kxs0o= 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=Qak+EPArHZxfXTEKyh4QFXpOBg8gzFK/byDRaTxFtr6GIf42kQVNSHVE7f9Nt8J74R zV3F/0cgmLjnwHH+0q+JrjsZEOtH1DVJX00OjCp+wW/qvGv8lZBDLNAfvXEG0RNXrzzm 7CiiU0Z/h7ebjBDMxmjqlijMFkujayk9vv/Ury9yUobKMUgAoxeOOuElV9QIXfAvtsqr N9ecDVdD0mStdqtZS5IKZT+ILmeRslbR/d3/yL7bQe1f6rsOuH+OxL6T0cwIjpu7CF5w 2fx5fhm7dOJKxRotUcNnNSqIRxc2ihUN1uWM8yn/QTFTh6J/tWo7FVQXDzQVAVXHheSW SqsQ== X-Gm-Message-State: AJcUukf8+YPAuhESkejL0B8jV6xW6AEnEb4WzdBWpFYNJiuiB9PZW6iK B2XF8465IRtH2zjxrur61Eikh8g6Hjc= X-Received: by 2002:a17:902:aa0a:: with SMTP id be10mr4117258plb.266.1548284229177; Wed, 23 Jan 2019 14:57:09 -0800 (PST) Received: from cloudburst.twiddle.net (97-126-115-157.tukw.qwest.net. [97.126.115.157]) by smtp.gmail.com with ESMTPSA id y9sm23858132pfi.74.2019.01.23.14.57.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 23 Jan 2019 14:57:08 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 23 Jan 2019 14:56:53 -0800 Message-Id: <20190123225705.28963-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190123225705.28963-1-richard.henderson@linaro.org> References: <20190123225705.28963-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::641 Subject: [Qemu-devel] [PATCH 01/13] 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: cota@braap.org, alex.bennee@linaro.org 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];