From owner-svn-src-all@freebsd.org Wed May 23 17:44:30 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5859FEAA87A; Wed, 23 May 2018 17:44:30 +0000 (UTC) (envelope-from mmacy@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E890275DDE; Wed, 23 May 2018 17:44:29 +0000 (UTC) (envelope-from mmacy@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C240C26022; Wed, 23 May 2018 17:44:29 +0000 (UTC) (envelope-from mmacy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w4NHiT5Y072383; Wed, 23 May 2018 17:44:29 GMT (envelope-from mmacy@FreeBSD.org) Received: (from mmacy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w4NHiTB3072381; Wed, 23 May 2018 17:44:29 GMT (envelope-from mmacy@FreeBSD.org) Message-Id: <201805231744.w4NHiTB3072381@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmacy set sender to mmacy@FreeBSD.org using -f From: Matt Macy Date: Wed, 23 May 2018 17:44:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334110 - head/sys/dev/hwpmc X-SVN-Group: head X-SVN-Commit-Author: mmacy X-SVN-Commit-Paths: head/sys/dev/hwpmc X-SVN-Commit-Revision: 334110 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 May 2018 17:44:30 -0000 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;