perf tools: Rewrite and improve support for kernel modules

Representing modules as struct map entries, backed by a DSO, etc,
using /proc/modules to find where the module is loaded.

DSOs now can have a short and long name, so that in verbose mode we
can show exactly which .ko or vmlinux image was used.

As kernel modules now are a DSO separate from the kernel, we can
ask for just the hits for a particular set of kernel modules, just
like we can do with shared libraries:

[root@doppio linux-2.6-tip]# perf report -n --vmlinux
/home/acme/git/build/tip-recvmmsg/vmlinux --modules --dsos \[drm\] | head -15
    84.58%      13266             Xorg  [k] drm_clflush_pages
     4.02%        630             Xorg  [k] trace_kmalloc.clone.0
     3.95%        619             Xorg  [k] drm_ioctl
     2.07%        324             Xorg  [k] drm_addbufs
     1.68%        263             Xorg  [k] drm_gem_close_ioctl
     0.77%        120             Xorg  [k] drm_setmaster_ioctl
     0.70%        110             Xorg  [k] drm_lastclose
     0.68%        106             Xorg  [k] drm_open
     0.54%         85             Xorg  [k] drm_mm_search_free
[root@doppio linux-2.6-tip]#

Specifying --dsos /lib/modules/2.6.31-tip/kernel/drivers/gpu/drm/drm.ko
would have the same effect. Allowing specifying just 'drm.ko' is left
for another patch.

Processing kallsyms so that per kernel module struct map are
instantiated was also left for another patch. That will allow
removing the module name from each of its symbols.

struct symbol was reduced by removing the ->module backpointer and
moving it (well now the map) to struct symbol_entry in perf top,
that is its only user right now.

The total linecount went down by ~500 lines.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Avi Kivity <avi@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index ee164f6..5339fd8 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -5,7 +5,6 @@
 #include "types.h"
 #include <linux/list.h>
 #include <linux/rbtree.h>
-#include "module.h"
 #include "event.h"
 
 #ifdef HAVE_CPLUS_DEMANGLE
@@ -36,10 +35,8 @@
 	struct rb_node	rb_node;
 	u64		start;
 	u64		end;
-	u64		obj_start;
 	u64		hist_sum;
 	u64		*hist;
-	struct module	*module;
 	void		*priv;
 	char		name[0];
 };
@@ -52,12 +49,14 @@
 	unsigned char	 adjust_symbols;
 	unsigned char	 slen_calculated;
 	unsigned char	 origin;
+	const char	 *short_name;
+	char	 	 *long_name;
 	char		 name[0];
 };
 
 extern const char *sym_hist_filter;
 
-typedef int (*symbol_filter_t)(struct dso *self, struct symbol *sym);
+typedef int (*symbol_filter_t)(struct map *map, struct symbol *sym);
 
 struct dso *dso__new(const char *name, unsigned int sym_priv_size);
 void dso__delete(struct dso *self);
@@ -69,10 +68,12 @@
 
 struct symbol *dso__find_symbol(struct dso *self, u64 ip);
 
-int dso__load_kernel(struct dso *self, const char *vmlinux,
-		     symbol_filter_t filter, int verbose, int modules);
-int dso__load_modules(struct dso *self, symbol_filter_t filter, int verbose);
-int dso__load(struct dso *self, symbol_filter_t filter, int verbose);
+int dsos__load_kernel(const char *vmlinux, unsigned int sym_priv_size,
+		      symbol_filter_t filter, int verbose, int modules);
+int dsos__load_modules(unsigned int sym_priv_size, symbol_filter_t filter,
+		       int verbose);
+int dso__load(struct dso *self, struct map *map, symbol_filter_t filter,
+	      int verbose);
 struct dso *dsos__findnew(const char *name);
 void dsos__fprintf(FILE *fp);
 
@@ -84,9 +85,8 @@
 void symbol__init(void);
 
 extern struct list_head dsos;
-extern struct dso *kernel_dso;
+extern struct map *kernel_map;
 extern struct dso *vdso;
-extern struct dso *hypervisor_dso;
 extern const char *vmlinux_name;
 extern int   modules;
 #endif /* __PERF_SYMBOL */