Date: Wed, 23 May 2018 17:44:29 +0000 (UTC) From: Matt Macy <mmacy@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334110 - head/sys/dev/hwpmc Message-ID: <201805231744.w4NHiTB3072381@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mmacy Date: Wed May 23 17:44:29 2018 New Revision: 334110 URL: https://svnweb.freebsd.org/changeset/base/334110 Log: hwppmc: set threadid in callchain records - second part of r334108 Modified: head/sys/dev/hwpmc/hwpmc_logging.c head/sys/dev/hwpmc/hwpmc_mod.c Modified: head/sys/dev/hwpmc/hwpmc_logging.c ============================================================================== --- head/sys/dev/hwpmc/hwpmc_logging.c Wed May 23 17:30:23 2018 (r334109) +++ head/sys/dev/hwpmc/hwpmc_logging.c Wed May 23 17:44:29 2018 (r334110) @@ -181,7 +181,7 @@ static struct mtx pmc_kthread_mtx; /* sleep lock */ * Assertions about the log file format. */ -CTASSERT(sizeof(struct pmclog_callchain) == 6*4 + +CTASSERT(sizeof(struct pmclog_callchain) == 8*4 + PMC_CALLCHAIN_DEPTH_MAX*sizeof(uintfptr_t)); CTASSERT(sizeof(struct pmclog_closelog) == 3*4); CTASSERT(sizeof(struct pmclog_dropnotify) == 3*4); @@ -190,12 +190,12 @@ CTASSERT(sizeof(struct pmclog_map_in) == PATH_MAX + CTASSERT(offsetof(struct pmclog_map_in,pl_pathname) == 4*4 + sizeof(uintfptr_t)); CTASSERT(sizeof(struct pmclog_map_out) == 4*4 + 2*sizeof(uintfptr_t)); -CTASSERT(sizeof(struct pmclog_pcsample) == 6*4 + sizeof(uintfptr_t)); +CTASSERT(sizeof(struct pmclog_pcsample) == 8*4 + sizeof(uintfptr_t)); CTASSERT(sizeof(struct pmclog_pmcallocate) == 6*4); CTASSERT(sizeof(struct pmclog_pmcattach) == 5*4 + PATH_MAX); CTASSERT(offsetof(struct pmclog_pmcattach,pl_pathname) == 5*4); CTASSERT(sizeof(struct pmclog_pmcdetach) == 5*4); -CTASSERT(sizeof(struct pmclog_proccsw) == 5*4 + 8); +CTASSERT(sizeof(struct pmclog_proccsw) == 6*4 + 8); CTASSERT(sizeof(struct pmclog_procexec) == 5*4 + PATH_MAX + sizeof(uintfptr_t)); CTASSERT(offsetof(struct pmclog_procexec,pl_pathname) == 5*4 + @@ -907,8 +907,11 @@ pmclog_process_callchain(struct pmc *pm, struct pmc_sa flags = PMC_CALLCHAIN_TO_CPUFLAGS(ps->ps_cpu,ps->ps_flags); PMCLOG_RESERVE_SAFE(po, CALLCHAIN, recordlen); PMCLOG_EMIT32(ps->ps_pid); + PMCLOG_EMIT32(ps->ps_tid); PMCLOG_EMIT32(pm->pm_id); PMCLOG_EMIT32(flags); + /* unused for now */ + PMCLOG_EMIT32(0); for (n = 0; n < ps->ps_nsamples; n++) PMCLOG_EMITADDR(ps->ps_pc[n]); PMCLOG_DESPATCH_SAFE(po); @@ -1033,7 +1036,7 @@ pmclog_process_pmcdetach(struct pmc *pm, pid_t pid) */ void -pmclog_process_proccsw(struct pmc *pm, struct pmc_process *pp, pmc_value_t v) +pmclog_process_proccsw(struct pmc *pm, struct pmc_process *pp, pmc_value_t v, struct thread *td) { struct pmc_owner *po; @@ -1049,6 +1052,7 @@ pmclog_process_proccsw(struct pmc *pm, struct pmc_proc PMCLOG_EMIT32(pm->pm_id); PMCLOG_EMIT64(v); PMCLOG_EMIT32(pp->pp_proc->p_pid); + PMCLOG_EMIT32(td->td_tid); PMCLOG_DESPATCH(po); } Modified: head/sys/dev/hwpmc/hwpmc_mod.c ============================================================================== --- head/sys/dev/hwpmc/hwpmc_mod.c Wed May 23 17:30:23 2018 (r334109) +++ head/sys/dev/hwpmc/hwpmc_mod.c Wed May 23 17:44:29 2018 (r334110) @@ -1657,7 +1657,7 @@ pmc_process_csw_out(struct thread *td) mtx_pool_unlock_spin(pmc_mtxpool, pm); if (pm->pm_flags & PMC_F_LOG_PROCCSW) - pmclog_process_proccsw(pm, pp, tmp); + pmclog_process_proccsw(pm, pp, tmp, td); } } @@ -4576,10 +4576,13 @@ pmc_process_interrupt(int cpu, int ring, struct pmc *p counter_u64_add(pm->pm_runcount, 1); /* hold onto PMC */ ps->ps_pmc = pm; - if ((td = curthread) && td->td_proc) - ps->ps_pid = td->td_proc->p_pid; - else - ps->ps_pid = -1; + ps->ps_pid = -1; + ps->ps_tid = -1; + if ((td = curthread) != NULL) { + ps->ps_tid = td->td_tid; + if (td->td_proc) + ps->ps_pid = td->td_proc->p_pid; + } ps->ps_cpu = cpu; ps->ps_td = td; ps->ps_flags = inuserspace ? PMC_CC_F_USERSPACE : 0;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201805231744.w4NHiTB3072381>