goto exit;
}
- VM_DEBUG_EVENT(vm_pageout_scan, VM_PRESSURE_EVENT, DBG_FUNC_NONE, target_pid, resident_max, 0, 0);
+ VM_DEBUG_CONSTANT_EVENT(vm_pressure_event, VM_PRESSURE_EVENT, DBG_FUNC_NONE, target_pid, resident_max, 0, 0);
VM_PRESSURE_DEBUG(1, "[vm_pressure] sending event to pid %d with %u resident\n", kn_max->kn_kq->kq_p->p_pid, resident_max);
KNOTE_DETACH(&vm_pressure_klist, kn_max);
struct task* t = TASK_NULL;
int curr_task_importance = 0;
boolean_t consider_knote = FALSE;
+ boolean_t privileged_listener = FALSE;
p = kn->kn_kq->kq_p;
proc_list_lock();
curr_task_importance = task_importance_estimate(t);
- /*
+ /*
+ * Privileged listeners are only considered in the multi-level pressure scheme
+ * AND only if the pressure is increasing.
+ */
+ if (level > 0) {
+
+ if (task_has_been_notified(t, level) == FALSE) {
+
+ /*
+ * Is this a privileged listener?
+ */
+ if (task_low_mem_privileged_listener(t, FALSE, &privileged_listener) == 0) {
+
+ if (privileged_listener) {
+ kn_max = kn;
+ proc_rele(p);
+ goto done_scanning;
+ }
+ }
+ } else {
+ proc_rele(p);
+ continue;
+ }
+ } else if (level == 0) {
+
+ /*
+ * Task wasn't notified when the pressure was increasing and so
+ * no need to notify it that the pressure is decreasing.
+ */
+ if ((task_has_been_notified(t, kVMPressureWarning) == FALSE) && (task_has_been_notified(t, kVMPressureCritical) == FALSE)) {
+ proc_rele(p);
+ continue;
+ }
+ }
+
+ /*
* We don't want a small process to block large processes from
* being notified again. <rdar://problem/7955532>
*/
* b) has importance equal to that of the current selected process but is larger
*/
- if (task_has_been_notified(t, level) == FALSE) {
- consider_knote = TRUE;
- }
+ consider_knote = TRUE;
}
} else {
if ((curr_task_importance > selected_task_importance) ||
* b) has importance equal to that of the current selected process but is larger
*/
- if (task_has_been_notified(t, level) == FALSE) {
- consider_knote = TRUE;
- }
+ consider_knote = TRUE;
}
}
} else if (level == 0) {
if ((curr_task_importance > selected_task_importance) ||
((curr_task_importance == selected_task_importance) && (resident_size > resident_max))) {
- if ((task_has_been_notified(t, kVMPressureWarning) == TRUE) || (task_has_been_notified(t, kVMPressureCritical) == TRUE)) {
- consider_knote = TRUE;
- }
+ consider_knote = TRUE;
}
} else if (level == -1) {
proc_rele(p);
}
+done_scanning:
if (kn_max) {
- VM_PRESSURE_DEBUG(1, "[vm_pressure] sending event to pid %d with %u resident\n", kn_max->kn_kq->kq_p->p_pid, resident_max);
+ VM_DEBUG_CONSTANT_EVENT(vm_pressure_event, VM_PRESSURE_EVENT, DBG_FUNC_NONE, kn_max->kn_kq->kq_p->p_pid, resident_max, 0, 0);
+ VM_PRESSURE_DEBUG(1, "[vm_pressure] sending event to pid %d with %u resident\n", kn_max->kn_kq->kq_p->p_pid, resident_max);
}
return kn_max;