From nobody Tue Feb 10 03:40:19 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1591989184; cv=none; d=zohomail.com; s=zohoarc; b=Uro0Tfqaq8ad+8Ij6/lm0k/LmQiomDNdnDNvVqgVQa4vtlR0bSGTWqb0R9FnRvIR1tKzr7FUK7g2WUnA1I5XGsiuyPOUvMX27FFWsdHNJNNLlE65+5HIirKCQnN7zvw9xNIdqRy2wTAkAAPLy2jgEEL0nnZ+7m3zcJ6QTCnopSI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591989184; h=Content-Type: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=P8SWRQjM/hyOQzCww/NtPUfXAjDnTeW6mt1PLc5HvvU=; b=IHXc2n4bce2BZKEGzo9egpqxUOCsHignJfewN+rUjIKOy68gMfJ8yG8uRDFWGXZ5aLxNPLG0zivdzpost4tZ8gkHiH5QuceCr8rfHKrChITOaivi7IhgwpsMhLf7coDrPF6P40mKLnqRPpJqTdclRBXsrkGUTe67MDTCNZ8IP8U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail 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 1591989184125369.7515014678588; Fri, 12 Jun 2020 12:13:04 -0700 (PDT) Received: from localhost ([::1]:49462 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjp6s-00017i-R3 for importer@patchew.org; Fri, 12 Jun 2020 15:13:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54942) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjoxO-0000u4-KY for qemu-devel@nongnu.org; Fri, 12 Jun 2020 15:03:14 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:41816) by eggs.gnu.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jjoxC-0006tL-Da for qemu-devel@nongnu.org; Fri, 12 Jun 2020 15:03:12 -0400 Received: by mail-wr1-x443.google.com with SMTP id j10so10809066wrw.8 for ; Fri, 12 Jun 2020 12:02:53 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id s8sm11086125wrm.96.2020.06.12.12.02.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jun 2020 12:02:46 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 3B1041FF93; Fri, 12 Jun 2020 20:02:39 +0100 (BST) 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=P8SWRQjM/hyOQzCww/NtPUfXAjDnTeW6mt1PLc5HvvU=; b=d4eEGV7bcMlhiVx8vuNQOsPDaXZKjqzivKKDK7+hv6LPH8PqIV23FKTzycZ0Ik9hl5 G61VZr5zSql7sBHcFx9neOxHbWVZe2KvQ/8V4qrGYD1OCciY9TlCg7zq7L0zm9R9YyWr h7kPVvZiA7XJem4+QZhkfMHcK8/78oVoB+zEdgteAVje/SbIO4simACoFr4y1IzIOqg3 Ks4RKIk1ARPFwSaAgMDbNvBcbxPY8Ybb7TnpbzlOMYDakqDKOTQidejcYN0He0tN7EIO gD5LQi0d+j3wgsC/de6lH1ZfomON8M+SReSETDcfiNwLU6Qqtb9SQ39Fkq+V0VElX0EF +iLA== 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=P8SWRQjM/hyOQzCww/NtPUfXAjDnTeW6mt1PLc5HvvU=; b=GUMSdLFcYPyjv84BlUUxuhm5WIqPlumngriPljUe2ztjhAd4lu6Su7hY8yKUuM8AfK gOmxkF+jv3iCDLSzN3TEbFhMswUgaGg5CZGDsPqhVMzrKdhjgNx/Fkr7q6rlNaz/fbZi KMr39hnm1GdTkt2Ks8wEOBMnRW4BmUd4UxAtqzoET1wulsmCED/bVhWgTTAytPf8HRuY r/8xaqehus9R0IaqHPaP4fhm4E0+mlGovqn2z+AYFW6cQ8d6NCqAVck3+sYWahH7RRmB F8DNyKlHdX8NwA9ql2xzSu3p3MpJuAxRcGg3x455GIUolozy2zImcoolJ5jv1LT0f19e +o3A== X-Gm-Message-State: AOAM531QmHH9Otwuut5I6YW6suZBnNlQSmkzt2vyD2QUoEcS0lh4j6Dk bpGz5LrEqORY1nJSM55qFLK56w== X-Google-Smtp-Source: ABdhPJx3HUHvkomFSiWJWl50PF2vdUVOgkZHWU3Yw4gJ2Ep4s1gVzxqXTvsS+UqeT4gW4N1MCIgw/w== X-Received: by 2002:a5d:4385:: with SMTP id i5mr16069155wrq.420.1591988572195; Fri, 12 Jun 2020 12:02:52 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 07/18] cputlb: destroy CPUTLB with tlb_destroy Date: Fri, 12 Jun 2020 20:02:26 +0100 Message-Id: <20200612190237.30436-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200612190237.30436-1-alex.bennee@linaro.org> References: <20200612190237.30436-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=2a00:1450:4864:20::443; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x443.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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: fam@euphon.net, berrange@redhat.com, Robert Foley , =?UTF-8?q?Alex=20Benn=C3=A9e?= , richard.henderson@linaro.org, f4bug@amsat.org, cota@braap.org, Paolo Bonzini , aurelien@aurel32.net, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: "Emilio G. Cota" I was after adding qemu_spin_destroy calls, but while at it I noticed that we are leaking some memory. Signed-off-by: Emilio G. Cota Signed-off-by: Robert Foley Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Alex Benn=C3=A9e Message-Id: <20200609200738.445-5-robert.foley@linaro.org> --- include/exec/exec-all.h | 8 ++++++++ accel/tcg/cputlb.c | 15 +++++++++++++++ exec.c | 1 + 3 files changed, 24 insertions(+) diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 8792bea07ab..3cf88272df9 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -124,6 +124,11 @@ void cpu_address_space_init(CPUState *cpu, int asidx, * @cpu: CPU whose TLB should be initialized */ void tlb_init(CPUState *cpu); +/** + * tlb_destroy - destroy a CPU's TLB + * @cpu: CPU whose TLB should be destroyed + */ +void tlb_destroy(CPUState *cpu); /** * tlb_flush_page: * @cpu: CPU whose TLB should be flushed @@ -284,6 +289,9 @@ void tlb_set_page(CPUState *cpu, target_ulong vaddr, static inline void tlb_init(CPUState *cpu) { } +static inline void tlb_destroy(CPUState *cpu) +{ +} static inline void tlb_flush_page(CPUState *cpu, target_ulong addr) { } diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index eb2cf9de5e6..1e815357c70 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -270,6 +270,21 @@ void tlb_init(CPUState *cpu) } } =20 +void tlb_destroy(CPUState *cpu) +{ + CPUArchState *env =3D cpu->env_ptr; + int i; + + qemu_spin_destroy(&env_tlb(env)->c.lock); + for (i =3D 0; i < NB_MMU_MODES; i++) { + CPUTLBDesc *desc =3D &env_tlb(env)->d[i]; + CPUTLBDescFast *fast =3D &env_tlb(env)->f[i]; + + g_free(fast->table); + g_free(desc->iotlb); + } +} + /* flush_all_helper: run fn across all cpus * * If the wait flag is set then the src cpu's helper will be queued as diff --git a/exec.c b/exec.c index a0bf9d61c87..6d7c312c910 100644 --- a/exec.c +++ b/exec.c @@ -892,6 +892,7 @@ void cpu_exec_unrealizefn(CPUState *cpu) { CPUClass *cc =3D CPU_GET_CLASS(cpu); =20 + tlb_destroy(cpu); cpu_list_remove(cpu); =20 if (cc->vmsd !=3D NULL) { --=20 2.20.1