Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F157466156
D23282.id67059.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D23282.id67059.diff
View Options
Index: sys/vm/vm_fault.c
===================================================================
--- sys/vm/vm_fault.c
+++ sys/vm/vm_fault.c
@@ -681,6 +681,59 @@
return (KERN_RESOURCE_SHORTAGE);
}
+/*
+ * Calculate the desired readahead. Handle drop-behind.
+ *
+ * Returns the number of readahead blocks to pass to the pager.
+ */
+static int
+vm_fault_readahead(struct faultstate *fs)
+{
+ int era, nera;
+ u_char behavior;
+
+ KASSERT(fs->lookup_still_valid, ("map unlocked"));
+ era = fs->entry->read_ahead;
+ behavior = vm_map_entry_behavior(fs->entry);
+ if (behavior == MAP_ENTRY_BEHAV_RANDOM) {
+ nera = 0;
+ } else if (behavior == MAP_ENTRY_BEHAV_SEQUENTIAL) {
+ nera = VM_FAULT_READ_AHEAD_MAX;
+ if (fs->vaddr == fs->entry->next_read)
+ vm_fault_dontneed(fs, fs->vaddr, nera);
+ } else if (fs->vaddr == fs->entry->next_read) {
+ /*
+ * This is a sequential fault. Arithmetically
+ * increase the requested number of pages in
+ * the read-ahead window. The requested
+ * number of pages is "# of sequential faults
+ * x (read ahead min + 1) + read ahead min"
+ */
+ nera = VM_FAULT_READ_AHEAD_MIN;
+ if (era > 0) {
+ nera += era + 1;
+ if (nera > VM_FAULT_READ_AHEAD_MAX)
+ nera = VM_FAULT_READ_AHEAD_MAX;
+ }
+ if (era == VM_FAULT_READ_AHEAD_MAX)
+ vm_fault_dontneed(fs, fs->vaddr, nera);
+ } else {
+ /*
+ * This is a non-sequential fault.
+ */
+ nera = 0;
+ }
+ if (era != nera) {
+ /*
+ * A read lock on the map suffices to update
+ * the read ahead count safely.
+ */
+ fs->entry->read_ahead = nera;
+ }
+
+ return (nera);
+}
+
/*
* Wait/Retry if the page is busy. We have to do this if the page is
* either exclusive or shared busy because the vm_pager may be using
@@ -727,7 +780,7 @@
vm_offset_t e_end, e_start;
vm_pindex_t retry_pindex;
vm_prot_t prot, retry_prot;
- int ahead, alloc_req, behind, cluster_offset, era, faultcount;
+ int ahead, alloc_req, behind, cluster_offset, faultcount;
int nera, oom, result, rv;
u_char behavior;
boolean_t wired; /* Passed by reference. */
@@ -991,45 +1044,7 @@
* apply to subsequent objects in the shadow chain.
*/
if (nera == -1 && !P_KILLED(curproc)) {
- KASSERT(fs.lookup_still_valid, ("map unlocked"));
- era = fs.entry->read_ahead;
- behavior = vm_map_entry_behavior(fs.entry);
- if (behavior == MAP_ENTRY_BEHAV_RANDOM) {
- nera = 0;
- } else if (behavior == MAP_ENTRY_BEHAV_SEQUENTIAL) {
- nera = VM_FAULT_READ_AHEAD_MAX;
- if (vaddr == fs.entry->next_read)
- vm_fault_dontneed(&fs, vaddr, nera);
- } else if (vaddr == fs.entry->next_read) {
- /*
- * This is a sequential fault. Arithmetically
- * increase the requested number of pages in
- * the read-ahead window. The requested
- * number of pages is "# of sequential faults
- * x (read ahead min + 1) + read ahead min"
- */
- nera = VM_FAULT_READ_AHEAD_MIN;
- if (era > 0) {
- nera += era + 1;
- if (nera > VM_FAULT_READ_AHEAD_MAX)
- nera = VM_FAULT_READ_AHEAD_MAX;
- }
- if (era == VM_FAULT_READ_AHEAD_MAX)
- vm_fault_dontneed(&fs, vaddr, nera);
- } else {
- /*
- * This is a non-sequential fault.
- */
- nera = 0;
- }
- if (era != nera) {
- /*
- * A read lock on the map suffices to update
- * the read ahead count safely.
- */
- fs.entry->read_ahead = nera;
- }
-
+ nera = vm_fault_readahead(&fs);
/*
* Prepare for unlocking the map. Save the map
* entry's start and end addresses, which are used to
@@ -1040,6 +1055,7 @@
*/
e_start = fs.entry->start;
e_end = fs.entry->end;
+ behavior = vm_map_entry_behavior(fs.entry);
}
/*
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, May 22, 6:48 PM (14 h, 21 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33427771
Default Alt Text
D23282.id67059.diff (3 KB)
Attached To
Mode
D23282: Move readahead into its own function.
Attached
Detach File
Event Timeline
Log In to Comment