1 /*
2 * Copyright (c) 2006-2019 Apple Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 *
28 */
29
30 #ifndef _KERN_MEMORYSTATUS_INTERNAL_H_
31 #define _KERN_MEMORYSTATUS_INTERNAL_H_
32
33 /*
34 * Contains memorystatus subsystem definitions that are not
35 * exported outside of the memorystatus subsystem.
36 *
37 * For example, all of the mechanisms used by kern_memorystatus_policy.c
38 * should be defined in this header.
39 */
40
41 #if BSD_KERNEL_PRIVATE
42
43 #include <mach/boolean.h>
44 #include <stdbool.h>
45 #include <os/atomic_private.h>
46 #include <os/base.h>
47 #include <os/log.h>
48 #include <os/overflow.h>
49 #include <kern/locks.h>
50 #include <kern/sched_prim.h>
51 #include <sys/kern_memorystatus.h>
52 #include <sys/kernel_types.h>
53 #include <sys/proc.h>
54 #include <sys/proc_internal.h>
55
56 #if CONFIG_FREEZE
57 #include <sys/kern_memorystatus_freeze.h>
58 #endif /* CONFIG_FREEZE */
59
60 /*
61 * memorystatus subsystem globals
62 */
63 extern uint32_t memorystatus_available_pages;
64 #if CONFIG_JETSAM
65 extern bool jetsam_kill_on_low_swap;
66 #endif /* CONFIG_JETSAM */
67 extern bool kill_on_no_paging_space;
68 extern int block_corpses; /* counter to block new corpses if jetsam purges them */
69 extern int system_procs_aging_band;
70 extern int applications_aging_band;
71 /* the jetsam band which will contain P_MEMSTAT_FROZEN processes */
72 extern int memorystatus_freeze_jetsam_band;
73 #if CONFIG_FREEZE
74 extern unsigned int memorystatus_suspended_count;
75 #endif /* CONFIG_FREEZE */
76 extern uint64_t memorystatus_sysprocs_idle_delay_time;
77 extern uint64_t memorystatus_apps_idle_delay_time;
78
79 /*
80 * TODO(jason): This should really be calculated dynamically by the zalloc
81 * subsystem before we do a zone map exhaustion kill. But the zone_gc
82 * logic is non-trivial, so for now it just sets this global.
83 */
84 extern _Atomic bool memorystatus_zone_map_is_exhausted;
85 /*
86 * TODO(jason): We should get rid of this global
87 * and have the memorystatus thread check for compressor space shortages
88 * itself. However, there are 3 async call sites remaining that require more work to get us there:
89 * 2 of them are in vm_swap_defragment. When it's about to swap in a segment, it checks if that
90 * will cause a compressor space shortage & pre-emptively triggers jetsam. vm_compressor_backing_store
91 * needs to keep track of in-flight swapins due to defrag so we can perform those checks
92 * in the memorystatus thread.
93 * The other is in no_paging_space_action. This is only on macOS right now, but will
94 * be needed on iPad when we run out of swap space. This should be a new kill
95 * reason and we need to add a new health check for it.
96 * We need to maintain the macOS behavior though that we kill no more than 1 process
97 * every 5 seconds.
98 */
99 extern _Atomic bool memorystatus_compressor_space_shortage;
100 /*
101 * TODO(jason): We should also get rid of this global
102 * and check for phantom cache pressure from the memorystatus
103 * thread. But first we need to fix the syncronization in
104 * vm_phantom_cache_check_pressure
105 */
106 extern _Atomic bool memorystatus_phantom_cache_pressure;
107
108 extern _Atomic bool memorystatus_pageout_starved;
109 /*
110 * The actions that the memorystatus thread can perform
111 * when we're low on memory.
112 * See memorystatus_pick_action to see when each action is deployed.
113 */
114 OS_CLOSED_ENUM(memorystatus_action, uint32_t,
115 MEMORYSTATUS_KILL_HIWATER, // Kill 1 highwatermark process
116 MEMORYSTATUS_KILL_AGGRESSIVE, // Do aggressive jetsam
117 MEMORYSTATUS_KILL_TOP_PROCESS, // Kill based on jetsam priority
118 MEMORYSTATUS_WAKE_SWAPPER, // Wake up the swap thread
119 MEMORYSTATUS_PROCESS_SWAPIN_QUEUE, // Compact the swapin queue and move segments to the swapout queue
120 MEMORYSTATUS_KILL_SUSPENDED_SWAPPABLE, // Kill a suspended swap-eligible processes based on jetsam priority
121 MEMORYSTATUS_KILL_SWAPPABLE, // Kill a swap-eligible process (even if it's running) based on jetsam priority
122 MEMORYSTATUS_KILL_IDLE, // Kill an idle process
123 MEMORYSTATUS_KILL_LONG_IDLE, // Kill a long-idle process (reaper)
124 MEMORYSTATUS_KILL_NONE, // Do nothing
125 );
126
127 /*
128 * Structure to hold state for a jetsam thread.
129 * Typically there should be a single jetsam thread
130 * unless parallel jetsam is enabled.
131 */
132 typedef struct jetsam_state_s {
133 bool inited; /* if the thread is initialized */
134 bool limit_to_low_bands; /* limit kills to < JETSAM_PRIORITY_ELEVATED_INACTIVE */
135 int index; /* jetsam thread index */
136 thread_t thread; /* jetsam thread pointer */
137 int jld_idle_kills; /* idle jetsam kill counter for this session */
138 uint32_t errors; /* Error accumulator */
139 bool sort_flag; /* Sort the fg band (idle on macOS) before killing? */
140 bool corpse_list_purged; /* Has the corpse list been purged? */
141 bool post_snapshot; /* Do we need to post a jetsam snapshot after this session? */
142 uint64_t memory_reclaimed; /* Amount of memory that was just reclaimed */
143 uint32_t hwm_kills; /* hwm kill counter for this session */
144 sched_cond_atomic_t jt_wakeup_cond; /* condition var used to synchronize wake/sleep operations for this jetsam thread */
145 } *jetsam_state_t;
146
147 /*
148 * The memorystatus thread monitors these conditions
149 * and will continue to act until the system is considered
150 * healthy.
151 */
152 typedef struct memorystatus_system_health {
153 #if CONFIG_JETSAM
154 bool msh_available_pages_below_soft;
155 bool msh_available_pages_below_idle;
156 bool msh_available_pages_below_critical;
157 bool msh_available_pages_below_reaper;
158 bool msh_compressor_needs_to_swap;
159 bool msh_compressor_is_thrashing;
160 bool msh_filecache_is_thrashing;
161 bool msh_phantom_cache_pressure;
162 bool msh_swappable_compressor_segments_over_limit;
163 bool msh_swapin_queue_over_limit;
164 bool msh_pageout_starved;
165 #endif /* CONFIG_JETSAM */
166 bool msh_compressor_exhausted;
167 bool msh_swap_exhausted;
168 bool msh_swap_low_on_space;
169 bool msh_zone_map_is_exhausted;
170 } memorystatus_system_health_t;
171
172 void memorystatus_log_system_health(const memorystatus_system_health_t *health);
173 bool memorystatus_is_system_healthy(const memorystatus_system_health_t *status);
174 /* Picks a kill cause given an unhealthy system status */
175 uint32_t memorystatus_pick_kill_cause(const memorystatus_system_health_t *status);
176
177 #pragma mark Locks
178
179 extern lck_mtx_t memorystatus_jetsam_broadcast_lock;
180
181 #pragma mark Agressive jetsam tunables
182
183 extern boolean_t memorystatus_jld_enabled; /* Enable jetsam loop detection */
184 extern uint32_t memorystatus_jld_eval_period_msecs; /* Init pass sets this based on device memory size */
185 extern int memorystatus_jld_max_kill_loops; /* How many times should we try and kill up to the target band */
186 extern unsigned int memorystatus_sysproc_aging_aggr_pages; /* Aggressive jetsam pages threshold for sysproc aging policy */
187 extern unsigned int jld_eval_aggressive_count;
188 extern uint64_t jld_timestamp_msecs;
189 extern int jld_idle_kill_candidates;
190
191 #pragma mark No Paging Space Globals
192
193 extern _Atomic uint64_t last_no_space_action_ts;
194 extern uint64_t no_paging_space_action_throttle_delay_ns;
195
196 #pragma mark VM globals read by the memorystatus subsystem
197
198 extern unsigned int vm_page_free_count;
199 extern unsigned int vm_page_active_count;
200 extern unsigned int vm_page_inactive_count;
201 extern unsigned int vm_page_throttled_count;
202 extern unsigned int vm_page_purgeable_count;
203 extern unsigned int vm_page_wire_count;
204 extern unsigned int vm_page_speculative_count;
205 extern uint32_t c_late_swapout_count, c_late_swappedin_count;
206 extern uint32_t c_seg_allocsize;
207 extern bool vm_swapout_thread_running;
208 extern _Atomic bool vm_swapout_wake_pending;
209 #define VM_PAGE_DONATE_DISABLED 0
210 #define VM_PAGE_DONATE_ENABLED 1
211 extern uint32_t vm_page_donate_mode;
212
213 #if CONFIG_JETSAM
214 #define MEMORYSTATUS_LOG_AVAILABLE_PAGES os_atomic_load(&memorystatus_available_pages, relaxed)
215 #else /* CONFIG_JETSAM */
216 #define MEMORYSTATUS_LOG_AVAILABLE_PAGES (vm_page_active_count + vm_page_inactive_count + vm_page_free_count + vm_page_speculative_count)
217 #endif /* CONFIG_JETSAM */
218
219 bool memorystatus_avail_pages_below_pressure(void);
220 bool memorystatus_avail_pages_below_critical(void);
221 #if CONFIG_JETSAM
222 bool memorystatus_swap_over_trigger(uint64_t adjustment_factor);
223 bool memorystatus_swapin_over_trigger(void);
224 #endif /* CONFIG_JETSAM */
225
226 /* Does cause indicate vm or fc thrashing? */
227 bool is_reason_thrashing(unsigned cause);
228 /* Is the zone map almost full? */
229 bool is_reason_zone_map_exhaustion(unsigned cause);
230
231 memorystatus_action_t memorystatus_pick_action(jetsam_state_t state,
232 uint32_t *kill_cause, bool highwater_remaining,
233 bool suspended_swappable_apps_remaining,
234 bool swappable_apps_remaining, int *jld_idle_kills);
235
236 #define MEMSTAT_PERCENT_TOTAL_PAGES(p) ((uint32_t)(p * atop_64(max_mem) / 100))
237
238 /*
239 * Take a (redacted) zprint snapshot along with the jetsam snapshot.
240 */
241 #define JETSAM_ZPRINT_SNAPSHOT (CONFIG_MEMORYSTATUS && (DEBUG || DEVELOPMENT))
242
243 #pragma mark Logging Utilities
244
245 __enum_decl(memorystatus_log_level_t, unsigned int, {
246 MEMORYSTATUS_LOG_LEVEL_DEFAULT = 0,
247 MEMORYSTATUS_LOG_LEVEL_INFO = 1,
248 MEMORYSTATUS_LOG_LEVEL_DEBUG = 2,
249 });
250
251 extern os_log_t memorystatus_log_handle;
252 extern memorystatus_log_level_t memorystatus_log_level;
253
254 /*
255 * NB: Critical memorystatus logs (e.g. jetsam kills) are load-bearing for OS
256 * performance testing infrastructure. Be careful when modifying the log-level for
257 * important system events.
258 *
259 * Memorystatus logs are interpreted by a wide audience. To avoid logging information
260 * that could lead to false diagnoses, INFO and DEBUG messages are only logged if the
261 * system has been configured to do so via `kern.memorystatus_log_level` (sysctl) or
262 * `memorystatus_log_level` (boot-arg).
263 *
264 * os_log supports a mechanism for configuring these properties dynamically; however,
265 * this mechanism is currently unsupported in XNU.
266 *
267 * TODO (JC) Deprecate sysctl/boot-arg and move to subsystem preferences pending:
268 * - rdar://27006343 (Custom kernel log handles)
269 * - rdar://80958044 (Kernel Logging Configuration)
270 */
271 #define _memorystatus_log_with_type(type, format, ...) os_log_with_startup_serial_and_type(memorystatus_log_handle, type, format, ##__VA_ARGS__)
272 #define memorystatus_log(format, ...) _memorystatus_log_with_type(OS_LOG_TYPE_DEFAULT, format, ##__VA_ARGS__)
273 #define memorystatus_log_info(format, ...) if (memorystatus_log_level >= MEMORYSTATUS_LOG_LEVEL_INFO) { _memorystatus_log_with_type(OS_LOG_TYPE_INFO, format, ##__VA_ARGS__); }
274 #define memorystatus_log_debug(format, ...) if (memorystatus_log_level >= MEMORYSTATUS_LOG_LEVEL_DEBUG) { _memorystatus_log_with_type(OS_LOG_TYPE_DEBUG, format, ##__VA_ARGS__); }
275 #define memorystatus_log_error(format, ...) _memorystatus_log_with_type(OS_LOG_TYPE_ERROR, format, ##__VA_ARGS__)
276 #define memorystatus_log_fault(format, ...) _memorystatus_log_with_type(OS_LOG_TYPE_FAULT, format, ##__VA_ARGS__)
277
278 #pragma mark Jetsam Priority Management
279
280 /*
281 * Cancel a process' idle aging
282 * Returns whether a reschedule of the idle demotion thread is needed.
283 */
284 void memstat_update_priority_locked(proc_t p, int priority,
285 memstat_priority_options_t options);
286
287 static inline bool
_memstat_proc_is_aging(proc_t p)288 _memstat_proc_is_aging(proc_t p)
289 {
290 return p->p_memstat_dirty & P_DIRTY_AGING_IN_PROGRESS;
291 }
292
293 static inline bool
_memstat_proc_is_tracked(proc_t p)294 _memstat_proc_is_tracked(proc_t p)
295 {
296 return p->p_memstat_dirty & P_DIRTY_TRACK;
297 }
298
299 static inline bool
_memstat_proc_is_dirty(proc_t p)300 _memstat_proc_is_dirty(proc_t p)
301 {
302 return p->p_memstat_dirty & P_DIRTY_IS_DIRTY;
303 }
304
305 static inline bool
_memstat_proc_is_internal(proc_t p)306 _memstat_proc_is_internal(proc_t p)
307 {
308 return p->p_memstat_state & P_MEMSTAT_INTERNAL;
309 }
310
311 static inline bool
_memstat_proc_can_idle_exit(proc_t p)312 _memstat_proc_can_idle_exit(proc_t p)
313 {
314 return _memstat_proc_is_tracked(p) &&
315 (p->p_memstat_dirty & P_DIRTY_ALLOW_IDLE_EXIT);
316 }
317
318 static inline bool
_memstat_proc_shutdown_on_clean(proc_t p)319 _memstat_proc_shutdown_on_clean(proc_t p)
320 {
321 return _memstat_proc_is_tracked(p) &&
322 (p->p_memstat_dirty & P_DIRTY_SHUTDOWN_ON_CLEAN);
323 }
324
325 static inline bool
_memstat_proc_has_priority_assertion(proc_t p)326 _memstat_proc_has_priority_assertion(proc_t p)
327 {
328 return p->p_memstat_state & P_MEMSTAT_PRIORITY_ASSERTION;
329 }
330
331 static inline bool
_memstat_proc_is_managed(proc_t p)332 _memstat_proc_is_managed(proc_t p)
333 {
334 return p->p_memstat_state & P_MEMSTAT_MANAGED;
335 }
336
337 static inline bool
_memstat_proc_is_frozen(proc_t p)338 _memstat_proc_is_frozen(proc_t p)
339 {
340 return p->p_memstat_state & P_MEMSTAT_FROZEN;
341 }
342
343 static inline bool
_memstat_proc_is_suspended(proc_t p)344 _memstat_proc_is_suspended(proc_t p)
345 {
346 return p->p_memstat_state & P_MEMSTAT_SUSPENDED;
347 }
348
349 static inline void
_memstat_proc_set_suspended(proc_t p)350 _memstat_proc_set_suspended(proc_t p)
351 {
352 LCK_MTX_ASSERT(&proc_list_mlock, LCK_ASSERT_OWNED);
353 if (!_memstat_proc_is_suspended(p)) {
354 p->p_memstat_state |= P_MEMSTAT_SUSPENDED;
355 #if CONFIG_FREEZE
356 if (os_inc_overflow(&memorystatus_suspended_count)) {
357 panic("Overflowed memorystatus_suspended_count");
358 }
359 #endif /* CONFIG_FREEZE */
360 }
361 }
362
363 static inline void
_memstat_proc_set_resumed(proc_t p)364 _memstat_proc_set_resumed(proc_t p)
365 {
366 LCK_MTX_ASSERT(&proc_list_mlock, LCK_ASSERT_OWNED);
367 if (_memstat_proc_is_suspended(p)) {
368 p->p_memstat_state &= ~P_MEMSTAT_SUSPENDED;
369 #if CONFIG_FREEZE
370 if (os_dec_overflow(&memorystatus_suspended_count)) {
371 panic("Underflowed memorystatus_suspended_count");
372 }
373 #endif /* CONFIG_FREEZE */
374 }
375 }
376
377 /*
378 * Return whether the process is to be placed in an elevated band while idle.
379 */
380 static inline bool
_memstat_proc_is_elevated(proc_t p)381 _memstat_proc_is_elevated(proc_t p)
382 {
383 return p->p_memstat_state & P_MEMSTAT_USE_ELEVATED_INACTIVE_BAND;
384 }
385
386 /*
387 * Return whether p's ledger-enforced memlimit is fatal (as last cached by
388 * memorystatus)
389 */
390 static inline bool
_memstat_proc_cached_memlimit_is_fatal(proc_t p)391 _memstat_proc_cached_memlimit_is_fatal(proc_t p)
392 {
393 return p->p_memstat_state & P_MEMSTAT_FATAL_MEMLIMIT;
394 }
395
396 /*
397 * Return whether p's inactive/active memlimit is fatal
398 */
399 static inline bool
_memstat_proc_memlimit_is_fatal(proc_t p,bool is_active)400 _memstat_proc_memlimit_is_fatal(proc_t p, bool is_active)
401 {
402 const uint32_t flag = is_active ?
403 P_MEMSTAT_MEMLIMIT_ACTIVE_FATAL : P_MEMSTAT_MEMLIMIT_INACTIVE_FATAL;
404 return p->p_memstat_state & flag;
405 }
406
407 static inline bool
_memstat_proc_active_memlimit_is_fatal(proc_t p)408 _memstat_proc_active_memlimit_is_fatal(proc_t p)
409 {
410 return _memstat_proc_memlimit_is_fatal(p, true);
411 }
412
413 static inline bool
_memstat_proc_inactive_memlimit_is_fatal(proc_t p)414 _memstat_proc_inactive_memlimit_is_fatal(proc_t p)
415 {
416 return _memstat_proc_memlimit_is_fatal(p, false);
417 }
418
419 #pragma mark Jetsam
420
421 /*
422 * @func memstat_evaluate_page_shortage
423 *
424 * @brief
425 * Evaluate page shortage conditions. Returns true if the jetsam thread should be woken up.
426 *
427 * @param should_enforce_memlimits
428 * Set to true if soft memory limits should be enforced
429 *
430 * @param should_idle_exit
431 * Set to true if idle processes should begin exiting
432 *
433 * @param should_jetsam
434 * Set to true if non-idle processes should be jetsammed
435 *
436 * @param should_reap
437 * Set to true if long-idle processes should be jetsammed
438 */
439 bool memstat_evaluate_page_shortage(
440 bool *should_enforce_memlimits,
441 bool *should_idle_exit,
442 bool *should_jetsam,
443 bool *should_reap);
444
445 /*
446 * In nautical applications, ballast tanks are tanks on boats or submarines
447 * which can be filled with water. When flooded, they provide stability and
448 * reduce buoyancy. When drained (and filled with air), they provide buoyancy.
449 *
450 * In our analogy, the ballast tanks may be drained of unneeded weight (as
451 * occupied by idle processes or processes who have exceeded their memory
452 * limit) and filled with air (available memory). Userspace may toggle between
453 * these two states (filled/drained) depending on system requirements. For
454 * example, drained ballast tanks (i.e. evelated available memory pools) may
455 * have benefits to power and latency. However, applications with large
456 * working sets may need to flood the ballast tanks (i.e. with
457 * anonymous/wired memory) to avoid issues like jetsam loops of daemons that it
458 * has IPC relationships with.
459 *
460 * Mechanically, "draining" the ballast tanks means applying a configurable
461 * offset to the idle and soft available page shortage thresholds. This offset
462 * is then removed when the policy is disengaged.
463 *
464 * The ballast mechanism is intended to be used over long time periods and the
465 * ballast_offset should be sustainable for general applications. If response to
466 * transient spikes in memory demand is desired, the clear-the-decks policy
467 * should be used instead.
468 *
469 * Clients may toggle this behavior via sysctl: kern.memorystatus.ballast_drained
470 */
471 int memorystatus_ballast_control(bool drain);
472
473 /* Synchronously kill a process due to sustained memory pressure */
474 bool memorystatus_kill_on_sustained_pressure(void);
475
476 /* Synchronously kill an idle process */
477 bool memstat_kill_idle_process(memorystatus_kill_cause_t cause,
478 uint64_t *footprint_out);
479
480 /*
481 * Attempt to kill the specified pid with the given reason.
482 * Consumes a reference on the jetsam_reason.
483 */
484 bool memstat_kill_with_jetsam_reason_sync(pid_t pid, os_reason_t jetsam_reason);
485
486 /* Count the number of processes at priority <= max_bucket_index */
487 uint32_t memstat_get_proccnt_upto_priority(uint32_t max_bucket_index);
488
489 /*
490 * @func memstat_get_idle_proccnt
491 * @brief Return the number of idle processes which may be terminated.
492 */
493 uint32_t memstat_get_idle_proccnt(void);
494
495 #pragma mark Freezer
496 #if CONFIG_FREEZE
497 /*
498 * Freezer data types
499 */
500
501 /* An ordered list of freeze or demotion candidates */
502 struct memorystatus_freezer_candidate_list {
503 memorystatus_properties_freeze_entry_v1 *mfcl_list;
504 size_t mfcl_length;
505 };
506
507 struct memorystatus_freeze_list_iterator {
508 bool refreeze_only;
509 proc_t last_p;
510 size_t global_freeze_list_index;
511 };
512
513 /*
514 * Freezer globals
515 */
516 extern struct memorystatus_freezer_stats_t memorystatus_freezer_stats;
517 extern int memorystatus_freezer_use_ordered_list;
518 extern struct memorystatus_freezer_candidate_list memorystatus_global_freeze_list;
519 extern struct memorystatus_freezer_candidate_list memorystatus_global_demote_list;
520 extern uint64_t memorystatus_freezer_thread_next_run_ts;
521 bool memorystatus_is_process_eligible_for_freeze(proc_t p);
522 bool memorystatus_freeze_proc_is_refreeze_eligible(proc_t p);
523
524 proc_t memorystatus_freezer_candidate_list_get_proc(
525 struct memorystatus_freezer_candidate_list *list,
526 size_t index,
527 uint64_t *pid_mismatch_counter);
528 /*
529 * Returns the leader of the p's jetsam coalition
530 * and the role of p in that coalition.
531 */
532 proc_t memorystatus_get_coalition_leader_and_role(proc_t p, int *role_in_coalition);
533 bool memorystatus_freeze_process_is_recommended(const proc_t p);
534
535 /*
536 * Ordered iterator over all freeze candidates.
537 * The iterator should initially be zeroed out by the caller and
538 * can be zeroed out whenever the caller wishes to start from the beginning
539 * of the list again.
540 * Returns PROC_NULL when all candidates have been iterated over.
541 */
542 proc_t memorystatus_freeze_pick_process(struct memorystatus_freeze_list_iterator *iterator);
543
544 /*
545 * Returns the number of processes that the freezer thread should try to freeze
546 * on this wakeup.
547 */
548 size_t memorystatus_pick_freeze_count_for_wakeup(void);
549
550 /*
551 * Configure the freezer for app-based swap mode.
552 * Should be called at boot.
553 */
554 void memorystatus_freeze_configure_for_swap(void);
555 /*
556 * Undo memorystatus_freeze_configure_for_swap
557 */
558 void memorystatus_freeze_disable_swap(void);
559 #endif /* CONFIG_FREEZE */
560
561 #endif /* BSD_KERNEL_PRIVATE */
562
563 #endif /* _KERN_MEMORYSTATUS_INTERNAL_H_ */
564