]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.14-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 20 Mar 2021 11:02:55 +0000 (12:02 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 20 Mar 2021 11:02:55 +0000 (12:02 +0100)
added patches:
perf-make-perf-able-to-build-with-latest-libbfd.patch
perf-tools-use-define-api.pure-full-instead-of-pure-parser.patch
tools-build-check-if-gettid-is-available-before-providing-helper.patch
tools-build-feature-check-if-eventfd-is-available.patch
tools-build-feature-check-if-get_current_dir_name-is-available.patch
tools-build-feature-check-if-pthread_barrier_t-is-available.patch

queue-4.14/perf-make-perf-able-to-build-with-latest-libbfd.patch [new file with mode: 0644]
queue-4.14/perf-tools-use-define-api.pure-full-instead-of-pure-parser.patch [new file with mode: 0644]
queue-4.14/series
queue-4.14/tools-build-check-if-gettid-is-available-before-providing-helper.patch [new file with mode: 0644]
queue-4.14/tools-build-feature-check-if-eventfd-is-available.patch [new file with mode: 0644]
queue-4.14/tools-build-feature-check-if-get_current_dir_name-is-available.patch [new file with mode: 0644]
queue-4.14/tools-build-feature-check-if-pthread_barrier_t-is-available.patch [new file with mode: 0644]

diff --git a/queue-4.14/perf-make-perf-able-to-build-with-latest-libbfd.patch b/queue-4.14/perf-make-perf-able-to-build-with-latest-libbfd.patch
new file mode 100644 (file)
index 0000000..f914381
--- /dev/null
@@ -0,0 +1,61 @@
+From 0ada120c883d4f1f6aafd01cf0fbb10d8bbba015 Mon Sep 17 00:00:00 2001
+From: Changbin Du <changbin.du@gmail.com>
+Date: Tue, 28 Jan 2020 23:29:38 +0800
+Subject: perf: Make perf able to build with latest libbfd
+
+From: Changbin Du <changbin.du@gmail.com>
+
+commit 0ada120c883d4f1f6aafd01cf0fbb10d8bbba015 upstream.
+
+libbfd has changed the bfd_section_* macros to inline functions
+bfd_section_<field> since 2019-09-18. See below two commits:
+  o http://www.sourceware.org/ml/gdb-cvs/2019-09/msg00064.html
+  o https://www.sourceware.org/ml/gdb-cvs/2019-09/msg00072.html
+
+This fix make perf able to build with both old and new libbfd.
+
+Signed-off-by: Changbin Du <changbin.du@gmail.com>
+Acked-by: Jiri Olsa <jolsa@redhat.com>
+Cc: Peter Zijlstra <peterz@infradead.org>
+Link: http://lore.kernel.org/lkml/20200128152938.31413-1-changbin.du@gmail.com
+Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
+Cc: Guenter Roeck <linux@roeck-us.net>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ tools/perf/util/srcline.c |   16 +++++++++++++++-
+ 1 file changed, 15 insertions(+), 1 deletion(-)
+
+--- a/tools/perf/util/srcline.c
++++ b/tools/perf/util/srcline.c
+@@ -139,16 +139,30 @@ static void find_address_in_section(bfd
+       bfd_vma pc, vma;
+       bfd_size_type size;
+       struct a2l_data *a2l = data;
++      flagword flags;
+       if (a2l->found)
+               return;
+-      if ((bfd_get_section_flags(abfd, section) & SEC_ALLOC) == 0)
++#ifdef bfd_get_section_flags
++      flags = bfd_get_section_flags(abfd, section);
++#else
++      flags = bfd_section_flags(section);
++#endif
++      if ((flags & SEC_ALLOC) == 0)
+               return;
+       pc = a2l->addr;
++#ifdef bfd_get_section_vma
+       vma = bfd_get_section_vma(abfd, section);
++#else
++      vma = bfd_section_vma(section);
++#endif
++#ifdef bfd_get_section_size
+       size = bfd_get_section_size(section);
++#else
++      size = bfd_section_size(section);
++#endif
+       if (pc < vma || pc >= vma + size)
+               return;
diff --git a/queue-4.14/perf-tools-use-define-api.pure-full-instead-of-pure-parser.patch b/queue-4.14/perf-tools-use-define-api.pure-full-instead-of-pure-parser.patch
new file mode 100644 (file)
index 0000000..40a9ec0
--- /dev/null
@@ -0,0 +1,51 @@
+From fc8c0a99223367b071c83711259d754b6bb7a379 Mon Sep 17 00:00:00 2001
+From: Jiri Olsa <jolsa@redhat.com>
+Date: Sun, 12 Jan 2020 20:22:59 +0100
+Subject: perf tools: Use %define api.pure full instead of %pure-parser
+
+From: Jiri Olsa <jolsa@redhat.com>
+
+commit fc8c0a99223367b071c83711259d754b6bb7a379 upstream.
+
+bison deprecated the "%pure-parser" directive in favor of "%define
+api.pure full".
+
+The api.pure got introduced in bison 2.3 (Oct 2007), so it seems safe to
+use it without any version check.
+
+Signed-off-by: Jiri Olsa <jolsa@kernel.org>
+Cc: Adrian Hunter <adrian.hunter@intel.com>
+Cc: Clark Williams <williams@redhat.com>
+Cc: Jiri Olsa <jolsa@kernel.org>
+Cc: Namhyung Kim <namhyung@kernel.org>
+Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
+Cc: Thomas Gleixner <tglx@linutronix.de>
+Link: http://lore.kernel.org/lkml/20200112192259.GA35080@krava
+Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
+Cc: Guenter Roeck <linux@roeck-us.net>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ tools/perf/util/expr.y         |    3 ++-
+ tools/perf/util/parse-events.y |    2 +-
+ 2 files changed, 3 insertions(+), 2 deletions(-)
+
+--- a/tools/perf/util/expr.y
++++ b/tools/perf/util/expr.y
+@@ -10,7 +10,8 @@
+ #define MAXIDLEN 256
+ %}
+-%pure-parser
++%define api.pure full
++
+ %parse-param { double *final_val }
+ %parse-param { struct parse_ctx *ctx }
+ %parse-param { const char **pp }
+--- a/tools/perf/util/parse-events.y
++++ b/tools/perf/util/parse-events.y
+@@ -1,4 +1,4 @@
+-%pure-parser
++%define api.pure full
+ %parse-param {void *_parse_state}
+ %parse-param {void *scanner}
+ %lex-param {void* scanner}
index f52928951cef31d704fd2a6894e69757e44a1275..2d0b35a739fea8c7079ce6e8c79410ced4569be0 100644 (file)
@@ -7,3 +7,9 @@ bpf-add-sanity-check-for-upper-ptr_limit.patch
 net-dsa-b53-support-setting-learning-on-port.patch
 bpf-prohibit-alu-ops-for-pointer-types-not-defining-ptr_limit.patch
 revert-pm-runtime-update-device-status-before-letting-suppliers-suspend.patch
+perf-tools-use-define-api.pure-full-instead-of-pure-parser.patch
+tools-build-feature-check-if-get_current_dir_name-is-available.patch
+tools-build-feature-check-if-eventfd-is-available.patch
+tools-build-check-if-gettid-is-available-before-providing-helper.patch
+perf-make-perf-able-to-build-with-latest-libbfd.patch
+tools-build-feature-check-if-pthread_barrier_t-is-available.patch
diff --git a/queue-4.14/tools-build-check-if-gettid-is-available-before-providing-helper.patch b/queue-4.14/tools-build-check-if-gettid-is-available-before-providing-helper.patch
new file mode 100644 (file)
index 0000000..b94229d
--- /dev/null
@@ -0,0 +1,158 @@
+From 4541a8bb13a86e504416a13360c8dc64d2fd612a Mon Sep 17 00:00:00 2001
+From: Arnaldo Carvalho de Melo <acme@redhat.com>
+Date: Thu, 13 Jun 2019 12:04:19 -0300
+Subject: tools build: Check if gettid() is available before providing helper
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Arnaldo Carvalho de Melo <acme@redhat.com>
+
+commit 4541a8bb13a86e504416a13360c8dc64d2fd612a upstream.
+
+Laura reported that the perf build failed in fedora when we got a glibc
+that provides gettid(), which I reproduced using fedora rawhide with the
+glibc-devel-2.29.9000-26.fc31.x86_64 package.
+
+Add a feature check to avoid providing a gettid() helper in such
+systems.
+
+On a fedora rawhide system with this patch applied we now get:
+
+  [root@7a5f55352234 perf]# grep gettid /tmp/build/perf/FEATURE-DUMP
+  feature-gettid=1
+  [root@7a5f55352234 perf]# cat /tmp/build/perf/feature/test-gettid.make.output
+  [root@7a5f55352234 perf]# ldd /tmp/build/perf/feature/test-gettid.bin
+          linux-vdso.so.1 (0x00007ffc6b1f6000)
+          libc.so.6 => /lib64/libc.so.6 (0x00007f04e0a74000)
+          /lib64/ld-linux-x86-64.so.2 (0x00007f04e0c47000)
+  [root@7a5f55352234 perf]# nm /tmp/build/perf/feature/test-gettid.bin | grep -w gettid
+                   U gettid@@GLIBC_2.30
+  [root@7a5f55352234 perf]#
+
+While on a fedora:29 system:
+
+  [acme@quaco perf]$ grep gettid /tmp/build/perf/FEATURE-DUMP
+  feature-gettid=0
+  [acme@quaco perf]$ cat /tmp/build/perf/feature/test-gettid.make.output
+  test-gettid.c: In function ‘main’:
+  test-gettid.c:8:9: error: implicit declaration of function ‘gettid’; did you mean ‘getgid’? [-Werror=implicit-function-declaration]
+    return gettid();
+           ^~~~~~
+           getgid
+  cc1: all warnings being treated as errors
+  [acme@quaco perf]$
+
+Reported-by: Laura Abbott <labbott@redhat.com>
+Tested-by: Laura Abbott <labbott@redhat.com>
+Acked-by: Jiri Olsa <jolsa@kernel.org>
+Cc: Adrian Hunter <adrian.hunter@intel.com>
+Cc: Florian Weimer <fweimer@redhat.com>
+Cc: Namhyung Kim <namhyung@kernel.org>
+Cc: Stephane Eranian <eranian@google.com>
+Link: https://lkml.kernel.org/n/tip-yfy3ch53agmklwu9o7rlgf9c@git.kernel.org
+Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ tools/build/Makefile.feature      |    1 +
+ tools/build/feature/Makefile      |    4 ++++
+ tools/build/feature/test-all.c    |    5 +++++
+ tools/build/feature/test-gettid.c |   11 +++++++++++
+ tools/perf/Makefile.config        |    4 ++++
+ tools/perf/jvmti/jvmti_agent.c    |    2 ++
+ 6 files changed, 27 insertions(+)
+ create mode 100644 tools/build/feature/test-gettid.c
+
+--- a/tools/build/Makefile.feature
++++ b/tools/build/Makefile.feature
+@@ -35,6 +35,7 @@ FEATURE_TESTS_BASIC :=
+         fortify-source                  \
+         sync-compare-and-swap           \
+         get_current_dir_name            \
++        gettid                                \
+         glibc                           \
+         gtk2                            \
+         gtk2-infobar                    \
+--- a/tools/build/feature/Makefile
++++ b/tools/build/feature/Makefile
+@@ -51,6 +51,7 @@ FILES=
+          test-get_cpuid.bin                     \
+          test-sdt.bin                           \
+          test-cxx.bin                           \
++         test-gettid.bin                      \
+          test-jvmti.bin                               \
+          test-sched_getcpu.bin                        \
+          test-setns.bin
+@@ -242,6 +243,9 @@ $(OUTPUT)test-sdt.bin:
+ $(OUTPUT)test-cxx.bin:
+       $(BUILDXX) -std=gnu++11
++$(OUTPUT)test-gettid.bin:
++      $(BUILD)
++
+ $(OUTPUT)test-jvmti.bin:
+       $(BUILD)
+--- a/tools/build/feature/test-all.c
++++ b/tools/build/feature/test-all.c
+@@ -38,6 +38,10 @@
+ # include "test-get_current_dir_name.c"
+ #undef main
++#define main main_test_gettid
++# include "test-gettid.c"
++#undef main
++
+ #define main main_test_glibc
+ # include "test-glibc.c"
+ #undef main
+@@ -175,6 +179,7 @@ int main(int argc, char *argv[])
+       main_test_libelf();
+       main_test_libelf_mmap();
+       main_test_get_current_dir_name();
++      main_test_gettid();
+       main_test_glibc();
+       main_test_dwarf();
+       main_test_dwarf_getlocations();
+--- /dev/null
++++ b/tools/build/feature/test-gettid.c
+@@ -0,0 +1,11 @@
++// SPDX-License-Identifier: GPL-2.0
++// Copyright (C) 2019, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
++#define _GNU_SOURCE
++#include <unistd.h>
++
++int main(void)
++{
++      return gettid();
++}
++
++#undef _GNU_SOURCE
+--- a/tools/perf/Makefile.config
++++ b/tools/perf/Makefile.config
+@@ -289,6 +289,10 @@ ifeq ($(feature-get_current_dir_name), 1
+   CFLAGS += -DHAVE_GET_CURRENT_DIR_NAME
+ endif
++ifeq ($(feature-gettid), 1)
++  CFLAGS += -DHAVE_GETTID
++endif
++
+ ifdef NO_LIBELF
+   NO_DWARF := 1
+   NO_DEMANGLE := 1
+--- a/tools/perf/jvmti/jvmti_agent.c
++++ b/tools/perf/jvmti/jvmti_agent.c
+@@ -45,10 +45,12 @@
+ static char jit_path[PATH_MAX];
+ static void *marker_addr;
++#ifndef HAVE_GETTID
+ static inline pid_t gettid(void)
+ {
+       return (pid_t)syscall(__NR_gettid);
+ }
++#endif
+ static int get_e_machine(struct jitheader *hdr)
+ {
diff --git a/queue-4.14/tools-build-feature-check-if-eventfd-is-available.patch b/queue-4.14/tools-build-feature-check-if-eventfd-is-available.patch
new file mode 100644 (file)
index 0000000..e13ffbf
--- /dev/null
@@ -0,0 +1,139 @@
+From 11c6cbe706f218a8dc7e1f962f12b3a52ddd33a9 Mon Sep 17 00:00:00 2001
+From: Arnaldo Carvalho de Melo <acme@redhat.com>
+Date: Wed, 21 Nov 2018 17:42:00 -0300
+Subject: tools build feature: Check if eventfd() is available
+
+From: Arnaldo Carvalho de Melo <acme@redhat.com>
+
+commit 11c6cbe706f218a8dc7e1f962f12b3a52ddd33a9 upstream.
+
+A new 'perf bench epoll' will use this, and to disable it for older
+systems, add a feature test for this API.
+
+This is just a simple program that if successfully compiled, means that
+the feature is present, at least at the library level, in a build that
+sets the output directory to /tmp/build/perf (using O=/tmp/build/perf),
+we end up with:
+
+  $ ls -la /tmp/build/perf/feature/test-eventfd*
+  -rwxrwxr-x. 1 acme acme 8176 Nov 21 15:58 /tmp/build/perf/feature/test-eventfd.bin
+  -rw-rw-r--. 1 acme acme  588 Nov 21 15:58 /tmp/build/perf/feature/test-eventfd.d
+  -rw-rw-r--. 1 acme acme    0 Nov 21 15:58 /tmp/build/perf/feature/test-eventfd.make.output
+  $ ldd /tmp/build/perf/feature/test-eventfd.bin
+         linux-vdso.so.1 (0x00007fff3bf3f000)
+         libc.so.6 => /lib64/libc.so.6 (0x00007fa984061000)
+         /lib64/ld-linux-x86-64.so.2 (0x00007fa984417000)
+  $ grep eventfd -A 2 -B 2 /tmp/build/perf/FEATURE-DUMP
+  feature-dwarf=1
+  feature-dwarf_getlocations=1
+  feature-eventfd=1
+  feature-fortify-source=1
+  feature-sync-compare-and-swap=1
+  $
+
+The main thing here is that in the end we'll have -DHAVE_EVENTFD in
+CFLAGS, and then the 'perf bench' entry needing that API can be
+selectively pruned.
+
+Cc: Adrian Hunter <adrian.hunter@intel.com>
+Cc: Andrew Morton <akpm@linux-foundation.org>
+Cc: David Ahern <dsahern@gmail.com>
+Cc: Davidlohr Bueso <dbueso@suse.de>
+Cc: Jason Baron <jbaron@akamai.com>
+Cc: Jiri Olsa <jolsa@kernel.org>
+Cc: Namhyung Kim <namhyung@kernel.org>
+Cc: Wang Nan <wangnan0@huawei.com>
+Link: https://lkml.kernel.org/n/tip-wkeldwob7dpx6jvtuzl8164k@git.kernel.org
+Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
+Cc: Guenter Roeck <linux@roeck-us.net>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ tools/build/Makefile.feature       |    1 +
+ tools/build/feature/Makefile       |    4 ++++
+ tools/build/feature/test-all.c     |    5 +++++
+ tools/build/feature/test-eventfd.c |    9 +++++++++
+ tools/perf/Makefile.config         |    5 ++++-
+ 5 files changed, 23 insertions(+), 1 deletion(-)
+ create mode 100644 tools/build/feature/test-eventfd.c
+
+--- a/tools/build/Makefile.feature
++++ b/tools/build/Makefile.feature
+@@ -31,6 +31,7 @@ FEATURE_TESTS_BASIC :=
+         backtrace                       \
+         dwarf                           \
+         dwarf_getlocations              \
++        eventfd                         \
+         fortify-source                  \
+         sync-compare-and-swap           \
+         get_current_dir_name            \
+--- a/tools/build/feature/Makefile
++++ b/tools/build/feature/Makefile
+@@ -5,6 +5,7 @@ FILES=
+          test-bionic.bin                        \
+          test-dwarf.bin                         \
+          test-dwarf_getlocations.bin            \
++         test-eventfd.bin                       \
+          test-fortify-source.bin                \
+          test-sync-compare-and-swap.bin         \
+          test-get_current_dir_name.bin          \
+@@ -90,6 +91,9 @@ $(OUTPUT)test-bionic.bin:
+ $(OUTPUT)test-libelf.bin:
+       $(BUILD) -lelf
++$(OUTPUT)test-eventfd.bin:
++      $(BUILD)
++
+ $(OUTPUT)test-get_current_dir_name.bin:
+       $(BUILD)
+--- a/tools/build/feature/test-all.c
++++ b/tools/build/feature/test-all.c
+@@ -50,6 +50,10 @@
+ # include "test-dwarf_getlocations.c"
+ #undef main
++#define main main_test_eventfd
++# include "test-eventfd.c"
++#undef main
++
+ #define main main_test_libelf_getphdrnum
+ # include "test-libelf-getphdrnum.c"
+ #undef main
+@@ -174,6 +178,7 @@ int main(int argc, char *argv[])
+       main_test_glibc();
+       main_test_dwarf();
+       main_test_dwarf_getlocations();
++      main_test_eventfd();
+       main_test_libelf_getphdrnum();
+       main_test_libelf_gelf_getnote();
+       main_test_libelf_getshdrstrndx();
+--- /dev/null
++++ b/tools/build/feature/test-eventfd.c
+@@ -0,0 +1,9 @@
++// SPDX-License-Identifier: GPL-2.0
++// Copyright (C) 2018, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
++
++#include <sys/eventfd.h>
++
++int main(void)
++{
++      return eventfd(0, EFD_NONBLOCK);
++}
+--- a/tools/perf/Makefile.config
++++ b/tools/perf/Makefile.config
+@@ -281,11 +281,14 @@ ifndef NO_BIONIC
+   endif
+ endif
++ifeq ($(feature-eventfd), 1)
++  CFLAGS += -DHAVE_EVENTFD
++endif
++
+ ifeq ($(feature-get_current_dir_name), 1)
+   CFLAGS += -DHAVE_GET_CURRENT_DIR_NAME
+ endif
+-
+ ifdef NO_LIBELF
+   NO_DWARF := 1
+   NO_DEMANGLE := 1
diff --git a/queue-4.14/tools-build-feature-check-if-get_current_dir_name-is-available.patch b/queue-4.14/tools-build-feature-check-if-get_current_dir_name-is-available.patch
new file mode 100644 (file)
index 0000000..55913d0
--- /dev/null
@@ -0,0 +1,157 @@
+From 8feb8efef97a134933620071e0b6384cb3238b4e Mon Sep 17 00:00:00 2001
+From: Arnaldo Carvalho de Melo <acme@redhat.com>
+Date: Mon, 19 Nov 2018 16:56:22 -0300
+Subject: tools build feature: Check if get_current_dir_name() is available
+
+From: Arnaldo Carvalho de Melo <acme@redhat.com>
+
+commit 8feb8efef97a134933620071e0b6384cb3238b4e upstream.
+
+As the namespace support code will use this, which is not available in
+some non _GNU_SOURCE libraries such as Android's bionic used in my
+container build tests (r12b and r15c at the moment).
+
+Cc: Adrian Hunter <adrian.hunter@intel.com>
+Cc: David Ahern <dsahern@gmail.com>
+Cc: Jiri Olsa <jolsa@kernel.org>
+Cc: Namhyung Kim <namhyung@kernel.org>
+Cc: Wang Nan <wangnan0@huawei.com>
+Link: https://lkml.kernel.org/n/tip-x56ypm940pwclwu45d7jfj47@git.kernel.org
+Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
+Cc: Guenter Roeck <linux@roeck-us.net>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ tools/build/Makefile.feature                    |    1 +
+ tools/build/feature/Makefile                    |    4 ++++
+ tools/build/feature/test-all.c                  |    5 +++++
+ tools/build/feature/test-get_current_dir_name.c |   10 ++++++++++
+ tools/perf/Makefile.config                      |    5 +++++
+ tools/perf/util/Build                           |    1 +
+ tools/perf/util/get_current_dir_name.c          |   18 ++++++++++++++++++
+ tools/perf/util/util.h                          |    4 ++++
+ 8 files changed, 48 insertions(+)
+ create mode 100644 tools/build/feature/test-get_current_dir_name.c
+ create mode 100644 tools/perf/util/get_current_dir_name.c
+
+--- a/tools/build/Makefile.feature
++++ b/tools/build/Makefile.feature
+@@ -33,6 +33,7 @@ FEATURE_TESTS_BASIC :=
+         dwarf_getlocations              \
+         fortify-source                  \
+         sync-compare-and-swap           \
++        get_current_dir_name            \
+         glibc                           \
+         gtk2                            \
+         gtk2-infobar                    \
+--- a/tools/build/feature/Makefile
++++ b/tools/build/feature/Makefile
+@@ -7,6 +7,7 @@ FILES=
+          test-dwarf_getlocations.bin            \
+          test-fortify-source.bin                \
+          test-sync-compare-and-swap.bin         \
++         test-get_current_dir_name.bin          \
+          test-glibc.bin                         \
+          test-gtk2.bin                          \
+          test-gtk2-infobar.bin                  \
+@@ -89,6 +90,9 @@ $(OUTPUT)test-bionic.bin:
+ $(OUTPUT)test-libelf.bin:
+       $(BUILD) -lelf
++$(OUTPUT)test-get_current_dir_name.bin:
++      $(BUILD)
++
+ $(OUTPUT)test-glibc.bin:
+       $(BUILD)
+--- a/tools/build/feature/test-all.c
++++ b/tools/build/feature/test-all.c
+@@ -34,6 +34,10 @@
+ # include "test-libelf-mmap.c"
+ #undef main
++#define main main_test_get_current_dir_name
++# include "test-get_current_dir_name.c"
++#undef main
++
+ #define main main_test_glibc
+ # include "test-glibc.c"
+ #undef main
+@@ -166,6 +170,7 @@ int main(int argc, char *argv[])
+       main_test_hello();
+       main_test_libelf();
+       main_test_libelf_mmap();
++      main_test_get_current_dir_name();
+       main_test_glibc();
+       main_test_dwarf();
+       main_test_dwarf_getlocations();
+--- /dev/null
++++ b/tools/build/feature/test-get_current_dir_name.c
+@@ -0,0 +1,10 @@
++// SPDX-License-Identifier: GPL-2.0
++#define _GNU_SOURCE
++#include <unistd.h>
++#include <stdlib.h>
++
++int main(void)
++{
++      free(get_current_dir_name());
++      return 0;
++}
+--- a/tools/perf/Makefile.config
++++ b/tools/perf/Makefile.config
+@@ -281,6 +281,11 @@ ifndef NO_BIONIC
+   endif
+ endif
++ifeq ($(feature-get_current_dir_name), 1)
++  CFLAGS += -DHAVE_GET_CURRENT_DIR_NAME
++endif
++
++
+ ifdef NO_LIBELF
+   NO_DWARF := 1
+   NO_DEMANGLE := 1
+--- a/tools/perf/util/Build
++++ b/tools/perf/util/Build
+@@ -10,6 +10,7 @@ libperf-y += evlist.o
+ libperf-y += evsel.o
+ libperf-y += evsel_fprintf.o
+ libperf-y += find_bit.o
++libperf-y += get_current_dir_name.o
+ libperf-y += kallsyms.o
+ libperf-y += levenshtein.o
+ libperf-y += llvm-utils.o
+--- /dev/null
++++ b/tools/perf/util/get_current_dir_name.c
+@@ -0,0 +1,18 @@
++// SPDX-License-Identifier: GPL-2.0
++// Copyright (C) 2018, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
++//
++#ifndef HAVE_GET_CURRENT_DIR_NAME
++#include "util.h"
++#include <unistd.h>
++#include <stdlib.h>
++#include <stdlib.h>
++
++/* Android's 'bionic' library, for one, doesn't have this */
++
++char *get_current_dir_name(void)
++{
++      char pwd[PATH_MAX];
++
++      return getcwd(pwd, sizeof(pwd)) == NULL ? NULL : strdup(pwd);
++}
++#endif // HAVE_GET_CURRENT_DIR_NAME
+--- a/tools/perf/util/util.h
++++ b/tools/perf/util/util.h
+@@ -57,6 +57,10 @@ int fetch_kernel_version(unsigned int *p
+ const char *perf_tip(const char *dirpath);
++#ifndef HAVE_GET_CURRENT_DIR_NAME
++char *get_current_dir_name(void);
++#endif
++
+ #ifndef HAVE_SCHED_GETCPU_SUPPORT
+ int sched_getcpu(void);
+ #endif
diff --git a/queue-4.14/tools-build-feature-check-if-pthread_barrier_t-is-available.patch b/queue-4.14/tools-build-feature-check-if-pthread_barrier_t-is-available.patch
new file mode 100644 (file)
index 0000000..97702df
--- /dev/null
@@ -0,0 +1,113 @@
+From 25ab5abf5b141d7fd13eed506c7458aa04749c29 Mon Sep 17 00:00:00 2001
+From: Arnaldo Carvalho de Melo <acme@redhat.com>
+Date: Tue, 5 Dec 2017 10:14:42 -0300
+Subject: tools build feature: Check if pthread_barrier_t is available
+
+From: Arnaldo Carvalho de Melo <acme@redhat.com>
+
+commit 25ab5abf5b141d7fd13eed506c7458aa04749c29 upstream.
+
+As 'perf bench futex wake-parallel" will use this, which is not
+available in older systems such as versions of the android NDK used in
+my container build tests (r12b and r15c at the moment).
+
+Cc: Adrian Hunter <adrian.hunter@intel.com>
+Cc: David Ahern <dsahern@gmail.com>
+Cc: Davidlohr Bueso <dave@stgolabs.net>
+Cc: James Yang <james.yang@arm.com
+Cc: Jiri Olsa <jolsa@kernel.org>
+Cc: Kim Phillips <kim.phillips@arm.com>
+Cc: Namhyung Kim <namhyung@kernel.org>
+Cc: Wang Nan <wangnan0@huawei.com>
+Link: https://lkml.kernel.org/n/tip-1i7iv54in4wj08lwo55b0pzv@git.kernel.org
+Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
+Cc: Guenter Roeck <linux@roeck-us.net>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ tools/build/Makefile.feature               |    1 +
+ tools/build/feature/Makefile               |    4 ++++
+ tools/build/feature/test-all.c             |    5 +++++
+ tools/build/feature/test-pthread-barrier.c |   12 ++++++++++++
+ tools/perf/Makefile.config                 |    4 ++++
+ 5 files changed, 26 insertions(+)
+ create mode 100644 tools/build/feature/test-pthread-barrier.c
+
+--- a/tools/build/Makefile.feature
++++ b/tools/build/Makefile.feature
+@@ -59,6 +59,7 @@ FEATURE_TESTS_BASIC :=
+         libunwind-arm                   \
+         libunwind-aarch64               \
+         pthread-attr-setaffinity-np     \
++        pthread-barrier               \
+         stackprotector-all              \
+         timerfd                         \
+         libdw-dwarf-unwind              \
+--- a/tools/build/feature/Makefile
++++ b/tools/build/feature/Makefile
+@@ -39,6 +39,7 @@ FILES=
+          test-libunwind-debug-frame-arm.bin     \
+          test-libunwind-debug-frame-aarch64.bin \
+          test-pthread-attr-setaffinity-np.bin   \
++         test-pthread-barrier.bin             \
+          test-stackprotector-all.bin            \
+          test-timerfd.bin                       \
+          test-libdw-dwarf-unwind.bin            \
+@@ -80,6 +81,9 @@ $(OUTPUT)test-hello.bin:
+ $(OUTPUT)test-pthread-attr-setaffinity-np.bin:
+       $(BUILD) -D_GNU_SOURCE -lpthread
++$(OUTPUT)test-pthread-barrier.bin:
++      $(BUILD) -lpthread
++
+ $(OUTPUT)test-stackprotector-all.bin:
+       $(BUILD) -fstack-protector-all
+--- a/tools/build/feature/test-all.c
++++ b/tools/build/feature/test-all.c
+@@ -130,6 +130,10 @@
+ # include "test-pthread-attr-setaffinity-np.c"
+ #undef main
++#define main main_test_pthread_barrier
++# include "test-pthread-barrier.c"
++#undef main
++
+ #define main main_test_sched_getcpu
+ # include "test-sched_getcpu.c"
+ #undef main
+@@ -202,6 +206,7 @@ int main(int argc, char *argv[])
+       main_test_sync_compare_and_swap(argc, argv);
+       main_test_zlib();
+       main_test_pthread_attr_setaffinity_np();
++      main_test_pthread_barrier();
+       main_test_lzma();
+       main_test_get_cpuid();
+       main_test_bpf();
+--- /dev/null
++++ b/tools/build/feature/test-pthread-barrier.c
+@@ -0,0 +1,12 @@
++// SPDX-License-Identifier: GPL-2.0
++#include <stdint.h>
++#include <pthread.h>
++
++int main(void)
++{
++      pthread_barrier_t barrier;
++
++      pthread_barrier_init(&barrier, NULL, 1);
++      pthread_barrier_wait(&barrier);
++      return pthread_barrier_destroy(&barrier);
++}
+--- a/tools/perf/Makefile.config
++++ b/tools/perf/Makefile.config
+@@ -272,6 +272,10 @@ ifeq ($(feature-pthread-attr-setaffinity
+   CFLAGS += -DHAVE_PTHREAD_ATTR_SETAFFINITY_NP
+ endif
++ifeq ($(feature-pthread-barrier), 1)
++  CFLAGS += -DHAVE_PTHREAD_BARRIER
++endif
++
+ ifndef NO_BIONIC
+   $(call feature_check,bionic)
+   ifeq ($(feature-bionic), 1)