Skip to content

Commit b95b4d5

Browse files
author
Ingo Molnar
committed
Merge tag 'perf-urgent-for-mingo-5.6-20200303' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent
Pull perf/urgent fixes from Arnaldo Carvalho de Melo: perf symbols: Arnaldo Carvalho de Melo: - Don't try to find a vmlinux file when looking for kernel modules, fixing symbol resolution in systems with compressed kernel modules. perf env: Arnaldo Carvalho de Melo: - Do not return pointers to local variables, fixing valid warning from gcc 10 for corner case that stops the build due to -Werror. perf tests: Arnaldo Carvalho de Melo: - Make global variable static in the bp_account entry to fix build with gcc 10. perf parse-events: Arnaldo Carvalho de Melo: - Use asprintf() instead of strncpy() to read tracepoint files, addressing compiler warning that stops the build as we use -Werror. perf bench: Arnaldo Carvalho de Melo: - Share some global variables to fix build with gcc 10. Signed-off-by: Arnaldo Carvalho de Melo <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2 parents 8b614cb + b5c0951 commit b95b4d5

File tree

9 files changed

+34
-40
lines changed

9 files changed

+34
-40
lines changed

tools/perf/bench/bench.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
#ifndef BENCH_H
33
#define BENCH_H
44

5+
#include <sys/time.h>
6+
7+
extern struct timeval bench__start, bench__end, bench__runtime;
8+
59
/*
610
* The madvise transparent hugepage constants were added in glibc
711
* 2.13. For compatibility with older versions of glibc, define these

tools/perf/bench/epoll-ctl.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535

3636
static unsigned int nthreads = 0;
3737
static unsigned int nsecs = 8;
38-
struct timeval start, end, runtime;
3938
static bool done, __verbose, randomize;
4039

4140
/*
@@ -94,8 +93,8 @@ static void toggle_done(int sig __maybe_unused,
9493
{
9594
/* inform all threads that we're done for the day */
9695
done = true;
97-
gettimeofday(&end, NULL);
98-
timersub(&end, &start, &runtime);
96+
gettimeofday(&bench__end, NULL);
97+
timersub(&bench__end, &bench__start, &bench__runtime);
9998
}
10099

101100
static void nest_epollfd(void)
@@ -361,7 +360,7 @@ int bench_epoll_ctl(int argc, const char **argv)
361360

362361
threads_starting = nthreads;
363362

364-
gettimeofday(&start, NULL);
363+
gettimeofday(&bench__start, NULL);
365364

366365
do_threads(worker, cpu);
367366

tools/perf/bench/epoll-wait.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@
9090

9191
static unsigned int nthreads = 0;
9292
static unsigned int nsecs = 8;
93-
struct timeval start, end, runtime;
9493
static bool wdone, done, __verbose, randomize, nonblocking;
9594

9695
/*
@@ -276,8 +275,8 @@ static void toggle_done(int sig __maybe_unused,
276275
{
277276
/* inform all threads that we're done for the day */
278277
done = true;
279-
gettimeofday(&end, NULL);
280-
timersub(&end, &start, &runtime);
278+
gettimeofday(&bench__end, NULL);
279+
timersub(&bench__end, &bench__start, &bench__runtime);
281280
}
282281

283282
static void print_summary(void)
@@ -287,7 +286,7 @@ static void print_summary(void)
287286

288287
printf("\nAveraged %ld operations/sec (+- %.2f%%), total secs = %d\n",
289288
avg, rel_stddev_stats(stddev, avg),
290-
(int) runtime.tv_sec);
289+
(int)bench__runtime.tv_sec);
291290
}
292291

293292
static int do_threads(struct worker *worker, struct perf_cpu_map *cpu)
@@ -479,7 +478,7 @@ int bench_epoll_wait(int argc, const char **argv)
479478

480479
threads_starting = nthreads;
481480

482-
gettimeofday(&start, NULL);
481+
gettimeofday(&bench__start, NULL);
483482

484483
do_threads(worker, cpu);
485484

@@ -519,7 +518,7 @@ int bench_epoll_wait(int argc, const char **argv)
519518
qsort(worker, nthreads, sizeof(struct worker), cmpworker);
520519

521520
for (i = 0; i < nthreads; i++) {
522-
unsigned long t = worker[i].ops/runtime.tv_sec;
521+
unsigned long t = worker[i].ops / bench__runtime.tv_sec;
523522

524523
update_stats(&throughput_stats, t);
525524

tools/perf/bench/futex-hash.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static unsigned int nfutexes = 1024;
3737
static bool fshared = false, done = false, silent = false;
3838
static int futex_flag = 0;
3939

40-
struct timeval start, end, runtime;
40+
struct timeval bench__start, bench__end, bench__runtime;
4141
static pthread_mutex_t thread_lock;
4242
static unsigned int threads_starting;
4343
static struct stats throughput_stats;
@@ -103,8 +103,8 @@ static void toggle_done(int sig __maybe_unused,
103103
{
104104
/* inform all threads that we're done for the day */
105105
done = true;
106-
gettimeofday(&end, NULL);
107-
timersub(&end, &start, &runtime);
106+
gettimeofday(&bench__end, NULL);
107+
timersub(&bench__end, &bench__start, &bench__runtime);
108108
}
109109

110110
static void print_summary(void)
@@ -114,7 +114,7 @@ static void print_summary(void)
114114

115115
printf("%sAveraged %ld operations/sec (+- %.2f%%), total secs = %d\n",
116116
!silent ? "\n" : "", avg, rel_stddev_stats(stddev, avg),
117-
(int) runtime.tv_sec);
117+
(int)bench__runtime.tv_sec);
118118
}
119119

120120
int bench_futex_hash(int argc, const char **argv)
@@ -161,7 +161,7 @@ int bench_futex_hash(int argc, const char **argv)
161161

162162
threads_starting = nthreads;
163163
pthread_attr_init(&thread_attr);
164-
gettimeofday(&start, NULL);
164+
gettimeofday(&bench__start, NULL);
165165
for (i = 0; i < nthreads; i++) {
166166
worker[i].tid = i;
167167
worker[i].futex = calloc(nfutexes, sizeof(*worker[i].futex));
@@ -204,7 +204,7 @@ int bench_futex_hash(int argc, const char **argv)
204204
pthread_mutex_destroy(&thread_lock);
205205

206206
for (i = 0; i < nthreads; i++) {
207-
unsigned long t = worker[i].ops/runtime.tv_sec;
207+
unsigned long t = worker[i].ops / bench__runtime.tv_sec;
208208
update_stats(&throughput_stats, t);
209209
if (!silent) {
210210
if (nfutexes == 1)

tools/perf/bench/futex-lock-pi.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ static bool silent = false, multi = false;
3737
static bool done = false, fshared = false;
3838
static unsigned int nthreads = 0;
3939
static int futex_flag = 0;
40-
struct timeval start, end, runtime;
4140
static pthread_mutex_t thread_lock;
4241
static unsigned int threads_starting;
4342
static struct stats throughput_stats;
@@ -64,7 +63,7 @@ static void print_summary(void)
6463

6564
printf("%sAveraged %ld operations/sec (+- %.2f%%), total secs = %d\n",
6665
!silent ? "\n" : "", avg, rel_stddev_stats(stddev, avg),
67-
(int) runtime.tv_sec);
66+
(int)bench__runtime.tv_sec);
6867
}
6968

7069
static void toggle_done(int sig __maybe_unused,
@@ -73,8 +72,8 @@ static void toggle_done(int sig __maybe_unused,
7372
{
7473
/* inform all threads that we're done for the day */
7574
done = true;
76-
gettimeofday(&end, NULL);
77-
timersub(&end, &start, &runtime);
75+
gettimeofday(&bench__end, NULL);
76+
timersub(&bench__end, &bench__start, &bench__runtime);
7877
}
7978

8079
static void *workerfn(void *arg)
@@ -185,7 +184,7 @@ int bench_futex_lock_pi(int argc, const char **argv)
185184

186185
threads_starting = nthreads;
187186
pthread_attr_init(&thread_attr);
188-
gettimeofday(&start, NULL);
187+
gettimeofday(&bench__start, NULL);
189188

190189
create_threads(worker, thread_attr, cpu);
191190
pthread_attr_destroy(&thread_attr);
@@ -211,7 +210,7 @@ int bench_futex_lock_pi(int argc, const char **argv)
211210
pthread_mutex_destroy(&thread_lock);
212211

213212
for (i = 0; i < nthreads; i++) {
214-
unsigned long t = worker[i].ops/runtime.tv_sec;
213+
unsigned long t = worker[i].ops / bench__runtime.tv_sec;
215214

216215
update_stats(&throughput_stats, t);
217216
if (!silent)

tools/perf/tests/bp_account.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include "../perf-sys.h"
2020
#include "cloexec.h"
2121

22-
volatile long the_var;
22+
static volatile long the_var;
2323

2424
static noinline int test_function(void)
2525
{

tools/perf/util/env.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,11 +343,11 @@ static const char *normalize_arch(char *arch)
343343

344344
const char *perf_env__arch(struct perf_env *env)
345345
{
346-
struct utsname uts;
347346
char *arch_name;
348347

349348
if (!env || !env->arch) { /* Assume local operation */
350-
if (uname(&uts) < 0)
349+
static struct utsname uts = { .machine[0] = '\0', };
350+
if (uts.machine[0] == '\0' && uname(&uts) < 0)
351351
return NULL;
352352
arch_name = uts.machine;
353353
} else

tools/perf/util/parse-events.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -257,21 +257,15 @@ struct tracepoint_path *tracepoint_id_to_path(u64 config)
257257
path = zalloc(sizeof(*path));
258258
if (!path)
259259
return NULL;
260-
path->system = malloc(MAX_EVENT_LENGTH);
261-
if (!path->system) {
260+
if (asprintf(&path->system, "%.*s", MAX_EVENT_LENGTH, sys_dirent->d_name) < 0) {
262261
free(path);
263262
return NULL;
264263
}
265-
path->name = malloc(MAX_EVENT_LENGTH);
266-
if (!path->name) {
264+
if (asprintf(&path->name, "%.*s", MAX_EVENT_LENGTH, evt_dirent->d_name) < 0) {
267265
zfree(&path->system);
268266
free(path);
269267
return NULL;
270268
}
271-
strncpy(path->system, sys_dirent->d_name,
272-
MAX_EVENT_LENGTH);
273-
strncpy(path->name, evt_dirent->d_name,
274-
MAX_EVENT_LENGTH);
275269
return path;
276270
}
277271
}

tools/perf/util/symbol.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1622,7 +1622,12 @@ int dso__load(struct dso *dso, struct map *map)
16221622
goto out;
16231623
}
16241624

1625-
if (dso->kernel) {
1625+
kmod = dso->symtab_type == DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE ||
1626+
dso->symtab_type == DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE_COMP ||
1627+
dso->symtab_type == DSO_BINARY_TYPE__GUEST_KMODULE ||
1628+
dso->symtab_type == DSO_BINARY_TYPE__GUEST_KMODULE_COMP;
1629+
1630+
if (dso->kernel && !kmod) {
16261631
if (dso->kernel == DSO_TYPE_KERNEL)
16271632
ret = dso__load_kernel_sym(dso, map);
16281633
else if (dso->kernel == DSO_TYPE_GUEST_KERNEL)
@@ -1650,12 +1655,6 @@ int dso__load(struct dso *dso, struct map *map)
16501655
if (!name)
16511656
goto out;
16521657

1653-
kmod = dso->symtab_type == DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE ||
1654-
dso->symtab_type == DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE_COMP ||
1655-
dso->symtab_type == DSO_BINARY_TYPE__GUEST_KMODULE ||
1656-
dso->symtab_type == DSO_BINARY_TYPE__GUEST_KMODULE_COMP;
1657-
1658-
16591658
/*
16601659
* Read the build id if possible. This is required for
16611660
* DSO_BINARY_TYPE__BUILDID_DEBUGINFO to work

0 commit comments

Comments
 (0)