From patchwork Tue Jan 2 01:58:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 759351 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp5857220wrw; Mon, 1 Jan 2024 18:02:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IFjKNL6ntsSeSOFoUrKNTLKsZ4sv93fqVxayYc2ft6WvKHsV9TJdu6if2fOajrrI8gDNpjH X-Received: by 2002:a37:ef16:0:b0:781:5b99:3a67 with SMTP id j22-20020a37ef16000000b007815b993a67mr10033334qkk.31.1704160953635; Mon, 01 Jan 2024 18:02:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704160953; cv=none; d=google.com; s=arc-20160816; b=JZJu95xf8rIfpx/3G7t7r037s3309yJvfU/CjC3Y9yLG6qBtzrGjcHOvuG2HhlU04n 8hTnHwPpVJ4KLgiqfDoa+rXGsctdjWIxAI5TNHRkTMUiT7C+P9bFsUhyOMYwSbAKhRUk LIrpOzNgujS2EJSS/1N+Lmjcv/76aAh1H6lrVxPxV8Ca1YECFsJR32RYCYxXx+7zwo/8 VDmgRCYkPk0R1iE0QTLpYmAjEzGxkPKTEaO8yXAnje8Utaxclom3XOPOZ2nyoCx/5K6o j1K+B8ZTwKhHXYgrnXS1nAo6JpavP0W2U64iiKYoNFO3B8EVhut62++gudtON12tW0dh dTWg== 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:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=va71e7xBlqUEdFqBnPLdQG8F1PWGxU4pyOMI1WZcB6A=; fh=kQadAhxV42GJ3cd2VUw1RyURv/zJQGvmUdF7iLEVTtc=; b=Fs/16vEv3y6mzvYeKFw5dK3Dr+WXj7125mBc/AlYr9Zy70KLms7HEE8q/IX2qJbFJB 8VGq+q643aD+IciSbMvelCwRKj+KaGHhN8N19mX22/5EUaGhEmMafOMroR784QH/q7Yv h/r0Rge9CSySFccRem9kmjkptePFciigZNqNov5ae+4jttHPu/8f5G4F7DDWUA528hGX 7PkqUs0y0CW+wjF/9irFQYbyt/FlhgW+qAMN+8vR7HkC8GMHNrnTh7y9GUEqEd64tCwF 1rSJTs8gIpEMHAmhLPzQ2kXEg+gSQyw05n1cdNfKx/7y72vmTu4dOY5A0U4U5aE/VzAB yx7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=C6ST8qIz; 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 a20-20020a05620a439400b0077fbe2de1bbsi28226738qkp.518.2024.01.01.18.02.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Jan 2024 18:02:33 -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=pass header.i=@linaro.org header.s=google header.b=C6ST8qIz; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rKU3q-0003uR-ED; Mon, 01 Jan 2024 20:59:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rKU3n-0003mQ-Hh for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:16 -0500 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU3l-00076K-2f for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:14 -0500 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-6da16ec9be4so2960039b3a.1 for ; Mon, 01 Jan 2024 17:59:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160752; x=1704765552; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=va71e7xBlqUEdFqBnPLdQG8F1PWGxU4pyOMI1WZcB6A=; b=C6ST8qIzbaU42A9lEtS7ekxef0XwDsuruGRnmCpEB0JjOgKDeNkSaMWiZ57Akwf+4e 7im0+1R86pa71KK+ism5m4vu8juewvFB/d9qrxPtRjSrBKUct5PyUpk1Jjm0oYA6RbCV Ii/NcEaC9WRYT1LTjUHd4oZLF9+OqSwMmPvOXEH+f9qLV9DaBxhvi7ZpGlSx0sFZv555 Vcyh2pxt5wx6Yw6iWXlmRb8rhTSCzThAgvZ97dCvPi+reRR9kQNORtc0K7hn8SvM5C9c rWGU8JQXpwwlyQamBuNl08kwsYTE1IUF2Yo1nrd7y4EdobMc502WUxbHrUJmZAoYiMcb 2jig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160752; x=1704765552; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=va71e7xBlqUEdFqBnPLdQG8F1PWGxU4pyOMI1WZcB6A=; b=qC+uwnpxE8I3eemnOM//osKQ067qzp3/MVa+3CvOs42vHwO8PHE71Ek6hRkBXje+4Y fzkM6w/2m/eWWdcqJHzVxeoYdoGcya3Y6TaLnyri4NSCYzZ2tp/NeMDsc+NsnFVZTyck LJZT8ddrLX8UA0a/0IU7rZk6SyAyrcF89geY3HmLwDBw8SbOttpS0VL9n+hzJpMERW7m Nl0KTYN52JsyUppbhgVeed4xS2oBdOCWlde6c3Xl8VpZh69Rwe2niYC2wRi3ENSqoK2n 6DW/ke9x9r+vpdyxHFGZJXYJOADqFndoH1bY+aAy/HavjQIKIpShmY7+g7DDINrxh0GF T7Vw== X-Gm-Message-State: AOJu0YyxKNWOlXP6UzH5ZiHMHbZrKJGjkiqo25SSYr2ZRhb3IXpgXX1b +0TDRfjsmeSlN6BChRczKccsVyy8IDcgs4i8YtKE7GQegRE= X-Received: by 2002:a62:8455:0:b0:6d9:8f56:106b with SMTP id k82-20020a628455000000b006d98f56106bmr14876576pfd.39.1704160751781; Mon, 01 Jan 2024 17:59:11 -0800 (PST) Received: from stoup.. (124-149-254-207.tpgi.com.au. [124.149.254.207]) by smtp.gmail.com with ESMTPSA id g33-20020a635221000000b0058ee60f8e4dsm19561891pgb.34.2024.01.01.17.59.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:59:11 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 28/33] accel/tcg: Disconnect TargetPageDataNode from page size Date: Tue, 2 Jan 2024 12:58:03 +1100 Message-Id: <20240102015808.132373-29-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240102015808.132373-1-richard.henderson@linaro.org> References: <20240102015808.132373-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::433; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x433.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-bounces+patch=linaro.org@nongnu.org Dynamically size the node for the runtime target page size. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Reviewed-by: Ilya Leoshkevich --- accel/tcg/user-exec.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index 69b7429e31..3cac3a78c4 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -864,7 +864,7 @@ tb_page_addr_t get_page_addr_code_hostp(CPUArchState *env, vaddr addr, typedef struct TargetPageDataNode { struct rcu_head rcu; IntervalTreeNode itree; - char data[TPD_PAGES][TARGET_PAGE_DATA_SIZE] __attribute__((aligned)); + char data[] __attribute__((aligned)); } TargetPageDataNode; static IntervalTreeRoot targetdata_root; @@ -902,7 +902,8 @@ void page_reset_target_data(target_ulong start, target_ulong last) n_last = MIN(last, n->last); p_len = (n_last + 1 - n_start) >> TARGET_PAGE_BITS; - memset(t->data[p_ofs], 0, p_len * TARGET_PAGE_DATA_SIZE); + memset(t->data + p_ofs * TARGET_PAGE_DATA_SIZE, 0, + p_len * TARGET_PAGE_DATA_SIZE); } } @@ -910,7 +911,7 @@ void *page_get_target_data(target_ulong address) { IntervalTreeNode *n; TargetPageDataNode *t; - target_ulong page, region; + target_ulong page, region, p_ofs; page = address & TARGET_PAGE_MASK; region = address & TBD_MASK; @@ -926,7 +927,8 @@ void *page_get_target_data(target_ulong address) mmap_lock(); n = interval_tree_iter_first(&targetdata_root, page, page); if (!n) { - t = g_new0(TargetPageDataNode, 1); + t = g_malloc0(sizeof(TargetPageDataNode) + + TPD_PAGES * TARGET_PAGE_DATA_SIZE); n = &t->itree; n->start = region; n->last = region | ~TBD_MASK; @@ -936,7 +938,8 @@ void *page_get_target_data(target_ulong address) } t = container_of(n, TargetPageDataNode, itree); - return t->data[(page - region) >> TARGET_PAGE_BITS]; + p_ofs = (page - region) >> TARGET_PAGE_BITS; + return t->data + p_ofs * TARGET_PAGE_DATA_SIZE; } #else void page_reset_target_data(target_ulong start, target_ulong last) { }