From patchwork Fri Feb 7 15:01:18 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: 183204 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp853571ile; Fri, 7 Feb 2020 07:15:03 -0800 (PST) X-Google-Smtp-Source: APXvYqwCeWU2W0PD2WdhqlfbEom7+qj09od0YAMBtwkWhsYCfYlGNQj7iM03HlrQHhG69kzqvUEj X-Received: by 2002:a37:6897:: with SMTP id d145mr7575370qkc.398.1581088503888; Fri, 07 Feb 2020 07:15:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581088503; cv=none; d=google.com; s=arc-20160816; b=QWyY6gks/DY+I0PdMjbCc5+CT66Dzzmfz02PtHYCXTzM8uEqF+XeK53Uux3/T130Tm TDMhyjv53odceMQoeo4Vw+lcUYNye8XXPXO9Z15XA1i2wDpk4lotYNbn42NaPQ9/4R8L MJskS/aMBH5lUki1pFlKjrOBm2larmyj8Mg/N5HTU7RYnodAw6RhDioPi6BI8rtGQoru 53Q0eyVDNHZAgg5Ag9AxQCDbrWuI/BATv1YcH1LbpM8z+AzTrQ7huIXz3KDKaSumjvEK GsL6LYUvf1e1TlfPV+SW21eJ+ChTYhrYk8hDedq7WA47pXVJUzC2WkeZGPw8PDxBhBHz 2QmQ== 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=20w7i9jiAm5hvyfwFIkzlqbRcfX9RLZbq6NcYeukZyY=; b=NXL5HLa0NbD26o4Nqb5UlZ4nkC6Xre/7noAujWXKGEqPGhKygWfUFd2SIQq28Z7Osj sQGnHyh8debxr//D7vPWv/8ywFAO0zlu3D8V+XFrrcw3oARphPbQWIpu3cQMBC9OoIjr FH2f4Egw6uuKTQnyDV7GufsVpdZxO30O5JgeY3+xEcs1zopUZbyl/zq3Re+3mniafok9 HHwjxOPu9LLySYgTe9DWN9Fv6La2lpDrQhCbsodyBb+BBS7aSzBBEvtaNqwNEgmSEfAw 3goMvcKuECMb37E9GRP4AQHnIodADMp6E4xUe4B1Ch4sLuYp8LtqoExXlRNdQP7cQbFz 0dPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=OLxckoe3; 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 u18si1621441qtq.36.2020.02.07.07.15.03 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Feb 2020 07:15:03 -0800 (PST) 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=OLxckoe3; 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]:59186 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j05LT-000865-EV for patch@linaro.org; Fri, 07 Feb 2020 10:15:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60333) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j058K-0000wL-JE for qemu-devel@nongnu.org; Fri, 07 Feb 2020 10:01:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j058J-0004D6-BW for qemu-devel@nongnu.org; Fri, 07 Feb 2020 10:01:28 -0500 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:55457) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j058J-00047j-3I for qemu-devel@nongnu.org; Fri, 07 Feb 2020 10:01:27 -0500 Received: by mail-wm1-x343.google.com with SMTP id q9so2869375wmj.5 for ; Fri, 07 Feb 2020 07:01:26 -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=20w7i9jiAm5hvyfwFIkzlqbRcfX9RLZbq6NcYeukZyY=; b=OLxckoe3p/ZV52/++8NBWwJliB6tjTDM7yc0RH2OX4Wutq0kcWEFI1ohBipqxVjeRj DLZ14vPK1pUv9xrG3Ni1fGdTJgbDoSl5Ic09YpiYJFvyp/wfpwZWGsP2uhDjHjghj6Az k+p3PTKVBPDlMj6k5qbhVGZ1hjpf5JN6ABTtzz6S1O4vnQ5eguAczP4wTt57N7AgocUf zn62knDIgt5wFA7SXOfZfLSOaaUnRVgz6IN0H0wWUTJ29RUN6ybt5zmyb15qt+yYmxPb fS+sTqjgjlQqrxFJeVbMpF12Kx/m1jlbiqgmrGAvy0Bdae4CnE5GpHMWH201757AEEpt Hhpg== 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=20w7i9jiAm5hvyfwFIkzlqbRcfX9RLZbq6NcYeukZyY=; b=UJjlxpNEXXR82YibifaBWhawMTzHWxjMm1XiC5Z8wLMkGf/O9Zpc7QGMbTrBM5EWYS tohjlVewGddZahIyCGx65Jv8SkEGSSxI5m073i2P5Rje0i62S39CMBkoaocuLcZNv/b0 +5xoaHqypZfIVrbSHzWCqU6gkAuaiMM0faNffdiYdPxI6/3r90tQZRHVQeFsUImxmLto sGiJ66OqK5o8CaRnA37b8MpUErXsFB64swNwzGfHfB/UFbic2Nsi5rjRgvtcsDgec/O9 jdZQ+urpp9vcr4SvrDQLmB/f2mEl4m6pAdYVxxLYjxdUWvxiQapRxeHw9RM0h//Wmrw2 Q7Mg== X-Gm-Message-State: APjAAAVJ5p/HRnr84WVnXT0m0kZgycd5NnNkBwsuI7w04Uzb8gJNFc+L iHEZI8RxdRdjV/axBAof0kJdaA== X-Received: by 2002:a05:600c:d5:: with SMTP id u21mr4819763wmm.98.1581087686129; Fri, 07 Feb 2020 07:01:26 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id s22sm3535449wmh.4.2020.02.07.07.01.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Feb 2020 07:01:23 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 5CAAE1FF92; Fri, 7 Feb 2020 15:01:19 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 5/5] tests/plugins: make howvec clean-up after itself. Date: Fri, 7 Feb 2020 15:01:18 +0000 Message-Id: <20200207150118.23007-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200207150118.23007-1-alex.bennee@linaro.org> References: <20200207150118.23007-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 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, robhenry@microsoft.com, aaron@os.amperecomputing.com, cota@braap.org, kuhn.chenqun@huawei.com, peter.puhov@linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" TCG plugins are responsible for their own memory usage and although the plugin_exit is tied to the end of execution in this case it is still poor practice. Ensure we delete the hash table and related data when we are done to be a good plugin citizen. Signed-off-by: Alex Bennée --- tests/plugin/howvec.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) -- 2.20.1 Reviewed-by: Robert Foley Reviewed-by: Richard Henderson diff --git a/tests/plugin/howvec.c b/tests/plugin/howvec.c index 4ca555e1239..7b77403559d 100644 --- a/tests/plugin/howvec.c +++ b/tests/plugin/howvec.c @@ -163,6 +163,13 @@ static gint cmp_exec_count(gconstpointer a, gconstpointer b) return ea->count > eb->count ? -1 : 1; } +static void free_record(gpointer data) +{ + InsnExecCount *rec = (InsnExecCount *) data; + g_free(rec->insn); + g_free(rec); +} + static void plugin_exit(qemu_plugin_id_t id, void *p) { g_autoptr(GString) report = g_string_new("Instruction Classes:\n"); @@ -213,12 +220,15 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) g_list_free(it); } + g_list_free(counts); + g_hash_table_destroy(insns); + qemu_plugin_outs(report->str); } static void plugin_init(void) { - insns = g_hash_table_new(NULL, g_direct_equal); + insns = g_hash_table_new_full(NULL, g_direct_equal, NULL, &free_record); } static void vcpu_insn_exec_before(unsigned int cpu_index, void *udata)