From nobody Sat May 06 17:49:49 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4QDFSF4GWMz49sl1; Sat, 6 May 2023 17:49:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4QDFSF2z9Wz3GGB; Sat, 6 May 2023 17:49:49 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1683395389; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/oHp43lVVxxnq5TC0StC6gjIyLlw7YlmwbOvNGXB4PE=; b=EC2Np4skNZsmXOPI4l42k+xtFcV3RHWF5R5ONR67qHBv03ZfUPypLoHqLAWsccl72UaTsy /iTXWZbpiTxZhgeSPNB6PPNwgjSFVieT/uPoSWEaKoTAPFbj4Jy5fAPsuo/7EpaORyaYNS rhxfob+kz/GLliPyVMVt2rTMpKfxvZcatbCGVKiDW0jRuoCcNKs9bHILxDQ/dVFggvKOSk T+goOEq6Uwp9BJNfRd6WUYYpBITLEUS4lr8HaDFybvHhVYJfIc7UnbPM0RTtPEwpQic5i6 aitSjm5HiQ/XIUX+R8E8FQkG2nu9vMjo/8J7cB4u/vV09EtL/RWfPKwwXI6Grg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1683395389; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/oHp43lVVxxnq5TC0StC6gjIyLlw7YlmwbOvNGXB4PE=; b=x3hHgcGO0PAw+tD4XQthmwobhZDqtAA1E2FCm8YLSi4aWliAP8hS/l1s4kvtrouew4Aap5 ksP+xGMNEstMMEEFnpGPDb6obY+FP63wvthv13rytP62sllLEtcks79b6cH/XC8kv10s+I k2ehbi8il1CIpMQXaTqOlp73/RqP8hBGUbZRpz1uiaXzGVBis2TzXKq+ZSopjK0b2gXWmy VSyauM4QHNP/g/jxprK8DZbbLUJsz+MGI7ANE9OEyYbgFZse9yS7vicugD4K63WgyVYkay 7Rc3j6RkpTAqy5DldTD9G0QAMNT8DPGgsW1H+wB5sllziarmffUl4/g76H7zCg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1683395389; a=rsa-sha256; cv=none; b=k2K/QimOoFepmMIJHYMh+yEtEOqQNkfqEN9AJy+oW6PHfH9I6UMh2hwYVEPbb6j3zChXys ijCDC2LhojH/xq6NyB1vwuXknBFhM1HyefIJD6ppOUZ/0zWE+hyLEj8tkUxpXJp20IoDfg bInxUNZk2mComxtPY3EK0kQBLy+9xLZmhpXexgGREXaJXeCFyMH1CylZgjgmRYkN3DqZid fhnYIEiI8SQ6mQKyTfi2KhgR95qhLFfqWcHLsUUdo2egIY2LNi2HlVxwg7TtU086J1zSan UY3lBMMB0gOOxgTY0iPc/9P2KivJCG1Cn1XlWSW3aAoFQxVlpPIm4kJa2h6Ikw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4QDFSF1wPbzm8l; Sat, 6 May 2023 17:49:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 346HnnZP018013; Sat, 6 May 2023 17:49:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 346Hnn30018012; Sat, 6 May 2023 17:49:49 GMT (envelope-from git) Date: Sat, 6 May 2023 17:49:49 GMT Message-Id: <202305061749.346Hnn30018012@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mitchell Horne Subject: git: 3a7c9fc01bda - main - hwpmc_logging: less macro magic for type names List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3a7c9fc01bdae13edbd5724745b748e6a61065eb Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=3a7c9fc01bdae13edbd5724745b748e6a61065eb commit 3a7c9fc01bdae13edbd5724745b748e6a61065eb Author: Mitchell Horne AuthorDate: 2023-05-05 21:59:27 +0000 Commit: Mitchell Horne CommitDate: 2023-05-06 17:49:19 +0000 hwpmc_logging: less macro magic for type names Provide the log type names in their entirely, rather than relying on the macro to prepend the prefix. This improves their searchability; for example, if I see PMCLOG_TYPE_PMCALLOCATE in libpmc I will now be able to find where that is emitted in the kernel with a simple grep. Reviewed by: jkoshy, emaste MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D39911 --- sys/dev/hwpmc/hwpmc_logging.c | 57 +++++++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/sys/dev/hwpmc/hwpmc_logging.c b/sys/dev/hwpmc/hwpmc_logging.c index 1c48089a58dc..e0ff87619137 100644 --- a/sys/dev/hwpmc/hwpmc_logging.c +++ b/sys/dev/hwpmc/hwpmc_logging.c @@ -110,9 +110,7 @@ static struct mtx pmc_kthread_mtx; /* sleep lock */ * Log file record constructors. */ #define _PMCLOG_TO_HEADER(T,L) \ - ((PMCLOG_HEADER_MAGIC << 24) | \ - (PMCLOG_TYPE_ ## T << 16) | \ - ((L) & 0xFFFF)) + ((PMCLOG_HEADER_MAGIC << 24) | (T << 16) | ((L) & 0xFFFF)) /* reserve LEN bytes of space and initialize the entry header */ #define _PMCLOG_RESERVE_SAFE(PO,TYPE,LEN,ACTION, TSC) do { \ @@ -716,7 +714,7 @@ pmclog_configure_log(struct pmc_mdep *md, struct pmc_owner *po, int logfd) PROC_UNLOCK(p); nanotime(&ts); /* create a log initialization entry */ - PMCLOG_RESERVE_WITH_ERROR(po, INITIALIZE, + PMCLOG_RESERVE_WITH_ERROR(po, PMCLOG_TYPE_INITIALIZE, sizeof(struct pmclog_initialize)); PMCLOG_EMIT32(PMC_VERSION); PMCLOG_EMIT32(md->pmd_cputype); @@ -916,7 +914,7 @@ pmclog_process_callchain(struct pmc *pm, struct pmc_sample *ps) ps->ps_nsamples * sizeof(uintfptr_t); po = pm->pm_owner; flags = PMC_CALLCHAIN_TO_CPUFLAGS(ps->ps_cpu,ps->ps_flags); - PMCLOG_RESERVE_SAFE(po, CALLCHAIN, recordlen, ps->ps_tsc); + PMCLOG_RESERVE_SAFE(po, PMCLOG_TYPE_CALLCHAIN, recordlen, ps->ps_tsc); PMCLOG_EMIT32(ps->ps_pid); PMCLOG_EMIT32(ps->ps_tid); PMCLOG_EMIT32(pm->pm_id); @@ -929,14 +927,16 @@ pmclog_process_callchain(struct pmc *pm, struct pmc_sample *ps) void pmclog_process_closelog(struct pmc_owner *po) { - PMCLOG_RESERVE(po,CLOSELOG,sizeof(struct pmclog_closelog)); + PMCLOG_RESERVE(po, PMCLOG_TYPE_CLOSELOG, + sizeof(struct pmclog_closelog)); PMCLOG_DESPATCH_SYNC(po); } void pmclog_process_dropnotify(struct pmc_owner *po) { - PMCLOG_RESERVE(po,DROPNOTIFY,sizeof(struct pmclog_dropnotify)); + PMCLOG_RESERVE(po, PMCLOG_TYPE_DROPNOTIFY, + sizeof(struct pmclog_dropnotify)); PMCLOG_DESPATCH(po); } @@ -952,7 +952,7 @@ pmclog_process_map_in(struct pmc_owner *po, pid_t pid, uintfptr_t start, recordlen = offsetof(struct pmclog_map_in, pl_pathname) + pathlen; - PMCLOG_RESERVE(po, MAP_IN, recordlen); + PMCLOG_RESERVE(po, PMCLOG_TYPE_MAP_IN, recordlen); PMCLOG_EMIT32(pid); PMCLOG_EMIT32(0); PMCLOG_EMITADDR(start); @@ -966,7 +966,7 @@ pmclog_process_map_out(struct pmc_owner *po, pid_t pid, uintfptr_t start, { KASSERT(start <= end, ("[pmclog,%d] start > end", __LINE__)); - PMCLOG_RESERVE(po, MAP_OUT, sizeof(struct pmclog_map_out)); + PMCLOG_RESERVE(po, PMCLOG_TYPE_MAP_OUT, sizeof(struct pmclog_map_out)); PMCLOG_EMIT32(pid); PMCLOG_EMIT32(0); PMCLOG_EMITADDR(start); @@ -985,7 +985,7 @@ pmclog_process_pmcallocate(struct pmc *pm) PMCDBG1(LOG,ALL,1, "pm=%p", pm); if (PMC_TO_CLASS(pm) == PMC_CLASS_SOFT) { - PMCLOG_RESERVE(po, PMCALLOCATEDYN, + PMCLOG_RESERVE(po, PMCLOG_TYPE_PMCALLOCATEDYN, sizeof(struct pmclog_pmcallocatedyn)); PMCLOG_EMIT32(pm->pm_id); PMCLOG_EMIT32(pm->pm_event); @@ -1000,7 +1000,7 @@ pmclog_process_pmcallocate(struct pmc *pm) pmc_soft_ev_release(ps); PMCLOG_DESPATCH_SYNC(po); } else { - PMCLOG_RESERVE(po, PMCALLOCATE, + PMCLOG_RESERVE(po, PMCLOG_TYPE_PMCALLOCATE, sizeof(struct pmclog_pmcallocate)); PMCLOG_EMIT32(pm->pm_id); PMCLOG_EMIT32(pm->pm_event); @@ -1024,7 +1024,7 @@ pmclog_process_pmcattach(struct pmc *pm, pid_t pid, char *path) pathlen = strlen(path) + 1; /* #bytes for the string */ recordlen = offsetof(struct pmclog_pmcattach, pl_pathname) + pathlen; - PMCLOG_RESERVE(po, PMCATTACH, recordlen); + PMCLOG_RESERVE(po, PMCLOG_TYPE_PMCATTACH, recordlen); PMCLOG_EMIT32(pm->pm_id); PMCLOG_EMIT32(pid); PMCLOG_EMITSTRING(path, pathlen); @@ -1040,7 +1040,8 @@ pmclog_process_pmcdetach(struct pmc *pm, pid_t pid) po = pm->pm_owner; - PMCLOG_RESERVE(po, PMCDETACH, sizeof(struct pmclog_pmcdetach)); + PMCLOG_RESERVE(po, PMCLOG_TYPE_PMCDETACH, + sizeof(struct pmclog_pmcdetach)); PMCLOG_EMIT32(pm->pm_id); PMCLOG_EMIT32(pid); PMCLOG_DESPATCH_SYNC(po); @@ -1050,13 +1051,15 @@ void pmclog_process_proccreate(struct pmc_owner *po, struct proc *p, int sync) { if (sync) { - PMCLOG_RESERVE(po, PROC_CREATE, sizeof(struct pmclog_proccreate)); + PMCLOG_RESERVE(po, PMCLOG_TYPE_PROC_CREATE, + sizeof(struct pmclog_proccreate)); PMCLOG_EMIT32(p->p_pid); PMCLOG_EMIT32(p->p_flag); PMCLOG_EMITSTRING(p->p_comm, MAXCOMLEN+1); PMCLOG_DESPATCH_SYNC(po); } else { - PMCLOG_RESERVE(po, PROC_CREATE, sizeof(struct pmclog_proccreate)); + PMCLOG_RESERVE(po, PMCLOG_TYPE_PROC_CREATE, + sizeof(struct pmclog_proccreate)); PMCLOG_EMIT32(p->p_pid); PMCLOG_EMIT32(p->p_flag); PMCLOG_EMITSTRING(p->p_comm, MAXCOMLEN+1); @@ -1081,7 +1084,8 @@ pmclog_process_proccsw(struct pmc *pm, struct pmc_process *pp, pmc_value_t v, st po = pm->pm_owner; - PMCLOG_RESERVE_SAFE(po, PROCCSW, sizeof(struct pmclog_proccsw), pmc_rdtsc()); + PMCLOG_RESERVE_SAFE(po, PMCLOG_TYPE_PROCCSW, + sizeof(struct pmclog_proccsw), pmc_rdtsc()); PMCLOG_EMIT64(v); PMCLOG_EMIT32(pm->pm_id); PMCLOG_EMIT32(pp->pp_proc->p_pid); @@ -1100,7 +1104,7 @@ pmclog_process_procexec(struct pmc_owner *po, pmc_id_t pmid, pid_t pid, pathlen = strlen(path) + 1; /* #bytes for the path */ recordlen = offsetof(struct pmclog_procexec, pl_pathname) + pathlen; - PMCLOG_RESERVE(po, PROCEXEC, recordlen); + PMCLOG_RESERVE(po, PMCLOG_TYPE_PROCEXEC, recordlen); PMCLOG_EMIT32(pid); PMCLOG_EMIT32(pmid); PMCLOG_EMITADDR(startaddr); @@ -1124,7 +1128,8 @@ pmclog_process_procexit(struct pmc *pm, struct pmc_process *pp) po = pm->pm_owner; - PMCLOG_RESERVE(po, PROCEXIT, sizeof(struct pmclog_procexit)); + PMCLOG_RESERVE(po, PMCLOG_TYPE_PROCEXIT, + sizeof(struct pmclog_procexit)); PMCLOG_EMIT32(pm->pm_id); PMCLOG_EMIT32(pp->pp_proc->p_pid); PMCLOG_EMIT64(pp->pp_pmcs[ri].pp_pmcval); @@ -1138,7 +1143,8 @@ pmclog_process_procexit(struct pmc *pm, struct pmc_process *pp) void pmclog_process_procfork(struct pmc_owner *po, pid_t oldpid, pid_t newpid) { - PMCLOG_RESERVE(po, PROCFORK, sizeof(struct pmclog_procfork)); + PMCLOG_RESERVE(po, PMCLOG_TYPE_PROCFORK, + sizeof(struct pmclog_procfork)); PMCLOG_EMIT32(oldpid); PMCLOG_EMIT32(newpid); PMCLOG_DESPATCH(po); @@ -1151,7 +1157,7 @@ pmclog_process_procfork(struct pmc_owner *po, pid_t oldpid, pid_t newpid) void pmclog_process_sysexit(struct pmc_owner *po, pid_t pid) { - PMCLOG_RESERVE(po, SYSEXIT, sizeof(struct pmclog_sysexit)); + PMCLOG_RESERVE(po, PMCLOG_TYPE_SYSEXIT, sizeof(struct pmclog_sysexit)); PMCLOG_EMIT32(pid); PMCLOG_DESPATCH(po); } @@ -1163,7 +1169,8 @@ pmclog_process_threadcreate(struct pmc_owner *po, struct thread *td, int sync) p = td->td_proc; if (sync) { - PMCLOG_RESERVE(po, THR_CREATE, sizeof(struct pmclog_threadcreate)); + PMCLOG_RESERVE(po, PMCLOG_TYPE_THR_CREATE, + sizeof(struct pmclog_threadcreate)); PMCLOG_EMIT32(td->td_tid); PMCLOG_EMIT32(p->p_pid); PMCLOG_EMIT32(p->p_flag); @@ -1171,7 +1178,8 @@ pmclog_process_threadcreate(struct pmc_owner *po, struct thread *td, int sync) PMCLOG_EMITSTRING(td->td_name, MAXCOMLEN+1); PMCLOG_DESPATCH_SYNC(po); } else { - PMCLOG_RESERVE(po, THR_CREATE, sizeof(struct pmclog_threadcreate)); + PMCLOG_RESERVE(po, PMCLOG_TYPE_THR_CREATE, + sizeof(struct pmclog_threadcreate)); PMCLOG_EMIT32(td->td_tid); PMCLOG_EMIT32(p->p_pid); PMCLOG_EMIT32(p->p_flag); @@ -1185,7 +1193,8 @@ void pmclog_process_threadexit(struct pmc_owner *po, struct thread *td) { - PMCLOG_RESERVE(po, THR_EXIT, sizeof(struct pmclog_threadexit)); + PMCLOG_RESERVE(po, PMCLOG_TYPE_THR_EXIT, + sizeof(struct pmclog_threadexit)); PMCLOG_EMIT32(td->td_tid); PMCLOG_DESPATCH(po); } @@ -1203,7 +1212,7 @@ pmclog_process_userlog(struct pmc_owner *po, struct pmc_op_writelog *wl) error = 0; - PMCLOG_RESERVE_WITH_ERROR(po, USERDATA, + PMCLOG_RESERVE_WITH_ERROR(po, PMCLOG_TYPE_USERDATA, sizeof(struct pmclog_userdata)); PMCLOG_EMIT32(wl->pm_userdata); PMCLOG_DESPATCH(po);