Changeset 58873 in vbox
- Timestamp:
- Nov 26, 2015 2:20:06 AM (9 years ago)
- svn:sync-xref-src-repo-rev:
- 104359
- Location:
- trunk/src/VBox/HostDrivers/Support
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/Support/SUPDrvInternal.h
r58872 r58873 395 395 /** Hack for seeing the module in perf, dtrace and other stack crawlers. */ 396 396 struct module *pLnxModHack; 397 /** Hack for seeing the module in perf, dtrace and other stack crawlers .398 * Required for Linux v3.19+. */399 struct supdrv_ftrace_ops *pLnxFTraceHack;400 397 #endif 401 398 /** Whether it's loaded by the native loader or not. */ -
trunk/src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c
r58872 r58873 64 64 # define SUPDRV_LINUX_HAS_SAFE_MSR_API 65 65 # include <asm/msr.h> 66 #endif67 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0) && defined(CONFIG_DYNAMIC_FTRACE)68 # include <linux/ftrace.h>69 66 #endif 70 67 … … 984 981 #endif 985 982 986 #if 0 /* instant host lockup, can't be bothered debugging it */987 #if defined(VBOX_WITH_NON_PROD_HACK_FOR_PERF_STACKS) \988 && LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0) \989 && defined(CONFIG_MODULES_TREE_LOOKUP) \990 && defined(CONFIG_DYNAMIC_FTRACE)991 992 /**993 * Using a static array here because that's what is suggested in the docs to994 * avoid/reduce potential race conditions.995 */996 static struct supdrv_ftrace_ops997 {998 struct ftrace_ops Core;999 bool volatile fUsed;1000 } g_aFTraceOps[16] __read_mostly;1001 1002 /** Stub function for the ugly debug hack below. */1003 static void notrace __attribute__((optimize("-fomit-frame-pointer")))1004 supdrvLnxFTraceStub(unsigned long ip, unsigned long parent_ip, struct ftrace_ops *op, struct pt_regs *regs)1005 {1006 return;1007 }1008 1009 #endif1010 #endif1011 1012 983 1013 984 void VBOXCALL supdrvOSLdrNotifyOpened(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage, const char *pszFilename) … … 1026 997 1027 998 pImage->pLnxModHack = NULL; 1028 pImage->pLnxFTraceHack = NULL;1029 999 1030 1000 # ifdef CONFIG_MODULES_TREE_LOOKUP … … 1080 1050 { 1081 1051 int rc = VINF_SUCCESS; 1082 //size_t cch;1083 1052 # ifdef CONFIG_KALLSYMS 1084 1053 Elf_Sym *paSymbols = (Elf_Sym *)(pMyMod + 1); … … 1089 1058 INIT_LIST_HEAD(&pMyMod->list); /* just in case */ 1090 1059 1091 /* Come up with a good name that perf can translate with minimum help... */1092 # if 01093 cch = strlen(pszFilename);1094 if (cch < sizeof(pMyMod->name))1095 memcpy(pMyMod->name, pszFilename, cch + 1);1096 else1097 {1098 const char *pszTmp = pszFilename;1099 for (;;)1100 {1101 /* skip one path component. */1102 while (*pszTmp == '/')1103 pszTmp++, cch--;1104 while (*pszTmp != '/' && *pszTmp != '\0')1105 pszTmp++, cch--;1106 1107 /* If we've skipped past the final component, hack something up based on the module name. */1108 if (*pszTmp != '/')1109 {1110 RTStrPrintf(pMyMod->name, sizeof(pMyMod->name), "/opt/VirtualBox/%s", pImage->szName);1111 break;1112 }1113 /* When we've got space for two dots and the remaining path, we're done. */1114 if (cch + 2 < sizeof(pMyMod->name))1115 {1116 pMyMod->name[0] = '.';1117 pMyMod->name[1] = '.';1118 memcpy(&pMyMod->name[2], pszTmp, cch + 1);1119 break;1120 }1121 }1122 }1123 # else1124 1060 /* Perf only matches up files with a .ko extension (maybe .ko.gz), 1125 1061 so in order for this crap to work smoothly, we append .ko to the … … 1130 1066 done */ 1131 1067 RTStrPrintf(pMyMod->name, sizeof(pMyMod->name), "%s", pImage->szName); 1132 # endif1133 1068 1134 1069 /* sysfs bits. */ … … 1315 1250 mutex_unlock(&module_mutex); 1316 1251 1317 #if 0 /* Horrible, non-working hack. Debug when __mod_tree_remove can't be found on a box we care about. */1318 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0) && defined(CONFIG_MODULES_TREE_LOOKUP)1319 # if defined(CONFIG_DYNAMIC_FTRACE)1320 /*1321 * Starting with 4.2 there's the module tree lookup which thwarts1322 * the above module hack. So, we must install an additional hack1323 * to get the job done. This relies on dynmaic ftrace trampolines1324 * and is just as ugly as the above. Only for debugging!!1325 */1326 uint32_t i = 0;1327 while (i < RT_ELEMENTS(g_aFTraceOps)1328 && ASMAtomicXchgBool(&g_aFTraceOps[i].fUsed, true) == true)1329 i++;1330 if (i < RT_ELEMENTS(g_aFTraceOps))1331 {1332 struct supdrv_ftrace_ops *pOps = &g_aFTraceOps[i];1333 pOps->Core.func = supdrvLnxFTraceStub;1334 pOps->Core.flags = /*FTRACE_OPS_FL_RECURSION_SAFE | FTRACE_OPS_FL_STUB |*/ FTRACE_OPS_FL_DYNAMIC;1335 pOps->Core.trampoline = (uintptr_t)pImage->pvImage;1336 pOps->Core.trampoline_size = (uintptr_t)pImage->cbImageBits;1337 1338 rc = register_ftrace_function(&pOps->Core);1339 if (rc == 0)1340 pImage->pLnxFTraceHack = pOps;1341 else1342 printk(KERN_ERR "vboxdrv: register_ftrace_function failed: %d\n", rc);1343 }1344 # else1345 # error "Sorry, without CONFIG_DYNAMIC_FTRACE currently not possible to get proper stack traces"1346 # endif1347 # endif1348 #endif1349 1252 /* 1350 1253 * Test it. … … 1371 1274 #else 1372 1275 pImage->pLnxModHack = NULL; 1373 pImage->pLnxFTraceHack = NULL;1374 1276 #endif 1375 1277 NOREF(pDevExt); NOREF(pImage); … … 1402 1304 IPRT_LINUX_RESTORE_EFL_AC(); 1403 1305 } 1404 1405 #if 0 /* Butt-ugly and ain't working yet. */1406 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0) && defined(CONFIG_MODULES_TREE_LOOKUP)1407 # if defined(CONFIG_DYNAMIC_FTRACE)1408 {1409 /*1410 * Undo the ftrace hack.1411 */1412 struct supdrv_ftrace_ops *pOps = pImage->pLnxFTraceHack;1413 pImage->pLnxFTraceHack = NULL;1414 if (pOps)1415 {1416 IPRT_LINUX_SAVE_EFL_AC();1417 int rc = unregister_ftrace_function(&pOps->Core);1418 if (rc == 0)1419 ASMAtomicWriteBool(&pOps->fUsed, false);1420 else1421 printk(KERN_ERR "vboxdrv: unregister_ftrace_function failed: %d\n", rc);1422 IPRT_LINUX_RESTORE_EFL_AC();1423 }1424 }1425 # else1426 # error "Sorry, without CONFIG_DYNAMIC_FTRACE currently not possible to get proper stack traces"1427 # endif1428 # endif1429 #endif1430 1306 1431 1307 #else
Note:
See TracChangeset
for help on using the changeset viewer.