xref: /xnu-11215.61.5/bsd/sys/kern_memorystatus_xnu.h (revision 4f1223e81cd707a65cc109d0b8ad6653699da3c4)
1 /*
2  * Copyright (c) 2024 Apple Computer, 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 #include <stdbool.h>
29 #include <stdint.h>
30 
31 #pragma once
32 
33 __BEGIN_DECLS
34 #if XNU_KERNEL_PRIVATE
35 
36 /* TODO: migrate other xnu-private interfaces from kern_memorystatus.h */
37 
38 /*
39  * Return the minimum number of available pages jetsam requires before it
40  * begins killing non-idle processes. This is useful for some pageout
41  * mechanisms to avoid deadlock.
42  */
43 extern uint32_t memorystatus_get_critical_page_shortage_threshold(void);
44 
45 /*
46  * Return the minimum number of available pages jetsam requires before it
47  * begins killing idle processes. This is consumed by the vm pressure
48  * notification system in the absence of the compressor.
49  */
50 extern uint32_t memorystatus_get_idle_exit_page_shortage_threshold(void);
51 
52 /*
53  * Return the minimum number of available pages jetsam requires before it
54  * begins killing processes which have violated their soft memory limit. This
55  * is consumed by the vm pressure notification system in the absence of the
56  * compressor.
57  */
58 extern uint32_t memorystatus_get_soft_memlimit_page_shortage_threshold(void);
59 
60 /*
61  * Return the current number of available pages in the system.
62  */
63 extern uint32_t memorystatus_get_available_page_count(void);
64 
65 /*
66  * Set the available page count and consider engaging response measures (e.g.
67  * waking jetsam thread/pressure-notification thread).
68  */
69 extern void memorystatus_update_available_page_count(uint32_t available_pages);
70 
71 /*
72  * Override fast-jetsam support. If override is enabled, fast-jetsam will be
73  * disabled.
74  */
75 extern void memorystatus_fast_jetsam_override(bool enable_override);
76 
77 #endif /* XNU_KERNEL_PRIVATE */
78 __END_DECLS
79