From patchwork Tue Jun 16 12:53:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 188029 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp3624347ilo; Tue, 16 Jun 2020 05:57:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMxzq3tHqMw5SgpsaY28Jglb3+Zz74QESh5IHfupx+KU0ZMxk/CZ00KO3QaLKDMH2voVTX X-Received: by 2002:a25:8403:: with SMTP id u3mr4018183ybk.276.1592312264123; Tue, 16 Jun 2020 05:57:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592312264; cv=none; d=google.com; s=arc-20160816; b=z950Up3KOnJqp1OhbYxlaMwVX75gvJAbOeLAvlQb3Dw3z6KEmJDaFd1t9W63rmQ1GN ++6/6Pp30Qg+uj3LKViwI6xXr3gAhYqsiFLlzfgLRQkPZ00fQl4Yft8ME1wjE8HE+VNx jhW2u8djOmOvnfBNbcs17CL0/cP55ku3wdcGG+u6QraBcQAeiNT/shYlT/sf5pG+Clwp MBDAEmQbra10uQdGRnGVgPbIKuUn4HsqiXXkujyEYKpbLZZCo585njSv2KmQPL+Jxsuu sLdpTANP5lchhKt+mgTz9E0sdq3KJUtE+euaz8Gl24K2RSsnt9LM3g9quDljQMXJ8A93 un0Q== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=exFtdpeiE/YU2NIFtj2aRDoc3cKhGjW3auP7rUrwYDs=; b=bSHl3zdx3ChpPLMz+yKrq+M7/6tDJq2O2MaHSWv8qhi3dZqN55Pvm5EhKZTsHRADh0 o0BiJMVmjiXeefoA68p2OP5X7tDi2Ux25H7e19g2ZHKC31K2N0z9CuLK2vQn58JhvUk1 HwLXr8MaajlfqB6SqHDAeUXhwr/VjsFewS5XiyNOZo0AuOT1iv0tEZVvI0pi6i1/gqeM ImgREPLKGOYeSxKwxCQgas8GG4S4Ox7y2VKAogJ4X6ASxIfLQwGd9Y6cfiiWuuoCim0K J78JKVgFOs8nkbR2CyRye0q2xmmcw/v3hyy1ASgGupV0QWAYaZ9lXyssShkkZa6cKLhd kg1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Pr0eH5Ko; 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 l143si16110936ybf.155.2020.06.16.05.57.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 05:57:44 -0700 (PDT) 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=Pr0eH5Ko; 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 ([::1]:50144 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlB9r-0002PA-H7 for patch@linaro.org; Tue, 16 Jun 2020 08:57:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33800) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlB5t-0003nf-LW for qemu-devel@nongnu.org; Tue, 16 Jun 2020 08:53:37 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]:37731) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlB5r-00006S-T4 for qemu-devel@nongnu.org; Tue, 16 Jun 2020 08:53:37 -0400 Received: by mail-wr1-x42e.google.com with SMTP id x13so20638092wrv.4 for ; Tue, 16 Jun 2020 05:53:35 -0700 (PDT) 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=exFtdpeiE/YU2NIFtj2aRDoc3cKhGjW3auP7rUrwYDs=; b=Pr0eH5Ko6K0UxbL2ea5LQKMJoe5pTYseSfudKNNX6qSsA9Zq9U0DaYl64Qc/9SxSn0 4eVQvPva1CLCO/hk6EqjQti4I0p1RgV6tPe7fRbSsKvmtBXkmrcXuf4pL69asuaXCdj3 4m+OuwVPZVMKlBYDBDvrUcpy3CusRxgKr1zB7n+fzSB04rhMCcmRtboqcSuBJyJxh/+3 i/YfsAVtz8vG4iC/D6L9Gjh2h0983BKfdQGn29X1YrKcyGSFWiSmzPr/Inmf2ioTpcEi O+IzXTgzVKjfyk2A1zwH3InkSNuxj/yVIL0QHQde44nW/LuF3oejJGfei88WMcF//5VY YH/Q== 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=exFtdpeiE/YU2NIFtj2aRDoc3cKhGjW3auP7rUrwYDs=; b=PaUlOih15y2+bB63tsZUFiVjCHFDet1SN7JY6oPTSGOsGLdhDVpqea5Z2b3v/7GCx+ eWQmcbCa7JUUg+oFYNaRHAaQ5aheSaTC/L89jSufIS8yeCmet7V1uMJ0VjzULM6YlP9j KPOcfu8D0n54WoA3SiqJpokU/k+ULXh2QG3KOpn5TAoEeWaICKAhJ1fT08KHQZ+u+CHb +OPtFvHgqpuo3qKF8427VNh40ICWmvlIXPe1dsYTbj7mhAlf3FP3uFnmgHG9R8gUSsFM Ut6BxSzjKsocTIkUjMn04m81bSNVwfNfptTjP2LseArkUBOHUNCP/eTuQSwao5NWLg8i dkMA== X-Gm-Message-State: AOAM533MFLoPqqqfDE0SijuIOpeacclmYJ95IXFtvy3M+r+6FHK4STEZ +a5aHPjFAayPwMpdYAZ+/cJf2d2yqvI= X-Received: by 2002:a5d:4701:: with SMTP id y1mr2914014wrq.310.1592312014401; Tue, 16 Jun 2020 05:53:34 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id r14sm789732wrx.42.2020.06.16.05.53.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jun 2020 05:53:29 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id F04281FF93; Tue, 16 Jun 2020 13:53:24 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 07/21] cputlb: destroy CPUTLB with tlb_destroy Date: Tue, 16 Jun 2020 13:53:10 +0100 Message-Id: <20200616125324.19045-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200616125324.19045-1-alex.bennee@linaro.org> References: <20200616125324.19045-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42e.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: Robert Foley , qemu-devel@nongnu.org, "Emilio G. Cota" , Paolo Bonzini , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée Signed-off-by: Alex Bennée Message-Id: <20200609200738.445-5-robert.foley@linaro.org> Message-Id: <20200612190237.30436-8-alex.bennee@linaro.org> -- 2.20.1 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) } } +void tlb_destroy(CPUState *cpu) +{ + CPUArchState *env = cpu->env_ptr; + int i; + + qemu_spin_destroy(&env_tlb(env)->c.lock); + for (i = 0; i < NB_MMU_MODES; i++) { + CPUTLBDesc *desc = &env_tlb(env)->d[i]; + CPUTLBDescFast *fast = &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 9c8f558590d..d6712fba7eb 100644 --- a/exec.c +++ b/exec.c @@ -892,6 +892,7 @@ void cpu_exec_unrealizefn(CPUState *cpu) { CPUClass *cc = CPU_GET_CLASS(cpu); + tlb_destroy(cpu); cpu_list_remove(cpu); if (cc->vmsd != NULL) {