vm_phys.c (370a338a7db27ff9244d2cd24cedf75e992daa80) vm_phys.c (67d33338c0b29cc5c64af79f31d79b8e5c7125da)
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3 *
4 * Copyright (c) 2002-2006 Rice University
5 * Copyright (c) 2007 Alan L. Cox <alc@cs.rice.edu>
6 * All rights reserved.
7 *
8 * This software was developed for the FreeBSD Project by Alan L. Cox,

--- 101 unchanged lines hidden (view full) ---

110
111/*
112 * Provides the mapping from VM_FREELIST_* to free list indices (flind).
113 */
114static int __read_mostly vm_freelist_to_flind[VM_NFREELIST];
115
116CTASSERT(VM_FREELIST_DEFAULT == 0);
117
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3 *
4 * Copyright (c) 2002-2006 Rice University
5 * Copyright (c) 2007 Alan L. Cox <alc@cs.rice.edu>
6 * All rights reserved.
7 *
8 * This software was developed for the FreeBSD Project by Alan L. Cox,

--- 101 unchanged lines hidden (view full) ---

110
111/*
112 * Provides the mapping from VM_FREELIST_* to free list indices (flind).
113 */
114static int __read_mostly vm_freelist_to_flind[VM_NFREELIST];
115
116CTASSERT(VM_FREELIST_DEFAULT == 0);
117
118#ifdef VM_FREELIST_ISADMA
119#define VM_ISADMA_BOUNDARY 16777216
120#endif
121#ifdef VM_FREELIST_DMA32
122#define VM_DMA32_BOUNDARY ((vm_paddr_t)1 << 32)
123#endif
124
125/*
126 * Enforce the assumptions made by vm_phys_add_seg() and vm_phys_init() about
127 * the ordering of the free list boundaries.
128 */
118#ifdef VM_FREELIST_DMA32
119#define VM_DMA32_BOUNDARY ((vm_paddr_t)1 << 32)
120#endif
121
122/*
123 * Enforce the assumptions made by vm_phys_add_seg() and vm_phys_init() about
124 * the ordering of the free list boundaries.
125 */
129#if defined(VM_ISADMA_BOUNDARY) && defined(VM_LOWMEM_BOUNDARY)
130CTASSERT(VM_ISADMA_BOUNDARY < VM_LOWMEM_BOUNDARY);
131#endif
132#if defined(VM_LOWMEM_BOUNDARY) && defined(VM_DMA32_BOUNDARY)
133CTASSERT(VM_LOWMEM_BOUNDARY < VM_DMA32_BOUNDARY);
134#endif
135
136static int sysctl_vm_phys_free(SYSCTL_HANDLER_ARGS);
137SYSCTL_OID(_vm, OID_AUTO, phys_free, CTLTYPE_STRING | CTLFLAG_RD,
138 NULL, 0, sysctl_vm_phys_free, "A", "Phys Free Info");
139

--- 297 unchanged lines hidden (view full) ---

437 KASSERT((end & PAGE_MASK) == 0,
438 ("vm_phys_define_seg: end is not page aligned"));
439
440 /*
441 * Split the physical memory segment if it spans two or more free
442 * list boundaries.
443 */
444 paddr = start;
126#if defined(VM_LOWMEM_BOUNDARY) && defined(VM_DMA32_BOUNDARY)
127CTASSERT(VM_LOWMEM_BOUNDARY < VM_DMA32_BOUNDARY);
128#endif
129
130static int sysctl_vm_phys_free(SYSCTL_HANDLER_ARGS);
131SYSCTL_OID(_vm, OID_AUTO, phys_free, CTLTYPE_STRING | CTLFLAG_RD,
132 NULL, 0, sysctl_vm_phys_free, "A", "Phys Free Info");
133

--- 297 unchanged lines hidden (view full) ---

431 KASSERT((end & PAGE_MASK) == 0,
432 ("vm_phys_define_seg: end is not page aligned"));
433
434 /*
435 * Split the physical memory segment if it spans two or more free
436 * list boundaries.
437 */
438 paddr = start;
445#ifdef VM_FREELIST_ISADMA
446 if (paddr < VM_ISADMA_BOUNDARY && end > VM_ISADMA_BOUNDARY) {
447 vm_phys_create_seg(paddr, VM_ISADMA_BOUNDARY);
448 paddr = VM_ISADMA_BOUNDARY;
449 }
450#endif
451#ifdef VM_FREELIST_LOWMEM
452 if (paddr < VM_LOWMEM_BOUNDARY && end > VM_LOWMEM_BOUNDARY) {
453 vm_phys_create_seg(paddr, VM_LOWMEM_BOUNDARY);
454 paddr = VM_LOWMEM_BOUNDARY;
455 }
456#endif
457#ifdef VM_FREELIST_DMA32
458 if (paddr < VM_DMA32_BOUNDARY && end > VM_DMA32_BOUNDARY) {

--- 22 unchanged lines hidden (view full) ---

481 * manifest constants VM_FREELIST_* to the free list indices.
482 *
483 * Initially, the entries of vm_freelist_to_flind[] are set to either
484 * 0 or 1 to indicate which free lists should be created.
485 */
486 npages = 0;
487 for (segind = vm_phys_nsegs - 1; segind >= 0; segind--) {
488 seg = &vm_phys_segs[segind];
439#ifdef VM_FREELIST_LOWMEM
440 if (paddr < VM_LOWMEM_BOUNDARY && end > VM_LOWMEM_BOUNDARY) {
441 vm_phys_create_seg(paddr, VM_LOWMEM_BOUNDARY);
442 paddr = VM_LOWMEM_BOUNDARY;
443 }
444#endif
445#ifdef VM_FREELIST_DMA32
446 if (paddr < VM_DMA32_BOUNDARY && end > VM_DMA32_BOUNDARY) {

--- 22 unchanged lines hidden (view full) ---

469 * manifest constants VM_FREELIST_* to the free list indices.
470 *
471 * Initially, the entries of vm_freelist_to_flind[] are set to either
472 * 0 or 1 to indicate which free lists should be created.
473 */
474 npages = 0;
475 for (segind = vm_phys_nsegs - 1; segind >= 0; segind--) {
476 seg = &vm_phys_segs[segind];
489#ifdef VM_FREELIST_ISADMA
490 if (seg->end <= VM_ISADMA_BOUNDARY)
491 vm_freelist_to_flind[VM_FREELIST_ISADMA] = 1;
492 else
493#endif
494#ifdef VM_FREELIST_LOWMEM
495 if (seg->end <= VM_LOWMEM_BOUNDARY)
496 vm_freelist_to_flind[VM_FREELIST_LOWMEM] = 1;
497 else
498#endif
499#ifdef VM_FREELIST_DMA32
500 if (
501#ifdef VM_DMA32_NPAGES_THRESHOLD

--- 34 unchanged lines hidden (view full) ---

536 for (segind = 0; segind < vm_phys_nsegs; segind++) {
537 seg = &vm_phys_segs[segind];
538#ifdef VM_PHYSSEG_SPARSE
539 seg->first_page = &vm_page_array[npages];
540 npages += atop(seg->end - seg->start);
541#else
542 seg->first_page = PHYS_TO_VM_PAGE(seg->start);
543#endif
477#ifdef VM_FREELIST_LOWMEM
478 if (seg->end <= VM_LOWMEM_BOUNDARY)
479 vm_freelist_to_flind[VM_FREELIST_LOWMEM] = 1;
480 else
481#endif
482#ifdef VM_FREELIST_DMA32
483 if (
484#ifdef VM_DMA32_NPAGES_THRESHOLD

--- 34 unchanged lines hidden (view full) ---

519 for (segind = 0; segind < vm_phys_nsegs; segind++) {
520 seg = &vm_phys_segs[segind];
521#ifdef VM_PHYSSEG_SPARSE
522 seg->first_page = &vm_page_array[npages];
523 npages += atop(seg->end - seg->start);
524#else
525 seg->first_page = PHYS_TO_VM_PAGE(seg->start);
526#endif
544#ifdef VM_FREELIST_ISADMA
545 if (seg->end <= VM_ISADMA_BOUNDARY) {
546 flind = vm_freelist_to_flind[VM_FREELIST_ISADMA];
547 KASSERT(flind >= 0,
548 ("vm_phys_init: ISADMA flind < 0"));
549 } else
550#endif
551#ifdef VM_FREELIST_LOWMEM
552 if (seg->end <= VM_LOWMEM_BOUNDARY) {
553 flind = vm_freelist_to_flind[VM_FREELIST_LOWMEM];
554 KASSERT(flind >= 0,
555 ("vm_phys_init: LOWMEM flind < 0"));
556 } else
557#endif
558#ifdef VM_FREELIST_DMA32

--- 846 unchanged lines hidden ---
527#ifdef VM_FREELIST_LOWMEM
528 if (seg->end <= VM_LOWMEM_BOUNDARY) {
529 flind = vm_freelist_to_flind[VM_FREELIST_LOWMEM];
530 KASSERT(flind >= 0,
531 ("vm_phys_init: LOWMEM flind < 0"));
532 } else
533#endif
534#ifdef VM_FREELIST_DMA32

--- 846 unchanged lines hidden ---