diff options
author | Ben Hutchings <ben@decadent.org.uk> | 2018-11-11 19:17:17 +0000 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2018-11-11 19:17:17 +0000 |
commit | 22faea663c83a57c5be71858107d7e41e5f86595 (patch) | |
tree | 801c2d2b5cbff6c7c16a7cb87755f1d24548c11d | |
parent | 46d80906d6f4e2212b1bf6b3419d7c60d1ef4158 (diff) | |
download | linux-stable-queue-22faea663c83a57c5be71858107d7e41e5f86595.tar.gz |
Add perf build error/warning fixes
16 files changed, 1281 insertions, 0 deletions
diff --git a/queue-3.16/perf-script-use-readdir-instead-of-deprecated-readdir_r.patch b/queue-3.16/perf-script-use-readdir-instead-of-deprecated-readdir_r.patch new file mode 100644 index 00000000..0ae8f1e7 --- /dev/null +++ b/queue-3.16/perf-script-use-readdir-instead-of-deprecated-readdir_r.patch @@ -0,0 +1,183 @@ +From: Arnaldo Carvalho de Melo <acme@redhat.com> +Date: Fri, 8 Apr 2016 11:25:59 -0300 +Subject: perf script: Use readdir() instead of deprecated readdir_r() + +commit a5e8e825bd1704c488bf6a46936aaf3b9f203d6a upstream. + +The readdir() function is thread safe as long as just one thread uses a +DIR, which is the case in 'perf script', so, to avoid breaking the build +with glibc-2.23.90 (upcoming 2.24), use it instead of readdir_r(). + +See: http://man7.org/linux/man-pages/man3/readdir.3.html + +"However, in modern implementations (including the glibc implementation), +concurrent calls to readdir() that specify different directory streams +are thread-safe. In cases where multiple threads must read from the +same directory stream, using readdir() with external synchronization is +still preferable to the use of the deprecated readdir_r(3) function." + +Noticed while building on a Fedora Rawhide docker container. + +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: http://lkml.kernel.org/n/tip-mt3xz7n2hl49ni2vx7kuq74g@git.kernel.org +Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> +Signed-off-by: Ben Hutchings <ben@decadent.org.uk> +--- + tools/perf/builtin-script.c | 70 ++++++++++++++++++------------------- + 1 file changed, 34 insertions(+), 36 deletions(-) + +--- a/tools/perf/builtin-script.c ++++ b/tools/perf/builtin-script.c +@@ -1061,21 +1061,19 @@ static int is_directory(const char *base + return S_ISDIR(st.st_mode); + } + +-#define for_each_lang(scripts_path, scripts_dir, lang_dirent, lang_next)\ +- while (!readdir_r(scripts_dir, &lang_dirent, &lang_next) && \ +- lang_next) \ +- if ((lang_dirent.d_type == DT_DIR || \ +- (lang_dirent.d_type == DT_UNKNOWN && \ +- is_directory(scripts_path, &lang_dirent))) && \ +- (strcmp(lang_dirent.d_name, ".")) && \ +- (strcmp(lang_dirent.d_name, ".."))) +- +-#define for_each_script(lang_path, lang_dir, script_dirent, script_next)\ +- while (!readdir_r(lang_dir, &script_dirent, &script_next) && \ +- script_next) \ +- if (script_dirent.d_type != DT_DIR && \ +- (script_dirent.d_type != DT_UNKNOWN || \ +- !is_directory(lang_path, &script_dirent))) ++#define for_each_lang(scripts_path, scripts_dir, lang_dirent) \ ++ while ((lang_dirent = readdir(scripts_dir)) != NULL) \ ++ if ((lang_dirent->d_type == DT_DIR || \ ++ (lang_dirent->d_type == DT_UNKNOWN && \ ++ is_directory(scripts_path, lang_dirent))) && \ ++ (strcmp(lang_dirent->d_name, ".")) && \ ++ (strcmp(lang_dirent->d_name, ".."))) ++ ++#define for_each_script(lang_path, lang_dir, script_dirent) \ ++ while ((script_dirent = readdir(lang_dir)) != NULL) \ ++ if (script_dirent->d_type != DT_DIR && \ ++ (script_dirent->d_type != DT_UNKNOWN || \ ++ !is_directory(lang_path, script_dirent))) + + + #define RECORD_SUFFIX "-record" +@@ -1221,7 +1219,7 @@ static int list_available_scripts(const + const char *s __maybe_unused, + int unset __maybe_unused) + { +- struct dirent *script_next, *lang_next, script_dirent, lang_dirent; ++ struct dirent *script_dirent, *lang_dirent; + char scripts_path[MAXPATHLEN]; + DIR *scripts_dir, *lang_dir; + char script_path[MAXPATHLEN]; +@@ -1236,19 +1234,19 @@ static int list_available_scripts(const + if (!scripts_dir) + return -1; + +- for_each_lang(scripts_path, scripts_dir, lang_dirent, lang_next) { ++ for_each_lang(scripts_path, scripts_dir, lang_dirent) { + snprintf(lang_path, MAXPATHLEN, "%s/%s/bin", scripts_path, +- lang_dirent.d_name); ++ lang_dirent->d_name); + lang_dir = opendir(lang_path); + if (!lang_dir) + continue; + +- for_each_script(lang_path, lang_dir, script_dirent, script_next) { +- script_root = get_script_root(&script_dirent, REPORT_SUFFIX); ++ for_each_script(lang_path, lang_dir, script_dirent) { ++ script_root = get_script_root(script_dirent, REPORT_SUFFIX); + if (script_root) { + desc = script_desc__findnew(script_root); + snprintf(script_path, MAXPATHLEN, "%s/%s", +- lang_path, script_dirent.d_name); ++ lang_path, script_dirent->d_name); + read_script_info(desc, script_path); + free(script_root); + } +@@ -1336,7 +1334,7 @@ static int check_ev_match(char *dir_name + */ + int find_scripts(char **scripts_array, char **scripts_path_array) + { +- struct dirent *script_next, *lang_next, script_dirent, lang_dirent; ++ struct dirent *script_dirent, *lang_dirent; + char scripts_path[MAXPATHLEN], lang_path[MAXPATHLEN]; + DIR *scripts_dir, *lang_dir; + struct perf_session *session; +@@ -1359,9 +1357,9 @@ int find_scripts(char **scripts_array, c + return -1; + } + +- for_each_lang(scripts_path, scripts_dir, lang_dirent, lang_next) { ++ for_each_lang(scripts_path, scripts_dir, lang_dirent) { + snprintf(lang_path, MAXPATHLEN, "%s/%s", scripts_path, +- lang_dirent.d_name); ++ lang_dirent->d_name); + #ifdef NO_LIBPERL + if (strstr(lang_path, "perl")) + continue; +@@ -1375,16 +1373,16 @@ int find_scripts(char **scripts_array, c + if (!lang_dir) + continue; + +- for_each_script(lang_path, lang_dir, script_dirent, script_next) { ++ for_each_script(lang_path, lang_dir, script_dirent) { + /* Skip those real time scripts: xxxtop.p[yl] */ +- if (strstr(script_dirent.d_name, "top.")) ++ if (strstr(script_dirent->d_name, "top.")) + continue; + sprintf(scripts_path_array[i], "%s/%s", lang_path, +- script_dirent.d_name); +- temp = strchr(script_dirent.d_name, '.'); ++ script_dirent->d_name); ++ temp = strchr(script_dirent->d_name, '.'); + snprintf(scripts_array[i], +- (temp - script_dirent.d_name) + 1, +- "%s", script_dirent.d_name); ++ (temp - script_dirent->d_name) + 1, ++ "%s", script_dirent->d_name); + + if (check_ev_match(lang_path, + scripts_array[i], session)) +@@ -1402,7 +1400,7 @@ int find_scripts(char **scripts_array, c + + static char *get_script_path(const char *script_root, const char *suffix) + { +- struct dirent *script_next, *lang_next, script_dirent, lang_dirent; ++ struct dirent *script_dirent, *lang_dirent; + char scripts_path[MAXPATHLEN]; + char script_path[MAXPATHLEN]; + DIR *scripts_dir, *lang_dir; +@@ -1415,21 +1413,21 @@ static char *get_script_path(const char + if (!scripts_dir) + return NULL; + +- for_each_lang(scripts_path, scripts_dir, lang_dirent, lang_next) { ++ for_each_lang(scripts_path, scripts_dir, lang_dirent) { + snprintf(lang_path, MAXPATHLEN, "%s/%s/bin", scripts_path, +- lang_dirent.d_name); ++ lang_dirent->d_name); + lang_dir = opendir(lang_path); + if (!lang_dir) + continue; + +- for_each_script(lang_path, lang_dir, script_dirent, script_next) { +- __script_root = get_script_root(&script_dirent, suffix); ++ for_each_script(lang_path, lang_dir, script_dirent) { ++ __script_root = get_script_root(script_dirent, suffix); + if (__script_root && !strcmp(script_root, __script_root)) { + free(__script_root); + closedir(lang_dir); + closedir(scripts_dir); + snprintf(script_path, MAXPATHLEN, "%s/%s", +- lang_path, script_dirent.d_name); ++ lang_path, script_dirent->d_name); + return strdup(script_path); + } + free(__script_root); diff --git a/queue-3.16/perf-thread_map-correctly-size-buffer-used-with-dirent-dt_name.patch b/queue-3.16/perf-thread_map-correctly-size-buffer-used-with-dirent-dt_name.patch new file mode 100644 index 00000000..8e94bbc5 --- /dev/null +++ b/queue-3.16/perf-thread_map-correctly-size-buffer-used-with-dirent-dt_name.patch @@ -0,0 +1,46 @@ +From: Arnaldo Carvalho de Melo <acme@redhat.com> +Date: Wed, 8 Feb 2017 17:01:46 -0300 +Subject: perf thread_map: Correctly size buffer used with dirent->dt_name + +commit bdf23a9a190d7ecea092fd5c4aabb7d4bd0a9980 upstream. + +The size of dirent->dt_name is NAME_MAX + 1, but the size for the 'path' +buffer is hard coded at 256, which may truncate it because we also +prepend "/proc/", so that all that into account and thank gcc 7 for this +warning: + + /git/linux/tools/perf/util/thread_map.c: In function 'thread_map__new_by_uid': + /git/linux/tools/perf/util/thread_map.c:119:39: error: '%s' directive output may be truncated writing up to 255 bytes into a region of size 250 [-Werror=format-truncation=] + snprintf(path, sizeof(path), "/proc/%s", dirent->d_name); + ^~ + In file included from /usr/include/stdio.h:939:0, + from /git/linux/tools/perf/util/thread_map.c:5: + /usr/include/bits/stdio2.h:64:10: note: '__builtin___snprintf_chk' output between 7 and 262 bytes into a destination of size 256 + return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, + ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + __bos (__s), __fmt, __va_arg_pack ()); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +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: http://lkml.kernel.org/n/tip-csy0r8zrvz5efccgd4k12c82@git.kernel.org +Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> +Signed-off-by: Ben Hutchings <ben@decadent.org.uk> +--- + tools/perf/util/thread_map.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/tools/perf/util/thread_map.c ++++ b/tools/perf/util/thread_map.c +@@ -63,7 +63,7 @@ struct thread_map *thread_map__new_by_ui + { + DIR *proc; + int max_threads = 32, items, i; +- char path[256]; ++ char path[NAME_MAX + 1 + 6]; + struct dirent *dirent, **namelist = NULL; + struct thread_map *threads = malloc(sizeof(*threads) + + max_threads * sizeof(pid_t)); diff --git a/queue-3.16/perf-thread_map-use-readdir-instead-of-deprecated-readdir_r.patch b/queue-3.16/perf-thread_map-use-readdir-instead-of-deprecated-readdir_r.patch new file mode 100644 index 00000000..c6d40e28 --- /dev/null +++ b/queue-3.16/perf-thread_map-use-readdir-instead-of-deprecated-readdir_r.patch @@ -0,0 +1,64 @@ +From: Arnaldo Carvalho de Melo <acme@redhat.com> +Date: Fri, 8 Apr 2016 11:31:24 -0300 +Subject: perf thread_map: Use readdir() instead of deprecated readdir_r() + +commit 3354cf71104de49326d19d2f9bdb1f66eea52ef4 upstream. + +The readdir() function is thread safe as long as just one thread uses a +DIR, which is the case in thread_map, so, to avoid breaking the build +with glibc-2.23.90 (upcoming 2.24), use it instead of readdir_r(). + +See: http://man7.org/linux/man-pages/man3/readdir.3.html + +"However, in modern implementations (including the glibc implementation), +concurrent calls to readdir() that specify different directory streams +are thread-safe. In cases where multiple threads must read from the +same directory stream, using readdir() with external synchronization is +still preferable to the use of the deprecated readdir_r(3) function." + +Noticed while building on a Fedora Rawhide docker container. + +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: http://lkml.kernel.org/n/tip-del8h2a0f40z75j4r42l96l0@git.kernel.org +Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> +[bwh: Backported to 3.16: adjust context] +Signed-off-by: Ben Hutchings <ben@decadent.org.uk> +--- + tools/perf/util/thread_map.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +--- a/tools/perf/util/thread_map.c ++++ b/tools/perf/util/thread_map.c +@@ -64,7 +64,7 @@ struct thread_map *thread_map__new_by_ui + DIR *proc; + int max_threads = 32, items, i; + char path[256]; +- struct dirent dirent, *next, **namelist = NULL; ++ struct dirent *dirent, **namelist = NULL; + struct thread_map *threads = malloc(sizeof(*threads) + + max_threads * sizeof(pid_t)); + if (threads == NULL) +@@ -76,16 +76,16 @@ struct thread_map *thread_map__new_by_ui + + threads->nr = 0; + +- while (!readdir_r(proc, &dirent, &next) && next) { ++ while ((dirent = readdir(proc)) != NULL) { + char *end; + bool grow = false; + struct stat st; +- pid_t pid = strtol(dirent.d_name, &end, 10); ++ pid_t pid = strtol(dirent->d_name, &end, 10); + + if (*end) /* only interested in proper numerical dirents */ + continue; + +- snprintf(path, sizeof(path), "/proc/%s", dirent.d_name); ++ snprintf(path, sizeof(path), "/proc/%s", dirent->d_name); + + if (stat(path, &st) != 0) + continue; diff --git a/queue-3.16/perf-tools-define-_default_source-for-glibc_2.20.patch b/queue-3.16/perf-tools-define-_default_source-for-glibc_2.20.patch new file mode 100644 index 00000000..d1f78e4d --- /dev/null +++ b/queue-3.16/perf-tools-define-_default_source-for-glibc_2.20.patch @@ -0,0 +1,34 @@ +From: Chanho Park <chanho61.park@samsung.com> +Date: Fri, 12 Sep 2014 11:10:17 +0900 +Subject: perf tools: define _DEFAULT_SOURCE for glibc_2.20 + +commit 512fe365373b9c95a70b4b6357503ee74d27214f upstream. + +_BSD_SOURCE was deprecated in favour of _DEFAULT_SOURCE since glibc +2.20[1]. To avoid build warning on glibc2.20, _DEFAULT_SOURCE should +also be defined. + +[1]: https://sourceware.org/glibc/wiki/Release/2.20 + +Signed-off-by: Chanho Park <chanho61.park@samsung.com> +Cc: Ingo Molnar <mingo@kernel.org> +Cc: Paul Mackerras <paulus@samba.org> +Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> +Link: http://lkml.kernel.org/r/1410487817-13403-1-git-send-email-chanho61.park@samsung.com +Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> +Signed-off-by: Ben Hutchings <ben@decadent.org.uk> +--- + tools/perf/util/util.h | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/tools/perf/util/util.h ++++ b/tools/perf/util/util.h +@@ -39,6 +39,8 @@ + + #define _ALL_SOURCE 1 + #define _BSD_SOURCE 1 ++/* glibc 2.20 deprecates _BSD_SOURCE in favour of _DEFAULT_SOURCE */ ++#define _DEFAULT_SOURCE 1 + #define HAS_BOOL + + #include <unistd.h> diff --git a/queue-3.16/perf-tools-fix-python-extension-build-for-gcc-8.patch b/queue-3.16/perf-tools-fix-python-extension-build-for-gcc-8.patch new file mode 100644 index 00000000..e5ebd078 --- /dev/null +++ b/queue-3.16/perf-tools-fix-python-extension-build-for-gcc-8.patch @@ -0,0 +1,73 @@ +From: Jiri Olsa <jolsa@kernel.org> +Date: Mon, 19 Mar 2018 09:29:02 +0100 +Subject: perf tools: Fix python extension build for gcc 8 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +commit b7a313d84e853049062011d78cb04b6decd12f5c upstream. + +The gcc 8 compiler won't compile the python extension code with the +following errors (one example): + + python.c:830:15: error: cast between incompatible function types from \ + ‘PyObject * (*)(struct pyrf_evsel *, PyObject *, PyObject *)’ \ + uct _object * (*)(struct pyrf_evsel *, struct _object *, struct _object *)’} to \ + ‘PyObject * (*)(PyObject *, PyObject *)’ {aka ‘struct _object * (*)(struct _objeuct \ + _object *)’} [-Werror=cast-function-type] + .ml_meth = (PyCFunction)pyrf_evsel__open, + +The problem with the PyMethodDef::ml_meth callback is that its type is +determined based on the PyMethodDef::ml_flags value, which we set as +METH_VARARGS | METH_KEYWORDS. + +That indicates that the callback is expecting an extra PyObject* arg, and is +actually PyCFunctionWithKeywords type, but the base PyMethodDef::ml_meth type +stays PyCFunction. + +Previous gccs did not find this, gcc8 now does. Fixing this by silencing this +warning for python.c build. + +Commiter notes: + +Do not do that for CC=clang, as it breaks the build in some clang +versions, like the ones in fedora up to fedora27: + + fedora:25:error: unknown warning option '-Wno-cast-function-type'; did you mean '-Wno-bad-function-cast'? [-Werror,-Wunknown-warning-option] + fedora:26:error: unknown warning option '-Wno-cast-function-type'; did you mean '-Wno-bad-function-cast'? [-Werror,-Wunknown-warning-option] + fedora:27:error: unknown warning option '-Wno-cast-function-type'; did you mean '-Wno-bad-function-cast'? [-Werror,-Wunknown-warning-option] + # + +those have: + + clang version 3.9.1 (tags/RELEASE_391/final) + +The one in rawhide accepts that: + + clang version 6.0.0 (tags/RELEASE_600/final) + +Signed-off-by: Jiri Olsa <jolsa@kernel.org> +Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> +Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> +Cc: David Ahern <dsahern@gmail.com> +Cc: Josh Poimboeuf <jpoimboe@redhat.com> +Cc: Namhyung Kim <namhyung@kernel.org> +Cc: Peter Zijlstra <peterz@infradead.org> +Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> +Link: http://lkml.kernel.org/r/20180319082902.4518-2-jolsa@kernel.org +Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> +Signed-off-by: Ben Hutchings <ben@decadent.org.uk> +--- + tools/perf/util/setup.py | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/tools/perf/util/setup.py ++++ b/tools/perf/util/setup.py +@@ -21,6 +21,7 @@ class install_lib(_install_lib): + cflags = getenv('CFLAGS', '').split() + # switch off several checks (need to be at the end of cflags list) + cflags += ['-fno-strict-aliasing', '-Wno-write-strings', '-Wno-unused-parameter' ] ++cflags += ['-Wno-cast-function-type' ] + + build_lib = getenv('PYTHON_EXTBUILD_LIB') + build_tmp = getenv('PYTHON_EXTBUILD_TMP') diff --git a/queue-3.16/perf-tools-fix-snprint-warnings-for-gcc-8.patch b/queue-3.16/perf-tools-fix-snprint-warnings-for-gcc-8.patch new file mode 100644 index 00000000..016ec196 --- /dev/null +++ b/queue-3.16/perf-tools-fix-snprint-warnings-for-gcc-8.patch @@ -0,0 +1,175 @@ +From: Jiri Olsa <jolsa@kernel.org> +Date: Mon, 19 Mar 2018 09:29:01 +0100 +Subject: perf tools: Fix snprint warnings for gcc 8 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +commit 77f18153c080855e1c3fb520ca31a4e61530121d upstream. + +With gcc 8 we get new set of snprintf() warnings that breaks the +compilation, one example: + + tests/mem.c: In function ‘check’: + tests/mem.c:19:48: error: ‘%s’ directive output may be truncated writing \ + up to 99 bytes into a region of size 89 [-Werror=format-truncation=] + snprintf(failure, sizeof failure, "unexpected %s", out); + +The gcc docs says: + + To avoid the warning either use a bigger buffer or handle the + function's return value which indicates whether or not its output + has been truncated. + +Given that all these warnings are harmless, because the code either +properly fails due to uncomplete file path or we don't care for +truncated output at all, I'm changing all those snprintf() calls to +scnprintf(), which actually 'checks' for the snprint return value so the +gcc stays silent. + +Signed-off-by: Jiri Olsa <jolsa@kernel.org> +Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> +Cc: David Ahern <dsahern@gmail.com> +Cc: Josh Poimboeuf <jpoimboe@redhat.com> +Cc: Namhyung Kim <namhyung@kernel.org> +Cc: Peter Zijlstra <peterz@infradead.org> +Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> +Link: http://lkml.kernel.org/r/20180319082902.4518-1-jolsa@kernel.org +Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> +[bwh: Backported to 3.16: Drop changes in tools/perf/tests/mem.c] +Signed-off-by: Ben Hutchings <ben@decadent.org.uk> +--- + tools/perf/builtin-script.c | 22 +++++++++++----------- + tools/perf/tests/attr.c | 4 ++-- + tools/perf/tests/mem.c | 2 +- + tools/perf/tests/pmu.c | 2 +- + tools/perf/util/cgroup.c | 2 +- + tools/perf/util/parse-events.c | 4 ++-- + tools/perf/util/pmu.c | 2 +- + 7 files changed, 19 insertions(+), 19 deletions(-) + +--- a/tools/perf/builtin-script.c ++++ b/tools/perf/builtin-script.c +@@ -1235,8 +1235,8 @@ static int list_available_scripts(const + return -1; + + for_each_lang(scripts_path, scripts_dir, lang_dirent) { +- snprintf(lang_path, MAXPATHLEN, "%s/%s/bin", scripts_path, +- lang_dirent->d_name); ++ scnprintf(lang_path, MAXPATHLEN, "%s/%s/bin", scripts_path, ++ lang_dirent->d_name); + lang_dir = opendir(lang_path); + if (!lang_dir) + continue; +@@ -1245,8 +1245,8 @@ static int list_available_scripts(const + script_root = get_script_root(script_dirent, REPORT_SUFFIX); + if (script_root) { + desc = script_desc__findnew(script_root); +- snprintf(script_path, MAXPATHLEN, "%s/%s", +- lang_path, script_dirent->d_name); ++ scnprintf(script_path, MAXPATHLEN, "%s/%s", ++ lang_path, script_dirent->d_name); + read_script_info(desc, script_path); + free(script_root); + } +@@ -1282,7 +1282,7 @@ static int check_ev_match(char *dir_name + int match, len; + FILE *fp; + +- sprintf(filename, "%s/bin/%s-record", dir_name, scriptname); ++ scnprintf(filename, MAXPATHLEN, "%s/bin/%s-record", dir_name, scriptname); + + fp = fopen(filename, "r"); + if (!fp) +@@ -1358,8 +1358,8 @@ int find_scripts(char **scripts_array, c + } + + for_each_lang(scripts_path, scripts_dir, lang_dirent) { +- snprintf(lang_path, MAXPATHLEN, "%s/%s", scripts_path, +- lang_dirent->d_name); ++ scnprintf(lang_path, MAXPATHLEN, "%s/%s", scripts_path, ++ lang_dirent->d_name); + #ifdef NO_LIBPERL + if (strstr(lang_path, "perl")) + continue; +@@ -1414,8 +1414,8 @@ static char *get_script_path(const char + return NULL; + + for_each_lang(scripts_path, scripts_dir, lang_dirent) { +- snprintf(lang_path, MAXPATHLEN, "%s/%s/bin", scripts_path, +- lang_dirent->d_name); ++ scnprintf(lang_path, MAXPATHLEN, "%s/%s/bin", scripts_path, ++ lang_dirent->d_name); + lang_dir = opendir(lang_path); + if (!lang_dir) + continue; +@@ -1426,8 +1426,8 @@ static char *get_script_path(const char + free(__script_root); + closedir(lang_dir); + closedir(scripts_dir); +- snprintf(script_path, MAXPATHLEN, "%s/%s", +- lang_path, script_dirent->d_name); ++ scnprintf(script_path, MAXPATHLEN, "%s/%s", ++ lang_path, script_dirent->d_name); + return strdup(script_path); + } + free(__script_root); +--- a/tools/perf/tests/attr.c ++++ b/tools/perf/tests/attr.c +@@ -147,8 +147,8 @@ static int run_dir(const char *d, const + if (verbose) + vcnt++; + +- snprintf(cmd, 3*PATH_MAX, PYTHON " %s/attr.py -d %s/attr/ -p %s %.*s", +- d, d, perf, vcnt, v); ++ scnprintf(cmd, 3*PATH_MAX, PYTHON " %s/attr.py -d %s/attr/ -p %s %.*s", ++ d, d, perf, vcnt, v); + + return system(cmd); + } +--- a/tools/perf/tests/pmu.c ++++ b/tools/perf/tests/pmu.c +@@ -95,7 +95,7 @@ static char *test_format_dir_get(void) + struct test_format *format = &test_formats[i]; + FILE *file; + +- snprintf(name, PATH_MAX, "%s/%s", dir, format->name); ++ scnprintf(name, PATH_MAX, "%s/%s", dir, format->name); + + file = fopen(name, "w"); + if (!file) +--- a/tools/perf/util/cgroup.c ++++ b/tools/perf/util/cgroup.c +@@ -64,7 +64,7 @@ static int open_cgroup(char *name) + if (cgroupfs_find_mountpoint(mnt, PATH_MAX + 1)) + return -1; + +- snprintf(path, PATH_MAX, "%s/%s", mnt, name); ++ scnprintf(path, PATH_MAX, "%s/%s", mnt, name); + + fd = open(path, O_RDONLY); + if (fd == -1) +--- a/tools/perf/util/parse-events.c ++++ b/tools/perf/util/parse-events.c +@@ -182,8 +182,8 @@ struct tracepoint_path *tracepoint_id_to + + for_each_event(sys_dirent, evt_dir, evt_dirent) { + +- snprintf(evt_path, MAXPATHLEN, "%s/%s/id", dir_path, +- evt_dirent->d_name); ++ scnprintf(evt_path, MAXPATHLEN, "%s/%s/id", dir_path, ++ evt_dirent->d_name); + fd = open(evt_path, O_RDONLY); + if (fd < 0) + continue; +--- a/tools/perf/util/pmu.c ++++ b/tools/perf/util/pmu.c +@@ -240,7 +240,7 @@ static int pmu_aliases_parse(char *dir, + if (len > 6 && !strcmp(name + len - 6, ".scale")) + continue; + +- snprintf(path, PATH_MAX, "%s/%s", dir, name); ++ scnprintf(path, PATH_MAX, "%s/%s", dir, name); + + file = fopen(path, "r"); + if (!file) { diff --git a/queue-3.16/perf-tools-move-syscall-number-fallbacks-from-perf-sys.h-to.patch b/queue-3.16/perf-tools-move-syscall-number-fallbacks-from-perf-sys.h-to.patch new file mode 100644 index 00000000..a7d9e54f --- /dev/null +++ b/queue-3.16/perf-tools-move-syscall-number-fallbacks-from-perf-sys.h-to.patch @@ -0,0 +1,113 @@ +From: Arnaldo Carvalho de Melo <acme@redhat.com> +Date: Thu, 7 Jul 2016 18:28:43 -0300 +Subject: perf tools: Move syscall number fallbacks from perf-sys.h to + tools/arch/x86/include/asm/ + +commit cec07f53c398f22576df77052c4777dc13f14962 upstream. + +And remove the empty tools/arch/x86/include/asm/unistd_{32,64}.h files +introduced by eae7a755ee81 ("perf tools, x86: Build perf on older +user-space as well"). + +This way we get closer to mirroring the kernel for cases where __NR_ +can't be found for some include path/_GNU_SOURCE/whatever scenario. + +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: http://lkml.kernel.org/n/tip-kpj6m3mbjw82kg6krk2z529e@git.kernel.org +Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> +[bwh: Backported to 3.16: + - Also remove the deleted headers from LIB_H in Makefile.perf + - Adjust context] +Signed-off-by: Ben Hutchings <ben@decadent.org.uk> +--- +--- /dev/null ++++ b/tools/arch/x86/include/asm/unistd_32.h +@@ -0,0 +1,9 @@ ++#ifndef __NR_perf_event_open ++# define __NR_perf_event_open 336 ++#endif ++#ifndef __NR_futex ++# define __NR_futex 240 ++#endif ++#ifndef __NR_gettid ++# define __NR_gettid 224 ++#endif +--- /dev/null ++++ b/tools/arch/x86/include/asm/unistd_64.h +@@ -0,0 +1,9 @@ ++#ifndef __NR_perf_event_open ++# define __NR_perf_event_open 298 ++#endif ++#ifndef __NR_futex ++# define __NR_futex 202 ++#endif ++#ifndef __NR_gettid ++# define __NR_gettid 186 ++#endif +--- a/tools/perf/config/Makefile ++++ b/tools/perf/config/Makefile +@@ -252,6 +252,7 @@ CFLAGS += -I$(src-perf)/arch/$(ARCH)/inc + CFLAGS += -I$(srctree)/tools/include/ + CFLAGS += -I$(srctree)/arch/$(ARCH)/include/uapi + CFLAGS += -I$(srctree)/arch/$(ARCH)/include ++CFLAGS += -I$(srctree)/tools/arch/$(ARCH)/include + CFLAGS += -I$(srctree)/include/uapi + CFLAGS += -I$(srctree)/include + +--- a/tools/perf/perf-sys.h ++++ b/tools/perf/perf-sys.h +@@ -14,15 +14,6 @@ + #define rmb() asm volatile("lock; addl $0,0(%%esp)" ::: "memory") + #define cpu_relax() asm volatile("rep; nop" ::: "memory"); + #define CPUINFO_PROC "model name" +-#ifndef __NR_perf_event_open +-# define __NR_perf_event_open 336 +-#endif +-#ifndef __NR_futex +-# define __NR_futex 240 +-#endif +-#ifndef __NR_gettid +-# define __NR_gettid 224 +-#endif + #endif + + #if defined(__x86_64__) +@@ -31,15 +22,6 @@ + #define rmb() asm volatile("lfence" ::: "memory") + #define cpu_relax() asm volatile("rep; nop" ::: "memory"); + #define CPUINFO_PROC "model name" +-#ifndef __NR_perf_event_open +-# define __NR_perf_event_open 298 +-#endif +-#ifndef __NR_futex +-# define __NR_futex 202 +-#endif +-#ifndef __NR_gettid +-# define __NR_gettid 186 +-#endif + #endif + + #ifdef __powerpc__ +--- a/tools/perf/util/include/asm/unistd_32.h ++++ /dev/null +@@ -1 +0,0 @@ +- +--- a/tools/perf/util/include/asm/unistd_64.h ++++ /dev/null +@@ -1 +0,0 @@ +- +--- a/tools/perf/Makefile.perf ++++ b/tools/perf/Makefile.perf +@@ -239,8 +239,6 @@ LIB_H += util/include/asm/uaccess.h + LIB_H += util/include/dwarf-regs.h + LIB_H += util/include/asm/dwarf2.h + LIB_H += util/include/asm/cpufeature.h +-LIB_H += util/include/asm/unistd_32.h +-LIB_H += util/include/asm/unistd_64.h + LIB_H += perf.h + LIB_H += util/annotate.h + LIB_H += util/cache.h diff --git a/queue-3.16/perf-tools-remove-duplicate-const-qualifier.patch b/queue-3.16/perf-tools-remove-duplicate-const-qualifier.patch new file mode 100644 index 00000000..35d4558d --- /dev/null +++ b/queue-3.16/perf-tools-remove-duplicate-const-qualifier.patch @@ -0,0 +1,28 @@ +From: Eric Engestrom <eric.engestrom@imgtec.com> +Date: Mon, 25 Apr 2016 10:47:54 +0100 +Subject: perf tools: Remove duplicate const qualifier + +commit 3b556bced46aa6b1873da7faa18eff235e896adc upstream. + +Signed-off-by: Eric Engestrom <eric.engestrom@imgtec.com> +Cc: Adrian Hunter <adrian.hunter@intel.com> +Cc: David Ahern <dsahern@gmail.com> +Cc: Peter Zijlstra <peterz@infradead.org> +Link: http://lkml.kernel.org/r/1461577678-29517-1-git-send-email-eric.engestrom@imgtec.com +Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> +Signed-off-by: Ben Hutchings <ben@decadent.org.uk> +--- + tools/perf/util/thread.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/tools/perf/util/thread.c ++++ b/tools/perf/util/thread.c +@@ -177,7 +177,7 @@ void thread__find_cpumode_addr_location( + struct addr_location *al) + { + size_t i; +- const u8 const cpumodes[] = { ++ const u8 cpumodes[] = { + PERF_RECORD_MISC_USER, + PERF_RECORD_MISC_KERNEL, + PERF_RECORD_MISC_GUEST_USER, diff --git a/queue-3.16/perf-tools-use-readdir-instead-of-deprecated-readdir_r-1.patch b/queue-3.16/perf-tools-use-readdir-instead-of-deprecated-readdir_r-1.patch new file mode 100644 index 00000000..48ce064f --- /dev/null +++ b/queue-3.16/perf-tools-use-readdir-instead-of-deprecated-readdir_r-1.patch @@ -0,0 +1,93 @@ +From: Arnaldo Carvalho de Melo <acme@redhat.com> +Date: Fri, 8 Apr 2016 11:32:15 -0300 +Subject: perf tools: Use readdir() instead of deprecated readdir_r() + +commit 7093b4c963cc4e344e490c774924a180602a7092 upstream. + +The readdir() function is thread safe as long as just one thread uses a +DIR, which is the case when synthesizing events for pre-existing threads +by traversing /proc, so, to avoid breaking the build with glibc-2.23.90 +(upcoming 2.24), use it instead of readdir_r(). + +See: http://man7.org/linux/man-pages/man3/readdir.3.html + +"However, in modern implementations (including the glibc implementation), +concurrent calls to readdir() that specify different directory streams +are thread-safe. In cases where multiple threads must read from the +same directory stream, using readdir() with external synchronization is +still preferable to the use of the deprecated readdir_r(3) function." + +Noticed while building on a Fedora Rawhide docker container. + + CC /tmp/build/perf/util/event.o + util/event.c: In function '__event__synthesize_thread': + util/event.c:466:2: error: 'readdir_r' is deprecated [-Werror=deprecated-declarations] + while (!readdir_r(tasks, &dirent, &next) && next) { + ^~~~~ + In file included from /usr/include/features.h:368:0, + from /usr/include/stdint.h:25, + from /usr/lib/gcc/x86_64-redhat-linux/6.0.0/include/stdint.h:9, + from /git/linux/tools/include/linux/types.h:6, + from util/event.c:1: + /usr/include/dirent.h:189:12: note: declared here + +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: http://lkml.kernel.org/n/tip-i1vj7nyjp2p750rirxgrfd3c@git.kernel.org +Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> +[bwh: Backported to 3.16: adjust context] +Signed-off-by: Ben Hutchings <ben@decadent.org.uk> +--- + tools/perf/util/event.c | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +--- a/tools/perf/util/event.c ++++ b/tools/perf/util/event.c +@@ -331,7 +331,7 @@ static int __event__synthesize_thread(un + { + char filename[PATH_MAX]; + DIR *tasks; +- struct dirent dirent, *next; ++ struct dirent *dirent; + pid_t tgid; + + /* special case: only send one comm event using passed in pid */ +@@ -358,12 +358,12 @@ static int __event__synthesize_thread(un + return 0; + } + +- while (!readdir_r(tasks, &dirent, &next) && next) { ++ while ((dirent = readdir(tasks)) != NULL) { + char *end; + int rc = 0; + pid_t _pid; + +- _pid = strtol(dirent.d_name, &end, 10); ++ _pid = strtol(dirent->d_name, &end, 10); + if (*end) + continue; + +@@ -464,7 +464,7 @@ int perf_event__synthesize_threads(struc + { + DIR *proc; + char proc_path[PATH_MAX]; +- struct dirent dirent, *next; ++ struct dirent *dirent; + union perf_event *comm_event, *mmap_event, *fork_event; + int err = -1; + +@@ -489,9 +489,9 @@ int perf_event__synthesize_threads(struc + if (proc == NULL) + goto out_free_fork; + +- while (!readdir_r(proc, &dirent, &next) && next) { ++ while ((dirent = readdir(proc)) != NULL) { + char *end; +- pid_t pid = strtol(dirent.d_name, &end, 10); ++ pid_t pid = strtol(dirent->d_name, &end, 10); + + if (*end) /* only interested in proper numerical dirents */ + continue; diff --git a/queue-3.16/perf-tools-use-readdir-instead-of-deprecated-readdir_r-2.patch b/queue-3.16/perf-tools-use-readdir-instead-of-deprecated-readdir_r-2.patch new file mode 100644 index 00000000..8b8fdf28 --- /dev/null +++ b/queue-3.16/perf-tools-use-readdir-instead-of-deprecated-readdir_r-2.patch @@ -0,0 +1,193 @@ +From: Arnaldo Carvalho de Melo <acme@redhat.com> +Date: Fri, 8 Apr 2016 11:53:02 -0300 +Subject: perf tools: Use readdir() instead of deprecated readdir_r() + +commit bfc279f3d233150ff260e9e93012e14f86810648 upstream. + +The readdir() function is thread safe as long as just one thread uses a +DIR, which is the case when parsing tracepoint event definitions, to +avoid breaking the build with glibc-2.23.90 (upcoming 2.24), use it +instead of readdir_r(). + +See: http://man7.org/linux/man-pages/man3/readdir.3.html + +"However, in modern implementations (including the glibc implementation), +concurrent calls to readdir() that specify different directory streams +are thread-safe. In cases where multiple threads must read from the +same directory stream, using readdir() with external synchronization is +still preferable to the use of the deprecated readdir_r(3) function." + +Noticed while building on a Fedora Rawhide docker container. + +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: http://lkml.kernel.org/n/tip-wddn49r6bz6wq4ee3dxbl7lo@git.kernel.org +Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> +[bwh: Backported to 3.16: adjust context] +Signed-off-by: Ben Hutchings <ben@decadent.org.uk> +--- + tools/perf/util/parse-events.c | 60 +++++++++++++++++----------------- + 1 file changed, 30 insertions(+), 30 deletions(-) + +--- a/tools/perf/util/parse-events.c ++++ b/tools/perf/util/parse-events.c +@@ -123,11 +123,11 @@ static struct event_symbol event_symbols + #define PERF_EVENT_TYPE(config) __PERF_EVENT_FIELD(config, TYPE) + #define PERF_EVENT_ID(config) __PERF_EVENT_FIELD(config, EVENT) + +-#define for_each_subsystem(sys_dir, sys_dirent, sys_next) \ +- while (!readdir_r(sys_dir, &sys_dirent, &sys_next) && sys_next) \ +- if (sys_dirent.d_type == DT_DIR && \ +- (strcmp(sys_dirent.d_name, ".")) && \ +- (strcmp(sys_dirent.d_name, ".."))) ++#define for_each_subsystem(sys_dir, sys_dirent) \ ++ while ((sys_dirent = readdir(sys_dir)) != NULL) \ ++ if (sys_dirent->d_type == DT_DIR && \ ++ (strcmp(sys_dirent->d_name, ".")) && \ ++ (strcmp(sys_dirent->d_name, ".."))) + + static int tp_event_has_id(struct dirent *sys_dir, struct dirent *evt_dir) + { +@@ -144,12 +144,12 @@ static int tp_event_has_id(struct dirent + return 0; + } + +-#define for_each_event(sys_dirent, evt_dir, evt_dirent, evt_next) \ +- while (!readdir_r(evt_dir, &evt_dirent, &evt_next) && evt_next) \ +- if (evt_dirent.d_type == DT_DIR && \ +- (strcmp(evt_dirent.d_name, ".")) && \ +- (strcmp(evt_dirent.d_name, "..")) && \ +- (!tp_event_has_id(&sys_dirent, &evt_dirent))) ++#define for_each_event(sys_dirent, evt_dir, evt_dirent) \ ++ while ((evt_dirent = readdir(evt_dir)) != NULL) \ ++ if (evt_dirent->d_type == DT_DIR && \ ++ (strcmp(evt_dirent->d_name, ".")) && \ ++ (strcmp(evt_dirent->d_name, "..")) && \ ++ (!tp_event_has_id(sys_dirent, evt_dirent))) + + #define MAX_EVENT_LENGTH 512 + +@@ -158,7 +158,7 @@ struct tracepoint_path *tracepoint_id_to + { + struct tracepoint_path *path = NULL; + DIR *sys_dir, *evt_dir; +- struct dirent *sys_next, *evt_next, sys_dirent, evt_dirent; ++ struct dirent *sys_dirent, *evt_dirent; + char id_buf[24]; + int fd; + u64 id; +@@ -172,18 +172,18 @@ struct tracepoint_path *tracepoint_id_to + if (!sys_dir) + return NULL; + +- for_each_subsystem(sys_dir, sys_dirent, sys_next) { ++ for_each_subsystem(sys_dir, sys_dirent) { + + snprintf(dir_path, MAXPATHLEN, "%s/%s", tracing_events_path, +- sys_dirent.d_name); ++ sys_dirent->d_name); + evt_dir = opendir(dir_path); + if (!evt_dir) + continue; + +- for_each_event(sys_dirent, evt_dir, evt_dirent, evt_next) { ++ for_each_event(sys_dirent, evt_dir, evt_dirent) { + + snprintf(evt_path, MAXPATHLEN, "%s/%s/id", dir_path, +- evt_dirent.d_name); ++ evt_dirent->d_name); + fd = open(evt_path, O_RDONLY); + if (fd < 0) + continue; +@@ -208,9 +208,9 @@ struct tracepoint_path *tracepoint_id_to + free(path); + return NULL; + } +- strncpy(path->system, sys_dirent.d_name, ++ strncpy(path->system, sys_dirent->d_name, + MAX_EVENT_LENGTH); +- strncpy(path->name, evt_dirent.d_name, ++ strncpy(path->name, evt_dirent->d_name, + MAX_EVENT_LENGTH); + return path; + } +@@ -1003,7 +1003,7 @@ void print_tracepoint_events(const char + bool name_only) + { + DIR *sys_dir, *evt_dir; +- struct dirent *sys_next, *evt_next, sys_dirent, evt_dirent; ++ struct dirent *sys_dirent, *evt_dirent; + char evt_path[MAXPATHLEN]; + char dir_path[MAXPATHLEN]; + +@@ -1016,29 +1016,29 @@ void print_tracepoint_events(const char + if (!sys_dir) + return; + +- for_each_subsystem(sys_dir, sys_dirent, sys_next) { ++ for_each_subsystem(sys_dir, sys_dirent) { + if (subsys_glob != NULL && +- !strglobmatch(sys_dirent.d_name, subsys_glob)) ++ !strglobmatch(sys_dirent->d_name, subsys_glob)) + continue; + + snprintf(dir_path, MAXPATHLEN, "%s/%s", tracing_events_path, +- sys_dirent.d_name); ++ sys_dirent->d_name); + evt_dir = opendir(dir_path); + if (!evt_dir) + continue; + +- for_each_event(sys_dirent, evt_dir, evt_dirent, evt_next) { ++ for_each_event(sys_dirent, evt_dir, evt_dirent) { + if (event_glob != NULL && +- !strglobmatch(evt_dirent.d_name, event_glob)) ++ !strglobmatch(evt_dirent->d_name, event_glob)) + continue; + + if (name_only) { +- printf("%s:%s ", sys_dirent.d_name, evt_dirent.d_name); ++ printf("%s:%s ", sys_dirent->d_name, evt_dirent->d_name); + continue; + } + + snprintf(evt_path, MAXPATHLEN, "%s:%s", +- sys_dirent.d_name, evt_dirent.d_name); ++ sys_dirent->d_name, evt_dirent->d_name); + printf(" %-50s [%s]\n", evt_path, + event_type_descriptors[PERF_TYPE_TRACEPOINT]); + } +@@ -1054,7 +1054,7 @@ void print_tracepoint_events(const char + int is_valid_tracepoint(const char *event_string) + { + DIR *sys_dir, *evt_dir; +- struct dirent *sys_next, *evt_next, sys_dirent, evt_dirent; ++ struct dirent *sys_dirent, *evt_dirent; + char evt_path[MAXPATHLEN]; + char dir_path[MAXPATHLEN]; + +@@ -1065,17 +1065,17 @@ int is_valid_tracepoint(const char *even + if (!sys_dir) + return 0; + +- for_each_subsystem(sys_dir, sys_dirent, sys_next) { ++ for_each_subsystem(sys_dir, sys_dirent) { + + snprintf(dir_path, MAXPATHLEN, "%s/%s", tracing_events_path, +- sys_dirent.d_name); ++ sys_dirent->d_name); + evt_dir = opendir(dir_path); + if (!evt_dir) + continue; + +- for_each_event(sys_dirent, evt_dir, evt_dirent, evt_next) { ++ for_each_event(sys_dirent, evt_dir, evt_dirent) { + snprintf(evt_path, MAXPATHLEN, "%s:%s", +- sys_dirent.d_name, evt_dirent.d_name); ++ sys_dirent->d_name, evt_dirent->d_name); + if (!strcmp(evt_path, event_string)) { + closedir(evt_dir); + closedir(sys_dir); diff --git a/queue-3.16/perf-top-use-__fallthrough.patch b/queue-3.16/perf-top-use-__fallthrough.patch new file mode 100644 index 00000000..4218cddd --- /dev/null +++ b/queue-3.16/perf-top-use-__fallthrough.patch @@ -0,0 +1,41 @@ +From: Arnaldo Carvalho de Melo <acme@redhat.com> +Date: Wed, 8 Feb 2017 17:01:46 -0300 +Subject: perf top: Use __fallthrough + +commit 7b0214b702ad8e124e039a317beeebb3f020d125 upstream. + +The implicit fall through case label here is intended, so let us inform +that to gcc >= 7: + + CC /tmp/build/perf/builtin-top.o + builtin-top.c: In function 'display_thread': + builtin-top.c:644:7: error: this statement may fall through [-Werror=implicit-fallthrough=] + if (errno == EINTR) + ^ + builtin-top.c:647:3: note: here + default: + ^~~~~~~ + +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: http://lkml.kernel.org/n/tip-lmcfnnyx9ic0m6j0aud98p4e@git.kernel.org +Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> +Signed-off-by: Ben Hutchings <ben@decadent.org.uk> +--- + tools/perf/builtin-top.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/tools/perf/builtin-top.c ++++ b/tools/perf/builtin-top.c +@@ -609,7 +609,7 @@ repeat: + case -1: + if (errno == EINTR) + continue; +- /* Fall trhu */ ++ __fallthrough; + default: + c = getc(stdin); + tcsetattr(0, TCSAFLUSH, &save); diff --git a/queue-3.16/perf-trace-do-not-process-perf_record_lost-twice.patch b/queue-3.16/perf-trace-do-not-process-perf_record_lost-twice.patch new file mode 100644 index 00000000..765dffe2 --- /dev/null +++ b/queue-3.16/perf-trace-do-not-process-perf_record_lost-twice.patch @@ -0,0 +1,36 @@ +From: Arnaldo Carvalho de Melo <acme@redhat.com> +Date: Wed, 30 Mar 2016 16:51:17 -0300 +Subject: perf trace: Do not process PERF_RECORD_LOST twice + +commit 3ed5ca2efff70e9f589087c2013789572901112d upstream. + +We catch this record to provide a visual indication that events are +getting lost, then call the default method to allow extra logging shared +with the other tools to take place. + +This extra logging was done twice because we were continuing to the +"default" clause where machine__process_event() will end up calling +machine__process_lost_event() again, fix it. + +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: http://lkml.kernel.org/n/tip-wus2zlhw3qo24ye84ewu4aqw@git.kernel.org +Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> +Signed-off-by: Ben Hutchings <ben@decadent.org.uk> +--- + tools/perf/builtin-trace.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/tools/perf/builtin-trace.c ++++ b/tools/perf/builtin-trace.c +@@ -1359,6 +1359,7 @@ static int trace__process_event(struct t + color_fprintf(trace->output, PERF_COLOR_RED, + "LOST %" PRIu64 " events!\n", event->lost.lost); + ret = machine__process_lost_event(machine, event, sample); ++ break; + default: + ret = machine__process_event(machine, event, sample); + break; diff --git a/queue-3.16/perf-trace-fix-up-fd-pathname-resolution.patch b/queue-3.16/perf-trace-fix-up-fd-pathname-resolution.patch new file mode 100644 index 00000000..8da264b0 --- /dev/null +++ b/queue-3.16/perf-trace-fix-up-fd-pathname-resolution.patch @@ -0,0 +1,93 @@ +From: Arnaldo Carvalho de Melo <acme@redhat.com> +Date: Tue, 10 Jun 2014 16:00:18 -0300 +Subject: perf trace: Fix up fd -> pathname resolution + +commit cdcd1e6bd8a92f8353fc2f37003c6eae2d1e6903 upstream. + +There was a brown paper bag bug in the patch that introduced a reference +implementation on using 'perf probe' made wannabe tracepoints that broke fd -> +pathname resolution, fix it: + + [root@zoo ~]# perf probe 'vfs_getname=getname_flags:65 pathname=result->name:string' + Added new event: + probe:vfs_getname (on getname_flags:65 with pathname=result->name:string) + + You can now use it in all perf tools, such as: + + perf record -e probe:vfs_getname -aR sleep 1 + + [root@zoo ~] + +Before: + + [acme@zoo linux]$ trace touch -e open,fstat /tmp/b + 1.159 ( 0.007 ms): open(filename: 0x7fd73f2fe088, flags: CLOEXEC ) = 3 + 1.163 ( 0.002 ms): fstat(fd: 3, statbuf: 0x7fff1b25e610 ) = 0 + 1.192 ( 0.009 ms): open(filename: 0x7fd73f4fedb8, flags: CLOEXEC ) = 3 + 1.201 ( 0.002 ms): fstat(fd: 3, statbuf: 0x7fff1b25e660 ) = 0 + 1.501 ( 0.013 ms): open(filename: 0x7fd73f0a1610, flags: CLOEXEC ) = 3 + 1.505 ( 0.002 ms): fstat(fd: 3, statbuf: 0x7fd73f2ddb60 ) = 0 + 1.581 ( 0.011 ms): open(filename: 0x7fff1b2603da, flags: CREAT|NOCTTY|NONBLOCK|WRONLY, mode: 438) = 3 + [acme@zoo linux]$ + +After: + + [acme@zoo linux]$ trace touch -e open,fstat,dup2,mmap,close /tmp/b + 1.105 ( 0.004 ms): mmap(len: 4096, prot: READ|WRITE, flags: PRIVATE|ANONYMOUS, fd: -1 ) = 0x2fbf000 + 1.136 ( 0.008 ms): open(filename: 0x7f8902dbc088, flags: CLOEXEC ) = 3 + 1.140 ( 0.002 ms): fstat(fd: 3</etc/ld.so.cache>, statbuf: 0x7fff19889ef0 ) = 0 + 1.146 ( 0.004 ms): mmap(len: 86079, prot: READ, flags: PRIVATE, fd: 3</etc/ld.so.cache> ) = 0x2fa9000 + 1.149 ( 0.001 ms): close(fd: 3</etc/ld.so.cache> ) = 0 + 1.170 ( 0.010 ms): open(filename: 0x7f8902fbcdb8, flags: CLOEXEC ) = 3 + 1.178 ( 0.002 ms): fstat(fd: 3</lib64/libc.so.6>, statbuf: 0x7fff19889f40 ) = 0 + 1.188 ( 0.006 ms): mmap(len: 3924576, prot: EXEC|READ, flags: PRIVATE|DENYWRITE, fd: 3</lib64/libc.so.6>) = 0x29e2000 + 1.207 ( 0.007 ms): mmap(addr: 0x7f8902d96000, len: 24576, prot: READ|WRITE, flags: PRIVATE|DENYWRITE|FIXED, fd: 3</lib64/libc.so.6>, off: 1785856) = 0x2d96000 + 1.217 ( 0.004 ms): mmap(addr: 0x7f8902d9c000, len: 16992, prot: READ|WRITE, flags: PRIVATE|ANONYMOUS|FIXED, fd: -1) = 0x2d9c000 + 1.228 ( 0.002 ms): close(fd: 3</lib64/libc.so.6> ) = 0 + 1.243 ( 0.003 ms): mmap(len: 4096, prot: READ|WRITE, flags: PRIVATE|ANONYMOUS, fd: -1 ) = 0x2fa8000 + 1.250 ( 0.003 ms): mmap(len: 8192, prot: READ|WRITE, flags: PRIVATE|ANONYMOUS, fd: -1 ) = 0x2fa6000 + 1.452 ( 0.010 ms): open(filename: 0x7f8902b5f610, flags: CLOEXEC ) = 3 + 1.455 ( 0.002 ms): fstat(fd: 3</usr/lib/locale/locale-archive>, statbuf: 0x7f8902d9bb60 ) = 0 + 1.461 ( 0.004 ms): mmap(len: 106070960, prot: READ, flags: PRIVATE, fd: 3</usr/lib/locale/locale-archive>) = 0xfc4b9000 + 1.469 ( 0.002 ms): close(fd: 3</usr/lib/locale/locale-archive> ) = 0 + 1.528 ( 0.010 ms): open(filename: 0x7fff1988c3da, flags: CREAT|NOCTTY|NONBLOCK|WRONLY, mode: 438) = 3 + 1.532 ( 0.002 ms): dup2(oldfd: 3</tmp/b> ) = 0 + 1.535 ( 0.001 ms): close(fd: 3</tmp/b> ) = 0 + 1.544 ( 0.001 ms): close( ) = 0 + 1.555 ( 0.001 ms): close(fd: 1 ) = 0 + 1.558 ( 0.001 ms): close(fd: 2 ) = 0 + [acme@zoo linux]$ + +Cc: Adrian Hunter <adrian.hunter@intel.com> +Cc: David Ahern <dsahern@gmail.com> +Cc: Don Zickus <dzickus@redhat.com> +Cc: Frederic Weisbecker <fweisbec@gmail.com> +Cc: Jiri Olsa <jolsa@redhat.com> +Cc: Mike Galbraith <efault@gmx.de> +Cc: Namhyung Kim <namhyung@kernel.org> +Cc: Paul Mackerras <paulus@samba.org> +Cc: Peter Zijlstra <peterz@infradead.org> +Cc: Stephane Eranian <eranian@google.com> +Link: http://lkml.kernel.org/n/tip-vcm22xpjxc3j4hbyuzjzf7ik@git.kernel.org +Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> +Signed-off-by: Ben Hutchings <ben@decadent.org.uk> +--- + tools/perf/builtin-trace.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/tools/perf/builtin-trace.c ++++ b/tools/perf/builtin-trace.c +@@ -1276,11 +1276,11 @@ static const char *thread__fd_path(struc + if (fd < 0) + return NULL; + +- if ((fd > ttrace->paths.max || ttrace->paths.table[fd] == NULL)) ++ if ((fd > ttrace->paths.max || ttrace->paths.table[fd] == NULL)) { + if (!trace->live) + return NULL; + ++trace->stats.proc_getname; +- if (thread__read_fd_path(thread, fd)) { ++ if (thread__read_fd_path(thread, fd)) + return NULL; + } + diff --git a/queue-3.16/series b/queue-3.16/series index bd777c72..d9789f55 100644 --- a/queue-3.16/series +++ b/queue-3.16/series @@ -349,3 +349,18 @@ mips-asmmacro-ensure-64-bit-fp-registers-are-used-with-msa.patch x86-apic-fix-build-failure-with-x86_io_apic-disabled.patch sched-topology-make-local-variables-static.patch usb-misc-usb3503-update-error-code-in-print-message.patch +perf-tools-move-syscall-number-fallbacks-from-perf-sys.h-to.patch +perf-tools-define-_default_source-for-glibc_2.20.patch +perf-script-use-readdir-instead-of-deprecated-readdir_r.patch +perf-thread_map-use-readdir-instead-of-deprecated-readdir_r.patch +perf-tools-use-readdir-instead-of-deprecated-readdir_r-1.patch +perf-tools-use-readdir-instead-of-deprecated-readdir_r-2.patch +tools-include-add-a-__fallthrough-statement.patch +perf-top-use-__fallthrough.patch +perf-tools-fix-snprint-warnings-for-gcc-8.patch +perf-trace-fix-up-fd-pathname-resolution.patch +tools-lib-subcmd-pager.c-do-not-alias-select-params.patch +perf-tools-remove-duplicate-const-qualifier.patch +perf-trace-do-not-process-perf_record_lost-twice.patch +perf-thread_map-correctly-size-buffer-used-with-dirent-dt_name.patch +perf-tools-fix-python-extension-build-for-gcc-8.patch diff --git a/queue-3.16/tools-include-add-a-__fallthrough-statement.patch b/queue-3.16/tools-include-add-a-__fallthrough-statement.patch new file mode 100644 index 00000000..b6ae159b --- /dev/null +++ b/queue-3.16/tools-include-add-a-__fallthrough-statement.patch @@ -0,0 +1,53 @@ +From: Arnaldo Carvalho de Melo <acme@redhat.com> +Date: Wed, 8 Feb 2017 17:01:46 -0300 +Subject: tools include: Add a __fallthrough statement + +commit b5bf1733d6a391c4e90ea8f8468d83023be74a2a upstream. + +For cases where implicit fall through case labels are intended, +to let us inform that to gcc >= 7: + + CC /tmp/build/perf/util/string.o + util/string.c: In function 'perf_atoll': + util/string.c:22:7: error: this statement may fall through [-Werror=implicit-fallthrough=] + if (*p) + ^ + util/string.c:24:3: note: here + case '\0': + ^~~~ + +So we introduce: + + #define __fallthrough __attribute__ ((fallthrough)) + +And use it in such cases. + +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> +Cc: William Cohen <wcohen@redhat.com> +Link: http://lkml.kernel.org/n/tip-qnpig0xfop4hwv6k4mv1wts5@git.kernel.org +Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> +Signed-off-by: Ben Hutchings <ben@decadent.org.uk> +--- + tools/include/linux/compiler.h | 9 +++++++++ + 1 file changed, 9 insertions(+) + +--- a/tools/include/linux/compiler.h ++++ b/tools/include/linux/compiler.h +@@ -37,4 +37,13 @@ + + #define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x)) + ++ ++#ifndef __fallthrough ++# if defined(__GNUC__) && __GNUC__ >= 7 ++# define __fallthrough __attribute__ ((fallthrough)) ++# else ++# define __fallthrough ++# endif ++#endif ++ + #endif /* _TOOLS_LINUX_COMPILER_H */ diff --git a/queue-3.16/tools-lib-subcmd-pager.c-do-not-alias-select-params.patch b/queue-3.16/tools-lib-subcmd-pager.c-do-not-alias-select-params.patch new file mode 100644 index 00000000..d79880b1 --- /dev/null +++ b/queue-3.16/tools-lib-subcmd-pager.c-do-not-alias-select-params.patch @@ -0,0 +1,41 @@ +From: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> +Date: Tue, 6 Feb 2018 15:37:52 -0800 +Subject: tools/lib/subcmd/pager.c: do not alias select() params + +commit ad343a98e74e85aa91d844310e797f96fee6983b upstream. + +Use a separate fd set for select()-s exception fds param to fix the +following gcc warning: + + pager.c:36:12: error: passing argument 2 to restrict-qualified parameter aliases with argument 4 [-Werror=restrict] + select(1, &in, NULL, &in, NULL); + ^~~ ~~~ + +Link: http://lkml.kernel.org/r/20180101105626.7168-1-sergey.senozhatsky@gmail.com +Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> +Cc: Arnaldo Carvalho de Melo <acme@redhat.com> +Signed-off-by: Andrew Morton <akpm@linux-foundation.org> +Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> +[bwh: Backported to 3.16: adjust filename] +Signed-off-by: Ben Hutchings <ben@decadent.org.uk> +--- + tools/perf/util/pager.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +--- a/tools/perf/util/pager.c ++++ b/tools/perf/util/pager.c +@@ -16,10 +16,13 @@ static void pager_preexec(void) + * have real input + */ + fd_set in; ++ fd_set exception; + + FD_ZERO(&in); ++ FD_ZERO(&exception); + FD_SET(0, &in); +- select(1, &in, NULL, &in, NULL); ++ FD_SET(0, &exception); ++ select(1, &in, NULL, &exception, NULL); + + setenv("LESS", "FRSX", 0); + } |