Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F178117309
D11000.1796016268.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
D11000.1796016268.diff
View Options
Index: head/sys/vm/vm_page.c
===================================================================
--- head/sys/vm/vm_page.c
+++ head/sys/vm/vm_page.c
@@ -573,8 +573,13 @@
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];
- page_range = size / (PAGE_SIZE + sizeof(struct vm_page));
#elif defined(VM_PHYSSEG_DENSE)
+ size = high_avail - low_avail;
+#else
+#error "Either VM_PHYSSEG_DENSE or VM_PHYSSEG_SPARSE must be defined."
+#endif
+
+#ifdef VM_PHYSSEG_DENSE
/*
* In the VM_PHYSSEG_DENSE case, the number of pages can account for
* the overhead of a page structure per page only if vm_page_array is
@@ -582,14 +587,27 @@
* allocate page structures representing the physical memory
* underlying vm_page_array, even though they will not be used.
*/
- if (new_end == high_avail)
- page_range = (high_avail - low_avail) / (PAGE_SIZE +
- sizeof(struct vm_page));
+ if (new_end != high_avail)
+ page_range = size / PAGE_SIZE;
else
- page_range = high_avail / PAGE_SIZE - first_page;
-#else
-#error "Either VM_PHYSSEG_DENSE or VM_PHYSSEG_SPARSE must be defined."
#endif
+ {
+ page_range = size / (PAGE_SIZE + sizeof(struct vm_page));
+
+ /*
+ * If the partial bytes remaining are large enough for
+ * a page (PAGE_SIZE) without a corresponding
+ * 'struct vm_page', then new_end will contain an
+ * extra page after subtracting the length of the VM
+ * page array. Compensate by subtracting an extra
+ * page from new_end.
+ */
+ if (size % (PAGE_SIZE + sizeof(struct vm_page)) >= PAGE_SIZE) {
+ if (new_end == high_avail)
+ high_avail -= PAGE_SIZE;
+ new_end -= PAGE_SIZE;
+ }
+ }
end = new_end;
/*
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 30, 5:24 AM (20 h, 57 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
42101110
Default Alt Text
D11000.1796016268.diff (1 KB)
Attached To
Mode
D11000: Fix an off-by-one error in the VM page array on some systems.
Attached
Detach File
Event Timeline