MCPcopy Create free account
hub / github.com/F-Stack/f-stack / vm_reserv_init

Function vm_reserv_init

freebsd/vm/vm_reserv.c:1063–1122  ·  view source on GitHub ↗

* Initializes the reservation management system. Specifically, initializes * the reservation array. * * Requires that vm_page_array and first_page are initialized! */

Source from the content-addressed store, hash-verified

1061 * Requires that vm_page_array and first_page are initialized!
1062 */
1063void
1064vm_reserv_init(void)
1065{
1066 vm_paddr_t paddr;
1067 struct vm_phys_seg *seg;
1068 struct vm_reserv *rv;
1069 struct vm_reserv_domain *rvd;
1070#ifdef VM_PHYSSEG_SPARSE
1071 vm_pindex_t used;
1072#endif
1073 int i, j, segind;
1074
1075 /*
1076 * Initialize the reservation array. Specifically, initialize the
1077 * "pages" field for every element that has an underlying superpage.
1078 */
1079#ifdef VM_PHYSSEG_SPARSE
1080 used = 0;
1081#endif
1082 for (segind = 0; segind < vm_phys_nsegs; segind++) {
1083 seg = &vm_phys_segs[segind];
1084#ifdef VM_PHYSSEG_SPARSE
1085 seg->first_reserv = &vm_reserv_array[used];
1086 used += howmany(seg->end, VM_LEVEL_0_SIZE) -
1087 seg->start / VM_LEVEL_0_SIZE;
1088#else
1089 seg->first_reserv =
1090 &vm_reserv_array[seg->start >> VM_LEVEL_0_SHIFT];
1091#endif
1092 paddr = roundup2(seg->start, VM_LEVEL_0_SIZE);
1093 rv = seg->first_reserv + (paddr >> VM_LEVEL_0_SHIFT) -
1094 (seg->start >> VM_LEVEL_0_SHIFT);
1095 while (paddr + VM_LEVEL_0_SIZE > paddr && paddr +
1096 VM_LEVEL_0_SIZE <= seg->end) {
1097 rv->pages = PHYS_TO_VM_PAGE(paddr);
1098 rv->domain = seg->domain;
1099 mtx_init(&rv->lock, "vm reserv", NULL, MTX_DEF);
1100 paddr += VM_LEVEL_0_SIZE;
1101 rv++;
1102 }
1103 }
1104 for (i = 0; i < MAXMEMDOM; i++) {
1105 rvd = &vm_rvd[i];
1106 mtx_init(&rvd->lock, "vm reserv domain", NULL, MTX_DEF);
1107 TAILQ_INIT(&rvd->partpop);
1108 mtx_init(&rvd->marker.lock, "vm reserv marker", NULL, MTX_DEF);
1109
1110 /*
1111 * Fully populated reservations should never be present in the
1112 * partially populated reservation queues.
1113 */
1114 rvd->marker.popcnt = VM_LEVEL_0_NPAGES;
1115 for (j = 0; j < NBPOPMAP; j++)
1116 popmap_set(rvd->marker.popmap, j);
1117 }
1118
1119 for (i = 0; i < VM_RESERV_OBJ_LOCK_COUNT; i++)
1120 mtx_init(&vm_reserv_object_mtx[i], "resv obj lock", NULL,

Callers 1

vm_page_startupFunction · 0.85

Calls 3

PHYS_TO_VM_PAGEFunction · 0.85
mtx_initFunction · 0.85
popmap_setFunction · 0.85

Tested by

no test coverage detected