From patchwork Fri May 29 13:23:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 187306 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp581689ilb; Fri, 29 May 2020 06:23:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMZ53YbMZp49XE2wkT8SeukPk71x4nLGOQdz+cuQZTH0vuXMsnAipr000reMke7jKrtGXR X-Received: by 2002:a25:7b41:: with SMTP id w62mr12681086ybc.435.1590758636041; Fri, 29 May 2020 06:23:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590758636; cv=none; d=google.com; s=arc-20160816; b=0fQ6OrGHww0y6zi+z17AY8Ap1rgo+FTv9U8yEsk0ZrOecUte9aFCVqNzc6BwnuY+0J 04E5cnloRubyYWoYufjykAR11sKFp5R+wOmaIPk1Up6FVRGhy1DtRvQb+KZ+XQWXvtgW WQHtTx7PBNY8QdLGZ/CyMr4n5nIZV6Gw/V0H7sIpSytixzyTbybPIMawsVk/6/wIbl6x G6PBxOWO0NnVP3ubfn2/s8jdSLKbVe2jbOkHIVcvMud4g9fuyDnLARD/c17QHfrQQL2C o1le/yyJA5vxWBfJp0j3DRGR0W948CyTcj3SDNUr479jKglhaezGUY98uRWTMbSghEBR q1Ug== 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:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=aGYJ5nJt/JAH6FWXmjwSAlg0Omv/+y0t2oEMaylOlqc=; b=aHqCTXnSxehyIJFqXK1LruybRLPJ90JlEpXxS5RKkD3u6p8zEDAT1MldCDycf334sT VlqVzSoi1wJZ08yMtpF7kTaB26FlBeROnd9RusuIipfG6Lp/z0zXfqGSAEF5F+f+i/tr 9IPd6Y8iC+COKA6+c5iMdena3NYI6C7wuKs7m3TOL9yexn/eVOtxY2ZSTmwlUlGCyHsn vj4SKgZ8iyjREY042QyKueOvKIv9zLN3yDnqpMY2QRiStdNOV/avN/2h9f4LZpO1DDD5 kUEjXuHyFPZIeT5RMx8/hoOZ2DyKVBuZpfaaJMHWwoabkPVEwXCi0l8rDGASeSLEPxQn Dg4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Q1hyMGOh; 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 u9si7768759ybu.360.2020.05.29.06.23.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 29 May 2020 06:23:56 -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=Q1hyMGOh; 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]:48044 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jeezL-0004NP-H5 for patch@linaro.org; Fri, 29 May 2020 09:23:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42798) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jeezA-0004Ln-Ng for qemu-devel@nongnu.org; Fri, 29 May 2020 09:23:44 -0400 Received: from mail-pj1-x1041.google.com ([2607:f8b0:4864:20::1041]:52839) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jeez9-0003aE-Po for qemu-devel@nongnu.org; Fri, 29 May 2020 09:23:44 -0400 Received: by mail-pj1-x1041.google.com with SMTP id k2so1336548pjs.2 for ; Fri, 29 May 2020 06:23:43 -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; bh=aGYJ5nJt/JAH6FWXmjwSAlg0Omv/+y0t2oEMaylOlqc=; b=Q1hyMGOhYqTQVuJ+eJ7rnzgRQjCTe2sbRcVbbB0u0iPqw943v5zjYVpInmgrG/XPne CCyum2Ee7JCWynyPEbNdxUcAzGK4sm9WvjiM4sZqCmLkx6ruFgT0Gt+Z0zS+ksEIJKWP 3xAHoPyj5VJC2da/ouxL1N/tNHZsC0hkAODuqBZilASz66z9T/+O8bmpt8GX84vvQiZT HfuZmhRYu43Br9BUnBTShGeC6bJ8FaZqOl8DuoOt+1EYKrk4RMDRFXH0X4/JEqgT1OQy ca0eoseUmdQTbCKVgiv6nmNoEB9Pmq3DjGpzEdtpfgEq31xKZsSnFtlngxdUB2q8kjw2 3cZA== 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; bh=aGYJ5nJt/JAH6FWXmjwSAlg0Omv/+y0t2oEMaylOlqc=; b=didnWF0vF98NNKcNPyNGqCJe0V/BAbwyHIaQwEJARo6BWlprnyz5U9UQB4av91fREK Jas8chaGqQEE1Qk8ZgVzcxVsRLGwCrs+CrMVf2xvhZXx/clhPaDFd0ZqJitLYKxaxhil ZB9hyfDzmbZq1Xsui7SD3g9uxN/cjiGCeRu7cPqsOc9Sxf8TxDlwadIGxFBTLvN/TXAA 9wBj8UagJGrV8NURMHfDH1Zpyupn2NgpSEqeh1Ay2r00SWsUwiJxhOqWcjWSmpp9I0cw k+7fjXV32cxGHOjf6fOuwNfmkJLgsyBV5iohGy4ryFy9A6IruMxvDs0KbQNYU2MpWQWn BAOA== X-Gm-Message-State: AOAM532qPSRPtHRGBsoZHdUwkaBAk5nNX377x9KWh91QvkvCPmrmHGJ/ nPGONy3aBQe6cDP4DgPVeIrStMFWbwkkww== X-Received: by 2002:a17:90a:f283:: with SMTP id fs3mr9206135pjb.1.1590758621974; Fri, 29 May 2020 06:23:41 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:75ac:d268:da04:dde4]) by smtp.gmail.com with ESMTPSA id e13sm1998686pfd.10.2020.05.29.06.23.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 May 2020 06:23:41 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v1 04/12] cputlb: destroy CPUTLB with tlb_destroy Date: Fri, 29 May 2020 09:23:34 -0400 Message-Id: <20200529132341.755-4-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200529132341.755-1-robert.foley@linaro.org> References: <20200529132341.755-1-robert.foley@linaro.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::1041; envelope-from=robert.foley@linaro.org; helo=mail-pj1-x1041.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_PASS=-0.001, URIBL_BLOCKED=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@linaro.org, cota@braap.org, Paolo Bonzini , peter.puhov@linaro.org, alex.bennee@linaro.org, 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 --- accel/tcg/cputlb.c | 15 +++++++++++++++ exec.c | 1 + include/exec/exec-all.h | 8 ++++++++ 3 files changed, 24 insertions(+) -- 2.17.1 Reviewed-by: Alex Bennée diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index eb2cf9de5e..1e815357c7 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 5162f0d12f..da3d60b034 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) { diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 8792bea07a..3cf88272df 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) { }