From nobody Tue Feb 10 19:15:36 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1578538438; cv=none; d=zohomail.com; s=zohoarc; b=J9k5/qNHe11cUIP8Mw05aLCxJe8bCAr+bM9II310k8M3vYCqiL6H5FKUJMxyGmTgPMoB+yLAUqcROm6chH5Bibs5fmSWOJKHMsVKaZPjBBnFCcVcyr5EAXbXEkmKxBZ6I1Zx8OQRZjyuqM7PKSUIhcpojgVaIzS3kBD3Cw0fiSc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578538438; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XoAjYNfihA3pIGGqUIgB1dF/4sSPCxOSmNDHQZwJ7Ug=; b=b6bkTC31phSYSKb75uDfV9kbU5EclPFgNVVuvUv9kxN6tW/50EiPHQzLXaMnQgcoQjYkZLT6pEe7jcpsXAx0SUjO2yQRfheMUCaMfhIaNO0TY3ilNe3O1Cfe8rSUBhJ0TYqTQ0/iFnl3TA5OVihT6aR61XAHpWfqQqQbVpayUJA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1578538438021161.66446929509505; Wed, 8 Jan 2020 18:53:58 -0800 (PST) Received: from localhost ([::1]:54030 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipNxM-0007iq-DL for importer@patchew.org; Wed, 08 Jan 2020 21:53:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52826) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipNt2-0002xK-FS for qemu-devel@nongnu.org; Wed, 08 Jan 2020 21:49:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ipNsx-0006ET-MF for qemu-devel@nongnu.org; Wed, 08 Jan 2020 21:49:28 -0500 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:45207) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ipNsx-0006C3-DO for qemu-devel@nongnu.org; Wed, 08 Jan 2020 21:49:23 -0500 Received: by mail-pf1-x444.google.com with SMTP id 2so2588376pfg.12 for ; Wed, 08 Jan 2020 18:49:23 -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.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jan 2020 18:49:21 -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=XoAjYNfihA3pIGGqUIgB1dF/4sSPCxOSmNDHQZwJ7Ug=; b=r6JgBjCbX+iAzAo3az7wVE6MO56Fl41zL8f5lLPDlelxnsfbcv9zpjRwgCc+fFSQA7 d/jdcCGQddvlYHvcxKN4edPMVptyqwRTpI25DCVZ5DH2scbJBJgvDBdZcEFlHFIUlrhI 7FfJmXuTg3AsMWtpfY84WirAf3DOO+cihzG0r9LWmO1EKg1DXpY9dFLe682cAvsdUQOk Y9u24WdlLDLfn8Mja0K1y5Bngx47rbSGu/HkH+FWKfWgxKrQAyGp9L5cOdQPzoI1qgQK edfzClUhlkh/FrqQ+++Q0FWhdJmTsgtBWlI4gnWHW84ctDD39qvc+ng+Qzyq9tE8V6jO zaJg== 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=XoAjYNfihA3pIGGqUIgB1dF/4sSPCxOSmNDHQZwJ7Ug=; b=Yhrd5sPgRq7OOWWPbElbt/Egh7pFm5QVCEuiUoCWvBCGwNjVgyOD6rgROuWUPi6VqB +66jw9vevUYFyNvVyFvOV3Hbge6pEbuKqQxM7i8WJlaTgFXQ78x2L7ZfDnIN8YwGBzr9 /yEMRUNqPOpfNPQICgleQB3VCHYEfT59VNX0QVZjQwIPR1cxaoZf/fm1Vjx4CVj4tPb1 jDU5diUJYWY5+Yq6+0D3ALX43SDCSH5x6mQsv7KHx+3XfnW/TEjnTOFaaj3C0vEmLHio PwP+zE/KnRMsfOwY4RrmuOem+++zDhgqIzFL9iFdjSmRxoni5yMUvIEXIz0ouJcvmWXV ZPjg== X-Gm-Message-State: APjAAAX6zk6CnG3zusgxg4Ifc0GENbQhaZxb3J0IxnjeHgWQb01et9BR E66lPCk+Lm+MdDCnQsyU2KdbBygfxvLQxA== X-Google-Smtp-Source: APXvYqwHSCGZtSusFZHT8Z0439TTfSajYojF25z5nOtewuLCnhLdhI7mCe6phd7CBQhQmzwyQl+y7w== X-Received: by 2002:a63:ed4a:: with SMTP id m10mr7793045pgk.99.1578538161944; Wed, 08 Jan 2020 18:49:21 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 4/9] cputlb: Hoist tlb portions in tlb_mmu_resize_locked Date: Thu, 9 Jan 2020 13:49:02 +1100 Message-Id: <20200109024907.2730-5-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 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" No functional change, but the smaller expressions make the code easier to read. Signed-off-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Alistair Francis Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- accel/tcg/cputlb.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 49c605b6d8..c7dc1dc85a 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -115,8 +115,8 @@ static void tlb_dyn_init(CPUArchState *env) =20 /** * tlb_mmu_resize_locked() - perform TLB resize bookkeeping; resize if nec= essary - * @env: CPU that owns the TLB - * @mmu_idx: MMU index of the TLB + * @desc: The CPUTLBDesc portion of the TLB + * @fast: The CPUTLBDescFast portion of the same TLB * * Called with tlb_lock_held. * @@ -153,10 +153,9 @@ static void tlb_dyn_init(CPUArchState *env) * high), since otherwise we are likely to have a significant amount of * conflict misses. */ -static void tlb_mmu_resize_locked(CPUArchState *env, int mmu_idx) +static void tlb_mmu_resize_locked(CPUTLBDesc *desc, CPUTLBDescFast *fast) { - CPUTLBDesc *desc =3D &env_tlb(env)->d[mmu_idx]; - size_t old_size =3D tlb_n_entries(&env_tlb(env)->f[mmu_idx]); + size_t old_size =3D tlb_n_entries(fast); size_t rate; size_t new_size =3D old_size; int64_t now =3D get_clock_realtime(); @@ -198,14 +197,15 @@ static void tlb_mmu_resize_locked(CPUArchState *env, = int mmu_idx) return; } =20 - g_free(env_tlb(env)->f[mmu_idx].table); - g_free(env_tlb(env)->d[mmu_idx].iotlb); + g_free(fast->table); + g_free(desc->iotlb); =20 tlb_window_reset(desc, now, 0); /* desc->n_used_entries is cleared by the caller */ - env_tlb(env)->f[mmu_idx].mask =3D (new_size - 1) << CPU_TLB_ENTRY_BITS; - env_tlb(env)->f[mmu_idx].table =3D g_try_new(CPUTLBEntry, new_size); - env_tlb(env)->d[mmu_idx].iotlb =3D g_try_new(CPUIOTLBEntry, new_size); + fast->mask =3D (new_size - 1) << CPU_TLB_ENTRY_BITS; + fast->table =3D g_try_new(CPUTLBEntry, new_size); + desc->iotlb =3D g_try_new(CPUIOTLBEntry, new_size); + /* * If the allocations fail, try smaller sizes. We just freed some * memory, so going back to half of new_size has a good chance of work= ing. @@ -213,25 +213,24 @@ static void tlb_mmu_resize_locked(CPUArchState *env, = int mmu_idx) * allocations to fail though, so we progressively reduce the allocati= on * size, aborting if we cannot even allocate the smallest TLB we suppo= rt. */ - while (env_tlb(env)->f[mmu_idx].table =3D=3D NULL || - env_tlb(env)->d[mmu_idx].iotlb =3D=3D NULL) { + while (fast->table =3D=3D NULL || desc->iotlb =3D=3D NULL) { if (new_size =3D=3D (1 << CPU_TLB_DYN_MIN_BITS)) { error_report("%s: %s", __func__, strerror(errno)); abort(); } new_size =3D MAX(new_size >> 1, 1 << CPU_TLB_DYN_MIN_BITS); - env_tlb(env)->f[mmu_idx].mask =3D (new_size - 1) << CPU_TLB_ENTRY_= BITS; + fast->mask =3D (new_size - 1) << CPU_TLB_ENTRY_BITS; =20 - g_free(env_tlb(env)->f[mmu_idx].table); - g_free(env_tlb(env)->d[mmu_idx].iotlb); - env_tlb(env)->f[mmu_idx].table =3D g_try_new(CPUTLBEntry, new_size= ); - env_tlb(env)->d[mmu_idx].iotlb =3D g_try_new(CPUIOTLBEntry, new_si= ze); + g_free(fast->table); + g_free(desc->iotlb); + fast->table =3D g_try_new(CPUTLBEntry, new_size); + desc->iotlb =3D g_try_new(CPUIOTLBEntry, new_size); } } =20 static void tlb_flush_one_mmuidx_locked(CPUArchState *env, int mmu_idx) { - tlb_mmu_resize_locked(env, mmu_idx); + tlb_mmu_resize_locked(&env_tlb(env)->d[mmu_idx], &env_tlb(env)->f[mmu_= idx]); env_tlb(env)->d[mmu_idx].n_used_entries =3D 0; env_tlb(env)->d[mmu_idx].large_page_addr =3D -1; env_tlb(env)->d[mmu_idx].large_page_mask =3D -1; --=20 2.20.1