Skip to content

Commit

Permalink
Merge tag 'perf-urgent-for-mingo-5.6-20200303' of git://git.kernel.or…
Browse files Browse the repository at this point in the history
…g/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 <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Ingo Molnar committed Mar 4, 2020
2 parents 8b614cb + b5c0951 commit b95b4d5
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 40 deletions.
4 changes: 4 additions & 0 deletions tools/perf/bench/bench.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
#ifndef BENCH_H
#define BENCH_H

#include <sys/time.h>

extern struct timeval bench__start, bench__end, bench__runtime;

/*
* The madvise transparent hugepage constants were added in glibc
* 2.13. For compatibility with older versions of glibc, define these
Expand Down
7 changes: 3 additions & 4 deletions tools/perf/bench/epoll-ctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@

static unsigned int nthreads = 0;
static unsigned int nsecs = 8;
struct timeval start, end, runtime;
static bool done, __verbose, randomize;

/*
Expand Down Expand Up @@ -94,8 +93,8 @@ static void toggle_done(int sig __maybe_unused,
{
/* inform all threads that we're done for the day */
done = true;
gettimeofday(&end, NULL);
timersub(&end, &start, &runtime);
gettimeofday(&bench__end, NULL);
timersub(&bench__end, &bench__start, &bench__runtime);
}

static void nest_epollfd(void)
Expand Down Expand Up @@ -361,7 +360,7 @@ int bench_epoll_ctl(int argc, const char **argv)

threads_starting = nthreads;

gettimeofday(&start, NULL);
gettimeofday(&bench__start, NULL);

do_threads(worker, cpu);

Expand Down
11 changes: 5 additions & 6 deletions tools/perf/bench/epoll-wait.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@

static unsigned int nthreads = 0;
static unsigned int nsecs = 8;
struct timeval start, end, runtime;
static bool wdone, done, __verbose, randomize, nonblocking;

/*
Expand Down Expand Up @@ -276,8 +275,8 @@ static void toggle_done(int sig __maybe_unused,
{
/* inform all threads that we're done for the day */
done = true;
gettimeofday(&end, NULL);
timersub(&end, &start, &runtime);
gettimeofday(&bench__end, NULL);
timersub(&bench__end, &bench__start, &bench__runtime);
}

static void print_summary(void)
Expand All @@ -287,7 +286,7 @@ static void print_summary(void)

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

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

threads_starting = nthreads;

gettimeofday(&start, NULL);
gettimeofday(&bench__start, NULL);

do_threads(worker, cpu);

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

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

update_stats(&throughput_stats, t);

Expand Down
12 changes: 6 additions & 6 deletions tools/perf/bench/futex-hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static unsigned int nfutexes = 1024;
static bool fshared = false, done = false, silent = false;
static int futex_flag = 0;

struct timeval start, end, runtime;
struct timeval bench__start, bench__end, bench__runtime;
static pthread_mutex_t thread_lock;
static unsigned int threads_starting;
static struct stats throughput_stats;
Expand Down Expand Up @@ -103,8 +103,8 @@ static void toggle_done(int sig __maybe_unused,
{
/* inform all threads that we're done for the day */
done = true;
gettimeofday(&end, NULL);
timersub(&end, &start, &runtime);
gettimeofday(&bench__end, NULL);
timersub(&bench__end, &bench__start, &bench__runtime);
}

static void print_summary(void)
Expand All @@ -114,7 +114,7 @@ static void print_summary(void)

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

int bench_futex_hash(int argc, const char **argv)
Expand Down Expand Up @@ -161,7 +161,7 @@ int bench_futex_hash(int argc, const char **argv)

threads_starting = nthreads;
pthread_attr_init(&thread_attr);
gettimeofday(&start, NULL);
gettimeofday(&bench__start, NULL);
for (i = 0; i < nthreads; i++) {
worker[i].tid = i;
worker[i].futex = calloc(nfutexes, sizeof(*worker[i].futex));
Expand Down Expand Up @@ -204,7 +204,7 @@ int bench_futex_hash(int argc, const char **argv)
pthread_mutex_destroy(&thread_lock);

for (i = 0; i < nthreads; i++) {
unsigned long t = worker[i].ops/runtime.tv_sec;
unsigned long t = worker[i].ops / bench__runtime.tv_sec;
update_stats(&throughput_stats, t);
if (!silent) {
if (nfutexes == 1)
Expand Down
11 changes: 5 additions & 6 deletions tools/perf/bench/futex-lock-pi.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ static bool silent = false, multi = false;
static bool done = false, fshared = false;
static unsigned int nthreads = 0;
static int futex_flag = 0;
struct timeval start, end, runtime;
static pthread_mutex_t thread_lock;
static unsigned int threads_starting;
static struct stats throughput_stats;
Expand All @@ -64,7 +63,7 @@ static void print_summary(void)

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

static void toggle_done(int sig __maybe_unused,
Expand All @@ -73,8 +72,8 @@ static void toggle_done(int sig __maybe_unused,
{
/* inform all threads that we're done for the day */
done = true;
gettimeofday(&end, NULL);
timersub(&end, &start, &runtime);
gettimeofday(&bench__end, NULL);
timersub(&bench__end, &bench__start, &bench__runtime);
}

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

threads_starting = nthreads;
pthread_attr_init(&thread_attr);
gettimeofday(&start, NULL);
gettimeofday(&bench__start, NULL);

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

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

update_stats(&throughput_stats, t);
if (!silent)
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/tests/bp_account.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "../perf-sys.h"
#include "cloexec.h"

volatile long the_var;
static volatile long the_var;

static noinline int test_function(void)
{
Expand Down
4 changes: 2 additions & 2 deletions tools/perf/util/env.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,11 +343,11 @@ static const char *normalize_arch(char *arch)

const char *perf_env__arch(struct perf_env *env)
{
struct utsname uts;
char *arch_name;

if (!env || !env->arch) { /* Assume local operation */
if (uname(&uts) < 0)
static struct utsname uts = { .machine[0] = '\0', };
if (uts.machine[0] == '\0' && uname(&uts) < 0)
return NULL;
arch_name = uts.machine;
} else
Expand Down
10 changes: 2 additions & 8 deletions tools/perf/util/parse-events.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,21 +257,15 @@ struct tracepoint_path *tracepoint_id_to_path(u64 config)
path = zalloc(sizeof(*path));
if (!path)
return NULL;
path->system = malloc(MAX_EVENT_LENGTH);
if (!path->system) {
if (asprintf(&path->system, "%.*s", MAX_EVENT_LENGTH, sys_dirent->d_name) < 0) {
free(path);
return NULL;
}
path->name = malloc(MAX_EVENT_LENGTH);
if (!path->name) {
if (asprintf(&path->name, "%.*s", MAX_EVENT_LENGTH, evt_dirent->d_name) < 0) {
zfree(&path->system);
free(path);
return NULL;
}
strncpy(path->system, sys_dirent->d_name,
MAX_EVENT_LENGTH);
strncpy(path->name, evt_dirent->d_name,
MAX_EVENT_LENGTH);
return path;
}
}
Expand Down
13 changes: 6 additions & 7 deletions tools/perf/util/symbol.c
Original file line number Diff line number Diff line change
Expand Up @@ -1622,7 +1622,12 @@ int dso__load(struct dso *dso, struct map *map)
goto out;
}

if (dso->kernel) {
kmod = dso->symtab_type == DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE ||
dso->symtab_type == DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE_COMP ||
dso->symtab_type == DSO_BINARY_TYPE__GUEST_KMODULE ||
dso->symtab_type == DSO_BINARY_TYPE__GUEST_KMODULE_COMP;

if (dso->kernel && !kmod) {
if (dso->kernel == DSO_TYPE_KERNEL)
ret = dso__load_kernel_sym(dso, map);
else if (dso->kernel == DSO_TYPE_GUEST_KERNEL)
Expand Down Expand Up @@ -1650,12 +1655,6 @@ int dso__load(struct dso *dso, struct map *map)
if (!name)
goto out;

kmod = dso->symtab_type == DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE ||
dso->symtab_type == DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE_COMP ||
dso->symtab_type == DSO_BINARY_TYPE__GUEST_KMODULE ||
dso->symtab_type == DSO_BINARY_TYPE__GUEST_KMODULE_COMP;


/*
* Read the build id if possible. This is required for
* DSO_BINARY_TYPE__BUILDID_DEBUGINFO to work
Expand Down

0 comments on commit b95b4d5

Please sign in to comment.