]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/sys/kern_memorystatus_freeze.h
xnu-7195.101.1.tar.gz
[apple/xnu.git] / bsd / sys / kern_memorystatus_freeze.h
index dd01e09ce8f2efd2e6049fc3477bcd645b024cf1..c962d09490cbc3ac95d7616703cb453638840312 100644 (file)
@@ -58,6 +58,7 @@ extern unsigned int memorystatus_freeze_private_shared_pages_ratio; /* Ratio of
 extern unsigned int memorystatus_suspended_count;
 extern unsigned int memorystatus_thaw_count; /* # of processes that have been thawed in the current interval. */
 extern unsigned int memorystatus_refreeze_eligible_count; /* # of processes currently thawed i.e. have state on disk & in-memory */
+extern uint32_t memorystatus_freeze_current_interval; /* Monotonically increasing interval id. */
 
 void memorystatus_freeze_init(void);
 extern int  memorystatus_freeze_process_sync(proc_t p);
@@ -115,6 +116,67 @@ int memorystatus_freezer_control(int32_t flags, user_addr_t buffer, size_t buffe
 void memorystatus_freeze_init_proc(proc_t p);
 errno_t memorystatus_get_process_is_frozen(pid_t pid, int *is_freezable);
 
+/* Freezer counters collected for telemtry */
+struct memorystatus_freezer_stats_t {
+       /*
+        * # of processes that we've considered freezing.
+        * Used to normalize the error reasons below.
+        */
+       uint64_t mfs_process_considered_count;
+
+       /*
+        * The following counters track how many times we've failed to freeze
+        * a process because of a specific FREEZER_ERROR.
+        */
+       /* EXCESS_SHARED_MEMORY */
+       uint64_t mfs_error_excess_shared_memory_count;
+       /* LOW_PRIVATE_SHARED_RATIO */
+       uint64_t mfs_error_low_private_shared_ratio_count;
+       /* NO_COMPRESSOR_SPACE */
+       uint64_t mfs_error_no_compressor_space_count;
+       /* NO_SWAP_SPACE */
+       uint64_t mfs_error_no_swap_space_count;
+       /* pages < memorystatus_freeze_pages_min */
+       uint64_t mfs_error_below_min_pages_count;
+       /* dasd determined it was unlikely to be relaunched. */
+       uint64_t mfs_error_low_probability_of_use_count;
+       /* transient reasons (like inability to acquire a lock). */
+       uint64_t mfs_error_other_count;
+
+       /*
+        * # of times that we saw memorystatus_available_pages <= memorystatus_freeze_threshold.
+        * Used to normalize skipped_full_count and shared_mb_high_count.
+        */
+       uint64_t mfs_below_threshold_count;
+
+       /* Skipped running the freezer because we were out of slots */
+       uint64_t mfs_skipped_full_count;
+
+       /* Skipped running the freezer because we were over the shared mb limit*/
+       uint64_t mfs_skipped_shared_mb_high_count;
+
+       /*
+        * How many pages have not been sent to swap because they were in a shared object?
+        * This is being used to gather telemtry so we can understand the impact we'd have
+        * on our NAND budget if we did swap out these pages.
+        */
+       uint64_t mfs_shared_pages_skipped;
+
+       /*
+        * A running sum of the total number of bytes sent to NAND during
+        * refreeze operations since boot.
+        */
+       uint64_t mfs_bytes_refrozen;
+       /* The number of refreeze operations since boot */
+       uint64_t mfs_refreeze_count;
+
+       /* The number of proceses which have been frozen at least once in the current interval. */
+       uint64_t mfs_processes_frozen;
+       /* THe number of processes which have been thawed at least once in the current interval. */
+       uint64_t mfs_processes_thawed;
+};
+extern struct memorystatus_freezer_stats_t memorystatus_freezer_stats;
+
 #endif /* CONFIG_FREEZE */
 
 #endif /* XNU_KERNEL_PRIVATE */