Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'perf-urgent-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent

Fixes for perf/urgent:

- Add fallback in 'perf stat' for kernels that don't support
perf_event_attr.exclude_guest, from Stephane Eranian.

- Fix build id cache add routine to take the size of the buffer and not of a
pointer, from Namhyung Kim.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>

+30 -5
+29 -4
tools/perf/builtin-stat.c
··· 283 283 { 284 284 struct perf_event_attr *attr = &evsel->attr; 285 285 struct xyarray *group_fd = NULL; 286 + bool exclude_guest_missing = false; 287 + int ret; 286 288 287 289 if (group && evsel != first) 288 290 group_fd = first->fd; ··· 295 293 296 294 attr->inherit = !no_inherit; 297 295 298 - if (system_wide) 299 - return perf_evsel__open_per_cpu(evsel, evsel_list->cpus, 296 + retry: 297 + if (exclude_guest_missing) 298 + evsel->attr.exclude_guest = evsel->attr.exclude_host = 0; 299 + 300 + if (system_wide) { 301 + ret = perf_evsel__open_per_cpu(evsel, evsel_list->cpus, 300 302 group, group_fd); 303 + if (ret) 304 + goto check_ret; 305 + return 0; 306 + } 307 + 301 308 if (!target_pid && !target_tid && (!group || evsel == first)) { 302 309 attr->disabled = 1; 303 310 attr->enable_on_exec = 1; 304 311 } 305 312 306 - return perf_evsel__open_per_thread(evsel, evsel_list->threads, 307 - group, group_fd); 313 + ret = perf_evsel__open_per_thread(evsel, evsel_list->threads, 314 + group, group_fd); 315 + if (!ret) 316 + return 0; 317 + /* fall through */ 318 + check_ret: 319 + if (ret && errno == EINVAL) { 320 + if (!exclude_guest_missing && 321 + (evsel->attr.exclude_guest || evsel->attr.exclude_host)) { 322 + pr_debug("Old kernel, cannot exclude " 323 + "guest or host samples.\n"); 324 + exclude_guest_missing = true; 325 + goto retry; 326 + } 327 + } 328 + return ret; 308 329 } 309 330 310 331 /*
+1 -1
tools/perf/util/header.c
··· 296 296 if (mkdir_p(filename, 0755)) 297 297 goto out_free; 298 298 299 - snprintf(filename + len, sizeof(filename) - len, "/%s", sbuild_id); 299 + snprintf(filename + len, size - len, "/%s", sbuild_id); 300 300 301 301 if (access(filename, F_OK)) { 302 302 if (is_kallsyms) {