]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/kperf/task_samplers.c
xnu-4903.241.1.tar.gz
[apple/xnu.git] / osfmk / kperf / task_samplers.c
index ae49da4b420f3706a5db52431ead499d6b03b73c..3d521b782988fd30d499f5097cc7aa0371afc517 100644 (file)
 
 #include <kern/task.h>
 
-extern boolean_t workqueue_get_pwq_exceeded(void *v, boolean_t *exceeded_total,
-                                            boolean_t *exceeded_constrained);
-extern boolean_t memorystatus_proc_is_dirty_unsafe(void *v);
+extern void memorystatus_proc_flags_unsafe(void * v, boolean_t *is_dirty,
+               boolean_t *is_dirty_tracked, boolean_t *allow_idle_exit);
 
 void
-kperf_task_snapshot_sample(struct kperf_task_snapshot *tksn,
-                           struct kperf_context *ctx)
+kperf_task_snapshot_sample(task_t task, struct kperf_task_snapshot *tksn)
 {
-       thread_t thread;
-       task_t task;
-       boolean_t wq_state_available = FALSE;
-       boolean_t exceeded_total, exceeded_constrained;
-
        BUF_INFO(PERF_TK_SNAP_SAMPLE | DBG_FUNC_START);
 
        assert(tksn != NULL);
-       assert(ctx != NULL);
-
-       thread = ctx->cur_thread;
-       task = get_threadtask(thread);
 
        tksn->kptksn_flags = 0;
        if (task->effective_policy.tep_darwinbg) {
@@ -65,26 +54,18 @@ kperf_task_snapshot_sample(struct kperf_task_snapshot *tksn,
                tksn->kptksn_flags |= KPERF_TASK_FLAG_BOOSTED;
        }
 #if CONFIG_MEMORYSTATUS
-       if (memorystatus_proc_is_dirty_unsafe(task->bsd_info)) {
+       boolean_t dirty = FALSE, dirty_tracked = FALSE, allow_idle_exit = FALSE;
+       memorystatus_proc_flags_unsafe(task->bsd_info, &dirty, &dirty_tracked, &allow_idle_exit);
+       if (dirty) {
                tksn->kptksn_flags |= KPERF_TASK_FLAG_DIRTY;
        }
-#endif
-
-       if (task->bsd_info) {
-               wq_state_available =
-                       workqueue_get_pwq_exceeded(task->bsd_info, &exceeded_total,
-                                                  &exceeded_constrained);
+       if (dirty_tracked) {
+               tksn->kptksn_flags |= KPERF_TASK_FLAG_DIRTY_TRACKED;
        }
-       if (wq_state_available) {
-               tksn->kptksn_flags |= KPERF_TASK_FLAG_WQ_FLAGS_VALID;
-
-               if (exceeded_total) {
-                       tksn->kptksn_flags |= KPERF_TASK_FLAG_WQ_EXCEEDED_TOTAL;
-               }
-               if (exceeded_constrained) {
-                       tksn->kptksn_flags |= KPERF_TASK_FLAG_WQ_EXCEEDED_CONSTRAINED;
-               }
+       if (allow_idle_exit) {
+               tksn->kptksn_flags |= KPERF_TASK_ALLOW_IDLE_EXIT;
        }
+#endif
 
        tksn->kptksn_suspend_count = task->suspend_count;
        tksn->kptksn_pageins = task->pageins;
@@ -116,3 +97,11 @@ kperf_task_snapshot_log(struct kperf_task_snapshot *tksn)
                                        LOWER_32(tksn->kptksn_system_time_in_terminated_threads));
 #endif /* defined(__LP64__) */
 }
+
+void
+kperf_task_info_log(struct kperf_context *ctx)
+{
+       assert(ctx != NULL);
+
+       BUF_DATA(PERF_TK_INFO_DATA, ctx->cur_pid);
+}