]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
5.4-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 3 Aug 2020 11:51:22 +0000 (13:51 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 3 Aug 2020 11:51:22 +0000 (13:51 +0200)
added patches:
perf-bench-share-some-global-variables-to-fix-build-with-gcc-10.patch
perf-env-do-not-return-pointers-to-local-variables.patch
perf-tests-bp_account-make-global-variable-static.patch

queue-5.4/perf-bench-share-some-global-variables-to-fix-build-with-gcc-10.patch [new file with mode: 0644]
queue-5.4/perf-env-do-not-return-pointers-to-local-variables.patch [new file with mode: 0644]
queue-5.4/perf-tests-bp_account-make-global-variable-static.patch [new file with mode: 0644]
queue-5.4/series

diff --git a/queue-5.4/perf-bench-share-some-global-variables-to-fix-build-with-gcc-10.patch b/queue-5.4/perf-bench-share-some-global-variables-to-fix-build-with-gcc-10.patch
new file mode 100644 (file)
index 0000000..03b46d8
--- /dev/null
@@ -0,0 +1,230 @@
+From e4d9b04b973b2dbce7b42af95ea70d07da1c936d Mon Sep 17 00:00:00 2001
+From: Arnaldo Carvalho de Melo <acme@redhat.com>
+Date: Mon, 2 Mar 2020 12:09:38 -0300
+Subject: perf bench: Share some global variables to fix build with gcc 10
+
+From: Arnaldo Carvalho de Melo <acme@redhat.com>
+
+commit e4d9b04b973b2dbce7b42af95ea70d07da1c936d upstream.
+
+Noticed with gcc 10 (fedora rawhide) that those variables were not being
+declared as static, so end up with:
+
+  ld: /tmp/build/perf/bench/epoll-wait.o:/git/perf/tools/perf/bench/epoll-wait.c:93: multiple definition of `end'; /tmp/build/perf/bench/futex-hash.o:/git/perf/tools/perf/bench/futex-hash.c:40: first defined here
+  ld: /tmp/build/perf/bench/epoll-wait.o:/git/perf/tools/perf/bench/epoll-wait.c:93: multiple definition of `start'; /tmp/build/perf/bench/futex-hash.o:/git/perf/tools/perf/bench/futex-hash.c:40: first defined here
+  ld: /tmp/build/perf/bench/epoll-wait.o:/git/perf/tools/perf/bench/epoll-wait.c:93: multiple definition of `runtime'; /tmp/build/perf/bench/futex-hash.o:/git/perf/tools/perf/bench/futex-hash.c:40: first defined here
+  ld: /tmp/build/perf/bench/epoll-ctl.o:/git/perf/tools/perf/bench/epoll-ctl.c:38: multiple definition of `end'; /tmp/build/perf/bench/futex-hash.o:/git/perf/tools/perf/bench/futex-hash.c:40: first defined here
+  ld: /tmp/build/perf/bench/epoll-ctl.o:/git/perf/tools/perf/bench/epoll-ctl.c:38: multiple definition of `start'; /tmp/build/perf/bench/futex-hash.o:/git/perf/tools/perf/bench/futex-hash.c:40: first defined here
+  ld: /tmp/build/perf/bench/epoll-ctl.o:/git/perf/tools/perf/bench/epoll-ctl.c:38: multiple definition of `runtime'; /tmp/build/perf/bench/futex-hash.o:/git/perf/tools/perf/bench/futex-hash.c:40: first defined here
+  make[4]: *** [/git/perf/tools/build/Makefile.build:145: /tmp/build/perf/bench/perf-in.o] Error 1
+
+Prefix those with bench__ and add them to bench/bench.h, so that we can
+share those on the tools needing to access those variables from signal
+handlers.
+
+Acked-by: Thomas Gleixner <tglx@linutronix.de>
+Cc: Adrian Hunter <adrian.hunter@intel.com>
+Cc: Davidlohr Bueso <dave@stgolabs.net>
+Cc: Jiri Olsa <jolsa@kernel.org>
+Cc: Namhyung Kim <namhyung@kernel.org>
+Link: http://lore.kernel.org/lkml/20200303155811.GD13702@kernel.org
+Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
+Cc: Ben Hutchings <ben@decadent.org.uk>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ tools/perf/bench/bench.h         |    4 ++++
+ tools/perf/bench/epoll-ctl.c     |    7 +++----
+ tools/perf/bench/epoll-wait.c    |   11 +++++------
+ tools/perf/bench/futex-hash.c    |   12 ++++++------
+ tools/perf/bench/futex-lock-pi.c |   11 +++++------
+ 5 files changed, 23 insertions(+), 22 deletions(-)
+
+--- a/tools/perf/bench/bench.h
++++ b/tools/perf/bench/bench.h
+@@ -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
+--- a/tools/perf/bench/epoll-ctl.c
++++ b/tools/perf/bench/epoll-ctl.c
+@@ -35,7 +35,6 @@
+ static unsigned int nthreads = 0;
+ static unsigned int nsecs    = 8;
+-struct timeval start, end, runtime;
+ static bool done, __verbose, randomize;
+ /*
+@@ -94,8 +93,8 @@ static void toggle_done(int sig __maybe_
+ {
+       /* 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)
+@@ -361,7 +360,7 @@ int bench_epoll_ctl(int argc, const char
+       threads_starting = nthreads;
+-      gettimeofday(&start, NULL);
++      gettimeofday(&bench__start, NULL);
+       do_threads(worker, cpu);
+--- a/tools/perf/bench/epoll-wait.c
++++ b/tools/perf/bench/epoll-wait.c
+@@ -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;
+ /*
+@@ -276,8 +275,8 @@ static void toggle_done(int sig __maybe_
+ {
+       /* 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)
+@@ -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)
+@@ -479,7 +478,7 @@ int bench_epoll_wait(int argc, const cha
+       threads_starting = nthreads;
+-      gettimeofday(&start, NULL);
++      gettimeofday(&bench__start, NULL);
+       do_threads(worker, cpu);
+@@ -519,7 +518,7 @@ int bench_epoll_wait(int argc, const cha
+               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);
+--- a/tools/perf/bench/futex-hash.c
++++ b/tools/perf/bench/futex-hash.c
+@@ -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;
+@@ -103,8 +103,8 @@ static void toggle_done(int sig __maybe_
+ {
+       /* 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)
+@@ -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)
+@@ -161,7 +161,7 @@ int bench_futex_hash(int argc, const cha
+       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));
+@@ -204,7 +204,7 @@ int bench_futex_hash(int argc, const cha
+       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)
+--- a/tools/perf/bench/futex-lock-pi.c
++++ b/tools/perf/bench/futex-lock-pi.c
+@@ -37,7 +37,6 @@ static bool silent = false, multi = fals
+ 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;
+@@ -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,
+@@ -73,8 +72,8 @@ static void toggle_done(int sig __maybe_
+ {
+       /* 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)
+@@ -185,7 +184,7 @@ int bench_futex_lock_pi(int argc, const
+       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);
+@@ -211,7 +210,7 @@ int bench_futex_lock_pi(int argc, const
+       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)
diff --git a/queue-5.4/perf-env-do-not-return-pointers-to-local-variables.patch b/queue-5.4/perf-env-do-not-return-pointers-to-local-variables.patch
new file mode 100644 (file)
index 0000000..c8572cb
--- /dev/null
@@ -0,0 +1,50 @@
+From ebcb9464a2ae3a547e97de476575c82ece0e93e2 Mon Sep 17 00:00:00 2001
+From: Arnaldo Carvalho de Melo <acme@redhat.com>
+Date: Mon, 2 Mar 2020 11:23:03 -0300
+Subject: perf env: Do not return pointers to local variables
+
+From: Arnaldo Carvalho de Melo <acme@redhat.com>
+
+commit ebcb9464a2ae3a547e97de476575c82ece0e93e2 upstream.
+
+It is possible to return a pointer to a local variable when looking up
+the architecture name for the running system and no normalization is
+done on that value, i.e. we may end up returning the uts.machine local
+variable.
+
+While this doesn't happen on most arches, as normalization takes place,
+lets fix this by making that a static variable and optimize it a bit by
+not always running uname(), only the first time.
+
+Noticed in fedora rawhide running with:
+
+  [perfbuilder@a5ff49d6e6e4 ~]$ gcc --version
+  gcc (GCC) 10.0.1 20200216 (Red Hat 10.0.1-0.8)
+
+Reported-by: Jiri Olsa <jolsa@kernel.org>
+Cc: Adrian Hunter <adrian.hunter@intel.com>
+Cc: Namhyung Kim <namhyung@kernel.org>
+Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
+Cc: Ben Hutchings <ben@decadent.org.uk>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ tools/perf/util/env.c |    4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/tools/perf/util/env.c
++++ b/tools/perf/util/env.c
+@@ -326,11 +326,11 @@ static const char *normalize_arch(char *
+ 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
diff --git a/queue-5.4/perf-tests-bp_account-make-global-variable-static.patch b/queue-5.4/perf-tests-bp_account-make-global-variable-static.patch
new file mode 100644 (file)
index 0000000..fabe6a8
--- /dev/null
@@ -0,0 +1,42 @@
+From cff20b3151ccab690715cb6cf0f5da5cccb32adf Mon Sep 17 00:00:00 2001
+From: Arnaldo Carvalho de Melo <acme@redhat.com>
+Date: Mon, 2 Mar 2020 11:13:19 -0300
+Subject: perf tests bp_account: Make global variable static
+
+From: Arnaldo Carvalho de Melo <acme@redhat.com>
+
+commit cff20b3151ccab690715cb6cf0f5da5cccb32adf upstream.
+
+To fix the build with newer gccs, that without this patch exit with:
+
+    LD       /tmp/build/perf/tests/perf-in.o
+  ld: /tmp/build/perf/tests/bp_account.o:/git/perf/tools/perf/tests/bp_account.c:22: multiple definition of `the_var'; /tmp/build/perf/tests/bp_signal.o:/git/perf/tools/perf/tests/bp_signal.c:38: first defined here
+  make[4]: *** [/git/perf/tools/build/Makefile.build:145: /tmp/build/perf/tests/perf-in.o] Error 1
+
+First noticed in fedora:rawhide/32 with:
+
+  [perfbuilder@a5ff49d6e6e4 ~]$ gcc --version
+  gcc (GCC) 10.0.1 20200216 (Red Hat 10.0.1-0.8)
+
+Reported-by: Jiri Olsa <jolsa@kernel.org>
+Cc: Adrian Hunter <adrian.hunter@intel.com>
+Cc: Namhyung Kim <namhyung@kernel.org>
+Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
+Cc: Ben Hutchings <ben@decadent.org.uk>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ tools/perf/tests/bp_account.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/tools/perf/tests/bp_account.c
++++ b/tools/perf/tests/bp_account.c
+@@ -23,7 +23,7 @@
+ #include "../perf-sys.h"
+ #include "cloexec.h"
+-volatile long the_var;
++static volatile long the_var;
+ static noinline int test_function(void)
+ {
index 6a6aa71008eeb83c280d78f2f42968b62075ddbe..eb2d0fc070dcfb02cb97995be0c4146b98e56950 100644 (file)
@@ -85,3 +85,6 @@ drivers-net-wan-lapb-corrected-the-usage-of-skb_cow.patch
 kvm-arm64-don-t-inherit-exec-permission-across-page-table-levels.patch
 kvm-lapic-prevent-setting-the-tscdeadline-timer-if-the-lapic-is-hw-disabled.patch
 x86-i8259-use-printk_deferred-to-prevent-deadlock.patch
+perf-tests-bp_account-make-global-variable-static.patch
+perf-env-do-not-return-pointers-to-local-variables.patch
+perf-bench-share-some-global-variables-to-fix-build-with-gcc-10.patch