1 #ifndef MEMORYSTATUS_ASSERTION_HELPERS_H
2 #define MEMORYSTATUS_ASSERTION_HELPERS_H
7 #define ASSERTION_STATE_IS_SET true
8 #define ASSERTION_STATE_IS_RELINQUISHED false
10 /* Helper functions for setting and checking memorystatus assertions
15 * Set the jetsam priority and user data for a process.
17 * If this request is assertion driven, the kernel will
18 * set the process's assertion priority.
20 * If this request is not assertion driven, the kernel
21 * will set the process's requested priority.
23 * The kernel will then apply policy and move the process
24 * to the appropriate jetsam priority.
26 * Returns: 0 on success
30 set_priority(pid_t pid
, int32_t priority
, uint64_t user_data
, boolean_t is_assertion_driven
);
33 * Return: true on success
34 * false on failure --> this asserts a failure and quits test
37 check_properties(pid_t pid
, int32_t expected_priority
, int32_t expected_limit_mb
, uint64_t expected_user_data
, boolean_t expected_assertion_state
, const char *test
);
40 * Set the active and inactive memlimits for a process.
41 * Set the fatalness for each limit.
43 * Returns: 0 on success
49 int32_t active_limit_mb
, int32_t inactive_limit_mb
,
50 boolean_t active_is_fatal
, boolean_t inactive_is_fatal
);
53 * Returns: 0 on success
57 set_assertion_priority(pid_t pid
, int32_t priority
, uint64_t user_data
);
60 * Returns: 0 on success
64 relinquish_assertion_priority(pid_t pid
, uint64_t user_data
);
67 * Get the priority properties for a single process.
69 * This returns the process's effective jetsam priority, jetsam limit,
70 * user_data (not kernel related), and proc's kernel state.
71 * If this call fails, there is no reason to continue the test.
73 * Return: true on success
74 * false on failure --> this asserts fail and test quits
77 get_priority_props(pid_t pid
, boolean_t verbose
, int32_t *priority
, int32_t *limit_mb
, uint64_t *user_data
, uint32_t *state
);
81 * state: kernel state bits from the get_priority_props() call
82 * expected_assertion_state:
83 * true if process should be holding an assertion state.
84 * false if no assertion state is held (eg: relinquished).
86 * Return true: verification passed
87 * false: verification failed
90 verify_assertion_state(uint32_t state
, boolean_t expected_assertion_state
);
92 #endif /* MEMORYSTATUS_ASSERTION_HELPERS_H */