[Bug 286153] kernel malloc should fail (panic) when the allocation obviously can never be made

From: <bugzilla-noreply_at_freebsd.org>
Date: Thu, 17 Apr 2025 10:28:45 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=286153

            Bug ID: 286153
           Summary: kernel malloc should fail (panic) when the allocation
                    obviously can never be made
           Product: Base System
           Version: 15.0-CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: avg@FreeBSD.org

If a caller requests to allocate more memory than is physically available
(e.g., v_page_count * PAGE_SIZE) and passes M_WAITOK, the current code would
just wait forever for that much memory to appear.

That's not very helpful.

IMO, the mistake should be made obvious by panic-ing.
At least, when INVARIANTS are enabled.

The check could be added to malloc_large or maybe downstream in
kmem_malloc_domainset.

-- 
You are receiving this mail because:
You are the assignee for the bug.