Bug 270495 - panic with insufficient memory: Could not malloc 163840 bytes with M_WAITOK from /usr/src/sys/contrib/openzfs/module/zstd/zfs_zstd.c line 670
Summary: panic with insufficient memory: Could not malloc 163840 bytes with M_WAITOK f...
Status: Closed Not A Bug
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 13.1-RELEASE
Hardware: i386 Any
: --- Affects Some People
Assignee: Graham Perrin
URL:
Keywords: crash
Depends on:
Blocks:
 
Reported: 2023-03-28 04:34 UTC by Tim McIntosh
Modified: 2023-04-01 00:04 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tim McIntosh 2023-03-28 04:34:42 UTC
I am trying to install FreeBSD 13.1 on my legacy i386 system:

- Supermicro P5STE motherboard (Intel 430HX) <https://theretroweb.com/motherboards/s/supermicro-p5ste>
- Pentium 90? CPU
- 64MB RAM
- Builtin dual-IDE:
  - IDE0
    - primary: 1GB WDC disk
    - secondary: Toshiba XM6202B CDROM drive
  - IDE1
    - primary: 2GB WDC disk
    - secondary: N/A
- Adaptec AHA-2940 SCSI controller (ID 0)
  - ID 6 - 1GB SEAGATE disk

In order to fit the installation media on a standard 700MB CDROM, I used `xorriso` to create a reduced-size version of the `disc1` ISO, removing the `src.txz` package, as follows:

```
xorriso -external_filter exclude_src default /usr/bin/grep -v src.txz -- \
-boot_image any discard \
-boot_image any bin_path=boot/cdboot \
-indev ~/Downloads/FreeBSD-13.1-RELEASE-i386-disc1.iso \
-outdev ~/Downloads/FreeBSD-13.1-RELEASE-i386-cd.iso \
-rm /usr/freebsd-dist/src.txz -- \
-set_filter exclude_src /usr/freebsd-dist/MANIFEST
```

I then attempted to boot the system from the CDROM (with the CDROM as the only bootable drive). The complete output looks like this:

```
Consoles: internal video/keyboard
BIOS CD is cd0
BIOS drive A: is fd0
BIOS drive B: is fd1
BIOS drive C: is disk0
BIOS drive D: is disk1
BIOS drive E: is disk2
panic: Could not malloc 163840 bytes with M_WAITOK from /usr/src/sys/contrib/openzfs/module/zstd/zfs_zstd.c line 670
--> Press a key on the console to reboot <--
```
Comment 1 Tim McIntosh 2023-03-29 01:01:30 UTC
For what it's worth, I was able to boot the NetBSD 9.3 installation CDROM on this machine without any configuration changes.
Comment 2 Tim McIntosh 2023-03-29 05:54:24 UTC
Update: I just tried booting from the standard `bootonly` ISO (FreeBSD-13.1-RELEASE-i386-bootonly.iso) and it fails on the exact same way.

So this confirms that it is a problem with the boot process itself, and not the CDROM image.
Comment 3 Robert Clausecker freebsd_committer freebsd_triage 2023-03-29 12:17:33 UTC
64 MB is very little memory.  I suspect the problem is that the ZFS boot code tries to allocate more memory than you have.  You could try building a custom image without the ZFS bits in the boot loader.  However, it will not be a pleasurable experience to run this system if it runs at all.
Comment 4 Tim McIntosh 2023-03-30 01:06:09 UTC
I see.  This machine used to run FreeBSD back in the day (like 20+ years ago), but I guess the footprint has significantly increased since then.
Comment 5 Tim McIntosh 2023-03-30 01:07:35 UTC
Are the current minimum hardware requirements for FreeBSD/i386 clearly documented anywhere?
Comment 6 Tim McIntosh 2023-03-30 02:48:41 UTC
Good news, I was able to get 64MB more of RAM into the machine, and that avoids this panic.

It would be good to document this RAM size constraint.
Comment 7 Tim McIntosh 2023-03-30 04:23:26 UTC
With 128MB of RAM installed, I avoid this panic, as mentioned above.

However, the next thing I hit is:

Bug #260229 - Install FreeBSD 13.0 stuck at can't find '/boot/entropy'

Are 486 and Pentium systems _really_ supported?
Comment 8 Tim McIntosh 2023-03-30 04:50:18 UTC
(In reply to Tim McIntosh from comment #7)

Actually, I presume that's not the same failure, just same benign message on the console preceding the failure.

I filed a separate report for my current problem:

Bug 270534 - i386 13.1-RELEASE install CD: BTX halted: int=00000006 err=00000000 efl=00010006 eip=01405b81
Comment 9 Tim McIntosh 2023-03-30 06:26:52 UTC
It seems that this class of machine is not well supported by modern FreeBSD, especially considering that things like drivers for 10/100 Ethernet cards from this era (e.g. ed(4)) have apparently been removed from tree since FreeBSD-12.

I'm going to consider trying an older release like 11.4, or perhaps NetBSD.
Comment 10 Graham Perrin freebsd_committer freebsd_triage 2023-03-31 01:42:00 UTC
(In reply to Tim McIntosh from comment #6)

> It would be good to document this RAM size constraint.

From <https://openzfs.github.io/openzfs-docs/Project%20and%20Community/FAQ.html#performance-considerations>: 

>> … A minimum of 2GB of memory is recommended …
Comment 11 Tim McIntosh 2023-03-31 03:26:14 UTC
(In reply to Graham Perrin from comment #10)

>> … A minimum of 2GB of memory is recommended …

Thanks, I did not find that when searching for it.

However, from https://www.freebsd.org/platforms/i386/:

> FreeBSD/i386 should support any CPU compatible with the Intel(T) 80486 or better in 32-bit mode....

2GB is an insane minimum memory requirement for systems on the low end of "80486 or better".

It would be good to have a more realistic minimum requirement documented directly on the FreeBSD/i386 page, along with more specific hardware requirements in general.  That page gives the impression that FreeBSD should still run on a typical '486 or Pentium system, which seems not to be the case.

Also, it would be good to check the memory requirements up front and fail with a clear error message, rather than failing with an obscure panic in malloc or similar. I wasted a lot of time trying to get this to work given the initial impression that it should. It's really a disappointing experience.

As mentioned above, I found that 128MB will avoid this particular panic, but it's unclear to me whether the next panic in bug #270534 is just another symptom of having insufficient memory, or something else.
Comment 12 Tim McIntosh 2023-03-31 03:30:37 UTC
(In reply to Tim McIntosh from comment #11)

A couple more thoughts:
1. Given the high memory requirements of ZFS, perhaps ZFS should not be enabled by default in the kernel used on the i386 installation disc if 486 and Pentium-class machines are truly to be supported.
2. The maximum amount of memory supported by this board is 512MB, which IIRC is near the high end for 486 and Pentium-class systems. If FreeBSD can't reasonably operate with less than 2GB, these systems should not be claimed as supported (I understand it's Tier 2, but still).
Comment 13 Robert Clausecker freebsd_committer freebsd_triage 2023-03-31 10:46:25 UTC
(In reply to Tim McIntosh from comment #12)

Note that starting with FreeBSD 13, an i686 class machine is required to build the default kernel and userland.  i486 is still supported, but requires you to build your own system.

As for the boot loader issue, I believe it can be worked around by installing the non-ZFS boot loader (does that one still exist?).
Comment 14 Graham Perrin freebsd_committer freebsd_triage 2023-03-31 21:57:48 UTC
(In reply to Tim McIntosh from comment #11)

It's a recommendation, not a requirement. 

If you'd like enhancements to OpenZFS-related documentation for FreeBSD: I suggest posting first to one of the lists <https://lists.freebsd.org/> to gain contexts, then make a new bug report. 

Also/alternatively <https://github.com/openzfs/zfs/discussions/>. 

Thanks
Comment 15 Tim McIntosh 2023-04-01 00:04:01 UTC
> Note that starting with FreeBSD 13, an i686 class machine is required to build the default kernel and userland.  i486 is still supported, but requires you to build your own system.

This is good clarification that would be great to see on the main FreeBSD/i386 page. Also a note about 10/100Mbps Ethernet support being dropped.

> If you'd like enhancements to OpenZFS-related documentation for FreeBSD

I never had any interest in OpenZFS in this context, so I would not have known to look there. I merely wanted to install a minimal FreeBSD install on my machine (which is actually a Pentium 200 MMX - I forgot I upgraded the processor years ago).

Unfortunately I’ve more than exhausted the time I had to spend on this exercise, so I’m giving up on running FreeBSD on this system.

I had taken the extra time to file bug reports in the hope that it may lead to some general improvement, at least in documentation if nothing else.