Lines Matching +full:os +full:- +full:initiated
1 // SPDX-License-Identifier: GPL-2.0-or-later
23 * DTL_CEDE(0x1): Trace voluntary (OS initiated) virtual
42 PMU_FORMAT_ATTR(event, "config:0-7");
99 * Formula is: ((timbase from DTL entry - boot time) / frequency)
124 struct dtl_entry *aux_copy_buf = (struct dtl_entry *)buf->base; in vpa_dtl_capture_aux()
131 if (buf->head + *n_entries >= buf->threshold) { in vpa_dtl_capture_aux()
132 *n_entries = buf->threshold - buf->head; in vpa_dtl_capture_aux()
133 buf->full = 1; in vpa_dtl_capture_aux()
137 * Copy to AUX buffer from per-thread address in vpa_dtl_capture_aux()
139 memcpy(aux_copy_buf + buf->head, &dtl->buf[index], *n_entries * sizeof(struct dtl_entry)); in vpa_dtl_capture_aux()
141 if (buf->full) { in vpa_dtl_capture_aux()
147 buf->head = 0; in vpa_dtl_capture_aux()
151 buf->head += *n_entries; in vpa_dtl_capture_aux()
172 * to copy data next time in the PMU driver. vpa_pmu_buf->head is moved to
178 * is called to move the aux->head of "struct perf_buffer" to indicate size of
182 * By this approach, all the DTL data will be present as-is in the
183 * perf.data. The data will be pre-processed in perf tools side when doing
203 struct vpa_dtl *dtl = &per_cpu(vpa_dtl_cpu, event->cpu); in vpa_dtl_dump_sample_data()
206 cur_idx = be64_to_cpu(lppaca_of(event->cpu).dtl_idx); in vpa_dtl_dump_sample_data()
207 last_idx = dtl->last_idx; in vpa_dtl_dump_sample_data()
210 last_idx = cur_idx - N_DISPATCH_LOG + 1; in vpa_dtl_dump_sample_data()
212 n_req = cur_idx - last_idx; in vpa_dtl_dump_sample_data()
218 dtl->last_idx = last_idx + n_req; in vpa_dtl_dump_sample_data()
223 aux_buf = perf_aux_output_begin(&vpa_ctx->handle, event); in vpa_dtl_dump_sample_data()
229 if (!aux_buf->boottb_freq_saved) { in vpa_dtl_dump_sample_data()
236 memcpy(aux_buf->base, &boottb_freq, sizeof(boottb_freq)); in vpa_dtl_dump_sample_data()
237 aux_buf->head += 1; in vpa_dtl_dump_sample_data()
238 aux_buf->boottb_freq_saved = 1; in vpa_dtl_dump_sample_data()
244 read_size = N_DISPATCH_LOG - i; in vpa_dtl_dump_sample_data()
246 n_req -= read_size; in vpa_dtl_dump_sample_data()
249 if (aux_buf->full) { in vpa_dtl_dump_sample_data()
251 if ((size + aux_buf->head_size) > aux_buf->size) { in vpa_dtl_dump_sample_data()
252 size = aux_buf->size - aux_buf->head_size; in vpa_dtl_dump_sample_data()
253 perf_aux_output_end(&vpa_ctx->handle, size); in vpa_dtl_dump_sample_data()
254 aux_buf->head = 0; in vpa_dtl_dump_sample_data()
255 aux_buf->head_size = 0; in vpa_dtl_dump_sample_data()
257 aux_buf->head_size += (n_read * sizeof(struct dtl_entry)); in vpa_dtl_dump_sample_data()
258 perf_aux_output_end(&vpa_ctx->handle, n_read * sizeof(struct dtl_entry)); in vpa_dtl_dump_sample_data()
268 if ((size + aux_buf->head_size) > aux_buf->size) { in vpa_dtl_dump_sample_data()
269 size = aux_buf->size - aux_buf->head_size; in vpa_dtl_dump_sample_data()
270 perf_aux_output_end(&vpa_ctx->handle, size); in vpa_dtl_dump_sample_data()
271 aux_buf->head = 0; in vpa_dtl_dump_sample_data()
272 aux_buf->head_size = 0; in vpa_dtl_dump_sample_data()
274 aux_buf->head_size += ((n_req + n_read) * sizeof(struct dtl_entry)); in vpa_dtl_dump_sample_data()
275 /* Move the aux->head to indicate size of data in aux buffer */ in vpa_dtl_dump_sample_data()
276 perf_aux_output_end(&vpa_ctx->handle, (n_req + n_read) * sizeof(struct dtl_entry)); in vpa_dtl_dump_sample_data()
279 aux_buf->full = 0; in vpa_dtl_dump_sample_data()
295 if (event->state != PERF_EVENT_STATE_ACTIVE) in vpa_dtl_hrtimer_handle()
299 period = max_t(u64, NSEC_PER_MSEC, event->hw.sample_period); in vpa_dtl_hrtimer_handle()
308 struct hw_perf_event *hwc = &event->hw; in vpa_dtl_start_hrtimer()
310 period = max_t(u64, NSEC_PER_MSEC, hwc->sample_period); in vpa_dtl_start_hrtimer()
311 hrtimer_start(&hwc->hrtimer, ns_to_ktime(period), HRTIMER_MODE_REL_PINNED); in vpa_dtl_start_hrtimer()
316 struct hw_perf_event *hwc = &event->hw; in vpa_dtl_stop_hrtimer()
318 hrtimer_cancel(&hwc->hrtimer); in vpa_dtl_stop_hrtimer()
324 dtl_global_refc--; in vpa_dtl_reset_global_refc()
339 return -ENOMEM; in vpa_dtl_mem_alloc()
344 return -ENOMEM; in vpa_dtl_mem_alloc()
346 dtl->buf = buf; in vpa_dtl_mem_alloc()
352 struct hw_perf_event *hwc = &event->hw; in vpa_dtl_event_init()
355 if (event->attr.type != event->pmu->type) in vpa_dtl_event_init()
356 return -ENOENT; in vpa_dtl_event_init()
359 return -EACCES; in vpa_dtl_event_init()
363 return -EOPNOTSUPP; in vpa_dtl_event_init()
367 return -EOPNOTSUPP; in vpa_dtl_event_init()
370 switch (event->attr.config) { in vpa_dtl_event_init()
377 return -EINVAL; in vpa_dtl_event_init()
394 return -EBUSY; in vpa_dtl_event_init()
398 if (vpa_dtl_mem_alloc(event->cpu)) { in vpa_dtl_event_init()
400 return -ENOMEM; in vpa_dtl_event_init()
412 hrtimer_setup(&hwc->hrtimer, vpa_dtl_hrtimer_handle, CLOCK_MONOTONIC, HRTIMER_MODE_REL); in vpa_dtl_event_init()
415 * Since hrtimers have a fixed rate, we can do a static freq->period in vpa_dtl_event_init()
418 if (event->attr.freq) { in vpa_dtl_event_init()
419 long freq = event->attr.sample_freq; in vpa_dtl_event_init()
421 event->attr.sample_period = NSEC_PER_SEC / freq; in vpa_dtl_event_init()
422 hwc->sample_period = event->attr.sample_period; in vpa_dtl_event_init()
423 local64_set(&hwc->period_left, hwc->sample_period); in vpa_dtl_event_init()
424 hwc->last_period = hwc->sample_period; in vpa_dtl_event_init()
425 event->attr.freq = 0; in vpa_dtl_event_init()
428 event->destroy = vpa_dtl_reset_global_refc; in vpa_dtl_event_init()
436 struct vpa_dtl *dtl = &per_cpu(vpa_dtl_cpu, event->cpu); in vpa_dtl_event_add()
444 ((u32 *)dtl->buf)[1] = cpu_to_be32(DISPATCH_LOG_BYTES); in vpa_dtl_event_add()
445 dtl->last_idx = 0; in vpa_dtl_event_add()
447 hwcpu = get_hard_smp_processor_id(event->cpu); in vpa_dtl_event_add()
448 addr = __pa(dtl->buf); in vpa_dtl_event_add()
453 event->cpu, hwcpu, ret); in vpa_dtl_event_add()
458 lppaca_of(event->cpu).dtl_idx = 0; in vpa_dtl_event_add()
467 lppaca_of(event->cpu).dtl_enable_mask = event->attr.config; in vpa_dtl_event_add()
476 int hwcpu = get_hard_smp_processor_id(event->cpu); in vpa_dtl_event_del()
477 struct vpa_dtl *dtl = &per_cpu(vpa_dtl_cpu, event->cpu); in vpa_dtl_event_del()
481 kmem_cache_free(dtl_cache, dtl->buf); in vpa_dtl_event_del()
482 dtl->buf = NULL; in vpa_dtl_event_del()
483 lppaca_of(event->cpu).dtl_enable_mask = 0x0; in vpa_dtl_event_del()
496 * Set up pmu-private data structures for an AUX area
504 * - buf->base: aux buffer base address
505 * - buf->head: offset from base address where data will be written to.
506 * - buf->size: Size of allocated memory
511 int i, cpu = event->cpu; in vpa_dtl_setup_aux()
519 if (cpu == -1) in vpa_dtl_setup_aux()
533 buf->base = vmap(pglist, nr_pages, VM_MAP, PAGE_KERNEL); in vpa_dtl_setup_aux()
534 if (!buf->base) in vpa_dtl_setup_aux()
537 buf->nr_pages = nr_pages; in vpa_dtl_setup_aux()
538 buf->snapshot = false; in vpa_dtl_setup_aux()
540 buf->size = nr_pages << PAGE_SHIFT; in vpa_dtl_setup_aux()
541 buf->head = 0; in vpa_dtl_setup_aux()
542 buf->head_size = 0; in vpa_dtl_setup_aux()
543 buf->boottb_freq_saved = 0; in vpa_dtl_setup_aux()
544 buf->threshold = ((buf->size - 32) / sizeof(struct dtl_entry)); in vpa_dtl_setup_aux()
549 * free pmu-private AUX data structures
555 vunmap(buf->base); in vpa_dtl_free_aux()
579 return -ENODEV; in vpa_dtl_init()
585 return -ENODEV; in vpa_dtl_init()
588 r = perf_pmu_register(&vpa_dtl_pmu, vpa_dtl_pmu.name, -1); in vpa_dtl_init()