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 */
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);
}
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) {
/*
* 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.