Author: mjg
Date: Fri Jan 27 22:13:15 2017
New Revision: 312901
URL: https://svnweb.freebsd.org/changeset/base/312901

Log:
  hwpmc: partially depessimize mmap handling if the module is not loaded
  
  In particular this means the pmc sx lock is no longer taken when an
  executable mapping succeeds.
  
  MFC after:    1 week

Modified:
  head/sys/kern/vfs_vnops.c

Modified: head/sys/kern/vfs_vnops.c
==============================================================================
--- head/sys/kern/vfs_vnops.c   Fri Jan 27 21:55:47 2017        (r312900)
+++ head/sys/kern/vfs_vnops.c   Fri Jan 27 22:13:15 2017        (r312901)
@@ -2460,10 +2460,12 @@ vn_mmap(struct file *fp, vm_map_t map, v
        }
 #ifdef HWPMC_HOOKS
        /* Inform hwpmc(4) if an executable is being mapped. */
-       if (error == 0 && (prot & VM_PROT_EXECUTE) != 0) {
-               pkm.pm_file = vp;
-               pkm.pm_address = (uintptr_t) *addr;
-               PMC_CALL_HOOK(td, PMC_FN_MMAP, (void *) &pkm);
+       if (PMC_HOOK_INSTALLED(PMC_FN_MMAP)) {
+               if ((prot & VM_PROT_EXECUTE) != 0 && error == 0) {
+                       pkm.pm_file = vp;
+                       pkm.pm_address = (uintptr_t) *addr;
+                       PMC_CALL_HOOK(td, PMC_FN_MMAP, (void *) &pkm);
+               }
        }
 #endif
        return (error);
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to