Page MenuHomeFreeBSD

D59361.id185758.diff
No OneTemporary

D59361.id185758.diff

diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c
--- a/sys/kern/kern_fork.c
+++ b/sys/kern/kern_fork.c
@@ -36,6 +36,7 @@
#include "opt_ktrace.h"
#include "opt_kstack_pages.h"
+#include "opt_hwpmc_hooks.h"
#define EXTERR_CATEGORY EXTERR_CAT_FORK
#include <sys/systm.h>
@@ -87,6 +88,10 @@
dtrace_fork_func_t dtrace_fasttrap_fork;
#endif
+#ifdef HWPMC_HOOKS
+#include <sys/pmckern.h>
+#endif
+
SDT_PROVIDER_DECLARE(proc);
SDT_PROBE_DEFINE3(proc, , , create, "struct proc *", "struct proc *", "int");
@@ -1211,6 +1216,16 @@
}
thread_unlock(td);
+#ifdef HWPMC_HOOKS
+ /*
+ * fork_exit() does not run the context-switch-in hook from
+ * sched_switch(). Program the inherited PMCs here. If you do not
+ * do this, hwpmc does not count the work of a short-lived child.
+ */
+ if (PMC_PROC_IS_USING_PMCS(p))
+ PMC_SWITCH_CONTEXT(td, PMC_FN_CSW_IN);
+#endif
+
/*
* cpu_fork_kthread_handler intercepts this function call to
* have this call a non-return function to stay in kernel mode.

File Metadata

Mime Type
text/plain
Expires
Wed, Sep 9, 12:12 PM (21 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
38466322
Default Alt Text
D59361.id185758.diff (1022 B)

Event Timeline