From owner-freebsd-fs@FreeBSD.ORG Tue Dec 8 23:06:25 2009 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0915A106566B; Tue, 8 Dec 2009 23:06:25 +0000 (UTC) (envelope-from mattjreimer@gmail.com) Received: from mail-pz0-f185.google.com (mail-pz0-f185.google.com [209.85.222.185]) by mx1.freebsd.org (Postfix) with ESMTP id C83E68FC0A; Tue, 8 Dec 2009 23:06:24 +0000 (UTC) Received: by pzk15 with SMTP id 15so2702811pzk.3 for ; Tue, 08 Dec 2009 15:06:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=I3A6cVy6tTxUMm72ddXe8J1ivM3u7sC7sb0gnYCYCms=; b=xKb1fxeKC+1sUZ4qQWc96Ld0vijXwz9dWLDg9CSNYLMjqaQX+js5IUwdW5cd4ygYap 8MTLl5VUZUUqOErpcHXdlSC7JFWkARYUtynw8EyWwPBZM7Jb0w5MrKceWIqZjvye2G0j kfWV2mrsxmynFo7PjjlGdhR3B+Yi0Eut0WyYw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=fZGrzOLieiSBy4ESSBCfWavIUf6Uxw0c0p4QertFAMTNm2fOtEV3N/AYH+q1QS6Xup ATD2KiPrh4eUkNoMulnsNn3Vlh7aZYpi9XFcOGM+PIN9ovRheWWS6rIFHiKntujC864j SdSYLtwQkqFwbsMsca7+OKxnJI+Jcm0IscDSk= MIME-Version: 1.0 Received: by 10.142.120.3 with SMTP id s3mr961769wfc.301.1260313574968; Tue, 08 Dec 2009 15:06:14 -0800 (PST) In-Reply-To: <200912080813.58600.jhb@freebsd.org> References: <200912080813.58600.jhb@freebsd.org> Date: Tue, 8 Dec 2009 15:06:14 -0800 Message-ID: From: Matt Reimer To: John Baldwin Content-Type: multipart/mixed; boundary=001636e0b9c5f10ee2047a3f9eb3 Cc: freebsd-fs@freebsd.org Subject: Re: PATCH: increase heap size for (gpt)zfsboot X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Dec 2009 23:06:25 -0000 --001636e0b9c5f10ee2047a3f9eb3 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Tue, Dec 8, 2009 at 5:13 AM, John Baldwin wrote: > On Monday 07 December 2009 7:01:03 pm Matt Reimer wrote: >> Enlarge the heap size for gptzfsboot and zfsboot. This is necessary so >> the ZFS code has enough memory to handle decompression and error >> recovery. >> >> Before this patch the heap grew from the end of the (gpt)zfsboot code >> and static data up to 640KB, possibly overrunning the stack. Now the >> heap is located at 16MB-64MB. >> >> Note that this requires machines with at least 64MB RAM, but this is >> not likely to be a problem on any machine running ZFS. >> >> Sponsored by: VPOP Technologies, Inc. >> >> Matt Reimer > > Unfortunately the 16M - 64M range may not all be useable RAM. =A0It may c= ontain > ACPI tables, etc. =A0A robust approach would involve walking the SMAP, et= c. =A0I > just committed some changes to sys/boot/i386/loader/biosmem.c that make i= t > smarter about choosing a heap region. =A0I suggest adopting that algorith= m for > figuring out a safe heap range. =A0zfsboot and gptzfsboot should have eno= ugh > free space to take the bios_getmem() function. =A0You can increase the mi= nimum > heap size beyond 3M if desired (though 3M is the minimum the loader will > guarantee currently, and if ZFS needs more than that it likely needs to b= e > changed in both places). Thanks John. I dropped the bios_getmem() into zfsboot.c and it works for me. How's the attached patch look to you? Matt --001636e0b9c5f10ee2047a3f9eb3 Content-Type: application/octet-stream; name="more-mem.patch" Content-Disposition: attachment; filename="more-mem.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_g2za5nle0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