#
0078df5f |
| 29-Jan-2025 |
Doug Moore <dougm@FreeBSD.org> |
vm_phys: reduce touching of page->pool fields
Change the usage of the pool field in vm_page structs.
Currently, every page belongs to a pool, and the pool field identifies that pool, whether the pa
vm_phys: reduce touching of page->pool fields
Change the usage of the pool field in vm_page structs.
Currently, every page belongs to a pool, and the pool field identifies that pool, whether the page is allocated or free.
With this change, the pool field of the first page of a free block is used by the buddy allocator to identify its pool, but the buddy allocator makes no guarantees about the pool field value for allocated pages. The buddy allocator requires that a pool parameter be passed as part of freeing memory. A function that allocates memory may use the pool field of a page to record what pool to pass as that parameter when the memory is freed, but might not need to do so for every allocated page.
Suggested by: alc Reviewed by: markj (previous version) Tested by: pho Differential Revision: https://reviews.freebsd.org/D45409
show more ...
|
#
18c47eab |
| 23-Jan-2025 |
Doug Moore <dougm@FreeBSD.org> |
Revert "vm_phys: reduce touching of page->pool fields". Pho reports, and I have verified, that it sometimes crashes the kernel on the mmap41.sh stress test.
This reverts commit c669b08bd834553ec056
Revert "vm_phys: reduce touching of page->pool fields". Pho reports, and I have verified, that it sometimes crashes the kernel on the mmap41.sh stress test.
This reverts commit c669b08bd834553ec056e3987693f247b2ec0433.
show more ...
|
#
c669b08b |
| 21-Jan-2025 |
Doug Moore <dougm@FreeBSD.org> |
vm_phys: reduce touching of page->pool fields
Change the usage of the pool field in vm_page structs.
Currently, every page belongs to a pool, and the pool field identifies that pool, whether the pa
vm_phys: reduce touching of page->pool fields
Change the usage of the pool field in vm_page structs.
Currently, every page belongs to a pool, and the pool field identifies that pool, whether the page is allocated or free.
With this change, the pool field of the first page of a free block is used by the buddy allocator to identify its pool, but the buddy allocator makes no guarantees about the pool field value for allocated pages. The buddy allocator requires that a pool parameter be passed as part of freeing memory. A function that allocates memory may use the pool field of a page to record what pool to pass as that parameter when the memory is freed, but might not need to do so for every allocated page.
Suggested by: alc Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D45409
show more ...
|
Revision tags: release/14.2.0, release/13.4.0 |
|
#
6aede562 |
| 05-Sep-2024 |
Doug Moore <dougm@FreeBSD.org> |
vm_phys: hide alloc_freelist_pages
Make vm_phys_alloc_freelist_pages static. There are no longer any callers outside of vm_phys.c.
Reviewed by: alc, markj Differential Revision: https://reviews.fr
vm_phys: hide alloc_freelist_pages
Make vm_phys_alloc_freelist_pages static. There are no longer any callers outside of vm_phys.c.
Reviewed by: alc, markj Differential Revision: https://reviews.freebsd.org/D46539
show more ...
|
#
b16b4c22 |
| 14-Jun-2024 |
Mark Johnston <markj@FreeBSD.org> |
vm_page: Implement lazy page initialization
FreeBSD's boot times have decreased to the point where vm_page array initialization represents a significant fraction of the total boot time. For example,
vm_page: Implement lazy page initialization
FreeBSD's boot times have decreased to the point where vm_page array initialization represents a significant fraction of the total boot time. For example, when booting FreeBSD in Firecracker (a VMM designed to support lightweight VMs) with 128MB and 1GB of RAM, vm_page initialization consumes 9% (3ms) and 37% (21.5ms) of the kernel boot time, respectively. This is generally relevant in cloud environments, where one wants to be able to spin up VMs as quickly as possible.
This patch implements lazy initialization of (most) page structures, following a suggestion from cperciva@. The idea is to introduce a new free pool, VM_FREEPOOL_LAZYINIT, into which all vm_page structures are initially placed. For this to work, we need only initialize the first free page of each chunk placed into the buddy allocator. Then, early page allocations draw from the lazy init pool and initialize vm_page chunks (up to 16MB, 4096 pages) on demand. Once APs are started, an idle-priority thread drains the lazy init pool in the background to avoid introducing extra latency in the allocator. With this scheme, almost all of the initialization work is moved out of the critical path.
A couple of vm_phys operations require the pool to be drained before they can run: vm_phys_find_range() and vm_phys_unfree_page(). However, these are rare operations. I believe that vm_phys_find_freelist_contig() does not require any special treatment, as it only ever accesses the first page in a power-of-2-sized free page chunk, which is always initialized.
For now the new pool is only used on amd64 and arm64, since that's where I can easily test and those platforms would get the most benefit.
Reviewed by: alc, kib Differential Revision: https://reviews.freebsd.org/D40403
show more ...
|
#
69cbb187 |
| 14-Jun-2024 |
Mark Johnston <markj@FreeBSD.org> |
vm_phys: Add a vm_phys_seg_paddr_to_vm_page() helper
No functional change intended.
Suggested by: alc Reviewed by: dougm, alc, kib MFC after: 2 weeks Differential Revision: https://reviews.freebsd.
vm_phys: Add a vm_phys_seg_paddr_to_vm_page() helper
No functional change intended.
Suggested by: alc Reviewed by: dougm, alc, kib MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D43636
show more ...
|
#
e3537f92 |
| 03-Jun-2024 |
Doug Moore <dougm@FreeBSD.org> |
Revert "subr_pctrie: use ilog2(x) instead of fls(x)-1"
This reverts commit 574ef650695088d56ea12df7da76155370286f9f.
|
#
574ef650 |
| 03-Jun-2024 |
Doug Moore <dougm@FreeBSD.org> |
subr_pctrie: use ilog2(x) instead of fls(x)-1
In three instances where fls(x)-1 is used, the compiler does not know that x is nonzero and so adds needless zero checks. Using ilog(x) instead saves,
subr_pctrie: use ilog2(x) instead of fls(x)-1
In three instances where fls(x)-1 is used, the compiler does not know that x is nonzero and so adds needless zero checks. Using ilog(x) instead saves, in each instance, about 4 instructions, including a conditional, and 16 or so bytes, on an amd64 build.
Reviewed by: alc Differential Revision: https://reviews.freebsd.org/D45330
show more ...
|
Revision tags: release/14.1.0 |
|
#
cb20a74c |
| 03-Apr-2024 |
Stephen J. Kiernan <stevek@FreeBSD.org> |
vm: add macro to mark arguments used when NUMA is defined
This fixes compiler warnings when -Wunused-arguments is enabled and not quieted.
Reviewed by: kib, markj Obtained from: Juniper Networks, I
vm: add macro to mark arguments used when NUMA is defined
This fixes compiler warnings when -Wunused-arguments is enabled and not quieted.
Reviewed by: kib, markj Obtained from: Juniper Networks, Inc. Differential Revision: https://reviews.freebsd.org/D44623
show more ...
|
Revision tags: release/13.3.0, release/14.0.0 |
|
#
95ee2897 |
| 16-Aug-2023 |
Warner Losh <imp@FreeBSD.org> |
sys: Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
|
#
9e817428 |
| 16-Jun-2023 |
Doug Moore <dougm@FreeBSD.org> |
vm_phys: add binary segment search
Replace several sequential searches for a segment that contains a phyiscal address with a call to a function that does it by binary search. In vm_page_reclaim_con
vm_phys: add binary segment search
Replace several sequential searches for a segment that contains a phyiscal address with a call to a function that does it by binary search. In vm_page_reclaim_contig_domain_ext, find the first segment to reclaim from, and reclaim from each subsequent appropriate segment. Eliminate vm_phys_scan_contig.
Reviewed by: alc, markj Differential Revision: https://reviews.freebsd.org/D40058
show more ...
|
#
6062d9fa |
| 05-Jun-2023 |
Mark Johnston <markj@FreeBSD.org> |
vm_phys: Change the return type of vm_phys_unfree_page() to bool
This is in keeping with the trend of removing uses of boolean_t, and the sole caller was implicitly converting it to a "bool".
No fu
vm_phys: Change the return type of vm_phys_unfree_page() to bool
This is in keeping with the trend of removing uses of boolean_t, and the sole caller was implicitly converting it to a "bool".
No functional change intended.
Reviewed by: dougm, alc, imp, kib MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D40401
show more ...
|
#
4d846d26 |
| 10-May-2023 |
Warner Losh <imp@FreeBSD.org> |
spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch up to that fact and revert to their recommended match of
spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch up to that fact and revert to their recommended match of BSD-2-Clause.
Discussed with: pfg MFC After: 3 days Sponsored by: Netflix
show more ...
|
Revision tags: release/13.2.0, release/12.4.0, release/13.1.0 |
|
#
8119cdd3 |
| 29-Dec-2021 |
Doug Moore <dougm@FreeBSD.org> |
vm_phys: hide vm_phys_set_pool
It is only called in the file that defines it, so make it static and remove the declaration from the header.
Reviewed by: kib Differential Revision: https://reviews.f
vm_phys: hide vm_phys_set_pool
It is only called in the file that defines it, so make it static and remove the declaration from the header.
Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D33688
show more ...
|
Revision tags: release/12.3.0 |
|
#
31991a5a |
| 29-Sep-2021 |
Mitchell Horne <mhorne@FreeBSD.org> |
minidump: De-duplicate is_dumpable()
The function is identical in each minidump implementation, so move it to vm_phys.c. The only slight exception is powerpc where the function was public, for use i
minidump: De-duplicate is_dumpable()
The function is identical in each minidump implementation, so move it to vm_phys.c. The only slight exception is powerpc where the function was public, for use in moea64_scan_pmap().
Reviewed by: kib, markj, imp (earlier version) MFC after: 2 weeks Sponsored by: Juniper Networks, Inc. Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D31884
show more ...
|
Revision tags: release/13.0.0 |
|
#
431fb8ab |
| 19-Nov-2020 |
Mark Johnston <markj@FreeBSD.org> |
vm_phys: Try to clean up NUMA KPIs
It can useful for code outside the VM system to look up the NUMA domain of a page backing a virtual or physical address, specifically when creating NUMA-aware data
vm_phys: Try to clean up NUMA KPIs
It can useful for code outside the VM system to look up the NUMA domain of a page backing a virtual or physical address, specifically when creating NUMA-aware data structures. We have _vm_phys_domain() for this, but the leading underscore implies that it's an internal function, and vm_phys.h has dependencies on a number of other headers.
Rename vm_phys_domain() to vm_page_domain(), and _vm_phys_domain() to vm_phys_domain(). Make the latter an inline function.
Add _vm_phys.h and define struct vm_phys_seg there so that it's easier to use in other headers. Include it from vm_page.h so that vm_page_domain() can be defined there.
Include machine/vmparam.h from _vm_phys.h since it depends directly on some constants defined there.
Reviewed by: alc Reviewed by: dougm, kib (earlier versions) Differential Revision: https://reviews.freebsd.org/D27207
show more ...
|
#
ccfd886a |
| 23-Oct-2020 |
Alan Cox <alc@FreeBSD.org> |
Conditionally compile struct vm_phys_seg's md_first field. This field is only used by arm64's pmap.
Reviewed by: kib, markj, scottph Differential Revision: https://reviews.freebsd.org/D26907
|
Revision tags: release/12.2.0 |
|
#
6f3b523c |
| 15-Oct-2020 |
Konstantin Belousov <kib@FreeBSD.org> |
Avoid dump_avail[] redefinition.
Move dump_avail[] extern declaration and inlines into a new header vm/vm_dumpset.h. This fixes default gcc build for mips.
Reviewed by: alc, scottph Tested by: kev
Avoid dump_avail[] redefinition.
Move dump_avail[] extern declaration and inlines into a new header vm/vm_dumpset.h. This fixes default gcc build for mips.
Reviewed by: alc, scottph Tested by: kevans (previous version) Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D26741
show more ...
|
#
de031846 |
| 22-Sep-2020 |
D Scott Phillips <scottph@FreeBSD.org> |
arm64/pmap: Sparsify pv_table
Reviewed by: markj, kib Approved by: scottl (implicit) MFC after: 1 week Sponsored by: Ampere Computing, Inc. Differential Revision: https://reviews.freebsd.org/D26132
|
#
7988971a |
| 22-Sep-2020 |
D Scott Phillips <scottph@FreeBSD.org> |
vm_reserv: Sparsify the vm_reserv_array when VM_PHYSSEG_SPARSE
On an Ampere Altra system, the physical memory is populated sparsely within the physical address space, with only about 0.4% of physica
vm_reserv: Sparsify the vm_reserv_array when VM_PHYSSEG_SPARSE
On an Ampere Altra system, the physical memory is populated sparsely within the physical address space, with only about 0.4% of physical addresses backed by RAM in the range [0, last_pa].
This is causing the vm_reserv_array to be over-sized by a few orders of magnitude, wasting roughly 5 GiB on a system with 256 GiB of RAM.
The sparse allocation of vm_reserv_array is controlled by defining VM_PHYSSEG_SPARSE, with the dense allocation still remaining for platforms with VM_PHYSSEG_DENSE.
Reviewed by: markj, alc, kib Approved by: scottl (implicit) MFC after: 1 week Sponsored by: Ampere Computing, Inc. Differential Revision: https://reviews.freebsd.org/D26130
show more ...
|
#
00e66147 |
| 22-Sep-2020 |
D Scott Phillips <scottph@FreeBSD.org> |
Sparsify the vm_page_dump bitmap
On Ampere Altra systems, the sparse population of RAM within the physical address space causes the vm_page_dump bitmap to be much larger than necessary, increasing t
Sparsify the vm_page_dump bitmap
On Ampere Altra systems, the sparse population of RAM within the physical address space causes the vm_page_dump bitmap to be much larger than necessary, increasing the size from ~8 Mib to > 2 Gib (and overflowing `int` for the size).
Changing the page dump bitmap also changes the minidump file format, so changes are also necessary in libkvm.
Reviewed by: jhb Approved by: scottl (implicit) MFC after: 1 week Sponsored by: Ampere Computing, Inc. Differential Revision: https://reviews.freebsd.org/D26131
show more ...
|
#
c3aa3bf9 |
| 01-Sep-2020 |
Mateusz Guzik <mjg@FreeBSD.org> |
vm: clean up empty lines in .c and .h files
|
Revision tags: release/11.4.0 |
|
#
81302f1d |
| 28-May-2020 |
Mark Johnston <markj@FreeBSD.org> |
Fix boot on systems where NUMA domain 0 is unpopulated.
- Add vm_phys_early_add_seg(), complementing vm_phys_early_alloc(), to ensure that segments registered during hammer_time() are placed in th
Fix boot on systems where NUMA domain 0 is unpopulated.
- Add vm_phys_early_add_seg(), complementing vm_phys_early_alloc(), to ensure that segments registered during hammer_time() are placed in the right domain. Otherwise, since the SRAT is not parsed at that point, we just add them to domain 0, which may be incorrect and results in a domain with only several MB worth of memory. - Fix uma_startup1() to try allocating memory for zones from any domain. If domain 0 is unpopulated, the allocation will simply fail, resulting in a page fault slightly later during boot. - Change _vm_phys_domain() to return -1 for addresses not covered by the affinity table, and change vm_phys_early_alloc() to handle wildcard domains. This is necessary on amd64, where the page array is dense and pmap_page_array_startup() may allocate page table pages for non-existent page frames.
Reported and tested by: Rafael Kitover <rkitover@gmail.com> Reviewed by: cem (earlier version), kib Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D25001
show more ...
|
Revision tags: release/12.1.0 |
|
#
b7565d44 |
| 18-Aug-2019 |
Jeff Roberson <jeff@FreeBSD.org> |
Encapsulate phys_avail manipulation in a set of simple routines. Add a NUMA aware boot time memory allocator that will be used to allocate early domain correct structures. Code partially submitted
Encapsulate phys_avail manipulation in a set of simple routines. Add a NUMA aware boot time memory allocator that will be used to allocate early domain correct structures. Code partially submitted by gallatin.
Reviewed by: gallatin, kib Tested by: pho Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D21251
show more ...
|
#
21943937 |
| 16-Aug-2019 |
Jeff Roberson <jeff@FreeBSD.org> |
Move phys_avail definition into MI code. It is consumed in the MI layer and doing so adds more flexibility with less redundant code.
Reviewed by: jhb, markj, kib Sponsored by: Netflix Differential
Move phys_avail definition into MI code. It is consumed in the MI layer and doing so adds more flexibility with less redundant code.
Reviewed by: jhb, markj, kib Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D21250
show more ...
|