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_has_priority_assertion(proc_t p)319 _memstat_proc_has_priority_assertion(proc_t p)
320 {
321 return p->p_memstat_state & P_MEMSTAT_PRIORITY_ASSERTION;
322 }
323
324 static inline bool
_memstat_proc_is_managed(proc_t p)325 _memstat_proc_is_managed(proc_t p)
326 {
327 return p->p_memstat_state & P_MEMSTAT_MANAGED;
328 }
329
330 static inline bool
_memstat_proc_is_frozen(proc_t p)331 _memstat_proc_is_frozen(proc_t p)
332 {
333 return p->p_memstat_state & P_MEMSTAT_FROZEN;
334 }
335
336 static inline bool
_memstat_proc_is_suspended(proc_t p)337 _memstat_proc_is_suspended(proc_t p)
338 {
339 return p->p_memstat_state & P_MEMSTAT_SUSPENDED;
340 }
341
342 static inline void
_memstat_proc_set_suspended(proc_t p)343 _memstat_proc_set_suspended(proc_t p)
344 {
345 LCK_MTX_ASSERT(&proc_list_mlock, LCK_ASSERT_OWNED);
346 if (!_memstat_proc_is_suspended(p)) {
347 p->p_memstat_state |= P_MEMSTAT_SUSPENDED;
348 #if CONFIG_FREEZE
349 if (os_inc_overflow(&memorystatus_suspended_count)) {
350 panic("Overflowed memorystatus_suspended_count");
351 }
352 #endif /* CONFIG_FREEZE */
353 }
354 }
355
356 static inline void
_memstat_proc_set_resumed(proc_t p)357 _memstat_proc_set_resumed(proc_t p)
358 {
359 LCK_MTX_ASSERT(&proc_list_mlock, LCK_ASSERT_OWNED);
360 if (_memstat_proc_is_suspended(p)) {
361 p->p_memstat_state &= ~P_MEMSTAT_SUSPENDED;
362 #if CONFIG_FREEZE
363 if (os_dec_overflow(&memorystatus_suspended_count)) {
364 panic("Underflowed memorystatus_suspended_count");
365 }
366 #endif /* CONFIG_FREEZE */
367 }
368 }
369
370 /*
371 * Return whether the process is to be placed in an elevated band while idle.
372 */
373 static inline bool
_memstat_proc_is_elevated(proc_t p)374 _memstat_proc_is_elevated(proc_t p)
375 {
376 return p->p_memstat_state & P_MEMSTAT_USE_ELEVATED_INACTIVE_BAND;
377 }
378
379 /*
380 * Return whether p's ledger-enforced memlimit is fatal (as last cached by
381 * memorystatus)
382 */
383 static inline bool
_memstat_proc_cached_memlimit_is_fatal(proc_t p)384 _memstat_proc_cached_memlimit_is_fatal(proc_t p)
385 {
386 return p->p_memstat_state & P_MEMSTAT_FATAL_MEMLIMIT;
387 }
388
389 /*
390 * Return whether p's inactive/active memlimit is fatal
391 */
392 static inline bool
_memstat_proc_memlimit_is_fatal(proc_t p,bool is_active)393 _memstat_proc_memlimit_is_fatal(proc_t p, bool is_active)
394 {
395 const uint32_t flag = is_active ?
396 P_MEMSTAT_MEMLIMIT_ACTIVE_FATAL : P_MEMSTAT_MEMLIMIT_INACTIVE_FATAL;
397 return p->p_memstat_state & flag;
398 }
399
400 static inline bool
_memstat_proc_active_memlimit_is_fatal(proc_t p)401 _memstat_proc_active_memlimit_is_fatal(proc_t p)
402 {
403 return _memstat_proc_memlimit_is_fatal(p, true);
404 }
405
406 static inline bool
_memstat_proc_inactive_memlimit_is_fatal(proc_t p)407 _memstat_proc_inactive_memlimit_is_fatal(proc_t p)
408 {
409 return _memstat_proc_memlimit_is_fatal(p, false);
410 }
411
412 #pragma mark Jetsam
413
414 /*
415 * @func memstat_evaluate_page_shortage
416 *
417 * @brief
418 * Evaluate page shortage conditions. Returns true if the jetsam thread should be woken up.
419 *
420 * @param should_enforce_memlimits
421 * Set to true if soft memory limits should be enforced
422 *
423 * @param should_idle_exit
424 * Set to true if idle processes should begin exiting
425 *
426 * @param should_jetsam
427 * Set to true if non-idle processes should be jetsammed
428 *
429 * @param should_reap
430 * Set to true if long-idle processes should be jetsammed
431 */
432 bool memstat_evaluate_page_shortage(
433 bool *should_enforce_memlimits,
434 bool *should_idle_exit,
435 bool *should_jetsam,
436 bool *should_reap);
437
438 /*
439 * In nautical applications, ballast tanks are tanks on boats or submarines
440 * which can be filled with water. When flooded, they provide stability and
441 * reduce buoyancy. When drained (and filled with air), they provide buoyancy.
442 *
443 * In our analogy, the ballast tanks may be drained of unneeded weight (as
444 * occupied by idle processes or processes who have exceeded their memory
445 * limit) and filled with air (available memory). Userspace may toggle between
446 * these two states (filled/drained) depending on system requirements. For
447 * example, drained ballast tanks (i.e. evelated available memory pools) may
448 * have benefits to power and latency. However, applications with large
449 * working sets may need to flood the ballast tanks (i.e. with
450 * anonymous/wired memory) to avoid issues like jetsam loops of daemons that it
451 * has IPC relationships with.
452 *
453 * Mechanically, "draining" the ballast tanks means applying a configurable
454 * offset to the idle and soft available page shortage thresholds. This offset
455 * is then removed when the policy is disengaged.
456 *
457 * The ballast mechanism is intended to be used over long time periods and the
458 * ballast_offset should be sustainable for general applications. If response to
459 * transient spikes in memory demand is desired, the clear-the-decks policy
460 * should be used instead.
461 *
462 * Clients may toggle this behavior via sysctl: kern.memorystatus.ballast_drained
463 */
464 int memorystatus_ballast_control(bool drain);
465
466 /* Synchronously kill a process due to sustained memory pressure */
467 bool memorystatus_kill_on_sustained_pressure(void);
468
469 /* Synchronously kill an idle process */
470 bool memstat_kill_idle_process(memorystatus_kill_cause_t cause,
471 uint64_t *footprint_out);
472
473 /*
474 * Attempt to kill the specified pid with the given reason.
475 * Consumes a reference on the jetsam_reason.
476 */
477 bool memstat_kill_with_jetsam_reason_sync(pid_t pid, os_reason_t jetsam_reason);
478
479 /* Count the number of processes at priority <= max_bucket_index */
480 uint32_t memstat_get_proccnt_upto_priority(uint32_t max_bucket_index);
481
482 /*
483 * @func memstat_get_idle_proccnt
484 * @brief Return the number of idle processes which may be terminated.
485 */
486 uint32_t memstat_get_idle_proccnt(void);
487
488 #pragma mark Freezer
489 #if CONFIG_FREEZE
490 /*
491 * Freezer data types
492 */
493
494 /* An ordered list of freeze or demotion candidates */
495 struct memorystatus_freezer_candidate_list {
496 memorystatus_properties_freeze_entry_v1 *mfcl_list;
497 size_t mfcl_length;
498 };
499
500 struct memorystatus_freeze_list_iterator {
501 bool refreeze_only;
502 proc_t last_p;
503 size_t global_freeze_list_index;
504 };
505
506 /*
507 * Freezer globals
508 */
509 extern struct memorystatus_freezer_stats_t memorystatus_freezer_stats;
510 extern int memorystatus_freezer_use_ordered_list;
511 extern struct memorystatus_freezer_candidate_list memorystatus_global_freeze_list;
512 extern struct memorystatus_freezer_candidate_list memorystatus_global_demote_list;
513 extern uint64_t memorystatus_freezer_thread_next_run_ts;
514 bool memorystatus_is_process_eligible_for_freeze(proc_t p);
515 bool memorystatus_freeze_proc_is_refreeze_eligible(proc_t p);
516
517 proc_t memorystatus_freezer_candidate_list_get_proc(
518 struct memorystatus_freezer_candidate_list *list,
519 size_t index,
520 uint64_t *pid_mismatch_counter);
521 /*
522 * Returns the leader of the p's jetsam coalition
523 * and the role of p in that coalition.
524 */
525 proc_t memorystatus_get_coalition_leader_and_role(proc_t p, int *role_in_coalition);
526 bool memorystatus_freeze_process_is_recommended(const proc_t p);
527
528 /*
529 * Ordered iterator over all freeze candidates.
530 * The iterator should initially be zeroed out by the caller and
531 * can be zeroed out whenever the caller wishes to start from the beginning
532 * of the list again.
533 * Returns PROC_NULL when all candidates have been iterated over.
534 */
535 proc_t memorystatus_freeze_pick_process(struct memorystatus_freeze_list_iterator *iterator);
536
537 /*
538 * Returns the number of processes that the freezer thread should try to freeze
539 * on this wakeup.
540 */
541 size_t memorystatus_pick_freeze_count_for_wakeup(void);
542
543 /*
544 * Configure the freezer for app-based swap mode.
545 * Should be called at boot.
546 */
547 void memorystatus_freeze_configure_for_swap(void);
548 /*
549 * Undo memorystatus_freeze_configure_for_swap
550 */
551 void memorystatus_freeze_disable_swap(void);
552 #endif /* CONFIG_FREEZE */
553
554 #endif /* BSD_KERNEL_PRIVATE */
555
556 #endif /* _KERN_MEMORYSTATUS_INTERNAL_H_ */
557