From nobody Sat Feb 7 04:06:01 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1538862459675318.4184667480275; Sat, 6 Oct 2018 14:47:39 -0700 (PDT) Received: from localhost ([::1]:40449 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8uQE-0001AB-CF for importer@patchew.org; Sat, 06 Oct 2018 17:47:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34476) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8uO9-0000AY-09 for qemu-devel@nongnu.org; Sat, 06 Oct 2018 17:45:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g8uO8-0007IZ-3O for qemu-devel@nongnu.org; Sat, 06 Oct 2018 17:45:28 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:53205) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g8uO7-00075S-S8 for qemu-devel@nongnu.org; Sat, 06 Oct 2018 17:45:27 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id DAED221F8E; Sat, 6 Oct 2018 17:45:14 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sat, 06 Oct 2018 17:45:14 -0400 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 894EC102EC; Sat, 6 Oct 2018 17:45:14 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= mesmtp; bh=Kks5MRe/oWUrPNG8WtoMLPgvHnBycaeNyuPSOqtMKOc=; b=xhg7V TqH30GlpDWuLFiP6xPcVg8d7bdO1a7sAZyAowt1/l9XTy8QhU5yx76ClzAyYItz/ mZU0wEwA4/YAoGgC3hLw0oF0FqLd6VL+E7SYRYmRwt0SfAlZRJZa8VdJQToCYlIh ohJJ625u+/X09a2Ie3739QKJs7ILAV63OMt8P0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; bh=Kks5MRe/oWUrPNG8WtoMLPgvHnByc aeNyuPSOqtMKOc=; b=pCP36mUVBgU8Q0WIb8ZU+fgXAY90MVyphTb8WNYeY0HIZ Nuhth4qJ/BrmIDdiQ/psP/ZyCuHUVMlSUkolYVEGGbsgpDFFuWpAfpnH+YpE5zjO zaLMs29Go9NIDz/4vE3uKxiMC7IRWUABnpPt3nGxC1jXlwOrGmlAC9+RdmQeyzw3 woWson2C90MXacJBQmY8YZVUSTQnH11DuRh1Gi4uWi7FkAmTB5u5bb28dX6G0K7Q BSQAUipFD1CzHbCyfTuN64V9t9hxrviSW+s2iwcCdng5kl45EAfhMHgCsgbCKJ5t blM9U8sBvwlGIavhXaPJe0Lmx1R5DSCNWp4WEq+Sw== X-ME-Sender: X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Sat, 6 Oct 2018 17:45:04 -0400 Message-Id: <20181006214508.5331-3-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181006214508.5331-1-cota@braap.org> References: <20181006214508.5331-1-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.111.4.27 Subject: [Qemu-devel] [RFC 2/6] cputlb: do not evict invalid 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: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pranith Kumar , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 invalid. Do not evict the entry to the vtlb in that case. This change will help us keep track of the TLB's use rate. Signed-off-by: Emilio G. Cota --- include/exec/cpu-all.h | 14 ++++++++++++++ accel/tcg/cputlb.c | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index 117d2fbbca..d938dedafc 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -362,6 +362,20 @@ static inline bool tlb_hit(target_ulong tlb_addr, targ= et_ulong addr) return tlb_hit_page(tlb_addr, addr & TARGET_PAGE_MASK); } =20 +/** + * tlb_is_valid - return true if at least one of the addresses is valid + * @te: pointer to CPUTLBEntry + * + * This is useful when we don't have a particular address to compare again= st, + * and we just want to know whether any entry holds valid data. + */ +static inline bool tlb_is_valid(const CPUTLBEntry *te) +{ + return !(te->addr_read & TLB_INVALID_MASK) || + !(te->addr_write & TLB_INVALID_MASK) || + !(te->addr_code & TLB_INVALID_MASK); +} + void dump_exec_info(FILE *f, fprintf_function cpu_fprintf); void dump_opcount_info(FILE *f, fprintf_function cpu_fprintf); #endif /* !CONFIG_USER_ONLY */ diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 0b51efc374..0e2c149d6b 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -695,7 +695,7 @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ulon= g 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_is_valid(te)) { unsigned vidx =3D env->vtlb_index++ % CPU_VTLB_SIZE; CPUTLBEntry *tv =3D &env->tlb_v_table[mmu_idx][vidx]; =20 --=20 2.17.1