git: b03535a3b559 - stable/13 - hwpmc: on process exit, ensure that the owned log is closed
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 28 Aug 2023 00:28:21 UTC
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=b03535a3b5591f460fe49256aa28313c9e17b37b commit b03535a3b5591f460fe49256aa28313c9e17b37b Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2023-08-13 13:42:49 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2023-08-28 00:27:48 +0000 hwpmc: on process exit, ensure that the owned log is closed (cherry picked from commit 3c872a70b883e4e2b38135bd6bd114ac9d2ea579) --- sys/dev/hwpmc/hwpmc_mod.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sys/dev/hwpmc/hwpmc_mod.c b/sys/dev/hwpmc/hwpmc_mod.c index 714e1f550144..c402c764d0a9 100644 --- a/sys/dev/hwpmc/hwpmc_mod.c +++ b/sys/dev/hwpmc/hwpmc_mod.c @@ -5078,13 +5078,13 @@ pmc_process_exit(void *arg __unused, struct proc *p) pmclog_process_sysexit(po, p->p_pid); PMC_EPOCH_EXIT(); - if (!is_using_hwpmcs) - return; - PMC_GET_SX_XLOCK(); PMCDBG3(PRC,EXT,1,"process-exit proc=%p (%d, %s)", p, p->p_pid, p->p_comm); + if (!is_using_hwpmcs) + goto out; + /* * Since this code is invoked by the last thread in an exiting * process, we would have context switched IN at some prior @@ -5222,6 +5222,8 @@ pmc_process_exit(void *arg __unused, struct proc *p) * memory. */ if ((po = pmc_find_owner_descriptor(p)) != NULL) { + if ((po->po_flags & PMC_PO_OWNS_LOGFILE) != 0) + pmclog_close(po); pmc_remove_owner(po); pmc_destroy_owner_descriptor(po); }