From nobody Fri Oct 18 08:31:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) client-ip=78.46.105.101; envelope-from=seabios-bounces@seabios.org; helo=coreboot.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from coreboot.org (coreboot.org [78.46.105.101]) by mx.zohomail.com with SMTPS id 1651044180605623.1980758693949; Wed, 27 Apr 2022 00:23:00 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id 3A7F816E3CFF; Wed, 27 Apr 2022 07:22:56 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id 4F46616E36D5 for ; Wed, 27 Apr 2022 07:22:11 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-461-gUU6x3Z5NxuI-crtaCX2Jg-1; Wed, 27 Apr 2022 03:22:08 -0400 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6171B8038E3 for ; Wed, 27 Apr 2022 07:22:08 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3567A416166; Wed, 27 Apr 2022 07:22:08 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) id E89071800D51; Wed, 27 Apr 2022 09:22:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651044130; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1g4/yFtYvpyZVdqpjEuCj+97ZaArRL6NVwPqHIqvFnw=; b=QM+UG/N8tksJTuh6HuKXUbmXFL3I6rOc7/1kvb5Wc6SzXWvDlxwbaF+LEHeQmG9nTxh8q9 LspQl1pfZ1GbdelU0Szj0eHiJ0+6x1EEO7OwdmCjj82KHSesfBLn+F6LiebxsNTyyHKgE7 KcVREYlwEwul3q46rgDRUVe8NmiHxis= X-MC-Unique: gUU6x3Z5NxuI-crtaCX2Jg-1 From: Gerd Hoffmann To: seabios@seabios.org Date: Wed, 27 Apr 2022 09:22:04 +0200 Message-Id: <20220427072204.2781045-3-kraxel@redhat.com> In-Reply-To: <20220427072204.2781045-1-kraxel@redhat.com> References: <20220427072204.2781045-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: RWTRCBLIPWKAQFRD6OB77SEWEGVE3F7W X-Message-ID-Hash: RWTRCBLIPWKAQFRD6OB77SEWEGVE3F7W X-MailFrom: kraxel@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-seabios.seabios.org-0; header-match-seabios.seabios.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Gerd Hoffmann X-Mailman-Version: 3.3.5rc1 Precedence: list Subject: [SeaBIOS] [PATCH v4 2/2] malloc: use large ZoneHigh when there is enough memory List-Id: SeaBIOS mailing list Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable Authentication-Results: coreboot.org; auth=pass smtp.auth=mailman@coreboot.org smtp.mailfrom=seabios-bounces@seabios.org X-Spamd-Bar: ------ X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1651044182278100001 Content-Type: text/plain; charset="utf-8"; x-default="true" In case there is enough memory installed use a large ZoneHigh. Signed-off-by: Gerd Hoffmann --- src/config.h | 3 ++- src/malloc.c | 14 +++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/config.h b/src/config.h index 93c8dbc2d530..9abe355b6c47 100644 --- a/src/config.h +++ b/src/config.h @@ -17,7 +17,8 @@ // Maximum number of map entries in the e820 map #define BUILD_MAX_E820 32 // Space to reserve in high-memory for tables -#define BUILD_MAX_HIGHTABLE (256*1024) +#define BUILD_MIN_HIGHTABLE (256*1024) +#define BUILD_MAX_HIGHTABLE (16*1024*1024) // Largest supported externaly facing drive id #define BUILD_MAX_EXTDRIVE 16 // Number of bytes the smbios may be and still live in the f-segment diff --git a/src/malloc.c b/src/malloc.c index ecd8c9ac78d2..da84098005f7 100644 --- a/src/malloc.c +++ b/src/malloc.c @@ -423,7 +423,7 @@ malloc_preinit(void) =20 // Populate temp high ram u32 highram_start =3D 0; - u32 highram_size =3D BUILD_MAX_HIGHTABLE; + u32 highram_size =3D 0; int i; for (i=3De820_count-1; i>=3D0; i--) { struct e820entry *en =3D &e820_list[i]; @@ -434,10 +434,14 @@ malloc_preinit(void) continue; u32 s =3D en->start, e =3D end; if (!highram_start) { - u32 newe =3D ALIGN_DOWN(e - highram_size, MALLOC_MIN_ALIGN); - if (newe <=3D e && newe >=3D s) { - highram_start =3D newe; - e =3D newe; + u32 new_max =3D ALIGN_DOWN(e - BUILD_MAX_HIGHTABLE, MALLOC_MIN= _ALIGN); + u32 new_min =3D ALIGN_DOWN(e - BUILD_MIN_HIGHTABLE, MALLOC_MIN= _ALIGN); + if (new_max <=3D e && new_max >=3D s + BUILD_MAX_HIGHTABLE) { + highram_start =3D e =3D new_max; + highram_size =3D BUILD_MAX_HIGHTABLE; + } else if (new_min <=3D e && new_min >=3D s) { + highram_start =3D e =3D new_min; + highram_size =3D BUILD_MIN_HIGHTABLE; } } alloc_add(&ZoneTmpHigh, s, e); --=20 2.35.1 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org