]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/kperf/kperf_timer.c
xnu-4903.231.4.tar.gz
[apple/xnu.git] / osfmk / kperf / kperf_timer.c
index a6cf3c2e333b3d9a69a7bb86f8a45a503cbe9521..49c16419c64700c6a9957ec01f1b80178b4186d8 100644 (file)
@@ -105,8 +105,6 @@ static void
 kperf_sample_cpu(struct kperf_timer *timer, bool system_sample,
                bool only_system)
 {
-       struct kperf_context ctx;
-
        assert(timer != NULL);
 
        /* Always cut a tracepoint to show a sample event occurred */
@@ -115,14 +113,20 @@ kperf_sample_cpu(struct kperf_timer *timer, bool system_sample,
        int ncpu = cpu_number();
 
        struct kperf_sample *intbuf = kperf_intr_sample_buffer();
+#if DEVELOPMENT || DEBUG
+       intbuf->sample_time = mach_absolute_time();
+#endif /* DEVELOPMENT || DEBUG */
 
        /* On a timer, we can see the "real" current thread */
-       ctx.cur_thread = current_thread();
-       ctx.cur_pid = task_pid(get_threadtask(ctx.cur_thread));
-
-       /* who fired */
-       ctx.trigger_type = TRIGGER_TYPE_TIMER;
-       ctx.trigger_id = (unsigned int)(timer - kperf_timerv);
+       thread_t thread = current_thread();
+       task_t task = get_threadtask(thread);
+       struct kperf_context ctx = {
+               .cur_thread = thread,
+               .cur_task = task,
+               .cur_pid = task_pid(task),
+               .trigger_type = TRIGGER_TYPE_TIMER,
+               .trigger_id = (unsigned int)(timer - kperf_timerv),
+       };
 
        if (ctx.trigger_id == pet_timer_id && ncpu < machine_info.logical_cpu_max) {
                kperf_tid_on_cpus[ncpu] = thread_tid(ctx.cur_thread);
@@ -169,6 +173,9 @@ kperf_timer_handler(void *param0, __unused void *param1)
        }
 
        timer->active = 1;
+#if DEVELOPMENT || DEBUG
+       timer->fire_time = mach_absolute_time();
+#endif /* DEVELOPMENT || DEBUG */
 
        /* along the lines of do not ipi if we are all shutting down */
        if (kperf_sampling_status() == KPERF_SAMPLING_SHUTDOWN) {
@@ -188,7 +195,7 @@ kperf_timer_handler(void *param0, __unused void *param1)
        /*
         * IPI other cores only if the action has non-system samplers.
         */
-       if (kperf_sample_has_non_system(timer->actionid)) {
+       if (kperf_action_has_non_system(timer->actionid)) {
                /*
                 * If the core that's handling the timer is not scheduling
                 * threads, only run system samplers.