From: Philippe E. <ph...@us...> - 2003-02-13 20:54:54
|
Update of /cvsroot/oprofile/oprofile/dae In directory sc8-pr-cvs1:/tmp/cvs-serv23037/dae Modified Files: opd_image.c opd_image.h opd_kernel.c Log Message: don't use hash entry zero for kernel image, fix #686175 regards, Phil Index: opd_image.c =================================================================== RCS file: /cvsroot/oprofile/oprofile/dae/opd_image.c,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- opd_image.c 13 Feb 2003 15:35:29 -0000 1.22 +++ opd_image.c 13 Feb 2003 20:54:50 -0000 1.23 @@ -28,9 +28,6 @@ /* maintained for statistics purpose only */ unsigned int nr_images=0; -/* module never return a 0 hash name, we use it for kernel and module name */ -#define HASH_KERNEL 0 - /* list of images */ static struct list_head opd_images = { &opd_images, &opd_images }; @@ -354,12 +351,17 @@ /** * opd_get_kernel_image - get a kernel image * @param name of image + * @param app_name application owner of this kernel image. non-null only + * when separate_kernel_sample != 0 * * Create and initialise an image adding it * to the image lists and to image hash list * entry HASH_KERNEL */ -struct opd_image * opd_get_kernel_image(char const * name) +struct opd_image * opd_get_kernel_image(char const * name, char const * app_name) { - return opd_get_image(name, HASH_KERNEL, NULL, 1); + /* FIXME: images_with_hash[0] is never used, can we use it and firstly + * do opd_get_image_by_hash() here ? Take care such change needs + * carefull test, think to --separate and initrd */ + return opd_get_image(name, -1, app_name, 1); } Index: opd_image.h =================================================================== RCS file: /cvsroot/oprofile/oprofile/dae/opd_image.h,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- opd_image.h 6 Dec 2002 04:37:45 -0000 1.12 +++ opd_image.h 13 Feb 2003 20:54:51 -0000 1.13 @@ -47,7 +47,7 @@ void opd_image_cleanup(void); -struct opd_image * opd_get_kernel_image(char const * name); +struct opd_image * opd_get_kernel_image(char const * name, char const * app_name); void opd_init_images(void); struct opd_image * opd_get_image(char const * name, int hash, char const * app_name, int kernel); Index: opd_kernel.c =================================================================== RCS file: /cvsroot/oprofile/oprofile/dae/opd_kernel.c,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- opd_kernel.c 11 Feb 2003 21:08:58 -0000 1.28 +++ opd_kernel.c 13 Feb 2003 20:54:51 -0000 1.29 @@ -50,7 +50,7 @@ */ void opd_init_kernel_image(void) { - kernel_image = opd_get_kernel_image(vmlinux); + kernel_image = opd_get_kernel_image(vmlinux, NULL); } /** @@ -230,7 +230,7 @@ strncpy(filename, cp2, (size_t)(cp3 - cp2)); filename[cp3-cp2] = '\0'; - mod->image = opd_get_kernel_image(filename); + mod->image = opd_get_kernel_image(filename, NULL); free(filename); break; @@ -261,6 +261,15 @@ /** * opd_drop_module_sample - drop a module sample efficiently * @param eip eip of sample + * + * This function is called to recover from failing to put a samples even + * after re-reading /proc/ksyms. It's either a rogue sample, or from a module + * that didn't create symbols (like in some initrd setups). So we check with + * query_module() if we can place it in a symbol-less module, and if so create + * a negative entry for it, to quickly ignore future samples. + * + * Problem uncovered by Bob Montgomery <bo...@fc...> + * */ static void opd_drop_module_sample(unsigned long eip) { @@ -271,6 +280,8 @@ uint nr_mods; uint mod = 0; + opd_stats[OPD_LOST_MODULE]++; + module_names = xmalloc(size); while (query_module(NULL, QM_MODULES, module_names, size, &ret)) { if (errno != ENOSPC) { @@ -363,16 +374,6 @@ module->name); } } else { - /* ok, we failed to place the sample even after re-reading - * /proc/ksyms. It's either a rogue sample, or from a module - * that didn't create symbols (like in some initrd setups). - * So we check with query_module() if we can place it in a - * symbol-less module, and if so create a negative entry for - * it, to quickly ignore future samples. - * - * Problem uncovered by Bob Montgomery <bo...@fc...> - */ - opd_stats[OPD_LOST_MODULE]++; opd_drop_module_sample(eip); } } @@ -432,7 +433,7 @@ if (eip < kernel_end) { - image = opd_get_image(vmlinux, -1, app_name, 1); + image = opd_get_kernel_image(vmlinux, app_name); if (!image) { verbprintf("Can't create image for %s %s\n", vmlinux, app_name); return; @@ -461,7 +462,7 @@ module->name); module_name = module->name; } - image = opd_get_image(module_name, -1, app_name, 1); + image = opd_get_kernel_image(module_name, app_name); if (!image) { verbprintf("Can't create image for %s %s\n", module->name, app_name); @@ -469,16 +470,6 @@ } opd_add_mapping(proc, image, module->start, 0, module->end); } else { - /* ok, we failed to place the sample even after re-reading - * /proc/ksyms. It's either a rogue sample, or from a module - * that didn't create symbols (like in some initrd setups). - * So we check with query_module() if we can place it in a - * symbol-less module, and if so create a negative entry for - * it, to quickly ignore future samples. - * - * Problem uncovered by Bob Montgomery <bo...@fc...> - */ - opd_stats[OPD_LOST_MODULE]++; opd_drop_module_sample(eip); } } |