PERFORCE change 213780 for review
John Baldwin
jhb at FreeBSD.org
Mon Jul 2 16:12:42 UTC 2012
http://p4web.freebsd.org/@@213780?ac=10
Change 213780 by jhb at jhb_jhbbsd on 2012/07/02 16:12:25
An experimental patch to let threads blocking on low memory during
page faults lend priority to pagedaemon.
Affected files ...
.. //depot/projects/smpng/sys/vm/vm_page.c#128 edit
.. //depot/projects/smpng/sys/vm/vm_pageout.c#90 edit
.. //depot/projects/smpng/sys/vm/vm_pageout.h#22 edit
Differences ...
==== //depot/projects/smpng/sys/vm/vm_page.c#128 (text+ko) ====
@@ -1866,6 +1866,7 @@
vm_pages_needed = 1;
wakeup(&vm_pages_needed);
}
+ pagedaemon_lendprio();
msleep(&cnt.v_free_count, &vm_page_queue_free_mtx, PDROP | PVM,
"vmwait", 0);
}
@@ -1890,6 +1891,7 @@
vm_pages_needed = 1;
wakeup(&vm_pages_needed);
}
+ pagedaemon_lendprio();
msleep(&cnt.v_free_count, &vm_page_queue_free_mtx, PDROP | PUSER,
"pfault", 0);
}
@@ -2340,7 +2342,7 @@
(object->type == OBJT_SWAP &&
!vm_pager_has_page(object, m->pindex, NULL, NULL))) {
/*
- * Hypothesis: A cache-elgible page belonging to a
+ * Hypothesis: A cache-eligible page belonging to a
* default object or swap object but without a backing
* store must be zero filled.
*/
==== //depot/projects/smpng/sys/vm/vm_pageout.c#90 (text+ko) ====
@@ -116,6 +116,7 @@
static void vm_pageout_scan(int pass);
struct proc *pageproc;
+static struct thread *pagethread;
static struct kproc_desc page_kp = {
"pagedaemon",
@@ -1558,6 +1559,7 @@
if (vm_pageout_full_stats_interval == 0)
vm_pageout_full_stats_interval = vm_pageout_stats_interval * 4;
+ pagethread = curthread;
swap_pager_swap_init();
pass = 0;
/*
@@ -1574,7 +1576,13 @@
if (vm_pages_needed && !vm_page_count_min()) {
if (!vm_paging_needed())
vm_pages_needed = 0;
+ critical_enter();
+ thread_lock(pagethread);
+ if (pagethread->td_flags & TDF_BORROWING)
+ sched_unlend_prio(pagethread, PRI_MAX);
+ thread_unlock(pagethread);
wakeup(&cnt.v_free_count);
+ critical_exit();
}
if (vm_pages_needed) {
/*
@@ -1614,6 +1622,22 @@
}
/*
+ * Called by threads blocking on pagedaemon to lend their priority to
+ * pagedaemon while waiting for it to free pages.
+ */
+void
+pagedaemon_lendprio(void)
+{
+
+ if (curthread != pagethread) {
+ thread_lock(pagethread);
+ if (pagethread->td_priority > curthread->td_priority)
+ sched_lend_prio(pagethread, curthread->td_priority);
+ thread_unlock(pagethread);
+ }
+}
+
+/*
* Unless the free page queue lock is held by the caller, this function
* should be regarded as advisory. Specifically, the caller should
* not msleep() on &cnt.v_free_count following this function unless
==== //depot/projects/smpng/sys/vm/vm_pageout.h#22 (text+ko) ====
@@ -94,6 +94,7 @@
* Signal pageout-daemon and wait for it.
*/
+void pagedaemon_lendprio(void);
extern void pagedaemon_wakeup(void);
#define VM_WAIT vm_wait()
#define VM_WAITPFAULT vm_waitpfault()
More information about the p4-projects
mailing list