Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
authorLinus Torvalds <torvalds@linux-foundation.org>
Sat, 18 Apr 2015 15:26:46 +0000 (11:26 -0400)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 18 Apr 2015 15:26:46 +0000 (11:26 -0400)
Pull perf updates from Ingo Molnar:
 "This update has mostly fixes, but also other bits:

   - perf tooling fixes

   - PMU driver fixes

   - Intel Broadwell PMU driver HW-enablement for LBR callstacks

   - a late coming 'perf kmem' tool update that enables it to also
     analyze page allocation data.  Note, this comes with MM tracepoint
     changes that we believe to not break anything: because it changes
     the formerly opaque 'struct page *' field that uniquely identifies
     pages to 'pfn' which identifies pages uniquely too, but isn't as
     opaque and can be used for other purposes as well"

* 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  perf/x86/intel/pt: Fix and clean up error handling in pt_event_add()
  perf/x86/intel: Add Broadwell support for the LBR callstack
  perf/x86/intel/rapl: Fix energy counter measurements but supporing per domain energy units
  perf/x86/intel: Fix Core2,Atom,NHM,WSM cycles:pp events
  perf/x86: Fix hw_perf_event::flags collision
  perf probe: Fix segfault when probe with lazy_line to file
  perf probe: Find compilation directory path for lazy matching
  perf probe: Set retprobe flag when probe in address-based alternative mode
  perf kmem: Analyze page allocator events also
  tracing, mm: Record pfn instead of pointer to struct page

1  2 
tools/perf/util/probe-finder.c

index e3074230f236ef13b077586bdd3678bde6525513,44554c3c2220f44e787f2bf1a7e39e49201ad207..b5bf9d5efeaf2dc32317573de059c1d73367cc7c
@@@ -456,7 -456,7 +456,7 @@@ static int convert_variable_fields(Dwar
                        return -EINVAL;
                }
                if (field->name[0] == '[') {
 -                      pr_err("Semantic error: %s is not a pointor"
 +                      pr_err("Semantic error: %s is not a pointer"
                               " nor array.\n", varname);
                        return -EINVAL;
                }
@@@ -855,11 -855,22 +855,22 @@@ static int probe_point_lazy_walker(cons
  static int find_probe_point_lazy(Dwarf_Die *sp_die, struct probe_finder *pf)
  {
        int ret = 0;
+       char *fpath;
  
        if (intlist__empty(pf->lcache)) {
+               const char *comp_dir;
+               comp_dir = cu_get_comp_dir(&pf->cu_die);
+               ret = get_real_path(pf->fname, comp_dir, &fpath);
+               if (ret < 0) {
+                       pr_warning("Failed to find source file path.\n");
+                       return ret;
+               }
                /* Matching lazy line pattern */
-               ret = find_lazy_match_lines(pf->lcache, pf->fname,
+               ret = find_lazy_match_lines(pf->lcache, fpath,
                                            pf->pev->point.lazy_line);
+               free(fpath);
                if (ret <= 0)
                        return ret;
        }
@@@ -1055,7 -1066,7 +1066,7 @@@ static int debuginfo__find_probes(struc
                        if (pp->function)
                                ret = find_probe_point_by_func(pf);
                        else if (pp->lazy_line)
-                               ret = find_probe_point_lazy(NULL, pf);
+                               ret = find_probe_point_lazy(&pf->cu_die, pf);
                        else {
                                pf->lno = pp->line;
                                ret = find_probe_point_by_line(pf);
@@@ -1622,3 -1633,61 +1633,61 @@@ found
        return (ret < 0) ? ret : lf.found;
  }
  
+ /*
+  * Find a src file from a DWARF tag path. Prepend optional source path prefix
+  * and chop off leading directories that do not exist. Result is passed back as
+  * a newly allocated path on success.
+  * Return 0 if file was found and readable, -errno otherwise.
+  */
+ int get_real_path(const char *raw_path, const char *comp_dir,
+                        char **new_path)
+ {
+       const char *prefix = symbol_conf.source_prefix;
+       if (!prefix) {
+               if (raw_path[0] != '/' && comp_dir)
+                       /* If not an absolute path, try to use comp_dir */
+                       prefix = comp_dir;
+               else {
+                       if (access(raw_path, R_OK) == 0) {
+                               *new_path = strdup(raw_path);
+                               return *new_path ? 0 : -ENOMEM;
+                       } else
+                               return -errno;
+               }
+       }
+       *new_path = malloc((strlen(prefix) + strlen(raw_path) + 2));
+       if (!*new_path)
+               return -ENOMEM;
+       for (;;) {
+               sprintf(*new_path, "%s/%s", prefix, raw_path);
+               if (access(*new_path, R_OK) == 0)
+                       return 0;
+               if (!symbol_conf.source_prefix) {
+                       /* In case of searching comp_dir, don't retry */
+                       zfree(new_path);
+                       return -errno;
+               }
+               switch (errno) {
+               case ENAMETOOLONG:
+               case ENOENT:
+               case EROFS:
+               case EFAULT:
+                       raw_path = strchr(++raw_path, '/');
+                       if (!raw_path) {
+                               zfree(new_path);
+                               return -ENOENT;
+                       }
+                       continue;
+               default:
+                       zfree(new_path);
+                       return -errno;
+               }
+       }
+ }