Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F115641216
D48632.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D48632.diff
View Options
diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c
--- a/sys/vm/vm_page.c
+++ b/sys/vm/vm_page.c
@@ -655,40 +655,39 @@
#else
(void)pa;
#endif
+
/*
- * Compute the number of pages of memory that will be available for
- * use, taking into account the overhead of a page structure per page.
- * In other words, solve
- * "available physical memory" - round_page(page_range *
- * sizeof(struct vm_page)) = page_range * PAGE_SIZE
- * for page_range.
+ * Determine the lowest and highest physical addresses and, in the case
+ * of VM_PHYSSEG_SPARSE, the exact size of the available physical
+ * memory. vm_phys_early_startup() already checked that phys_avail[]
+ * has at least one element.
*/
+#ifdef VM_PHYSSEG_SPARSE
+ size = phys_avail[1] - phys_avail[0];
+#endif
low_avail = phys_avail[0];
high_avail = phys_avail[1];
- for (i = 0; i < vm_phys_nsegs; i++) {
- if (vm_phys_segs[i].start < low_avail)
- low_avail = vm_phys_segs[i].start;
- if (vm_phys_segs[i].end > high_avail)
- high_avail = vm_phys_segs[i].end;
- }
- /* Skip the first chunk. It is already accounted for. */
for (i = 2; phys_avail[i + 1] != 0; i += 2) {
+#ifdef VM_PHYSSEG_SPARSE
+ size += phys_avail[i + 1] - phys_avail[i];
+#endif
if (phys_avail[i] < low_avail)
low_avail = phys_avail[i];
if (phys_avail[i + 1] > high_avail)
high_avail = phys_avail[i + 1];
}
- first_page = low_avail / PAGE_SIZE;
+ for (i = 0; i < vm_phys_nsegs; i++) {
#ifdef VM_PHYSSEG_SPARSE
- size = 0;
- for (i = 0; i < vm_phys_nsegs; i++)
size += vm_phys_segs[i].end - vm_phys_segs[i].start;
- for (i = 0; phys_avail[i + 1] != 0; i += 2)
- size += phys_avail[i + 1] - phys_avail[i];
-#elif defined(VM_PHYSSEG_DENSE)
+#endif
+ if (vm_phys_segs[i].start < low_avail)
+ low_avail = vm_phys_segs[i].start;
+ if (vm_phys_segs[i].end > high_avail)
+ high_avail = vm_phys_segs[i].end;
+ }
+ first_page = low_avail / PAGE_SIZE;
+#ifdef VM_PHYSSEG_DENSE
size = high_avail - low_avail;
-#else
-#error "Either VM_PHYSSEG_DENSE or VM_PHYSSEG_SPARSE must be defined."
#endif
#ifdef PMAP_HAS_PAGE_ARRAY
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Apr 27, 10:32 AM (16 h, 41 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16093471
Default Alt Text
D48632.diff (2 KB)
Attached To
Mode
D48632: vm_page_startup(): Clarify memory lowest, highest and size computation
Attached
Detach File
Event Timeline
Log In to Comment