From nobody Fri Nov 7 09:11:05 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547484969883213.7457564703227; Mon, 14 Jan 2019 08:56:09 -0800 (PST) Received: from localhost ([127.0.0.1]:45336 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gj5Wy-0002bf-7q for importer@patchew.org; Mon, 14 Jan 2019 11:56:08 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38190) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gj5RX-0006oP-RX for qemu-devel@nongnu.org; Mon, 14 Jan 2019 11:50:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gj5RW-0001xF-Ok for qemu-devel@nongnu.org; Mon, 14 Jan 2019 11:50:31 -0500 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:33241) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gj5RW-0001u6-IK for qemu-devel@nongnu.org; Mon, 14 Jan 2019 11:50:30 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id CDAD529F8E; Mon, 14 Jan 2019 11:50:20 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Mon, 14 Jan 2019 11:50:20 -0500 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 5ADF810087; Mon, 14 Jan 2019 11:50:20 -0500 (EST) 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 :mime-version:content-type:content-transfer-encoding; s=mesmtp; bh=MIX3vCXOYC9gw1f/sGJPxDGAFOF0zZ9csugcxwiHsT8=; b=eB43DnCqB89M egRVe1eEOPyKn7qvFlcWitGrFMy4UC7EzhXgEhLt5C9ogjRDY2oIWluOqjsKHoH6 7MoOfely6y/ZyX40nKpTZPH5ZMy07Lk7EP9KR8xrdnkhmZyTZd2512K2ixWYIhXv DvLXoWau3NPiM4B+qztRU1KhdUQlhfA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=MIX3vCXOYC9gw1f/sGJPxDGAFOF0zZ9csugcxwiHs T8=; b=waCUWjLDl4ywz+naE1ZzOk8CdPlUFyJsSlxLDSnAgBfZ8CoK+9lBU4MZz FTPqwdgrvmoss6kNtPQch178v5HTaQo3kXgCni6/euUMTOHLE9IK1qZteBucvY84 K9ga1DYzohrt7rN1AahW2SKrBgitM8CCgjyO8waIoCNoSkyPmZa+24JvWPx2Mi1y zPNMeHZZNXOyofXyi4NS9UyUojCTC1Tfl8gvp4zK1+B+N4kZArmPNpI/kvF3Z0U7 jiirlYmbYG6oDvKm8fJXIQgaXkSPhTTV6mRopUW1Kqwwex0jnl2ASisoaXahFYRe 6EtKi8GLQSMpmDie2xS0drtHCtEcA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtledrgedugdelfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecufedt tdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkffojg hfgggtgfesthekredtredtjeenucfhrhhomhepfdfgmhhilhhiohcuifdrucevohhtrgdf uceotghothgrsegsrhgrrghprdhorhhgqeenucfkphepuddvkedrheelrddvtddrvdduie enucfrrghrrghmpehmrghilhhfrhhomheptghothgrsegsrhgrrghprdhorhhgnecuvehl uhhsthgvrhfuihiivgeptd X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Mon, 14 Jan 2019 11:50:15 -0500 Message-Id: <20190114165017.27298-2-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190114165017.27298-1-cota@braap.org> References: <20190114165017.27298-1-cota@braap.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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] [PATCH v6 1/3] 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: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" 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. Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota --- include/exec/cpu-all.h | 9 +++++++++ accel/tcg/cputlb.c | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index 117d2fbbca..e21140049b 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -362,6 +362,15 @@ 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_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 =3D=3D -1 && te->addr_write =3D=3D -1 && te->addr= _code =3D=3D -1; +} + 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 af6bd8ccf9..5dc97212a9 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -591,7 +591,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_entry_is_empty(te)) { unsigned vidx =3D env->tlb_d[mmu_idx].vindex++ % CPU_VTLB_SIZE; CPUTLBEntry *tv =3D &env->tlb_v_table[mmu_idx][vidx]; =20 --=20 2.17.1