From 1dd462720ef58be0aa78ea1474bf697bbf18ffb4 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Fri, 14 Nov 2025 14:19:20 -0500 Subject: [PATCH] kernel/vm: Don't shrink commitment on precommit in VMAnonymousCache. If we were "donated" some commitment (e.g. in copy_on_write_area) then we don't want to drop it when pre-committing. Fixes some commitments being too low in forked teams. --- src/system/kernel/vm/VMAnonymousCache.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/system/kernel/vm/VMAnonymousCache.cpp b/src/system/kernel/vm/VMAnonymousCache.cpp index 9322a37cab..5cbcc3fd1b 100644 --- a/src/system/kernel/vm/VMAnonymousCache.cpp +++ b/src/system/kernel/vm/VMAnonymousCache.cpp @@ -734,9 +734,12 @@ VMAnonymousCache::Commit(off_t size, int priority) // pre-commit some pages to make a later failure less probable fHasPrecommitted = true; - uint32 precommitted = fPrecommittedPages * B_PAGE_SIZE; + uint32 precommitted = (fPrecommittedPages * B_PAGE_SIZE); if (size > precommitted) size = precommitted; + + // pre-commit should not shrink existing commitment + size += committed_size; } return _Commit(size, priority);