Module Name: src Committed By: martin Date: Sun Dec 15 14:56:53 UTC 2024
Modified Files: src/sys/uvm [netbsd-10]: uvm_km.c Log Message: Pull up following revision(s) (requested by chs in ticket #1027): sys/uvm/uvm_km.c: revision 1.166 kmem: improve behavior when using all of physical memory as kmem On systems where kmem does not need to be limited by kernel virtual space (essentially 64-bit platforms), we currently try to size the "kmem" space to be big enough for all of physical memory to be allocated as kmem, which really means that we will always run short of physical memory before we run out of kernel virtual space. However this does not take into account that uvm_km_va_starved_p() starts reporting that we are low on kmem virtual space when we have used 90% of it, in an attempt to avoid kmem space becoming too fragmented, which means on large memory systems we will still start reacting to being short of virtual space when there is plenty of physical memory still available. Fix this by overallocating the kmem space by a factor of 10/9 so that we always run low on physical memory first, as we want. To generate a diff of this commit: cvs rdiff -u -r1.162 -r1.162.4.1 src/sys/uvm/uvm_km.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/uvm/uvm_km.c diff -u src/sys/uvm/uvm_km.c:1.162 src/sys/uvm/uvm_km.c:1.162.4.1 --- src/sys/uvm/uvm_km.c:1.162 Sat Aug 6 05:55:37 2022 +++ src/sys/uvm/uvm_km.c Sun Dec 15 14:56:53 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_km.c,v 1.162 2022/08/06 05:55:37 chs Exp $ */ +/* $NetBSD: uvm_km.c,v 1.162.4.1 2024/12/15 14:56:53 martin Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -152,7 +152,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: uvm_km.c,v 1.162 2022/08/06 05:55:37 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_km.c,v 1.162.4.1 2024/12/15 14:56:53 martin Exp $"); #include "opt_uvmhist.h" @@ -227,7 +227,14 @@ kmeminit_nkmempages(void) } #if defined(NKMEMPAGES_MAX_UNLIMITED) && !defined(KMSAN) - npages = physmem; + /* + * The extra 1/9 here is to account for uvm_km_va_starved_p() + * wanting to keep 10% of kmem virtual space free. + * The intent is that on "unlimited" platforms we should be able + * to allocate all of physical memory as kmem without behaving + * as though we running short of kmem virtual space. + */ + npages = (physmem * 10) / 9; #else #if defined(KMSAN)