From patchwork Fri Jun 10 15:40:36 2022 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: 580597 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5806:0:0:0:0 with SMTP id j6csp1861242max; Fri, 10 Jun 2022 08:41:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzLszsoTXkMSg/IKvcHumWzcVZwOVJMSHNM02jQQxDqza1IFrOYaxrsRo4aiG5pLeANufXG X-Received: by 2002:a05:620a:45aa:b0:6a7:1b06:213b with SMTP id bp42-20020a05620a45aa00b006a71b06213bmr7989127qkb.766.1654875698809; Fri, 10 Jun 2022 08:41:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654875698; cv=none; d=google.com; s=arc-20160816; b=VEQFDN+umc7MWGIqaoP9Ftf0nX26Lz2VBF59UcXcqcmwbzVE3OBVw1ZmFe3D5jF+Dp zdhJLmtxmjOVeuEBF90TxA/A9SqI4oLYjc1b2gD//S0JQpZtOnhvJw51LEDdFhrAWXaq oV7yOvrA0O6qjJCEulHh5FsDjVB4/Na84MVvywoDqLWkF3jdaByGfZXQI6sG2PMydUjl Rg3n5PaBFCEyXgFySj3Zwve4e8g6cu8sTQNpn7nS2BszHLErl/WmEabDQrte3Ergdh3Y mW+/SheGQJH2qW/zHt1ZCsPyDNHJ6LkKxwVtaMUPfAOWA2I6ETT88cdb9Trz1q6NWTZZ HMmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=RzYJ3ADO8B5IeLwis6gFlwQIfqK+5ucvmMnVP4vhTF8=; b=fKd0cwrvQlPVoyOcmTDyJFS/ROBbc/oKufZydv69DqmBLvBeAvFrj/ZrIYgyAiuB3J zLach6mlRlhJ3/lk/4SjLJ4w0qu4nEV7rLjWjcGeyQLGW76Pgs18T2SGLW3eApTe3T4q TRburA/r0FpNs4KqJYQSnLcl+10gZlABBxzn0c95f3mgxR8EbXtelWncxdY3D06Rit8x wPo4r7ItbMFJvCwpv3mW8ZWIzeePhuWahjVi48mxbaITjjPAqgPzbEyN40AcEmhPLeSS rMUeGhbzh4ZpQBtp+4/SujPcT8MfHR4+MVi4ADctgD6orPwJ238MiELkGYT9sZxjrlY4 VYuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="EXvgQ/T/"; 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=pass (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 6-20020a0562140dc600b0046baf3370fcsi7233609qvt.97.2022.06.10.08.41.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 10 Jun 2022 08:41:38 -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=pass header.i=@linaro.org header.s=google header.b="EXvgQ/T/"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:57440 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzglW-00078r-DG for patch@linaro.org; Fri, 10 Jun 2022 11:41:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60216) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzgkh-000783-9K for qemu-devel@nongnu.org; Fri, 10 Jun 2022 11:40:47 -0400 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]:43638) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzgkf-0003E0-FL for qemu-devel@nongnu.org; Fri, 10 Jun 2022 11:40:46 -0400 Received: by mail-ed1-x532.google.com with SMTP id x62so35801148ede.10 for ; Fri, 10 Jun 2022 08:40:45 -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:mime-version :content-transfer-encoding; bh=RzYJ3ADO8B5IeLwis6gFlwQIfqK+5ucvmMnVP4vhTF8=; b=EXvgQ/T/MjaAa+1BW0YRUQY1LrfekKpOhVyCoL/E6wv5K27VhCeBKTH1PmS7d4nkuC pzvkIxKQzg/csX3cyuGWyXtekjnKy4uR5TTIAcZFniXp/j2aoLr5quaC6xO8ECCBmjbg N/6o7F85bhA0DYeuenpbOchkf6YO0ePRGCyhkdbLUDMJUsiM6p7ANk5FptoSgPig1t3K uwIY7gBSDRDX+tXnO2CF/9bUsFlQyyJwyVlRiB6EmB98gUME2+5mwnLMQgimywyXOXFb Zfu936U8b//krx95k/z9XjilPaIacVpkRhXbqvL2Rp/CuNBJjyrp8TOlP4f7O6r3m66A VpSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=RzYJ3ADO8B5IeLwis6gFlwQIfqK+5ucvmMnVP4vhTF8=; b=nDndbuagK4ff6krLi/sBMseAzWBIceszoyCdRw+cYOX+Aa14QxfhVvzknnve6uRUWT CW3utLGgAvUsxh07i5fg9S/YFKDQmdVylFc02FX1w7yueEiJ439Y04p5dwHn09cupkgC WQnyAW8GmF5lrQS3PWELrJ3nmudEp7LVAZqPSMlFhfmwOZcD4pIH9VMQ1Wsffqlm6x6i 5GyfJ3NUh6DhwiQElXLZAiy3tz+yLKEgDv2f9yNDuED5Tr3OAvZuPs2Sg3Ci4behDov8 A4/Rqc3EW0FzNMw9wLaxDPTBKEw+iJ8yQIcRKLd1G2NnTCj39ez1jANGIAzM+eo0q11k 5Cdg== X-Gm-Message-State: AOAM531RhN7FRm6PZX93n91aSvNfbFKiFVQJ6TZiSIai0W4a+GcLUJOt lHiLf7OKvOv4BQf9YXRxGX8Npw== X-Received: by 2002:a05:6402:528a:b0:42d:e116:fab8 with SMTP id en10-20020a056402528a00b0042de116fab8mr50584633edb.134.1654875643559; Fri, 10 Jun 2022 08:40:43 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id w7-20020a056402070700b0042aa153e73esm16298783edx.12.2022.06.10.08.40.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jun 2022 08:40:42 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id C4CAA1FFB7; Fri, 10 Jun 2022 16:40:41 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, agorglouk@gmail.com, =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , qemu-arm@nongnu.org (open list:ARM TCG CPUs) Subject: [RFC PATCH] target/arm: de-duplicate our register XML definitions Date: Fri, 10 Jun 2022 16:40:36 +0100 Message-Id: <20220610154036.1253158-1-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::532; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x532.google.com 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We generate the XML for each vCPU we create which for heavily threaded linux-user runs can add up to a lot of memory. Unfortunately we can't only do it once as we may have vCPUs with different capabilities in different cores but we can at least free duplicate definitions if we find them. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1070 Signed-off-by: Alex BennĂ©e --- target/arm/gdbstub.c | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c index 2f806512d0..85ef6dc6db 100644 --- a/target/arm/gdbstub.c +++ b/target/arm/gdbstub.c @@ -318,7 +318,24 @@ int arm_gen_dynamic_sysreg_xml(CPUState *cs, int base_reg) g_string_append_printf(s, ""); g_hash_table_foreach(cpu->cp_regs, arm_register_sysreg_for_xml, ¶m); g_string_append_printf(s, ""); - cpu->dyn_sysreg_xml.desc = g_string_free(s, false); + + /* De-duplicate system register descriptions */ + if (cs != first_cpu) { + CPUState *other_cs; + CPU_FOREACH(other_cs) { + ARMCPU *other_arm = ARM_CPU(other_cs); + if (g_strcmp0(other_arm->dyn_sysreg_xml.desc, s->str) == 0) { + cpu->dyn_sysreg_xml.desc = other_arm->dyn_sysreg_xml.desc; + g_string_free(s, true); + s = NULL; + break; + } + } + } + + if (s) { + cpu->dyn_sysreg_xml.desc = g_string_free(s, false); + } return cpu->dyn_sysreg_xml.num; } @@ -436,7 +453,24 @@ int arm_gen_dynamic_svereg_xml(CPUState *cs, int base_reg) base_reg++); info->num += 2; g_string_append_printf(s, ""); - cpu->dyn_svereg_xml.desc = g_string_free(s, false); + + /* De-duplicate SVE register descriptions */ + if (cs != first_cpu) { + CPUState *other_cs; + CPU_FOREACH(other_cs) { + ARMCPU *other_arm = ARM_CPU(other_cs); + if (g_strcmp0(other_arm->dyn_svereg_xml.desc, s->str) == 0) { + cpu->dyn_sysreg_xml.desc = other_arm->dyn_svereg_xml.desc; + g_string_free(s, true); + s = NULL; + break; + } + } + } + + if (s) { + cpu->dyn_svereg_xml.desc = g_string_free(s, false); + } return cpu->dyn_svereg_xml.num; }