hwpmc_mod.c (184997) | hwpmc_mod.c (185363) |
---|---|
1/*- 2 * Copyright (c) 2003-2008 Joseph Koshy 3 * Copyright (c) 2007 The FreeBSD Foundation 4 * All rights reserved. 5 * 6 * Portions of this software were developed by A. Joseph Koshy under 7 * sponsorship from the FreeBSD Foundation and Google, Inc. 8 * --- 16 unchanged lines hidden (view full) --- 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * SUCH DAMAGE. 29 * 30 */ 31 32#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2003-2008 Joseph Koshy 3 * Copyright (c) 2007 The FreeBSD Foundation 4 * All rights reserved. 5 * 6 * Portions of this software were developed by A. Joseph Koshy under 7 * sponsorship from the FreeBSD Foundation and Google, Inc. 8 * --- 16 unchanged lines hidden (view full) --- 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * SUCH DAMAGE. 29 * 30 */ 31 32#include <sys/cdefs.h> |
33__FBSDID("$FreeBSD: head/sys/dev/hwpmc/hwpmc_mod.c 184997 2008-11-16 04:21:59Z jkoshy $"); | 33__FBSDID("$FreeBSD: head/sys/dev/hwpmc/hwpmc_mod.c 185363 2008-11-27 09:00:47Z jkoshy $"); |
34 35#include <sys/param.h> 36#include <sys/eventhandler.h> 37#include <sys/jail.h> 38#include <sys/kernel.h> 39#include <sys/kthread.h> 40#include <sys/limits.h> 41#include <sys/lock.h> --- 81 unchanged lines hidden (view full) --- 123 124/* various event handlers */ 125static eventhandler_tag pmc_exit_tag, pmc_fork_tag; 126 127/* Module statistics */ 128struct pmc_op_getdriverstats pmc_stats; 129 130/* Machine/processor dependent operations */ | 34 35#include <sys/param.h> 36#include <sys/eventhandler.h> 37#include <sys/jail.h> 38#include <sys/kernel.h> 39#include <sys/kthread.h> 40#include <sys/limits.h> 41#include <sys/lock.h> --- 81 unchanged lines hidden (view full) --- 123 124/* various event handlers */ 125static eventhandler_tag pmc_exit_tag, pmc_fork_tag; 126 127/* Module statistics */ 128struct pmc_op_getdriverstats pmc_stats; 129 130/* Machine/processor dependent operations */ |
131struct pmc_mdep *md; | 131static struct pmc_mdep *md; |
132 133/* 134 * Hash tables mapping owner processes and target threads to PMCs. 135 */ 136 137struct mtx pmc_processhash_mtx; /* spin mutex */ 138static u_long pmc_processhashmask; 139static LIST_HEAD(pmc_processhash, pmc_process) *pmc_processhash; --- 2573 unchanged lines hidden (view full) --- 2713 2714 /* 2715 * If a valid fd was passed in, try to configure that, 2716 * otherwise if 'fd' was less than zero and there was 2717 * a log file configured, flush its buffers and 2718 * de-configure it. 2719 */ 2720 if (cl.pm_logfd >= 0) | 132 133/* 134 * Hash tables mapping owner processes and target threads to PMCs. 135 */ 136 137struct mtx pmc_processhash_mtx; /* spin mutex */ 138static u_long pmc_processhashmask; 139static LIST_HEAD(pmc_processhash, pmc_process) *pmc_processhash; --- 2573 unchanged lines hidden (view full) --- 2713 2714 /* 2715 * If a valid fd was passed in, try to configure that, 2716 * otherwise if 'fd' was less than zero and there was 2717 * a log file configured, flush its buffers and 2718 * de-configure it. 2719 */ 2720 if (cl.pm_logfd >= 0) |
2721 error = pmclog_configure_log(po, cl.pm_logfd); | 2721 error = pmclog_configure_log(md, po, cl.pm_logfd); |
2722 else if (po->po_flags & PMC_PO_OWNS_LOGFILE) { 2723 pmclog_process_closelog(po); 2724 error = pmclog_flush(po); 2725 if (error == 0) { 2726 LIST_FOREACH(pm, &po->po_pmcs, pm_next) 2727 if (pm->pm_flags & PMC_F_NEEDS_LOGFILE && 2728 pm->pm_state == PMC_STATE_RUNNING) 2729 pmc_stop(pm); --- 1231 unchanged lines hidden (view full) --- 3961/* 3962 * Process saved PC samples. 3963 */ 3964 3965static void 3966pmc_process_samples(int cpu) 3967{ 3968 struct pmc *pm; | 2722 else if (po->po_flags & PMC_PO_OWNS_LOGFILE) { 2723 pmclog_process_closelog(po); 2724 error = pmclog_flush(po); 2725 if (error == 0) { 2726 LIST_FOREACH(pm, &po->po_pmcs, pm_next) 2727 if (pm->pm_flags & PMC_F_NEEDS_LOGFILE && 2728 pm->pm_state == PMC_STATE_RUNNING) 2729 pmc_stop(pm); --- 1231 unchanged lines hidden (view full) --- 3961/* 3962 * Process saved PC samples. 3963 */ 3964 3965static void 3966pmc_process_samples(int cpu) 3967{ 3968 struct pmc *pm; |
3969 int adjri, n, ri; | 3969 int adjri, n; |
3970 struct thread *td; 3971 struct pmc_owner *po; 3972 struct pmc_sample *ps; 3973 struct pmc_classdep *pcd; 3974 struct pmc_samplebuffer *psb; 3975 3976 KASSERT(PCPU_GET(cpuid) == cpu, 3977 ("[pmc,%d] not on the correct CPU pcpu=%d cpu=%d", __LINE__, --- 83 unchanged lines hidden (view full) --- 4061 4062 if (pm == NULL || /* !cfg'ed */ 4063 pm->pm_state != PMC_STATE_RUNNING || /* !active */ 4064 !PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm)) || /* !sampling */ 4065 pm->pm_stalled == 0) /* !stalled */ 4066 continue; 4067 4068 pm->pm_stalled = 0; | 3970 struct thread *td; 3971 struct pmc_owner *po; 3972 struct pmc_sample *ps; 3973 struct pmc_classdep *pcd; 3974 struct pmc_samplebuffer *psb; 3975 3976 KASSERT(PCPU_GET(cpuid) == cpu, 3977 ("[pmc,%d] not on the correct CPU pcpu=%d cpu=%d", __LINE__, --- 83 unchanged lines hidden (view full) --- 4061 4062 if (pm == NULL || /* !cfg'ed */ 4063 pm->pm_state != PMC_STATE_RUNNING || /* !active */ 4064 !PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm)) || /* !sampling */ 4065 pm->pm_stalled == 0) /* !stalled */ 4066 continue; 4067 4068 pm->pm_stalled = 0; |
4069 ri = PMC_TO_ROWINDEX(pm); | |
4070 (*pcd->pcd_start_pmc)(cpu, adjri); 4071 } 4072} 4073 4074/* 4075 * Event handlers. 4076 */ 4077 --- 375 unchanged lines hidden (view full) --- 4453 for (cpu = 0; error == 0 && cpu < maxcpu; cpu++) { 4454 if (!pmc_cpu_is_active(cpu)) 4455 continue; 4456 pmc_select_cpu(cpu); 4457 pmc_pcpu[cpu] = malloc(sizeof(struct pmc_cpu) + 4458 md->pmd_npmc * sizeof(struct pmc_hw *), M_PMC, 4459 M_WAITOK|M_ZERO); 4460 if (md->pmd_pcpu_init) | 4069 (*pcd->pcd_start_pmc)(cpu, adjri); 4070 } 4071} 4072 4073/* 4074 * Event handlers. 4075 */ 4076 --- 375 unchanged lines hidden (view full) --- 4452 for (cpu = 0; error == 0 && cpu < maxcpu; cpu++) { 4453 if (!pmc_cpu_is_active(cpu)) 4454 continue; 4455 pmc_select_cpu(cpu); 4456 pmc_pcpu[cpu] = malloc(sizeof(struct pmc_cpu) + 4457 md->pmd_npmc * sizeof(struct pmc_hw *), M_PMC, 4458 M_WAITOK|M_ZERO); 4459 if (md->pmd_pcpu_init) |
4461 error = md->pmd_pcpu_init(cpu); | 4460 error = md->pmd_pcpu_init(md, cpu); |
4462 for (n = 0; error == 0 && n < md->pmd_nclass; n++) 4463 error = md->pmd_classdep[n].pcd_pcpu_init(md, cpu); 4464 } 4465 pmc_restore_cpu_binding(&pb); 4466 4467 if (error) 4468 return (error); 4469 --- 180 unchanged lines hidden (view full) --- 4650 PMCDBG(MOD,INI,1,"pmc-cleanup cpu=%d pcs=%p", 4651 cpu, pmc_pcpu[cpu]); 4652 if (!pmc_cpu_is_active(cpu) || pmc_pcpu[cpu] == NULL) 4653 continue; 4654 pmc_select_cpu(cpu); 4655 for (c = 0; c < md->pmd_nclass; c++) 4656 md->pmd_classdep[c].pcd_pcpu_fini(md, cpu); 4657 if (md->pmd_pcpu_fini) | 4461 for (n = 0; error == 0 && n < md->pmd_nclass; n++) 4462 error = md->pmd_classdep[n].pcd_pcpu_init(md, cpu); 4463 } 4464 pmc_restore_cpu_binding(&pb); 4465 4466 if (error) 4467 return (error); 4468 --- 180 unchanged lines hidden (view full) --- 4649 PMCDBG(MOD,INI,1,"pmc-cleanup cpu=%d pcs=%p", 4650 cpu, pmc_pcpu[cpu]); 4651 if (!pmc_cpu_is_active(cpu) || pmc_pcpu[cpu] == NULL) 4652 continue; 4653 pmc_select_cpu(cpu); 4654 for (c = 0; c < md->pmd_nclass; c++) 4655 md->pmd_classdep[c].pcd_pcpu_fini(md, cpu); 4656 if (md->pmd_pcpu_fini) |
4658 md->pmd_pcpu_fini(cpu); | 4657 md->pmd_pcpu_fini(md, cpu); |
4659 } 4660 4661 pmc_md_finalize(md); 4662 4663 free(md, M_PMC); 4664 md = NULL; 4665 pmc_restore_cpu_binding(&pb); 4666 } --- 72 unchanged lines hidden --- | 4658 } 4659 4660 pmc_md_finalize(md); 4661 4662 free(md, M_PMC); 4663 md = NULL; 4664 pmc_restore_cpu_binding(&pb); 4665 } --- 72 unchanged lines hidden --- |