static int xenoprof_setup(void) { int ret; if ( (ret = map_xenoprof_buffer(MAX_XENOPROF_SAMPLES)) ) return ret; if ( (ret = bind_virq()) ) { release_buffer_array(xenoprof_buf, nbuf); return ret; } if (xenoprof_is_primary) { /* Define dom0 as an active domain if not done yet */ if (!active_defined) { domid_t domid; ret = HYPERVISOR_xenoprof_op( XENOPROF_reset_active_list, NULL); if (ret) goto err; domid = 0; ret = HYPERVISOR_xenoprof_op( XENOPROF_set_active, &domid); if (ret) goto err; active_defined = 1; } if (oprofile_backtrace_depth > 0) { ret = HYPERVISOR_xenoprof_op(XENOPROF_set_backtrace, &oprofile_backtrace_depth); if (ret) oprofile_backtrace_depth = 0; } ret = HYPERVISOR_xenoprof_op(XENOPROF_reserve_counters, NULL); if (ret) goto err; xenoprof_arch_counter(); ret = HYPERVISOR_xenoprof_op(XENOPROF_setup_events, NULL); if (ret) goto err; } ret = HYPERVISOR_xenoprof_op(XENOPROF_enable_virq, NULL); if (ret) goto err; xenoprof_enabled = 1; return 0; err: unbind_virq(); release_buffer_array(xenoprof_buf, nbuf); return ret; }
static int xenoprof_setup(void) { int ret; int i; ret = bind_virq(); if (ret) return ret; if (is_primary) { struct xenoprof_counter counter; /* Define dom0 as an active domain if not done yet */ if (!active_defined) { domid_t domid; ret = HYPERVISOR_xenoprof_op(XENOPROF_reset_active_list, NULL); if (ret) goto err; domid = 0; ret = HYPERVISOR_xenoprof_op(XENOPROF_set_active, &domid); if (ret) goto err; active_defined = 1; } ret = HYPERVISOR_xenoprof_op(XENOPROF_reserve_counters, NULL); if (ret) goto err; for (i=0; i<num_events; i++) { counter.ind = i; counter.count = (uint64_t)counter_config[i].count; counter.enabled = (uint32_t)counter_config[i].enabled; counter.event = (uint32_t)counter_config[i].event; counter.kernel = (uint32_t)counter_config[i].kernel; counter.user = (uint32_t)counter_config[i].user; counter.unit_mask = (uint64_t)counter_config[i].unit_mask; HYPERVISOR_xenoprof_op(XENOPROF_counter, &counter); } ret = HYPERVISOR_xenoprof_op(XENOPROF_setup_events, NULL); if (ret) goto err; } ret = HYPERVISOR_xenoprof_op(XENOPROF_enable_virq, NULL); if (ret) goto err; xenoprof_enabled = 1; return 0; err: unbind_virq(); return ret; }
static void xenoprof_shutdown(void) { xenoprof_enabled = 0; HYPERVISOR_xenoprof_op(XENOPROF_disable_virq, NULL); if (is_primary) { HYPERVISOR_xenoprof_op(XENOPROF_release_counters, NULL); active_defined = 0; } unbind_virq(); }
static int bind_virq(void) { unsigned int i; int result; for_each_online_cpu(i) { result = bind_virq_to_irqaction(VIRQ_XENOPROF, i, &ovf_action); if (result < 0) { unbind_virq(); return result; } ovf_irq[i] = result; } return 0; }
static void xenoprof_shutdown(void) { xenoprof_enabled = 0; WARN_ON(HYPERVISOR_xenoprof_op(XENOPROF_disable_virq, NULL)); if (xenoprof_is_primary) { WARN_ON(HYPERVISOR_xenoprof_op(XENOPROF_release_counters, NULL)); active_defined = 0; } unbind_virq(); xenoprof_arch_unmap_shared_buffer(&shared_buffer); if (xenoprof_is_primary) unmap_passive_list(); release_buffer_array(xenoprof_buf, nbuf); }
static int bind_virq(void) { int i, result; for_each_cpu(i) { result = bind_virq_to_irqhandler(VIRQ_XENOPROF, i, xenoprof_ovf_interrupt, SA_INTERRUPT, "xenoprof", NULL); if (result < 0) { unbind_virq(); return result; } ovf_irq[i] = result; } return 0; }