Bug 252227 - Default value of vm.max_wired is too low in 12.2
Summary: Default value of vm.max_wired is too low in 12.2
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 12.2-RELEASE
Hardware: amd64 Any
: --- Affects Some People
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-12-28 04:53 UTC by VVD
Modified: 2021-01-20 18:05 UTC (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description VVD 2020-12-28 04:53:58 UTC
On 12.2 look like vm.max_wired is a hard limit for number of wired pages for user processes.
With 48GB of RAM default value is 9727317 - it's 9727317*4096/1024/1024/1024 = ~37.1GB only.
Use case:
1) I see 9GB of free RAM
2) started VM in VirtualBox with 8GB
3) started applications in VM
4) VM freezes with VERR_NO_MEMORY error in VBox.log
5) stopped VM
6) 46*1024*1024*1024/4096 = 12058624
sysctl vm.max_wired=12058624
7) repeat 2) and 3)
8) VM work fine now

/usr/src/sys/vm/vm_pageout.c (2082):
vm_page_max_user_wired = 4 * freecount / 5;

From dmesg: avail memory = 50130972672 (47808 MB)
47808 MB * 4/5/1024 = 37.35GB ~= 37.1GB

IMHO, it's very incorrect!
Something like 99/100 look more correct for VM servers with total RAM 48GB: 47808*99/100/1024 = 46.220625
Comment 1 VVD 2021-01-19 13:56:35 UTC
I want get solution before 13.0 release.

1) Increase default value for vm.max_wired:
vm_page_max_user_wired = 99 * freecount / 100;

Or

2) Write warning with very big and bold letters about this issue in release notes, in documentation on web-site, in manual pages and etc.

It's really critical regression for virtualization servers.

P.S. Sorry for my poor english.
Comment 2 Kyle Evans freebsd_committer 2021-01-20 15:49:26 UTC
Tagging in some VM folks to start with.
Comment 3 VVD 2021-01-20 16:57:48 UTC
1GB max reserved from wired ram:
-vm_page_max_user_wired = 4 * freecount / 5;
+vm_page_max_user_wired = freecount - min(freecount, 5 * 1048576 / PAGE_SIZE) / 5;
Comment 4 VVD 2021-01-20 17:09:16 UTC
(In reply to VVD from comment #3)
Fast fix.

1GB max reserved from wired ram:
-vm_page_max_user_wired = 4 * freecount / 5;
+vm_page_max_user_wired = freecount - min(freecount, 5 * 1024 * 1024 * 1024 / PAGE_SIZE) / 5;