Skip to content

Commit 8cc67c3

Browse files
author
Ingo Molnar
committed
Merge tag 'perf-urgent-for-mingo-2' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent
Pull perf tooling fixes from Arnaldo Carvalho de Melo: . Fix a segfault in 'perf top' when kernel map is restricted (Wang Nan) . Fix hung wakeup tasks after requeueing in 'perf bench futex' (Davidlohr Bueso) . Fix bug in perf probe global variables handling, missing curly braces on an if body (He Kuang) . 'perf bench numa' fixes (command line help/handling, etc) (Petr Holasek) . fix the 'perf kmem' build on RHEL6/OL6 (David Ahern) . fix the libtraceevent build on 32-bit arch (Namhyung Kim) Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Ingo Molnar <mingo@kernel.org>
2 parents 0140e61 + 1d90a68 commit 8cc67c3

File tree

8 files changed

+61
-44
lines changed

8 files changed

+61
-44
lines changed

tools/lib/api/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ MAKEFLAGS += --no-print-directory
1616
LIBFILE = $(OUTPUT)libapi.a
1717

1818
CFLAGS := $(EXTRA_WARNINGS) $(EXTRA_CFLAGS)
19-
CFLAGS += -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 -fPIC
19+
CFLAGS += -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC
2020
CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
2121

2222
RM = rm -f

tools/lib/traceevent/event-parse.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3865,7 +3865,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
38653865
} else if (el_size == 4) {
38663866
trace_seq_printf(s, "%u", *(uint32_t *)num);
38673867
} else if (el_size == 8) {
3868-
trace_seq_printf(s, "%lu", *(uint64_t *)num);
3868+
trace_seq_printf(s, "%"PRIu64, *(uint64_t *)num);
38693869
} else {
38703870
trace_seq_printf(s, "BAD SIZE:%d 0x%x",
38713871
el_size, *(uint8_t *)num);

tools/perf/bench/futex-requeue.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ int bench_futex_requeue(int argc, const char **argv,
132132
if (!fshared)
133133
futex_flag = FUTEX_PRIVATE_FLAG;
134134

135+
if (nrequeue > nthreads)
136+
nrequeue = nthreads;
137+
135138
printf("Run summary [PID %d]: Requeuing %d threads (from [%s] %p to %p), "
136139
"%d at a time.\n\n", getpid(), nthreads,
137140
fshared ? "shared":"private", &futex1, &futex2, nrequeue);
@@ -161,20 +164,18 @@ int bench_futex_requeue(int argc, const char **argv,
161164

162165
/* Ok, all threads are patiently blocked, start requeueing */
163166
gettimeofday(&start, NULL);
164-
for (nrequeued = 0; nrequeued < nthreads; nrequeued += nrequeue) {
167+
while (nrequeued < nthreads) {
165168
/*
166169
* Do not wakeup any tasks blocked on futex1, allowing
167170
* us to really measure futex_wait functionality.
168171
*/
169-
futex_cmp_requeue(&futex1, 0, &futex2, 0,
170-
nrequeue, futex_flag);
172+
nrequeued += futex_cmp_requeue(&futex1, 0, &futex2, 0,
173+
nrequeue, futex_flag);
171174
}
175+
172176
gettimeofday(&end, NULL);
173177
timersub(&end, &start, &runtime);
174178

175-
if (nrequeued > nthreads)
176-
nrequeued = nthreads;
177-
178179
update_stats(&requeued_stats, nrequeued);
179180
update_stats(&requeuetime_stats, runtime.tv_usec);
180181

@@ -184,7 +185,7 @@ int bench_futex_requeue(int argc, const char **argv,
184185
}
185186

186187
/* everybody should be blocked on futex2, wake'em up */
187-
nrequeued = futex_wake(&futex2, nthreads, futex_flag);
188+
nrequeued = futex_wake(&futex2, nrequeued, futex_flag);
188189
if (nthreads != nrequeued)
189190
warnx("couldn't wakeup all tasks (%d/%d)", nrequeued, nthreads);
190191

tools/perf/bench/numa.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ static const struct option options[] = {
180180
OPT_INTEGER('H', "thp" , &p0.thp, "MADV_NOHUGEPAGE < 0 < MADV_HUGEPAGE"),
181181
OPT_BOOLEAN('c', "show_convergence", &p0.show_convergence, "show convergence details"),
182182
OPT_BOOLEAN('m', "measure_convergence", &p0.measure_convergence, "measure convergence latency"),
183-
OPT_BOOLEAN('q', "quiet" , &p0.show_quiet, "bzero the initial allocations"),
183+
OPT_BOOLEAN('q', "quiet" , &p0.show_quiet, "quiet mode"),
184184
OPT_BOOLEAN('S', "serialize-startup", &p0.serialize_startup,"serialize thread startup"),
185185

186186
/* Special option string parsing callbacks: */
@@ -828,6 +828,9 @@ static int count_process_nodes(int process_nr)
828828
td = g->threads + task_nr;
829829

830830
node = numa_node_of_cpu(td->curr_cpu);
831+
if (node < 0) /* curr_cpu was likely still -1 */
832+
return 0;
833+
831834
node_present[node] = 1;
832835
}
833836

@@ -882,6 +885,11 @@ static void calc_convergence_compression(int *strong)
882885
for (p = 0; p < g->p.nr_proc; p++) {
883886
unsigned int nodes = count_process_nodes(p);
884887

888+
if (!nodes) {
889+
*strong = 0;
890+
return;
891+
}
892+
885893
nodes_min = min(nodes, nodes_min);
886894
nodes_max = max(nodes, nodes_max);
887895
}
@@ -1395,7 +1403,7 @@ static void print_res(const char *name, double val,
13951403
if (!name)
13961404
name = "main,";
13971405

1398-
if (g->p.show_quiet)
1406+
if (!g->p.show_quiet)
13991407
printf(" %-30s %15.3f, %-15s %s\n", name, val, txt_unit, txt_short);
14001408
else
14011409
printf(" %14.3f %s\n", val, txt_long);

tools/perf/builtin-kmem.c

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ static int page_stat_cmp(struct page_stat *a, struct page_stat *b)
319319
return 0;
320320
}
321321

322-
static struct page_stat *search_page_alloc_stat(struct page_stat *stat, bool create)
322+
static struct page_stat *search_page_alloc_stat(struct page_stat *pstat, bool create)
323323
{
324324
struct rb_node **node = &page_alloc_tree.rb_node;
325325
struct rb_node *parent = NULL;
@@ -331,7 +331,7 @@ static struct page_stat *search_page_alloc_stat(struct page_stat *stat, bool cre
331331
parent = *node;
332332
data = rb_entry(*node, struct page_stat, node);
333333

334-
cmp = page_stat_cmp(data, stat);
334+
cmp = page_stat_cmp(data, pstat);
335335
if (cmp < 0)
336336
node = &parent->rb_left;
337337
else if (cmp > 0)
@@ -345,10 +345,10 @@ static struct page_stat *search_page_alloc_stat(struct page_stat *stat, bool cre
345345

346346
data = zalloc(sizeof(*data));
347347
if (data != NULL) {
348-
data->page = stat->page;
349-
data->order = stat->order;
350-
data->gfp_flags = stat->gfp_flags;
351-
data->migrate_type = stat->migrate_type;
348+
data->page = pstat->page;
349+
data->order = pstat->order;
350+
data->gfp_flags = pstat->gfp_flags;
351+
data->migrate_type = pstat->migrate_type;
352352

353353
rb_link_node(&data->node, parent, node);
354354
rb_insert_color(&data->node, &page_alloc_tree);
@@ -375,7 +375,7 @@ static int perf_evsel__process_page_alloc_event(struct perf_evsel *evsel,
375375
unsigned int migrate_type = perf_evsel__intval(evsel, sample,
376376
"migratetype");
377377
u64 bytes = kmem_page_size << order;
378-
struct page_stat *stat;
378+
struct page_stat *pstat;
379379
struct page_stat this = {
380380
.order = order,
381381
.gfp_flags = gfp_flags,
@@ -401,21 +401,21 @@ static int perf_evsel__process_page_alloc_event(struct perf_evsel *evsel,
401401
* This is to find the current page (with correct gfp flags and
402402
* migrate type) at free event.
403403
*/
404-
stat = search_page(page, true);
405-
if (stat == NULL)
404+
pstat = search_page(page, true);
405+
if (pstat == NULL)
406406
return -ENOMEM;
407407

408-
stat->order = order;
409-
stat->gfp_flags = gfp_flags;
410-
stat->migrate_type = migrate_type;
408+
pstat->order = order;
409+
pstat->gfp_flags = gfp_flags;
410+
pstat->migrate_type = migrate_type;
411411

412412
this.page = page;
413-
stat = search_page_alloc_stat(&this, true);
414-
if (stat == NULL)
413+
pstat = search_page_alloc_stat(&this, true);
414+
if (pstat == NULL)
415415
return -ENOMEM;
416416

417-
stat->nr_alloc++;
418-
stat->alloc_bytes += bytes;
417+
pstat->nr_alloc++;
418+
pstat->alloc_bytes += bytes;
419419

420420
order_stats[order][migrate_type]++;
421421

@@ -428,7 +428,7 @@ static int perf_evsel__process_page_free_event(struct perf_evsel *evsel,
428428
u64 page;
429429
unsigned int order = perf_evsel__intval(evsel, sample, "order");
430430
u64 bytes = kmem_page_size << order;
431-
struct page_stat *stat;
431+
struct page_stat *pstat;
432432
struct page_stat this = {
433433
.order = order,
434434
};
@@ -441,8 +441,8 @@ static int perf_evsel__process_page_free_event(struct perf_evsel *evsel,
441441
nr_page_frees++;
442442
total_page_free_bytes += bytes;
443443

444-
stat = search_page(page, false);
445-
if (stat == NULL) {
444+
pstat = search_page(page, false);
445+
if (pstat == NULL) {
446446
pr_debug2("missing free at page %"PRIx64" (order: %d)\n",
447447
page, order);
448448

@@ -453,18 +453,18 @@ static int perf_evsel__process_page_free_event(struct perf_evsel *evsel,
453453
}
454454

455455
this.page = page;
456-
this.gfp_flags = stat->gfp_flags;
457-
this.migrate_type = stat->migrate_type;
456+
this.gfp_flags = pstat->gfp_flags;
457+
this.migrate_type = pstat->migrate_type;
458458

459-
rb_erase(&stat->node, &page_tree);
460-
free(stat);
459+
rb_erase(&pstat->node, &page_tree);
460+
free(pstat);
461461

462-
stat = search_page_alloc_stat(&this, false);
463-
if (stat == NULL)
462+
pstat = search_page_alloc_stat(&this, false);
463+
if (pstat == NULL)
464464
return -ENOENT;
465465

466-
stat->nr_free++;
467-
stat->free_bytes += bytes;
466+
pstat->nr_free++;
467+
pstat->free_bytes += bytes;
468468

469469
return 0;
470470
}
@@ -640,9 +640,9 @@ static void print_page_summary(void)
640640
nr_page_frees, total_page_free_bytes / 1024);
641641
printf("\n");
642642

643-
printf("%-30s: %'16lu [ %'16"PRIu64" KB ]\n", "Total alloc+freed requests",
643+
printf("%-30s: %'16"PRIu64" [ %'16"PRIu64" KB ]\n", "Total alloc+freed requests",
644644
nr_alloc_freed, (total_alloc_freed_bytes) / 1024);
645-
printf("%-30s: %'16lu [ %'16"PRIu64" KB ]\n", "Total alloc-only requests",
645+
printf("%-30s: %'16"PRIu64" [ %'16"PRIu64" KB ]\n", "Total alloc-only requests",
646646
nr_page_allocs - nr_alloc_freed,
647647
(total_page_alloc_bytes - total_alloc_freed_bytes) / 1024);
648648
printf("%-30s: %'16lu [ %'16"PRIu64" KB ]\n", "Total free-only requests",

tools/perf/builtin-top.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ static void perf_event__process_sample(struct perf_tool *tool,
733733
"Kernel address maps (/proc/{kallsyms,modules}) are restricted.\n\n"
734734
"Check /proc/sys/kernel/kptr_restrict.\n\n"
735735
"Kernel%s samples will not be resolved.\n",
736-
!RB_EMPTY_ROOT(&al.map->dso->symbols[MAP__FUNCTION]) ?
736+
al.map && !RB_EMPTY_ROOT(&al.map->dso->symbols[MAP__FUNCTION]) ?
737737
" modules" : "");
738738
if (use_browser <= 0)
739739
sleep(5);

tools/perf/builtin-trace.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2241,10 +2241,11 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
22412241
if (err < 0)
22422242
goto out_error_mmap;
22432243

2244+
if (!target__none(&trace->opts.target))
2245+
perf_evlist__enable(evlist);
2246+
22442247
if (forks)
22452248
perf_evlist__start_workload(evlist);
2246-
else
2247-
perf_evlist__enable(evlist);
22482249

22492250
trace->multiple_threads = evlist->threads->map[0] == -1 ||
22502251
evlist->threads->nr > 1 ||
@@ -2272,6 +2273,11 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
22722273

22732274
if (interrupted)
22742275
goto out_disable;
2276+
2277+
if (done && !draining) {
2278+
perf_evlist__disable(evlist);
2279+
draining = true;
2280+
}
22752281
}
22762282
}
22772283

tools/perf/util/probe-finder.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,10 +578,12 @@ static int find_variable(Dwarf_Die *sc_die, struct probe_finder *pf)
578578
/* Search child die for local variables and parameters. */
579579
if (!die_find_variable_at(sc_die, pf->pvar->var, pf->addr, &vr_die)) {
580580
/* Search again in global variables */
581-
if (!die_find_variable_at(&pf->cu_die, pf->pvar->var, 0, &vr_die))
581+
if (!die_find_variable_at(&pf->cu_die, pf->pvar->var,
582+
0, &vr_die)) {
582583
pr_warning("Failed to find '%s' in this function.\n",
583584
pf->pvar->var);
584585
ret = -ENOENT;
586+
}
585587
}
586588
if (ret >= 0)
587589
ret = convert_variable(&vr_die, pf);

0 commit comments

Comments
 (0)