[PATCH 00/13] Porting perf to Android
Hi, This is a set of patches to port perf to Android. My approach is to include missing functions in Android (like getline, getsid, etc). I am currently working on upstreaming these to Google. With the missing functionality added to bionic, this compiles on latest Android tree (JellyBean). This will make perf compile, but there are still fixes needed at runtime which I am currently working on. I have seen that another patch that ports perf to Android was recently submitted to this list. The approach is different and there are also changes that do not overlap. If the other patch will be merged first, I will rebase my work on top of it. Thank you, Irina -- Irina Tirdea (13): perf tools: include wrapper for magic.h perf tools: update types definitions for Android perf tools: drop asm/byteorder.h wrapper perf tools: include __WORDSIZE definition perf tools: fix ALIGN redefinition in system headers perf tools: include basename for non-glibc systems perf tools: fix missing winsize definition perf tools: Use __maybe_used for unused variables perf tools: include missing pthread.h header perf tools: fix non-void function without return statement perf tools: replace mempcpy with memcpy perf tools: replace on_exit with atexit perf tools: replace mkostemp with mkstemp tools/perf/Makefile |2 +- tools/perf/bench/bench.h |2 +- tools/perf/bench/mem-memcpy.c|2 +- tools/perf/bench/mem-memset.c|2 +- tools/perf/bench/sched-messaging.c |2 +- tools/perf/bench/sched-pipe.c|4 +- tools/perf/builtin-annotate.c|2 +- tools/perf/builtin-bench.c |2 +- tools/perf/builtin-buildid-cache.c |6 +-- tools/perf/builtin-buildid-list.c|2 +- tools/perf/builtin-diff.c|4 +- tools/perf/builtin-evlist.c |2 +- tools/perf/builtin-help.c|2 +- tools/perf/builtin-inject.c | 20 +++ tools/perf/builtin-kmem.c| 20 +++ tools/perf/builtin-kvm.c |2 +- tools/perf/builtin-list.c|2 +- tools/perf/builtin-lock.c|4 +- tools/perf/builtin-probe.c | 24 - tools/perf/builtin-record.c | 24 + tools/perf/builtin-report.c | 10 ++-- tools/perf/builtin-sched.c | 64 +++ tools/perf/builtin-script.c | 16 +++--- tools/perf/builtin-stat.c| 24 - tools/perf/builtin-test.c|6 +-- tools/perf/builtin-timechart.c | 28 +- tools/perf/builtin-top.c |6 +-- tools/perf/perf.c|1 + tools/perf/ui/browser.c |6 +-- tools/perf/ui/browsers/annotate.c|4 +- tools/perf/ui/gtk/browser.c |4 +- tools/perf/ui/gtk/setup.c|2 +- tools/perf/ui/gtk/util.c |4 +- tools/perf/ui/helpline.c |2 +- tools/perf/ui/helpline.h |8 +-- tools/perf/ui/tui/setup.c|4 +- tools/perf/util/alias.c |2 +- tools/perf/util/annotate.c |6 +-- tools/perf/util/annotate.h | 13 ++--- tools/perf/util/build-id.c | 10 ++-- tools/perf/util/cache.h |6 +-- tools/perf/util/callchain.c |6 +-- tools/perf/util/cgroup.c |4 +- tools/perf/util/config.c |4 +- tools/perf/util/debug.h |8 +-- tools/perf/util/dso-test-data.c |2 +- tools/perf/util/event.c | 28 +- tools/perf/util/event.h |2 +- tools/perf/util/header.c | 84 +++--- tools/perf/util/help.c |3 +- tools/perf/util/hist.c |2 +- tools/perf/util/hist.h | 30 +-- tools/perf/util/include/asm/byteorder.h |2 - tools/perf/util/include/asm/swab.h |2 +- tools/perf/util/include/linux/bitops.h |9 tools/perf/util/include/linux/compiler.h |6 ++- tools/perf/util/include/linux/kernel.h | 15 +- tools/perf/util/include/linux/magic.h| 12 + tools/perf/util/include/linux/types.h| 15 ++ tools/perf/util/intlist.c|6 +-- tools/perf/util/map.h|2 +- tools/perf/util/parse-events-test.c |6 +-- tools/perf/util/parse-events.c |6 +-- tools/perf/util/parse-events.l |3 +- tools/perf/util/parse-events.y |4 +- tools/perf/util/parse-options.c |2 +- tools/perf/util/perf_regs.h |2 +- tools/perf/util/pmu.y|6 +-- tools/perf
[PATCH 03/13] perf tools: drop asm/byteorder.h wrapper
Wrapping asm/byteorder.h will also replace the glibc header, not only the kernel one. asm/byteorder.h further includes architecture dependent headers that define endianess. Some systems (e.g. Android) need constant definitions that depend on endianess (e.g. __constant_htonl). In file included from bionic/libc/include/netinet/tcp.h:32:0, from kernel/intel/tools/perf/util/util.h:74, from kernel/intel/tools/perf/util/cache.h:5, from kernel/intel/tools/perf/util/abspath.c:1: bionic/libc/kernel/common/linux/tcp.h:61:2: error: enumerator value for 'TCP_FLAG_CWR' is not an integer constant bionic/libc/kernel/common/linux/tcp.h:62:2: error: enumerator value for 'TCP_FLAG_ECE' is not an integer constant bionic/libc/kernel/common/linux/tcp.h:63:2: error: enumerator value for 'TCP_FLAG_URG' is not an integer constant bionic/libc/kernel/common/linux/tcp.h:64:2: error: enumerator value for 'TCP_FLAG_ACK' is not an integer constant bionic/libc/kernel/common/linux/tcp.h:65:2: error: enumerator value for 'TCP_FLAG_PSH' is not an integer constant bionic/libc/kernel/common/linux/tcp.h:66:2: error: enumerator value for 'TCP_FLAG_RST' is not an integer constant bionic/libc/kernel/common/linux/tcp.h:67:2: error: enumerator value for 'TCP_FLAG_SYN' is not an integer constant bionic/libc/kernel/common/linux/tcp.h:68:2: error: enumerator value for 'TCP_FLAG_FIN' is not an integer constant bionic/libc/kernel/common/linux/tcp.h:69:2: error: enumerator value for 'TCP_RESERVED_BITS' is not an integer constant bionic/libc/kernel/common/linux/tcp.h:71:1: error: enumerator value for 'TCP_DATA_OFFSET' is not an integer constant Drop this wrapper and use swab.h. glibc byteorder.h header already includes asm/types.h and swab.h. Using swab.h wrapper to do the work from byteorder.h should be enough. Signed-off-by: Irina Tirdea --- tools/perf/Makefile |1 - tools/perf/util/include/asm/byteorder.h |2 -- tools/perf/util/include/asm/swab.h |2 +- tools/perf/util/parse-events.l |1 + tools/perf/util/util.h |1 + 5 files changed, 3 insertions(+), 4 deletions(-) delete mode 100644 tools/perf/util/include/asm/byteorder.h diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 58304d9..81ea120 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -273,7 +273,6 @@ LIB_H += util/include/linux/types.h LIB_H += util/include/linux/linkage.h LIB_H += util/include/asm/asm-offsets.h LIB_H += util/include/asm/bug.h -LIB_H += util/include/asm/byteorder.h LIB_H += util/include/asm/hweight.h LIB_H += util/include/asm/swab.h LIB_H += util/include/asm/system.h diff --git a/tools/perf/util/include/asm/byteorder.h b/tools/perf/util/include/asm/byteorder.h deleted file mode 100644 index b722abe..000 --- a/tools/perf/util/include/asm/byteorder.h +++ /dev/null @@ -1,2 +0,0 @@ -#include -#include "../../../../include/linux/swab.h" diff --git a/tools/perf/util/include/asm/swab.h b/tools/perf/util/include/asm/swab.h index ed53894..e1d3ae0 100644 --- a/tools/perf/util/include/asm/swab.h +++ b/tools/perf/util/include/asm/swab.h @@ -1 +1 @@ -/* stub */ +#include "../../../../include/linux/swab.h" diff --git a/tools/perf/util/parse-events.l b/tools/perf/util/parse-events.l index 2c0d006..73d123b 100644 --- a/tools/perf/util/parse-events.l +++ b/tools/perf/util/parse-events.l @@ -7,6 +7,7 @@ %{ #include #include "../perf.h" +#include #include "parse-events-bison.h" #include "parse-events.h" diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index d306ec1f..f6716be 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -78,6 +78,7 @@ #include #include "types.h" #include +#include extern const char *graph_line; extern const char *graph_dotted_line; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 04/13] perf tools: include __WORDSIZE definition
__WORDSIZE is GLibC-specific and is not defined on all systems or glibc versions (e.g. Android's bionic does not define it). In file included from util/include/linux/bitmap.h:5:0, from util/header.h:10, from util/session.h:6, from util/build-id.h:4, from util/annotate.c:11: util/include/linux/bitops.h: In function 'set_bit': util/include/linux/bitops.h:25:12: error: '__WORDSIZE' undeclared (first use in this function) util/include/linux/bitops.h:25:12: note: each undeclared identifier is reported only once for each function it appears in util/include/linux/bitops.h:23:51: error: parameter 'addr' set but not used [-Werror=unused-but-set-parameter] util/include/linux/bitops.h: In function 'clear_bit': util/include/linux/bitops.h:30:12: error: '__WORDSIZE' undeclared (first use in this function) util/include/linux/bitops.h:28:53: error: parameter 'addr' set but not used [-Werror=unused-but-set-parameter] In file included from util/header.h:10:0, from util/session.h:6, from util/build-id.h:4, from util/annotate.c:11: util/include/linux/bitmap.h: In function 'bitmap_zero': util/include/linux/bitmap.h:22:6: error: '__WORDSIZE' undeclared (first use in this function) Defining __WORDSIZE in perf's headers if it is not already defined. Signed-off-by: Irina Tirdea --- tools/perf/util/include/linux/bitops.h |9 + 1 file changed, 9 insertions(+) diff --git a/tools/perf/util/include/linux/bitops.h b/tools/perf/util/include/linux/bitops.h index 587a230..91779ec 100644 --- a/tools/perf/util/include/linux/bitops.h +++ b/tools/perf/util/include/linux/bitops.h @@ -5,6 +5,15 @@ #include #include +#ifndef __WORDSIZE +#if defined(__x86_64__) +# define __WORDSIZE 64 +#endif +#if defined(__i386__) || defined(__arm__) +# define __WORDSIZE 32 +#endif +#endif + #define BITS_PER_LONG __WORDSIZE #define BITS_PER_BYTE 8 #define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 05/13] perf tools: fix ALIGN redefinition in system headers
On some systems (e.g. Android), ALIGN is defined in system headers as ALIGN(p). The definition of ALIGN used in perf takes 2 parameters: ALIGN(x,a). This leads to redefinition conflicts. Redefinition error on Android: In file included from util/include/linux/list.h:1:0, from util/callchain.h:5, from util/hist.h:6, from util/session.h:4, from util/build-id.h:4, from util/annotate.c:11: util/include/linux/kernel.h:11:0: error: "ALIGN" redefined [-Werror] bionic/libc/include/sys/param.h:38:0: note: this is the location of the previous definition Conflics with system defined ALIGN in Android: util/event.c: In function 'perf_event__synthesize_comm': util/event.c:115:32: error: macro "ALIGN" passed 2 arguments, but takes just 1 util/event.c:115:9: error: 'ALIGN' undeclared (first use in this function) util/event.c:115:9: note: each undeclared identifier is reported only once for each function it appears in In order to avoid this redefinition, ALIGN is renamed to PERF_ALIGN. Signed-off-by: Irina Tirdea --- tools/perf/util/event.c| 10 +- tools/perf/util/event.h|2 +- tools/perf/util/header.c | 16 tools/perf/util/include/linux/kernel.h |4 ++-- tools/perf/util/session.c |4 ++-- tools/perf/util/symbol.c |2 +- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 3a0f1a5..aee4ddf 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -112,7 +112,7 @@ static pid_t perf_event__synthesize_comm(struct perf_tool *tool, event->comm.header.type = PERF_RECORD_COMM; size = strlen(event->comm.comm) + 1; -size = ALIGN(size, sizeof(u64)); +size = PERF_ALIGN(size, sizeof(u64)); memset(event->comm.comm + size, 0, machine->id_hdr_size); event->comm.header.size = (sizeof(event->comm) - (sizeof(event->comm.comm) - size) + @@ -143,7 +143,7 @@ static pid_t perf_event__synthesize_comm(struct perf_tool *tool, sizeof(event->comm.comm)); size = strlen(event->comm.comm) + 1; -size = ALIGN(size, sizeof(u64)); +size = PERF_ALIGN(size, sizeof(u64)); memset(event->comm.comm + size, 0, machine->id_hdr_size); event->comm.header.size = (sizeof(event->comm) - (sizeof(event->comm.comm) - size) + @@ -222,7 +222,7 @@ static int perf_event__synthesize_mmap_events(struct perf_tool *tool, size = strlen(execname); execname[size - 1] = '\0'; /* Remove \n */ memcpy(event->mmap.filename, execname, size); -size = ALIGN(size, sizeof(u64)); +size = PERF_ALIGN(size, sizeof(u64)); event->mmap.len -= event->mmap.start; event->mmap.header.size = (sizeof(event->mmap) - (sizeof(event->mmap.filename) - size)); @@ -272,7 +272,7 @@ int perf_event__synthesize_modules(struct perf_tool *tool, if (pos->dso->kernel) continue; -size = ALIGN(pos->dso->long_name_len + 1, sizeof(u64)); +size = PERF_ALIGN(pos->dso->long_name_len + 1, sizeof(u64)); event->mmap.header.type = PERF_RECORD_MMAP; event->mmap.header.size = (sizeof(event->mmap) - (sizeof(event->mmap.filename) - size)); @@ -477,7 +477,7 @@ int perf_event__synthesize_kernel_mmap(struct perf_tool *tool, map = machine->vmlinux_maps[MAP__FUNCTION]; size = snprintf(event->mmap.filename, sizeof(event->mmap.filename), "%s%s", mmap_name, symbol_name) + 1; -size = ALIGN(size, sizeof(u64)); +size = PERF_ALIGN(size, sizeof(u64)); event->mmap.header.type = PERF_RECORD_MMAP; event->mmap.header.size = (sizeof(event->mmap) - (sizeof(event->mmap.filename) - size) + machine->id_hdr_size); diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index 0e088d0..21b99e7 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h @@ -101,7 +101,7 @@ struct perf_sample { struct build_id_event { struct perf_event_header header; pid_t pid; -u8 build_id[ALIGN(BUILD_ID_SIZE, sizeof(u64))]; +u8 build_id[PERF_ALIGN(BUILD_ID_SIZE, sizeof(u64))]; char filename[]; }; diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 1e5b6aa..7f8631f 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -128,7 +128,7 @@ static int do_write_string(int fd, const char *str) int ret; olen = strlen(str) + 1; -len = ALIGN(olen, NAME_ALIGN); +len = PERF_ALIGN(olen, NAME_ALIGN); /* write len, incl. \0 */ ret = do_write(fd, &len, sizeof(len)); @@ -219,7 +219
[PATCH 06/13] perf tools: include basename for non-glibc systems
perf uses the glibc version of basename(), by defining _GNU_SOURCE, including string.h and not including libgen.h. The glibc version of basename is better than the POSIX version since it does not modify its argument. Android has only one version of basename which is defined in libgen.h. This version is the same as the glibc version. Error on Android: util/annotate.c: In function 'symbol__annotate_printf': util/annotate.c:503:3: error: implicit declaration of function 'basename' [-Werror=implicit-function-declaration] util/annotate.c:503:3: error: nested extern declaration of 'basename' [-Werror=nested-externs] util/annotate.c:503:14: error: assignment makes pointer from integer without a cast [-Werror] On Android libgen.h should be included to define basename. Signed-off-by: Irina Tirdea --- tools/perf/util/symbol.h |3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index fc4b1e6..d3b330c 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h @@ -10,6 +10,9 @@ #include #include #include +#if defined(__BIONIC__) +#include +#endif #ifndef NO_LIBELF_SUPPORT #include -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 07/13] perf tools: fix missing winsize definition
In Android, struct winsize is not defined in the headers already included in help.c. This leads to a compile error. Including termios.h fixes the compilation error since it defines struct winsize. Signed-off-by: Irina Tirdea --- tools/perf/util/help.c |1 + tools/perf/util/top.h |1 + 2 files changed, 2 insertions(+) diff --git a/tools/perf/util/help.c b/tools/perf/util/help.c index 6f2975a..4fa764d 100644 --- a/tools/perf/util/help.c +++ b/tools/perf/util/help.c @@ -3,6 +3,7 @@ #include "exec_cmd.h" #include "levenshtein.h" #include "help.h" +#include void add_cmdname(struct cmdnames *cmds, const char *name, size_t len) { diff --git a/tools/perf/util/top.h b/tools/perf/util/top.h index 33347ca..86ff1b1 100644 --- a/tools/perf/util/top.h +++ b/tools/perf/util/top.h @@ -5,6 +5,7 @@ #include "types.h" #include #include +#include struct perf_evlist; struct perf_evsel; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 09/13] perf tools: include missing pthread.h header
pthread variables are used in some files without explicitely including pthread.h. This leads to compile errors on Android. e.g.: in annotate.h, error: unknown type name 'pthread_mutex_t' Including pthread.h explicitely in files that use it to have all definitions included. Signed-off-by: Irina Tirdea --- tools/perf/perf.c |1 + tools/perf/util/annotate.h |1 + 2 files changed, 2 insertions(+) diff --git a/tools/perf/perf.c b/tools/perf/perf.c index e7840e5..fb8578c 100644 --- a/tools/perf/perf.c +++ b/tools/perf/perf.c @@ -14,6 +14,7 @@ #include "util/run-command.h" #include "util/parse-events.h" #include "util/debugfs.h" +#include const char perf_usage_string[] = "perf [--version] [--help] COMMAND [ARGS]"; diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index d6f1b4b..0c81586 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h @@ -7,6 +7,7 @@ #include "symbol.h" #include #include +#include struct ins; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 10/13] perf tools: fix non-void function without return statement
thread_func in builtin-sched.c has an internal loop and never returns. The only return from this thread are BUG_ON calls in case return values are not 0. The compiler on Android complains that the function needs to return a non-void value. Adding the noreturn function attribute to fix this error. Error in Android: target C: perf <= builtin-sched.c hardware/intel/linu/tools/perf/builtin-sched.c: In function 'thread_func': hardware/intel/linux/tools/perf/builtin-sched.c:476: error: no return statement in function returning non-void Signed-off-by: Irina Tirdea --- tools/perf/builtin-sched.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index 3d3cab46..da293b8 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -439,7 +439,7 @@ static u64 get_cpu_usage_nsec_self(int fd) return runtime; } -static void *thread_func(void *ctx) +static __attribute__ ((noreturn)) void *thread_func(void *ctx) { struct task_desc *this_task = ctx; u64 cpu_usage_0, cpu_usage_1; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 12/13] perf tools: replace on_exit with atexit
on_exit() is only available in new versions of glibc. Using on_exit on Android leads to errors at compile time. Replacing on_exit with its more portable version atexit. This leads to using a global variable since on_exit supports sending a parameters while atexit does not. Signed-off-by: Irina Tirdea --- tools/perf/builtin-record.c | 16 ++-- 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 3fc9bf9..f5daedf 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -66,6 +66,9 @@ struct perf_record { off_tpost_processing_offset; }; +/* for atexit */ +static struct perf_record *saved_rec; + static void advance_output(struct perf_record *rec, size_t size) { rec->bytes_written += size; @@ -143,9 +146,9 @@ static void sig_handler(int sig) signr = sig; } -static void perf_record__sig_exit(int exit_status __maybe_unused, void *arg) +static void perf_record__sig_exit(void) { -struct perf_record *rec = arg; +struct perf_record *rec = saved_rec; int status; if (rec->evlist->workload.pid > 0) { @@ -335,9 +338,9 @@ static int process_buildids(struct perf_record *rec) size, &build_id__mark_dso_hit_ops); } -static void perf_record__exit(int status __maybe_unused, void *arg) +static void perf_record__exit(void) { -struct perf_record *rec = arg; +struct perf_record *rec = saved_rec; if (!rec->opts.pipe_output) { rec->session->header.data_size += rec->bytes_written; @@ -424,7 +427,8 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv) rec->page_size = sysconf(_SC_PAGE_SIZE); -on_exit(perf_record__sig_exit, rec); +saved_rec = rec; +atexit(perf_record__sig_exit); signal(SIGCHLD, sig_handler); signal(SIGINT, sig_handler); signal(SIGUSR1, sig_handler); @@ -508,7 +512,7 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv) /* * perf_session__delete(session) will be called at perf_record__exit() */ -on_exit(perf_record__exit, rec); +atexit(perf_record__exit); if (opts->pipe_output) { err = perf_header__write_pipe(output); -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 13/13] perf tools: replace mkostemp with mkstemp
mkostemp is only available in glibc. This leads to compile error in Android, since bionic is derived from BSD. Replacing mkostemp with mkstemp. mkstemp is available on both glibc and bionic. Signed-off-by: Irina Tirdea --- tools/perf/util/dso-test-data.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/dso-test-data.c b/tools/perf/util/dso-test-data.c index 541cdc7..c6caede 100644 --- a/tools/perf/util/dso-test-data.c +++ b/tools/perf/util/dso-test-data.c @@ -23,7 +23,7 @@ static char *test_file(int size) int fd, i; unsigned char *buf; -fd = mkostemp(templ, O_CREAT|O_WRONLY|O_TRUNC); +fd = mkstemp(templ); buf = malloc(size); if (!buf) { -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 11/13] perf tools: replace mempcpy with memcpy
mempcpy is not supported by bionic in Android and will lead to compilation errors. Replacing mempcpy with memcpy so it will work in Android. Signed-off-by: Irina Tirdea --- tools/perf/util/target.c |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/target.c b/tools/perf/util/target.c index 051eaa6..065528b 100644 --- a/tools/perf/util/target.c +++ b/tools/perf/util/target.c @@ -117,8 +117,8 @@ int perf_target__strerror(struct perf_target *target, int errnum, if (err != buf) { size_t len = strlen(err); - char *c = mempcpy(buf, err, min(buflen - 1, len)); - *c = '\0'; + memcpy(buf, err, min(buflen - 1, len)); + *(buf + min(buflen - 1, len)) = '\0'; } return 0; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 01/13] perf tools: include wrapper for magic.h
perf is currently including magic.h directly from the kernel. If the glibc magic.h is also included, this leads to warnings that the constants are redefined. This happens on some systems (e.g. Android). Redefinition errors on Android: In file included from util/util.h:79:0, from util/cache.h:5, from util/abspath.c:1: util/../../../include/linux/magic.h:5:0: error: "AFFS_SUPER_MAGIC" redefined [-Werror] bionic/libc/include/sys/vfs.h:53:0: note: this is the location of the previous definition util/../../../include/linux/magic.h:19:0: error: "EFS_SUPER_MAGIC" redefined [-Werror] bionic/libc/include/sys/vfs.h:61:0: note: this is the location of the previous definition util/../../../include/linux/magic.h:26:0: error: "HPFS_SUPER_MAGIC" redefined [-Werror] bionic/libc/include/sys/vfs.h:67:0: note: this is the location of the previous definition Only two constants from magic.h are used by perf (DEBUGFS_MAGIC and SYSFS_MAGIC). This fix provides a wrapper for magic.h that includes only these constants instead of including the kernel header file directly. Signed-off-by: Irina Tirdea --- tools/perf/Makefile |1 + tools/perf/util/include/linux/magic.h | 12 tools/perf/util/util.h|2 +- 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 tools/perf/util/include/linux/magic.h diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 6bd888d..58304d9 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -264,6 +264,7 @@ LIB_H += util/include/linux/ctype.h LIB_H += util/include/linux/kernel.h LIB_H += util/include/linux/list.h LIB_H += util/include/linux/export.h +LIB_H += util/include/linux/magic.h LIB_H += util/include/linux/poison.h LIB_H += util/include/linux/prefetch.h LIB_H += util/include/linux/rbtree.h diff --git a/tools/perf/util/include/linux/magic.h b/tools/perf/util/include/linux/magic.h new file mode 100644 index 000..58b64ed --- /dev/null +++ b/tools/perf/util/include/linux/magic.h @@ -0,0 +1,12 @@ +#ifndef _PERF_LINUX_MAGIC_H_ +#define _PERF_LINUX_MAGIC_H_ + +#ifndef DEBUGFS_MAGIC +#define DEBUGFS_MAGIC 0x64626720 +#endif + +#ifndef SYSFS_MAGIC +#define SYSFS_MAGIC0x62656572 +#endif + +#endif diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 00a93a9..d306ec1f 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -75,7 +75,7 @@ #include #include #include -#include "../../../include/linux/magic.h" +#include #include "types.h" #include -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 02/13] perf tools: update types definitions for Android
Some systems (e.g. Android) define in their libc types.h __le16, __be16, etc. Since perf is wrapping with a local version, we need to define this constants in the local version too. Errors in Android: In file included from bionic/libc/include/netinet/in.h:34:0, from util/util.h:73, from util/cache.h:5, from util/abspath.c:1: bionic/libc/kernel/common/linux/in6.h:20:2: error: unknown type name '__be16' bionic/libc/kernel/common/linux/in6.h:21:2: error: unknown type name '__be32' bionic/libc/kernel/common/linux/in6.h:30:2: error: unknown type name '__be16' bionic/libc/kernel/common/linux/in6.h:31:2: error: unknown type name '__be32' bionic/libc/kernel/common/linux/in6.h:47:2: error: unknown type name '__be32' roundup() definition is also missing: util/symbol.c: In function 'symbols__fixup_end': util/symbol.c:106: warning: implicit declaration of function 'roundup' util/symbol.c:106: warning: nested extern declaration of 'roundup' Some macro defined in perf are also defined in libc which leads to redefinition errors. In order to avoid these, we guard these definitions with #ifndef. Signed-off-by: Irina Tirdea --- tools/perf/util/include/linux/compiler.h |4 tools/perf/util/include/linux/kernel.h | 11 +++ tools/perf/util/include/linux/types.h| 15 +++ 3 files changed, 30 insertions(+) diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h index 2dc8671..ce2367b 100644 --- a/tools/perf/util/include/linux/compiler.h +++ b/tools/perf/util/include/linux/compiler.h @@ -12,4 +12,8 @@ #define __used __attribute__((__unused__)) #define __packed __attribute__((__packed__)) +#ifndef __force +#define __force +#endif + #endif diff --git a/tools/perf/util/include/linux/kernel.h b/tools/perf/util/include/linux/kernel.h index b6842c1..391c425 100644 --- a/tools/perf/util/include/linux/kernel.h +++ b/tools/perf/util/include/linux/kernel.h @@ -46,6 +46,17 @@ _min1 < _min2 ? _min1 : _min2; }) #endif +#ifndef roundup +#define roundup(x, y) (\ +{ \ + const typeof(y) __y = y;\ + (((x) + (__y - 1)) / __y) * __y;\ +} \ +) +#endif + + + #ifndef BUG_ON #define BUG_ON(cond) assert(!(cond)) #endif diff --git a/tools/perf/util/include/linux/types.h b/tools/perf/util/include/linux/types.h index 12de3b8..60a97bb 100644 --- a/tools/perf/util/include/linux/types.h +++ b/tools/perf/util/include/linux/types.h @@ -3,6 +3,21 @@ #include +#ifndef __bitwise__ +#define __bitwise__ +#endif + +#ifndef __bitwise +#define __bitwise +#endif + +typedef __u16 __bitwise __le16; +typedef __u16 __bitwise __be16; +typedef __u32 __bitwise __le32; +typedef __u32 __bitwise __be32; +typedef __u64 __bitwise __le64; +typedef __u64 __bitwise __be64; + #define DECLARE_BITMAP(name,bits) \ unsigned long name[BITS_TO_LONGS(bits)] -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 02/13] perf tools: update types definitions for Android
Some systems (e.g. Android) define in their libc types.h __le16, __be16, etc. Since perf is wrapping with a local version, we need to define this constants in the local version too. Errors in Android: In file included from bionic/libc/include/netinet/in.h:34:0, from util/util.h:73, from util/cache.h:5, from util/abspath.c:1: bionic/libc/kernel/common/linux/in6.h:20:2: error: unknown type name '__be16' bionic/libc/kernel/common/linux/in6.h:21:2: error: unknown type name '__be32' bionic/libc/kernel/common/linux/in6.h:30:2: error: unknown type name '__be16' bionic/libc/kernel/common/linux/in6.h:31:2: error: unknown type name '__be32' bionic/libc/kernel/common/linux/in6.h:47:2: error: unknown type name '__be32' roundup() definition is also missing: util/symbol.c: In function 'symbols__fixup_end': util/symbol.c:106: warning: implicit declaration of function 'roundup' util/symbol.c:106: warning: nested extern declaration of 'roundup' Some macro defined in perf are also defined in libc which leads to redefinition errors. In order to avoid these, we guard these definitions with #ifndef. Signed-off-by: Irina Tirdea --- tools/perf/util/include/linux/compiler.h |4 tools/perf/util/include/linux/kernel.h | 11 +++ tools/perf/util/include/linux/types.h| 15 +++ 3 files changed, 30 insertions(+) diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h index 2dc8671..ce2367b 100644 --- a/tools/perf/util/include/linux/compiler.h +++ b/tools/perf/util/include/linux/compiler.h @@ -12,4 +12,8 @@ #define __used__attribute__((__unused__)) #define __packed__attribute__((__packed__)) +#ifndef __force +#define __force +#endif + #endif diff --git a/tools/perf/util/include/linux/kernel.h b/tools/perf/util/include/linux/kernel.h index b6842c1..391c425 100644 --- a/tools/perf/util/include/linux/kernel.h +++ b/tools/perf/util/include/linux/kernel.h @@ -46,6 +46,17 @@ _min1 < _min2 ? _min1 : _min2; }) #endif +#ifndef roundup +#define roundup(x, y) (\ +{ \ + const typeof(y) __y = y;\ + (((x) + (__y - 1)) / __y) * __y;\ +} \ +) +#endif + + + #ifndef BUG_ON #define BUG_ON(cond) assert(!(cond)) #endif diff --git a/tools/perf/util/include/linux/types.h b/tools/perf/util/include/linux/types.h index 12de3b8..60a97bb 100644 --- a/tools/perf/util/include/linux/types.h +++ b/tools/perf/util/include/linux/types.h @@ -3,6 +3,21 @@ #include +#ifndef __bitwise__ +#define __bitwise__ +#endif + +#ifndef __bitwise +#define __bitwise +#endif + +typedef __u16 __bitwise __le16; +typedef __u16 __bitwise __be16; +typedef __u32 __bitwise __le32; +typedef __u32 __bitwise __be32; +typedef __u64 __bitwise __le64; +typedef __u64 __bitwise __be64; + #define DECLARE_BITMAP(name,bits) \ unsigned long name[BITS_TO_LONGS(bits)] -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 03/13] perf tools: drop asm/byteorder.h wrapper
> This https://lkml.org/lkml/2012/8/29/150 should fix the netinet/tcp.h build > problem. > Thanks! Removing the header files is a much cleaner solution. I will remove this patch and use yours. Irina -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 02/13] perf tools: update types definitions for Android
> This https://lkml.org/lkml/2012/8/29/150 should fix the netinet/in.h build > problem. Thanks! I'll change this patch and resubmit. Irina -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 05/13] perf tools: fix ALIGN redefinition in system headers
> Simpler to undef ALIGN in util/include/linux/kernel.h right before the perf > version is declared. This was actually my initial approach as well. The problem is that just to undef ALIGN before it is defined in perf is not enough. Somehow the bionic version overrides the perf definition even if I use undef. A solution would be to move the entire block of #undef and #define ALIGN at the beginning of util/include/linux/kernel.h, before the header's #ifndef PERF_LINUX_KERNEL_H_ define. I thought that renaming the ALIGN in perf is cleaner than having defines outside the include guards. Irina -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 12/13] perf tools: replace on_exit with atexit
> Bernhard's patch implements on_exit. Why not go that route? > > The exit functions need the commands status to know whether to attempt to > process records. See: https://lkml.org/lkml/2012/8/26/123 > > Processing records on non-0 exit causes a segfault as the session has been > deleted. I was trying to avoid as much as possible adding implementations for functions in perf. Considering the patch you mentioned and the need to know the exit status, looks like Bernhard's solution is the best approach in this case. I will use his on_exit wrapper and drop this patch. Thanks, Irina -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 00/13] Porting perf to Android
On Thu, Aug 30, 2012 at 8:19 PM, Namhyung Kim wrote: > Irina Tirdea writes: > >> Hi, >> >> This is a set of patches to port perf to Android. >> My approach is to include missing functions in Android (like getline, >> getsid, etc). I am currently working on upstreaming these to Google. >> With the missing functionality added to bionic, this compiles on latest >> Android tree (JellyBean). This will make perf compile, but there are still >> fixes needed at runtime which I am currently working on. > > Yeah, I guess the callchain part which uses TLS is the one of them. Do > you have an idea how to deal with it? Yes, TLS defined through __thread is not supported by bionic. I was thinking of using pthread_getspecific/pthread_setspecific API instead. Thanks, Irina -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] perf bench: fix assert when NDEBUG is defined
From: Irina Tirdea When NDEBUG is defined, the assert macro will be expanded to nothing. Some assert calls used in perf are also including some functionality (e.g. system calls), not only validity checks. Therefore, if NDEBUG is defined, these functionality will be removed along with the assert. The functionality of the program needs to be separated from the assert checks. In perf, BUG_ON is also defined on assert, so we need to fix these statements too. Signed-off-by: Irina Tirdea --- tools/perf/bench/mem-memcpy.c |8 +--- tools/perf/bench/mem-memset.c |8 +--- tools/perf/bench/sched-pipe.c |6 -- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/tools/perf/bench/mem-memcpy.c b/tools/perf/bench/mem-memcpy.c index 02dad5d..bccb783 100644 --- a/tools/perf/bench/mem-memcpy.c +++ b/tools/perf/bench/mem-memcpy.c @@ -144,17 +144,19 @@ static double do_memcpy_gettimeofday(memcpy_t fn, size_t len, bool prefault) { struct timeval tv_start, tv_end, tv_diff; void *src = NULL, *dst = NULL; - int i; + int i, ret; alloc_mem(&src, &dst, len); if (prefault) fn(dst, src, len); - BUG_ON(gettimeofday(&tv_start, NULL)); + ret = gettimeofday(&tv_start, NULL); + BUG_ON(ret); for (i = 0; i < iterations; ++i) fn(dst, src, len); - BUG_ON(gettimeofday(&tv_end, NULL)); + ret = gettimeofday(&tv_end, NULL); + BUG_ON(ret); timersub(&tv_end, &tv_start, &tv_diff); diff --git a/tools/perf/bench/mem-memset.c b/tools/perf/bench/mem-memset.c index 350cc95..e0702d2 100644 --- a/tools/perf/bench/mem-memset.c +++ b/tools/perf/bench/mem-memset.c @@ -139,17 +139,19 @@ static double do_memset_gettimeofday(memset_t fn, size_t len, bool prefault) { struct timeval tv_start, tv_end, tv_diff; void *dst = NULL; - int i; + int i, ret; alloc_mem(&dst, len); if (prefault) fn(dst, -1, len); - BUG_ON(gettimeofday(&tv_start, NULL)); + ret = gettimeofday(&tv_start, NULL); + BUG_ON(ret); for (i = 0; i < iterations; ++i) fn(dst, i, len); - BUG_ON(gettimeofday(&tv_end, NULL)); + ret = gettimeofday(&tv_end, NULL); + BUG_ON(ret); timersub(&tv_end, &tv_start, &tv_diff); diff --git a/tools/perf/bench/sched-pipe.c b/tools/perf/bench/sched-pipe.c index 0c7454f..b35c94b 100644 --- a/tools/perf/bench/sched-pipe.c +++ b/tools/perf/bench/sched-pipe.c @@ -61,8 +61,10 @@ int bench_sched_pipe(int argc, const char **argv, argc = parse_options(argc, argv, options, bench_sched_pipe_usage, 0); - assert(!pipe(pipe_1)); - assert(!pipe(pipe_2)); + ret = pipe(pipe_1); + assert(!ret); + ret = !pipe(pipe_2); + assert(!ret); pid = fork(); assert(pid >= 0); -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 08/13] perf tools: Use __maybe_used for unused variables
On Mon, Sep 3, 2012 at 4:07 AM, Namhyung Kim wrote: > Hi, Hi, > > On Wed, 29 Aug 2012 01:04:25 +0300, Irina Tirdea wrote: >> perf defines __used to for marking unused variables. >> The variable __used is defined to __attribute__((__unused__)), which >> contradicts the kernel definition to __attribute__((__used__)) >> for new gcc versions. On Android), __used is also defined in >> system headers and this leads to warnings like: >> warning: '__used__' attribute ignored >> >> This patch simply replaces all instances of __used with __maybe_unused >> so there will be no such warnings. > > How about just using '__unused' for less typing? Replacing __used with __unused leads to conflicts with glibc headers, since glibc has a variable named __unused in the stat.h header. I forgot to mention this in the commit message. This is the error: In file included from /usr/include/x86_64-linux-gnu/sys/stat.h:107:0, from util/util.h:48, from builtin-bench.c:20: /usr/include/x86_64-linux-gnu/bits/stat.h:106:22: error: expected identifier or ‘(’ before ‘[’ token /usr/include/x86_64-linux-gnu/bits/stat.h:167:22: error: expected identifier or ‘(’ before ‘[’ token make: *** [builtin-bench.o] Error 1 > Btw, the patch looks whitespace-damaged. That's true. I'll fix it. Thanks, Irina -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 11/13] perf tools: replace mempcpy with memcpy
On Mon, Sep 3, 2012 at 4:09 AM, Namhyung Kim wrote: > On Wed, 29 Aug 2012 01:22:16 +0300, Irina Tirdea wrote: >> mempcpy is not supported by bionic in Android >> and will lead to compilation errors. >> >> Replacing mempcpy with memcpy so it will work in Android. > > Unfortunately I've added another instance of the mempcpy in a > libtraceevent code. :-/ > Thanks for the heads-up. I'll fix it. Irina > Thanks, > Namhyung > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 0/4] perf tools: runtime fixes for Android
This is a set of patches with runtime fixes for Android. Any comments and suggestions are wellcome. Thanks, Irina Irina Tirdea (4): perf tools: remove sscanf extension %as perf stat: add compile-time option to disable --big-num perf archive: remove -f from the rm command perf archive: make f the last parameter for tar tools/perf/Makefile |8 tools/perf/builtin-stat.c |8 tools/perf/config/feature-tests.mak | 12 tools/perf/perf-archive.sh |6 +++--- tools/perf/util/probe-event.c | 25 ++--- tools/perf/util/trace-event-parse.c | 18 -- 6 files changed, 57 insertions(+), 20 deletions(-) -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 1/4] perf tools: remove sscanf extension %as
From: Irina Tirdea perf uses sscanf extension %as to read and allocate a string in the same step. This is a non-standard extension only present in new versions of glibc. Replacing the use of sscanf and %as with strtok_r calls in order to parse a given string into its components. This is needed in Android since bionic does not support %as extension for sscanf. Signed-off-by: Irina Tirdea --- tools/perf/util/probe-event.c | 25 ++--- tools/perf/util/trace-event-parse.c | 18 -- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index 4ce04c2..685ddcf 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c @@ -1100,6 +1100,7 @@ static int parse_probe_trace_command(const char *cmd, struct probe_trace_point *tp = &tev->point; char pr; char *p; + char *argv0_str = NULL, *fmt, *fmt1_str, *fmt2_str, *fmt3_str; int ret, i, argc; char **argv; @@ -1116,14 +1117,19 @@ static int parse_probe_trace_command(const char *cmd, } /* Scan event and group name. */ - ret = sscanf(argv[0], "%c:%a[^/ \t]/%a[^ \t]", -&pr, (float *)(void *)&tev->group, -(float *)(void *)&tev->event); - if (ret != 3) { + argv0_str = strdup(argv[0]); + fmt1_str = strtok_r(argv0_str, ":", &fmt); + fmt2_str = strtok_r(NULL, "/", &fmt); + fmt3_str = strtok_r(NULL, " \t", &fmt); + if (fmt1_str == NULL || strlen(fmt1_str) != 1 || fmt2_str == NULL + || fmt3_str == NULL) { semantic_error("Failed to parse event name: %s\n", argv[0]); ret = -EINVAL; goto out; } + pr = fmt1_str[0]; + tev->group = strdup(fmt2_str); + tev->event = strdup(fmt3_str); pr_debug("Group:%s Event:%s probe:%c\n", tev->group, tev->event, pr); tp->retprobe = (pr == 'r'); @@ -1135,10 +1141,13 @@ static int parse_probe_trace_command(const char *cmd, p++; } else p = argv[1]; - ret = sscanf(p, "%a[^+]+%lu", (float *)(void *)&tp->symbol, -&tp->offset); - if (ret == 1) + fmt1_str = strtok_r(p, "+", &fmt); + tp->symbol = strdup(fmt1_str); + fmt2_str = strtok_r(NULL, "", &fmt); + if (fmt2_str == NULL) tp->offset = 0; + else + tp->offset = strtoul(fmt2_str, NULL, 10); tev->nargs = argc - 2; tev->args = zalloc(sizeof(struct probe_trace_arg) * tev->nargs); @@ -1162,6 +1171,8 @@ static int parse_probe_trace_command(const char *cmd, } ret = 0; out: + if (argv0_str) + free(argv0_str); argv_free(argv); return ret; } diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c index aa4c860..3aabcd6 100644 --- a/tools/perf/util/trace-event-parse.c +++ b/tools/perf/util/trace-event-parse.c @@ -229,24 +229,22 @@ void parse_proc_kallsyms(struct pevent *pevent, char *next = NULL; char *addr_str; char *mod; - char ch; + char *fmt; line = strtok_r(file, "\n", &next); while (line) { mod = NULL; - sscanf(line, "%as %c %as\t[%as", - (float *)(void *)&addr_str, /* workaround gcc warning */ - &ch, (float *)(void *)&func, (float *)(void *)&mod); + addr_str = strtok_r(line, " ", &fmt); addr = strtoull(addr_str, NULL, 16); - free(addr_str); - - /* truncate the extra ']' */ + /* skip character */ + strtok_r(NULL, " ", &fmt); + func = strtok_r(NULL, "\t", &fmt); + mod = strtok_r(NULL, "]", &fmt); + /* truncate the extra '[' */ if (mod) - mod[strlen(mod) - 1] = 0; + mod = mod + 1; pevent_register_function(pevent, func, addr, mod); - free(func); - free(mod); line = strtok_r(NULL, "\n", &next); } -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 2/4] perf stat: add compile-time option to disable --big-num
From: Irina Tirdea In printf's format, ' is used to group the output with thousands' grouping characters for decimal conversion. Bionic does not support ' for printf. Add a compile-time option (NO_BIG_NUM) to disable the --big-num option from perf stat. Signed-off-by: Irina Tirdea --- tools/perf/Makefile |8 tools/perf/builtin-stat.c |8 tools/perf/config/feature-tests.mak | 12 3 files changed, 28 insertions(+) diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 209774b..8daa781 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -768,6 +768,14 @@ else endif endif +ifdef NO_BIG_NUM + BASIC_CFLAGS += -DNO_BIG_NUM +else + ifneq ($(call try-cc,$(SOURCE_BIG_NUM),),y) + BASIC_CFLAGS += -DNO_BIG_NUM + endif +endif + ifdef ASCIIDOC8 export ASCIIDOC8 endif diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index dab347d..ad8013e 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -188,7 +188,11 @@ static pid_t child_pid = -1; static boolnull_run= false; static int detailed_run= 0; static boolsync_run= false; +#ifdef NO_BIG_NUM +static boolbig_num = false; +#else static boolbig_num = true; +#endif static int big_num_opt = -1; static const char *csv_sep= NULL; static boolcsv_output = false; @@ -1075,12 +1079,14 @@ static const char * const stat_usage[] = { NULL }; +#ifndef NO_BIG_NUM static int stat__set_big_num(const struct option *opt __maybe_unused, const char *s __maybe_unused, int unset) { big_num_opt = unset ? 0 : 1; return 0; } +#endif static bool append_file; @@ -1112,9 +1118,11 @@ static const struct option options[] = { "detailed run - start a lot of events"), OPT_BOOLEAN('S', "sync", &sync_run, "call sync() before starting a run"), +#ifndef NO_BIG_NUM OPT_CALLBACK_NOOPT('B', "big-num", NULL, NULL, "print large numbers with thousands\' separators", stat__set_big_num), +#endif OPT_STRING('C', "cpu", &target.cpu_list, "cpu", "list of cpus to monitor in system-wide"), OPT_BOOLEAN('A', "no-aggr", &no_aggr, diff --git a/tools/perf/config/feature-tests.mak b/tools/perf/config/feature-tests.mak index 116690a..2e5fad7 100644 --- a/tools/perf/config/feature-tests.mak +++ b/tools/perf/config/feature-tests.mak @@ -193,3 +193,15 @@ int main(void) } endef endif + +ifndef NO_BIG_NUM +define SOURCE_BIG_NUM +#include + +int main(void) +{ + printf(\"%'\''.2f\", 1234567.89); + return 0; +} +endef +endif -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 3/4] perf archive: remove -f from the rm command
From: Irina Tirdea In Android, rm does not support the -f parameter. Remove -f from rm and make sure rm does not fail even if the files to be removed are not found. Signed-off-by: Irina Tirdea --- tools/perf/perf-archive.sh |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/perf/perf-archive.sh b/tools/perf/perf-archive.sh index 95b6f8b..da94179 100644 --- a/tools/perf/perf-archive.sh +++ b/tools/perf/perf-archive.sh @@ -24,7 +24,7 @@ NOBUILDID= perf buildid-list -i $PERF_DATA --with-hits | grep -v "^$NOBUILDID " > $BUILDIDS if [ ! -s $BUILDIDS ] ; then echo "perf archive: no build-ids found" - rm -f $BUILDIDS + rm $BUILDIDS || true exit 1 fi @@ -40,7 +40,7 @@ while read build_id ; do done tar cfj $PERF_DATA.tar.bz2 -C $PERF_BUILDID_DIR -T $MANIFEST -rm -f $MANIFEST $BUILDIDS +rm $MANIFEST $BUILDIDS || true echo -e "Now please run:\n" echo -e "$ tar xvf $PERF_DATA.tar.bz2 -C ~/.debug\n" echo "wherever you need to run 'perf report' on." -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 4/4] perf archive: make f the last parameter for tar
From: Irina Tirdea On some systems, tar needs to specify the name of the archive immediately after the -f parameter. Change the order of the parameters so tar can run properly. Signed-off-by: Irina Tirdea --- tools/perf/perf-archive.sh |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/perf-archive.sh b/tools/perf/perf-archive.sh index da94179..e919306 100644 --- a/tools/perf/perf-archive.sh +++ b/tools/perf/perf-archive.sh @@ -39,7 +39,7 @@ while read build_id ; do echo ${filename#$PERF_BUILDID_LINKDIR} >> $MANIFEST done -tar cfj $PERF_DATA.tar.bz2 -C $PERF_BUILDID_DIR -T $MANIFEST +tar cjf $PERF_DATA.tar.bz2 -C $PERF_BUILDID_DIR -T $MANIFEST rm $MANIFEST $BUILDIDS || true echo -e "Now please run:\n" echo -e "$ tar xvf $PERF_DATA.tar.bz2 -C ~/.debug\n" -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 01/26] pstore: allow for big files
From: Adrian Hunter pstore reads all files into memory at mount time. To allow for back ends that will store arbitrarily large files, enhance pstore also to be able to read from the back end as needed. Signed-off-by: Adrian Hunter Signed-off-by: Irina Tirdea --- drivers/acpi/apei/erst.c | 16 +--- fs/pstore/inode.c| 26 -- fs/pstore/internal.h |5 +++-- fs/pstore/platform.c | 11 +++ fs/pstore/ram.c | 15 +++ include/linux/pstore.h |7 +-- 6 files changed, 51 insertions(+), 29 deletions(-) diff --git a/drivers/acpi/apei/erst.c b/drivers/acpi/apei/erst.c index e4d9d24..f70ba37 100644 --- a/drivers/acpi/apei/erst.c +++ b/drivers/acpi/apei/erst.c @@ -931,9 +931,9 @@ static int erst_check_table(struct acpi_table_erst *erst_tab) static int erst_open_pstore(struct pstore_info *psi); static int erst_close_pstore(struct pstore_info *psi); -static ssize_t erst_reader(u64 *id, enum pstore_type_id *type, - struct timespec *time, char **buf, - struct pstore_info *psi); +static int erst_reader(u64 *id, enum pstore_type_id *type, + struct timespec *time, char **buf, loff_t *size, + struct pstore_info *psi); static int erst_writer(enum pstore_type_id type, enum kmsg_dump_reason reason, u64 *id, unsigned int part, size_t size, struct pstore_info *psi); @@ -987,9 +987,9 @@ static int erst_close_pstore(struct pstore_info *psi) return 0; } -static ssize_t erst_reader(u64 *id, enum pstore_type_id *type, - struct timespec *time, char **buf, - struct pstore_info *psi) +static int erst_reader(u64 *id, enum pstore_type_id *type, + struct timespec *time, char **buf, loff_t *size, + struct pstore_info *psi) { int rc; ssize_t len = 0; @@ -1051,7 +1051,9 @@ skip: out: kfree(rcd); - return (rc < 0) ? rc : (len - sizeof(*rcd)); + if (!rc) + *size = len - sizeof(*rcd); + return rc; } static int erst_writer(enum pstore_type_id type, enum kmsg_dump_reason reason, diff --git a/fs/pstore/inode.c b/fs/pstore/inode.c index 4ab572e..ff0970f 100644 --- a/fs/pstore/inode.c +++ b/fs/pstore/inode.c @@ -49,7 +49,8 @@ struct pstore_private { struct pstore_info *psi; enum pstore_type_id type; u64 id; - ssize_t size; + loff_t size; + boolbig; chardata[]; }; @@ -65,12 +66,13 @@ static void *pstore_ftrace_seq_start(struct seq_file *s, loff_t *pos) { struct pstore_private *ps = s->private; struct pstore_ftrace_seq_data *data; + loff_t size = ps->size; data = kzalloc(sizeof(*data), GFP_KERNEL); if (!data) return NULL; - data->off = ps->size % REC_SIZE; + data->off = do_div(size, REC_SIZE); data->off += *pos * REC_SIZE; if (data->off + REC_SIZE > ps->size) { kfree(data); @@ -127,6 +129,12 @@ static ssize_t pstore_file_read(struct file *file, char __user *userbuf, if (ps->type == PSTORE_TYPE_FTRACE) return seq_read(file, userbuf, count, ppos); + if (ps->big) { + if (ps->psi->file_read) + return ps->psi->file_read(ps->id, ps->type, userbuf, + count, ppos, ps->psi); + return -EFBIG; + } return simple_read_from_buffer(userbuf, count, ppos, ps->data, ps->size); } @@ -271,8 +279,8 @@ int pstore_is_mounted(void) * Set the mtime & ctime to the date that this record was originally stored. */ int pstore_mkfile(enum pstore_type_id type, char *psname, u64 id, - char *data, size_t size, struct timespec time, - struct pstore_info *psi) + char *data, loff_t size, struct timespec time, + struct pstore_info *psi, bool big) { struct dentry *root = pstore_sb->s_root; struct dentry *dentry; @@ -281,6 +289,7 @@ int pstore_mkfile(enum pstore_type_id type, char *psname, u64 id, charname[PSTORE_NAMELEN]; struct pstore_private *private, *pos; unsigned long flags; + size_t inline_size; spin_lock_irqsave(&allpstore_lock, flags); list_for_each_entry(pos, &allpstore, list) { @@ -301,12 +310,17 @@ int pstore_mkfile(enum pstore_type_id type, char *psname, u64 id, goto fail; inode->i_mode = S_IFREG | 0444; inode->i_fop = &pstore_file_operations; - private = kmalloc(sizeof *private + size, GFP_KERNEL); + if (big) + inl
[PATCH 02/26] pstore: add flags
From: Adrian Hunter Let the back end tweak pstore behaviour. Flags added are: PSTORE_NO_HEADINGS Omit pstore heading lines from dumped data PSTORE_MAX_KMSG_BYTES Default kmsg_bytes to ULONG_MAX Signed-off-by: Adrian Hunter Signed-off-by: Irina Tirdea --- fs/pstore/platform.c |9 - include/linux/pstore.h |4 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c index 108bd69..b9ab942 100644 --- a/fs/pstore/platform.c +++ b/fs/pstore/platform.c @@ -128,7 +128,11 @@ static void pstore_dump(struct kmsg_dumper *dumper, size_t len; dst = psinfo->buf; - hsize = sprintf(dst, "%s#%d Part%d\n", why, oopscount, part); + if (psinfo->flags & PSTORE_NO_HEADINGS) + hsize = 0; + else + hsize = sprintf(dst, "%s#%d Part%d\n", why, oopscount, + part); size = psinfo->bufsize - hsize; dst += hsize; @@ -237,6 +241,9 @@ int pstore_register(struct pstore_info *psi) return -EINVAL; } + if (psinfo->flags & PSTORE_MAX_KMSG_BYTES) + kmsg_bytes = ULONG_MAX; + if (pstore_is_mounted()) pstore_get_records(0); diff --git a/include/linux/pstore.h b/include/linux/pstore.h index 3a293ff..27f1995 100644 --- a/include/linux/pstore.h +++ b/include/linux/pstore.h @@ -40,9 +40,13 @@ enum pstore_type_id { struct module; +#define PSTORE_NO_HEADINGS BIT(0) +#define PSTORE_MAX_KMSG_BYTES BIT(1) + struct pstore_info { struct module *owner; char*name; + unsigned intflags; spinlock_t buf_lock; /* serialize access to 'buf' */ char*buf; size_t bufsize; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 05/26] block: add panic write
From: Adrian Hunter Add a small interface to allow block devices to attempt to write during an oops or panic. Signed-off-by: Adrian Hunter Signed-off-by: Irina Tirdea --- drivers/block/Kconfig |3 ++ include/linux/blkdev.h | 77 include/linux/genhd.h |3 ++ 3 files changed, 83 insertions(+) diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig index 332ba52..f58853c 100644 --- a/drivers/block/Kconfig +++ b/drivers/block/Kconfig @@ -553,4 +553,7 @@ config BLK_DEV_OOPS See for more information. +config BLK_DEV_PANIC_WRITE + bool + endif # BLK_DEV diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 1756001..bedfaab 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1461,6 +1461,83 @@ static inline bool blk_integrity_is_initialized(struct gendisk *g) #endif /* CONFIG_BLK_DEV_INTEGRITY */ +#ifdef CONFIG_BLK_DEV_PANIC_WRITE + +/** + * struct panic_write_operations - operations to support writing during an oops + *or panic. + * @init: allocate resources + * @cleanup: release resources + * @write: called in an oops or panic context to write data + * @flush: called in an oops or panic context to finish write operations + * + * @write may need resources that cannot be allocated in a panic or oops + * context. @init can be used to allocate those resources in advance. + * @cleanup is called if panic writing becomes disabled. + */ +struct panic_write_operations { + int (*init)(struct block_device *); + void (*cleanup)(struct block_device *); + int (*write)(struct block_device *, sector_t, void *, unsigned long); + int (*flush)(struct block_device *); +}; + +static inline int blk_panic_init(struct block_device *bdev) +{ + if (!bdev->bd_disk->pwops || !bdev->bd_disk->pwops->write) + return -EOPNOTSUPP; + if (bdev->bd_disk->pwops && bdev->bd_disk->pwops->init) + return bdev->bd_disk->pwops->init(bdev); + return 0; +} + +static inline void blk_panic_cleanup(struct block_device *bdev) +{ + if (bdev->bd_disk->pwops && bdev->bd_disk->pwops->cleanup) + bdev->bd_disk->pwops->cleanup(bdev); +} + +static inline int blk_panic_write(struct block_device *bdev, sector_t sect, + void *addr, unsigned long len) +{ + if (!bdev->bd_disk->pwops || !bdev->bd_disk->pwops->write) + return -EOPNOTSUPP; + if (bdev != bdev->bd_contains) + sect += bdev->bd_part->start_sect; + return bdev->bd_disk->pwops->write(bdev, sect, addr, len); +} + +static inline int blk_panic_flush(struct block_device *bdev) +{ + if (bdev->bd_disk->pwops && bdev->bd_disk->pwops->flush) + return bdev->bd_disk->pwops->flush(bdev); + return 0; +} + +#else + +static inline int blk_panic_init(struct block_device *bdev) +{ + return -EOPNOTSUPP; +} + +static inline void blk_panic_cleanup(struct block_device *bdev) +{ +} + +static inline int blk_panic_write(struct block_device *bdev, sector_t sect, + void *addr, unsigned long len) +{ + return -EOPNOTSUPP; +} + +static inline int blk_panic_flush(struct block_device *bdev) +{ + return -EOPNOTSUPP; +} + +#endif /* CONFIG_BLK_DEV_PANIC_WRITE */ + struct block_device_operations { int (*open) (struct block_device *, fmode_t); int (*release) (struct gendisk *, fmode_t); diff --git a/include/linux/genhd.h b/include/linux/genhd.h index 4f440b3..73470af 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h @@ -195,6 +195,9 @@ struct gendisk { #ifdef CONFIG_BLK_DEV_INTEGRITY struct blk_integrity *integrity; #endif +#ifdef CONFIG_BLK_DEV_PANIC_WRITE + const struct panic_write_operations *pwops; +#endif int node_id; }; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 07/26] mmc: panic write: bypass host claiming
From: Adrian Hunter Signed-off-by: Adrian Hunter Signed-off-by: Irina Tirdea --- drivers/mmc/core/core.c |9 + 1 file changed, 9 insertions(+) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 06c42cf..dbe5332 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -767,6 +767,9 @@ int __mmc_claim_host(struct mmc_host *host, atomic_t *abort) unsigned long flags; int stop; + if (mmc_am_panic_task(host)) + return 0; + might_sleep(); add_wait_queue(&host->wq, &wait); @@ -807,6 +810,9 @@ int mmc_try_claim_host(struct mmc_host *host) int claimed_host = 0; unsigned long flags; + if (mmc_am_panic_task(host)) + return 1; + spin_lock_irqsave(&host->lock, flags); if (!host->claimed || host->claimer == current) { host->claimed = 1; @@ -837,6 +843,9 @@ void mmc_release_host(struct mmc_host *host) if (host->ops->disable && host->claim_cnt == 1) host->ops->disable(host); + if (mmc_am_panic_task(host)) + return; + spin_lock_irqsave(&host->lock, flags); if (--host->claim_cnt) { /* Release for nested claim */ -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 11/26] mmc: panic write: bypass clock gating
From: Adrian Hunter Signed-off-by: Adrian Hunter Signed-off-by: Irina Tirdea --- drivers/mmc/core/core.c |5 + drivers/mmc/core/host.c |9 + 2 files changed, 14 insertions(+) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 204a9bd..f7552af 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -956,6 +956,11 @@ void mmc_set_ungated(struct mmc_host *host) { unsigned long flags; + if (mmc_am_panic_task(host)) { + host->clk_gated = false; + return; + } + /* * We've been given a new frequency while the clock is gated, * so make sure we regard this as ungating it. diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c index ee2e16b..6eda5a1 100644 --- a/drivers/mmc/core/host.c +++ b/drivers/mmc/core/host.c @@ -153,6 +153,12 @@ void mmc_host_clk_hold(struct mmc_host *host) { unsigned long flags; + if (mmc_am_panic_task(host)) { + if (host->clk_gated) + mmc_ungate_clock(host); + return; + } + /* cancel any clock gating work scheduled by mmc_host_clk_release() */ cancel_delayed_work_sync(&host->clk_gate_work); mutex_lock(&host->clk_gate_mutex); @@ -200,6 +206,9 @@ void mmc_host_clk_release(struct mmc_host *host) { unsigned long flags; + if (mmc_am_panic_task(host)) + return; + spin_lock_irqsave(&host->clk_lock, flags); host->clk_requests--; if (mmc_host_may_gate_card(host->card) && -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 12/26] mmc: panic write: bypass regulators
From: Adrian Hunter Signed-off-by: Adrian Hunter Signed-off-by: Irina Tirdea --- drivers/mmc/core/core.c |3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index f7552af..d3caa7e 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -1128,6 +1128,9 @@ int mmc_regulator_set_ocr(struct mmc_host *mmc, int result = 0; int min_uV, max_uV; + if (mmc_am_panic_task(mmc)) + return 0; + if (vdd_bit) { int tmp; int voltage; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 10/26] mmc: panic write: do not msleep
From: Adrian Hunter Signed-off-by: Adrian Hunter Signed-off-by: Irina Tirdea --- drivers/mmc/core/core.c |6 +++--- drivers/mmc/core/core.h |6 -- drivers/mmc/core/mmc_ops.c | 10 +- drivers/mmc/core/sd_ops.c |2 +- drivers/mmc/core/sdio_ops.c |2 +- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 0b904bc..204a9bd 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -1331,7 +1331,7 @@ static void mmc_power_up(struct mmc_host *host) * This delay should be sufficient to allow the power supply * to reach the minimum voltage. */ - mmc_delay(10); + mmc_delay(host, 10); host->ios.clock = host->f_init; @@ -1342,7 +1342,7 @@ static void mmc_power_up(struct mmc_host *host) * This delay must be at least 74 clock sizes, or 1 ms, or the * time required to reach a stable voltage. */ - mmc_delay(10); + mmc_delay(host, 10); mmc_host_clk_release(host); } @@ -1378,7 +1378,7 @@ void mmc_power_off(struct mmc_host *host) * XO-1.5, require a short delay after poweroff before the card * can be successfully turned on again. */ - mmc_delay(1); + mmc_delay(host, 1); mmc_host_clk_release(host); } diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h index 3bdafbc..4cba1f1 100644 --- a/drivers/mmc/core/core.h +++ b/drivers/mmc/core/core.h @@ -46,9 +46,11 @@ void mmc_set_timing(struct mmc_host *host, unsigned int timing); void mmc_set_driver_type(struct mmc_host *host, unsigned int drv_type); void mmc_power_off(struct mmc_host *host); -static inline void mmc_delay(unsigned int ms) +static inline void mmc_delay(struct mmc_host *host, unsigned int ms) { - if (ms < 1000 / HZ) { + if (mmc_am_panic_task(host)) { + mdelay(ms); + } else if (ms < 1000 / HZ) { cond_resched(); mdelay(ms); } else { diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c index a0e1720..23eaeab 100644 --- a/drivers/mmc/core/mmc_ops.c +++ b/drivers/mmc/core/mmc_ops.c @@ -83,7 +83,7 @@ int mmc_card_sleepawake(struct mmc_host *host, int sleep) * others) is invalid while the card sleeps. */ if (!(host->caps & MMC_CAP_WAIT_WHILE_BUSY)) - mmc_delay(DIV_ROUND_UP(card->ext_csd.sa_timeout, 1)); + mmc_delay(host, DIV_ROUND_UP(card->ext_csd.sa_timeout, 1)); if (!sleep) err = mmc_select_card(card); @@ -107,7 +107,7 @@ int mmc_go_idle(struct mmc_host *host) */ if (!mmc_host_is_spi(host)) { mmc_set_chip_select(host, MMC_CS_HIGH); - mmc_delay(1); + mmc_delay(host, 1); } cmd.opcode = MMC_GO_IDLE_STATE; @@ -116,11 +116,11 @@ int mmc_go_idle(struct mmc_host *host) err = mmc_wait_for_cmd(host, &cmd, 0); - mmc_delay(1); + mmc_delay(host, 1); if (!mmc_host_is_spi(host)) { mmc_set_chip_select(host, MMC_CS_DONTCARE); - mmc_delay(1); + mmc_delay(host, 1); } host->use_spi_crc = 0; @@ -159,7 +159,7 @@ int mmc_send_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr) err = -ETIMEDOUT; - mmc_delay(10); + mmc_delay(host, 10); } if (rocr && !mmc_host_is_spi(host)) diff --git a/drivers/mmc/core/sd_ops.c b/drivers/mmc/core/sd_ops.c index 274ef00..d4573fb 100644 --- a/drivers/mmc/core/sd_ops.c +++ b/drivers/mmc/core/sd_ops.c @@ -181,7 +181,7 @@ int mmc_send_app_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr) err = -ETIMEDOUT; - mmc_delay(10); + mmc_delay(host, 10); } if (rocr && !mmc_host_is_spi(host)) diff --git a/drivers/mmc/core/sdio_ops.c b/drivers/mmc/core/sdio_ops.c index d29e206..099908c 100644 --- a/drivers/mmc/core/sdio_ops.c +++ b/drivers/mmc/core/sdio_ops.c @@ -56,7 +56,7 @@ int mmc_send_io_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr) err = -ETIMEDOUT; - mmc_delay(10); + mmc_delay(host, 10); } if (rocr) -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 19/26] mmc: sdhci: panic write: no runtime pm
From: Adrian Hunter Signed-off-by: Adrian Hunter Signed-off-by: Irina Tirdea --- drivers/mmc/host/sdhci.c |6 ++ 1 file changed, 6 insertions(+) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 3653494..fcedcec 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -2601,11 +2601,17 @@ EXPORT_SYMBOL_GPL(sdhci_enable_irq_wakeups); static int sdhci_runtime_pm_get(struct sdhci_host *host) { + if (mmc_am_panic_task(host->mmc)) + return 0; + return pm_runtime_get_sync(host->mmc->parent); } static int sdhci_runtime_pm_put(struct sdhci_host *host) { + if (mmc_am_panic_task(host->mmc)) + return 0; + pm_runtime_mark_last_busy(host->mmc->parent); return pm_runtime_put_autosuspend(host->mmc->parent); } -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 26/26] mmc: sdhci-pci: add panic write support
From: Adrian Hunter Signed-off-by: Adrian Hunter Signed-off-by: Irina Tirdea --- drivers/mmc/host/sdhci-pci.c |5 + 1 file changed, 5 insertions(+) diff --git a/drivers/mmc/host/sdhci-pci.c b/drivers/mmc/host/sdhci-pci.c index 4bb74b0..bee9a45 100644 --- a/drivers/mmc/host/sdhci-pci.c +++ b/drivers/mmc/host/sdhci-pci.c @@ -966,6 +966,8 @@ static void sdhci_pci_hw_reset(struct sdhci_host *host) if (!gpio_is_valid(rst_n_gpio)) return; + if (mmc_panic_task_active(host->mmc)) + return; gpio_set_value_cansleep(rst_n_gpio, 0); /* For eMMC, minimum is 1us but give it 10us for good measure */ udelay(10); @@ -1278,6 +1280,9 @@ static struct sdhci_pci_slot * __devinit sdhci_pci_probe_slot( } host->mmc->pm_caps = MMC_PM_KEEP_POWER | MMC_PM_WAKE_SDIO_IRQ; +#ifdef CONFIG_MMC_BLOCK_PANIC_WRITE + slot->host->mmc->caps2 = MMC_CAP_PANIC_WRITE; +#endif ret = sdhci_add_host(host); if (ret) -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 13/26] mmc: panic write: trap non panic tasks
From: Adrian Hunter Signed-off-by: Adrian Hunter Signed-off-by: Irina Tirdea --- drivers/mmc/core/core.c | 10 +- drivers/mmc/core/host.c |2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index d3caa7e..4fd7061 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -252,6 +252,7 @@ mmc_start_request(struct mmc_host *host, struct mmc_request *mrq) } mmc_host_clk_hold(host); led_trigger_event(host->led, LED_FULL); + mmc_trap_nonpanic_tasks(host); host->ops->request(host, mrq); } @@ -344,8 +345,10 @@ static void mmc_wait_for_req_done(struct mmc_host *host, while (1) { /* Panic task requests must be completed in ->request() */ - if (!mmc_am_panic_task(host)) + if (!mmc_am_panic_task(host)) { wait_for_completion(&mrq->completion); + mmc_trap_nonpanic_tasks(host); + } cmd = mrq->cmd; if (!cmd->error || !cmd->retries || @@ -774,6 +777,8 @@ int __mmc_claim_host(struct mmc_host *host, atomic_t *abort) if (mmc_am_panic_task(host)) return 0; + else + mmc_trap_nonpanic_tasks(host); might_sleep(); @@ -817,6 +822,8 @@ int mmc_try_claim_host(struct mmc_host *host) if (mmc_am_panic_task(host)) return 1; + else + mmc_trap_nonpanic_tasks(host); spin_lock_irqsave(&host->lock, flags); if (!host->claimed || host->claimer == current) { @@ -880,6 +887,7 @@ static inline void mmc_set_ios(struct mmc_host *host) if (ios->clock > 0) mmc_set_ungated(host); + mmc_trap_nonpanic_tasks(host); host->ops->set_ios(host, ios); } diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c index 6eda5a1..b76bfc8 100644 --- a/drivers/mmc/core/host.c +++ b/drivers/mmc/core/host.c @@ -90,6 +90,8 @@ static void mmc_host_clk_gate_delayed(struct mmc_host *host) unsigned long freq = host->ios.clock; unsigned long flags; + mmc_trap_nonpanic_tasks(host); + if (!freq) { pr_debug("%s: frequency set to 0 in disable function, " "this means the clock is already disabled.\n", -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 15/26] mmc: sdhci: panic write: bypass spin lock
From: Adrian Hunter Signed-off-by: Adrian Hunter Signed-off-by: Irina Tirdea --- drivers/mmc/host/sdhci.c | 119 ++ drivers/mmc/host/sdhci.h | 24 ++ 2 files changed, 101 insertions(+), 42 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 7922adb..1ed78f0 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -287,7 +287,7 @@ static void sdhci_led_control(struct led_classdev *led, struct sdhci_host *host = container_of(led, struct sdhci_host, led); unsigned long flags; - spin_lock_irqsave(&host->lock, flags); + sdhci_lock_irqsave(host, flags); if (host->runtime_suspended) goto out; @@ -297,7 +297,7 @@ static void sdhci_led_control(struct led_classdev *led, else sdhci_activate_led(host); out: - spin_unlock_irqrestore(&host->lock, flags); + sdhci_unlock_irqrestore(host, flags); } #endif @@ -1266,7 +1266,7 @@ static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq) sdhci_runtime_pm_get(host); - spin_lock_irqsave(&host->lock, flags); + sdhci_lock_irqsave(host, flags); WARN_ON(host->mrq != NULL); @@ -1319,9 +1319,9 @@ static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq) tuning_opcode = mmc->card->type == MMC_TYPE_MMC ? MMC_SEND_TUNING_BLOCK_HS200 : MMC_SEND_TUNING_BLOCK; - spin_unlock_irqrestore(&host->lock, flags); + sdhci_unlock_irqrestore(host, flags); sdhci_execute_tuning(mmc, tuning_opcode); - spin_lock_irqsave(&host->lock, flags); + sdhci_lock_irqsave(host, flags); /* Restore original mmc_request structure */ host->mrq = mrq; @@ -1334,7 +1334,7 @@ static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq) } mmiowb(); - spin_unlock_irqrestore(&host->lock, flags); + sdhci_unlock_irqrestore(host, flags); } static void sdhci_do_set_ios(struct sdhci_host *host, struct mmc_ios *ios) @@ -1343,10 +1343,10 @@ static void sdhci_do_set_ios(struct sdhci_host *host, struct mmc_ios *ios) int vdd_bit = -1; u8 ctrl; - spin_lock_irqsave(&host->lock, flags); + sdhci_lock_irqsave(host, flags); if (host->flags & SDHCI_DEVICE_DEAD) { - spin_unlock_irqrestore(&host->lock, flags); + sdhci_unlock_irqrestore(host, flags); if (host->vmmc && ios->power_mode == MMC_POWER_OFF) mmc_regulator_set_ocr(host->mmc, host->vmmc, 0); return; @@ -1369,9 +1369,9 @@ static void sdhci_do_set_ios(struct sdhci_host *host, struct mmc_ios *ios) vdd_bit = sdhci_set_power(host, ios->vdd); if (host->vmmc && vdd_bit != -1) { - spin_unlock_irqrestore(&host->lock, flags); + sdhci_unlock_irqrestore(host, flags); mmc_regulator_set_ocr(host->mmc, host->vmmc, vdd_bit); - spin_lock_irqsave(&host->lock, flags); + sdhci_lock_irqsave(host, flags); } if (host->ops->platform_send_init_74_clocks) @@ -1500,7 +1500,7 @@ static void sdhci_do_set_ios(struct sdhci_host *host, struct mmc_ios *ios) sdhci_reset(host, SDHCI_RESET_CMD | SDHCI_RESET_DATA); mmiowb(); - spin_unlock_irqrestore(&host->lock, flags); + sdhci_unlock_irqrestore(host, flags); } static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) @@ -1517,7 +1517,7 @@ static int sdhci_check_ro(struct sdhci_host *host) unsigned long flags; int is_readonly; - spin_lock_irqsave(&host->lock, flags); + sdhci_lock_irqsave(host, flags); if (host->flags & SDHCI_DEVICE_DEAD) is_readonly = 0; @@ -1527,7 +1527,7 @@ static int sdhci_check_ro(struct sdhci_host *host) is_readonly = !(sdhci_readl(host, SDHCI_PRESENT_STATE) & SDHCI_WRITE_PROTECT); - spin_unlock_irqrestore(&host->lock, flags); + sdhci_unlock_irqrestore(host, flags); /* This quirk needs to be replaced by a callback-function later */ return host->quirks & SDHCI_QUIRK_INVERTED_WRITE_PROTECT ? @@ -1600,9 +1600,9 @@ static void sdhci_enable_sdio_irq(struct mmc_host *mmc, int enable) struct sdhci_host *host = mmc_priv(mmc); unsigned long flags; - spin_lock_irqsave(&host->lock, flags); + sdhci_lock_irqsave(host, flags); sdhci_enable_sdio_irq_nolock(host,
[PATCH 18/26] mmc: sdhci: panic write: no timeout timer
From: Adrian Hunter Signed-off-by: Adrian Hunter Signed-off-by: Irina Tirdea --- drivers/mmc/host/sdhci.c |6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index ff72e98..3653494 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -1012,7 +1012,8 @@ static void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd) mdelay(1); } - mod_timer(&host->timer, jiffies + 10 * HZ); + if (!mmc_am_panic_task(host->mmc)) + mod_timer(&host->timer, jiffies + 10 * HZ); host->cmd = cmd; @@ -2117,7 +2118,8 @@ static void sdhci_tasklet_finish(unsigned long param) return; } - del_timer(&host->timer); + if (!mmc_am_panic_task(host->mmc)) + del_timer(&host->timer); mrq = host->mrq; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 22/26] mmc: sdhci: panic write: no dma mapping
From: Adrian Hunter Signed-off-by: Adrian Hunter Signed-off-by: Irina Tirdea --- drivers/mmc/host/sdhci.c | 158 - include/linux/mmc/sdhci.h |8 +++ 2 files changed, 164 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index d85e9d5..ab3f5ce 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -649,6 +649,69 @@ static void sdhci_adma_table_post(struct sdhci_host *host, data->sg_len, direction); } +#ifdef CONFIG_MMC_BLOCK_PANIC_WRITE + +static void sdhci_panic_dma_pre(struct sdhci_host *host, struct mmc_data *data) +{ + struct scatterlist *sg; + int i, len; + dma_addr_t addr; + u8 *desc; + + if (host->flags & SDHCI_USE_ADMA) { + if (data->sg_len != 1) { + WARN_ON(1); + host->flags &= ~SDHCI_REQ_USE_DMA; + return; + } + desc = host->panic_adma_desc; + for_each_sg(data->sg, sg, 1, i) { + addr = host->panic_dma_addr; + len = sg->length; + sdhci_set_adma_desc(desc, addr, len, 0x21); + desc += 8; + } + if (host->quirks & SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC) { + if (desc != host->panic_adma_desc) { + desc -= 8; + desc[0] |= 0x2; + } + } else { + sdhci_set_adma_desc(desc, 0, 0, 0x3); + } + sdhci_writel(host, host->panic_adma_addr, SDHCI_ADMA_ADDRESS); + } else { + sdhci_writel(host, host->panic_dma_addr, SDHCI_DMA_ADDRESS); + } + + if (data->flags & MMC_DATA_WRITE) { + sg_copy_to_buffer(data->sg, data->sg_len, host->panic_buf, + host->panic_bufsize); + } +} + +static void sdhci_panic_dma_post(struct sdhci_host *host, struct mmc_data *data) +{ + if (data->flags & MMC_DATA_READ) { + sg_copy_from_buffer(data->sg, data->sg_len, host->panic_buf, + host->panic_bufsize); + } +} + +#else + +static inline void sdhci_panic_dma_pre(struct sdhci_host *host, + struct mmc_data *data) +{ +} + +static inline void sdhci_panic_dma_post(struct sdhci_host *host, + struct mmc_data *data) +{ +} + +#endif + static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd) { u8 count; @@ -810,7 +873,9 @@ static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_command *cmd) } if (host->flags & SDHCI_REQ_USE_DMA) { - if (host->flags & SDHCI_USE_ADMA) { + if (mmc_am_panic_task(host->mmc)) { + sdhci_panic_dma_pre(host, data); + } else if (host->flags & SDHCI_USE_ADMA) { ret = sdhci_adma_table_pre(host, data); if (ret) { /* @@ -937,7 +1002,9 @@ static void sdhci_finish_data(struct sdhci_host *host) host->data = NULL; if (host->flags & SDHCI_REQ_USE_DMA) { - if (host->flags & SDHCI_USE_ADMA) + if (mmc_am_panic_task(host->mmc)) + sdhci_panic_dma_post(host, data); + else if (host->flags & SDHCI_USE_ADMA) sdhci_adma_table_post(host, data); else { dma_unmap_sg(mmc_dev(host->mmc), data->sg, @@ -2045,6 +2112,91 @@ static const struct mmc_host_ops sdhci_ops = { #ifdef CONFIG_MMC_BLOCK_PANIC_WRITE +/* + * Arbitrary maximum DMA buffer size and hence maximum request size when using + * DMA. + */ +#define SDHCI_PANIC_DMA_BUFSIZE (32 * 1024) + +/* + * We DMA at most one segment which is aligned. Plus we need an end descriptor. + * We allow for a 8 byte (32-bit address) descriptor size. + */ +#define SDHCI_PANIC_ADMA_DESC_SZ ((1 + 1) * 12) + +static void sdhci_panic_dma_cleanup(struct sdhci_host *host) +{ + if (host->panic_adma_desc) { + dma_free_coherent(mmc_dev(host->mmc), SDHCI_PANIC_ADMA_DESC_SZ, + host->panic_adma_desc, host->panic_adma_addr); + host->panic_adma_desc = NULL; + } + + if (host->panic_buf) { + dma_free_coherent(mmc_dev(host->mmc), host->panic_bufsize, + host->panic_buf, host->panic_dma_addr); + host->panic_buf = NULL; + } +} + +static int sdhci_panic_dma_init(struct sdhci_host *host) +{ + size_t
[PATCH 24/26] mmc: sdhci: panic write: abort request in progress
From: Adrian Hunter Signed-off-by: Adrian Hunter Signed-off-by: Irina Tirdea --- drivers/mmc/host/sdhci.c |5 + 1 file changed, 5 insertions(+) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 496adc8..9a24417 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -1351,6 +1351,11 @@ static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq) sdhci_lock_irqsave(host, flags); + if (mmc_am_panic_task(mmc) && host->mrq) { + host->mrq->cmd->error = -EILSEQ; + sdhci_sched_tasklet(host, finish); + } + WARN_ON(host->mrq != NULL); #ifndef SDHCI_USE_LEDS_CLASS -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 23/26] mmc: sdhci: panic write: resume suspended host
From: Adrian Hunter Signed-off-by: Adrian Hunter Signed-off-by: Irina Tirdea --- drivers/mmc/host/sdhci.c | 14 ++ 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index ab3f5ce..496adc8 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -2231,6 +2231,10 @@ static void sdhci_panic_begin(struct mmc_host *mmc) { struct sdhci_host *host = mmc_priv(mmc); + if (host->runtime_suspended) + sdhci_runtime_resume_host(host); + else if (mmc->ios.vdd == 0) + sdhci_resume_host(host); sdhci_writel(host, 0, SDHCI_SIGNAL_ENABLE); } @@ -2741,10 +2745,12 @@ int sdhci_resume_host(struct sdhci_host *host) host->ops->enable_dma(host); } - ret = request_irq(host->irq, sdhci_irq, IRQF_SHARED, - mmc_hostname(host->mmc), host); - if (ret) - return ret; + if (!mmc_am_panic_task(host->mmc)) { + ret = request_irq(host->irq, sdhci_irq, IRQF_SHARED, + mmc_hostname(host->mmc), host); + if (ret) + return ret; + } if ((host->mmc->pm_flags & MMC_PM_KEEP_POWER) && (host->quirks2 & SDHCI_QUIRK2_HOST_OFF_CARD_ON)) { -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 21/26] mmc: sdhci: panic write: poll interrupts
From: Adrian Hunter Signed-off-by: Adrian Hunter Signed-off-by: Irina Tirdea --- drivers/mmc/host/sdhci.c | 33 + 1 file changed, 33 insertions(+) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index e096526..d85e9d5 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -131,6 +131,8 @@ static void sdhci_clear_set_irqs(struct sdhci_host *host, u32 clear, u32 set) ier &= ~clear; ier |= set; sdhci_writel(host, ier, SDHCI_INT_ENABLE); + if (mmc_panic_task_active(host->mmc)) + ier = 0; sdhci_writel(host, ier, SDHCI_SIGNAL_ENABLE); } @@ -1267,6 +1269,8 @@ static int sdhci_set_power(struct sdhci_host *host, unsigned short power) * * \*/ +static irqreturn_t sdhci_irq(int irq, void *dev_id); + static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq) { struct sdhci_host *host; @@ -1347,6 +1351,11 @@ static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq) mmiowb(); sdhci_unlock_irqrestore(host, flags); + + if (mmc_am_panic_task(host->mmc)) { + while (host->mrq) + sdhci_irq(0, host); + } } static void sdhci_do_set_ios(struct sdhci_host *host, struct mmc_ios *ios) @@ -2066,6 +2075,27 @@ void sdhci_unlock_irqrestore(struct sdhci_host *host, unsigned long flags) spin_unlock_irqrestore(&host->lock, flags); } +static void sdhci_panic_begin(struct mmc_host *mmc) +{ + struct sdhci_host *host = mmc_priv(mmc); + + sdhci_writel(host, 0, SDHCI_SIGNAL_ENABLE); +} + +static void sdhci_panic_end(struct mmc_host *mmc) +{ + struct sdhci_host *host = mmc_priv(mmc); + u32 ier; + + ier = sdhci_readl(host, SDHCI_INT_ENABLE); + sdhci_writel(host, ier, SDHCI_SIGNAL_ENABLE); +} + +static const struct mmc_panic_ops sdhci_pops = { + .begin = sdhci_panic_begin, + .end= sdhci_panic_end, +}; + #endif /*\ @@ -2854,6 +2884,9 @@ int sdhci_add_host(struct sdhci_host *host) * Set host parameters. */ mmc->ops = &sdhci_ops; +#ifdef CONFIG_MMC_BLOCK_PANIC_WRITE + mmc->pops = &sdhci_pops; +#endif mmc->f_max = host->max_clk; if (host->ops->get_min_clock) mmc->f_min = host->ops->get_min_clock(host); -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 20/26] mmc: sdhci: panic write: no tuning
From: Adrian Hunter Signed-off-by: Adrian Hunter Signed-off-by: Irina Tirdea --- drivers/mmc/host/sdhci.c |4 1 file changed, 4 insertions(+) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index fcedcec..e096526 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -1794,6 +1794,10 @@ static int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode) int err = 0; bool requires_tuning_nonuhs = false; + /* Tuning may need a timer so it is not supported by the panic task */ + if (mmc_am_panic_task(mmc)) + return -EINVAL; + host = mmc_priv(mmc); sdhci_runtime_pm_get(host); -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 06/26] mmc: block: add panic write support
From: Adrian Hunter Signed-off-by: Adrian Hunter Signed-off-by: Irina Tirdea --- drivers/mmc/card/Kconfig | 11 ++ drivers/mmc/card/block.c | 257 +- include/linux/mmc/host.h | 92 + 3 files changed, 359 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/card/Kconfig b/drivers/mmc/card/Kconfig index 3b1f783..efc49e1 100644 --- a/drivers/mmc/card/Kconfig +++ b/drivers/mmc/card/Kconfig @@ -50,6 +50,17 @@ config MMC_BLOCK_BOUNCE If unsure, say Y here. +config MMC_BLOCK_PANIC_WRITE + bool "Panic write support" + depends on MMC_BLOCK + select BLK_DEV_PANIC_WRITE + default n + help + Say Y here to support panic write. Panic write enables upper + layers to write to MMC/SD cards during an oops or panic. + However a host controller driver that supports panic writes + is also needed. + config SDIO_UART tristate "SDIO UART/GPS class support" help diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index 172a768..e18ce4a 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c @@ -108,6 +108,11 @@ struct mmc_blk_data { struct device_attribute force_ro; struct device_attribute power_ro_lock; int area_type; +#ifdef CONFIG_MMC_BLOCK_PANIC_WRITE + int panic; + struct scatterlist *panic_sg; + struct mmc_blk_request *panic_brq; +#endif }; static DEFINE_MUTEX(open_lock); @@ -517,7 +522,7 @@ static const struct block_device_operations mmc_bdops = { #endif }; -static inline int mmc_blk_part_switch(struct mmc_card *card, +static int mmc_blk_part_switch(struct mmc_card *card, struct mmc_blk_data *md) { int ret; @@ -1432,6 +1437,253 @@ out: return ret; } +#ifdef CONFIG_MMC_BLOCK_PANIC_WRITE + +static int mmc_blk_panic_init_cleanup(struct block_device *bdev, int init) +{ + struct mmc_blk_data *md = mmc_blk_get(bdev->bd_disk); + struct mmc_card *card; + int err = 0; + + if (!md) + return -ENODEV; + + card = md->queue.card; + if (!card) { + err = -ENODEV; + goto out_put; + } + + mmc_claim_host(card->host); + + if (!init) { + mmc_panic_cleanup_host(card->host); + goto out_free_brq; + } + + md->panic_sg = kmalloc(sizeof(struct scatterlist), GFP_KERNEL); + if (!md->panic_sg) { + err = -ENOMEM; + goto out_release; + } + sg_init_table(md->panic_sg, 1); + + md->panic_brq = kmalloc(sizeof(struct mmc_blk_request), GFP_KERNEL); + if (!md->panic_brq) { + err = -ENOMEM; + goto out_free_sg; + } + + err = mmc_panic_init_host(card->host); + if (err) + goto out_free_brq; + + goto out_release; + +out_free_brq: + kfree(md->panic_brq); +out_free_sg: + kfree(md->panic_sg); +out_release: + mmc_release_host(card->host); +out_put: + mmc_blk_put(md); + return err; +} + +static int mmc_blk_panic_init(struct block_device *bdev) +{ + return mmc_blk_panic_init_cleanup(bdev, 1); +} + +static void mmc_blk_panic_cleanup(struct block_device *bdev) +{ + mmc_blk_panic_init_cleanup(bdev, 0); +} + +static int get_card_status(struct mmc_card *card, u32 *status, int retries); + +static int mmc_blk_panic_do_write(struct mmc_blk_data *md, + struct mmc_card *card, sector_t sect, + void *addr, unsigned long len) +{ + struct mmc_blk_request *brq = md->panic_brq; + unsigned int blocks = len >> 9; + unsigned int blksz = 512; + + int err = 0; + + sg_init_one(md->panic_sg, addr, len); + + memset(brq, 0, sizeof(struct mmc_blk_request)); + + brq->mrq.cmd = &brq->cmd; + brq->mrq.data = &brq->data; + brq->mrq.stop = &brq->stop; + + if (blocks > 1) + brq->mrq.cmd->opcode = MMC_WRITE_MULTIPLE_BLOCK; + else + brq->mrq.cmd->opcode = MMC_WRITE_BLOCK; + + brq->mrq.cmd->arg = sect; + if (!mmc_card_blockaddr(card)) + brq->mrq.cmd->arg <<= 9; + + brq->mrq.cmd->flags = MMC_RSP_R1 | MMC_CMD_ADTC; + + if (blocks == 1) + brq->mrq.stop = NULL; + else { + brq->mrq.stop->opcode = MMC_STOP_TRANSMISSION; + brq->mrq.stop->arg = 0; + brq->mrq.stop->flags = MMC_RSP_R1B | MMC_CMD_AC; + } + + brq->mrq.data->blksz = blksz; + brq->mrq.data->blocks = blocks; + brq->mrq.data->flags = MMC_DATA_WRITE; + brq->mrq.data->s
[PATCH 09/26] mmc: panic write: suppress host not claimed warnings
From: Adrian Hunter Signed-off-by: Adrian Hunter Signed-off-by: Irina Tirdea --- drivers/mmc/core/core.c | 13 +++-- drivers/mmc/core/mmc.c |4 ++-- drivers/mmc/core/sd.c |4 ++-- drivers/mmc/core/sdio.c |4 ++-- drivers/mmc/core/sdio_irq.c |4 ++-- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 6b2377a..0b904bc 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -224,7 +224,7 @@ mmc_start_request(struct mmc_host *host, struct mmc_request *mrq) mrq->stop->arg, mrq->stop->flags); } - WARN_ON(!host->claimed); + WARN_ON(!host->claimed && !mmc_am_panic_task(host)); mrq->cmd->error = 0; mrq->cmd->mrq = mrq; @@ -558,7 +558,7 @@ int mmc_wait_for_cmd(struct mmc_host *host, struct mmc_command *cmd, int retries { struct mmc_request mrq = {NULL}; - WARN_ON(!host->claimed); + WARN_ON(!host->claimed && !mmc_am_panic_task(host)); memset(cmd->resp, 0, sizeof(cmd->resp)); cmd->retries = retries; @@ -843,7 +843,7 @@ void mmc_release_host(struct mmc_host *host) { unsigned long flags; - WARN_ON(!host->claimed); + WARN_ON(!host->claimed && !mmc_am_panic_task(host)); if (host->ops->disable && host->claim_cnt == 1) host->ops->disable(host); @@ -1433,7 +1433,7 @@ void mmc_attach_bus(struct mmc_host *host, const struct mmc_bus_ops *ops) BUG_ON(!host); BUG_ON(!ops); - WARN_ON(!host->claimed); + WARN_ON(!host->claimed && !mmc_am_panic_task(host)); spin_lock_irqsave(&host->lock, flags); @@ -1456,7 +1456,7 @@ void mmc_detach_bus(struct mmc_host *host) BUG_ON(!host); - WARN_ON(!host->claimed); + WARN_ON(!host->claimed && !mmc_am_panic_task(host)); WARN_ON(!host->bus_ops); spin_lock_irqsave(&host->lock, flags); @@ -2106,7 +2106,8 @@ int mmc_detect_card_removed(struct mmc_host *host) struct mmc_card *card = host->card; int ret; - WARN_ON(!host->claimed); + WARN_ON(!host->claimed && !mmc_am_panic_task(host)); + if (!card) return 1; diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 7cc4638..9cc36c4 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -823,7 +823,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, u8 *ext_csd = NULL; BUG_ON(!host); - WARN_ON(!host->claimed); + WARN_ON(!host->claimed && !mmc_am_panic_task(host)); /* Set correct bus mode for MMC before attempting init */ if (!mmc_host_is_spi(host)) @@ -1478,7 +1478,7 @@ int mmc_attach_mmc(struct mmc_host *host) u32 ocr; BUG_ON(!host); - WARN_ON(!host->claimed); + WARN_ON(!host->claimed && !mmc_am_panic_task(host)); /* Set correct bus mode for MMC before attempting attach */ if (!mmc_host_is_spi(host)) diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index 74972c2..4ad079f 100644 --- a/drivers/mmc/core/sd.c +++ b/drivers/mmc/core/sd.c @@ -899,7 +899,7 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr, u32 rocr = 0; BUG_ON(!host); - WARN_ON(!host->claimed); + WARN_ON(!host->claimed && !mmc_am_panic_task(host)); err = mmc_sd_get_cid(host, ocr, cid, &rocr); if (err) @@ -1146,7 +1146,7 @@ int mmc_attach_sd(struct mmc_host *host) u32 ocr; BUG_ON(!host); - WARN_ON(!host->claimed); + WARN_ON(!host->claimed && !mmc_am_panic_task(host)); /* Disable preset value enable if already set since last time */ if (host->ops->enable_preset_value) { diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c index 2273ce6..af89c84 100644 --- a/drivers/mmc/core/sdio.c +++ b/drivers/mmc/core/sdio.c @@ -585,7 +585,7 @@ static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr, int err; BUG_ON(!host); - WARN_ON(!host->claimed); + WARN_ON(!host->claimed && !mmc_am_panic_task(host)); /* * Inform the card of the voltage @@ -1051,7 +1051,7 @@ int mmc_attach_sdio(struct mmc_host *host) struct mmc_card *card; BUG_ON(!host); - WARN_ON(!host->claimed); + WARN_ON(!host->claimed && !mmc_am_panic_task(host)); err = mmc_send_io_op_cond(host, 0, &ocr); if (err) diff --git a/drivers/mmc/core/sdio_irq.c b/drivers/mmc/core/sdio_irq.c index 3d8ceb4..719701c 100644 --- a/drivers/mmc/core/sdio_irq.c +++ b/drivers/mmc/core/sdio_irq.c @@ -175,7 +175,7 @@ stati
[PATCH 08/26] mmc: panic write: bypass request completion
From: Adrian Hunter Signed-off-by: Adrian Hunter Signed-off-by: Irina Tirdea --- drivers/mmc/core/core.c |7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index dbe5332..6b2377a 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -148,6 +148,9 @@ void mmc_request_done(struct mmc_host *host, struct mmc_request *mrq) cmd->retries = 0; } + if (mmc_am_panic_task(host)) + return; + if (err && cmd->retries && !mmc_card_removed(host->card)) { /* * Request starter must handle retries - see @@ -340,7 +343,9 @@ static void mmc_wait_for_req_done(struct mmc_host *host, struct mmc_command *cmd; while (1) { - wait_for_completion(&mrq->completion); + /* Panic task requests must be completed in ->request() */ + if (!mmc_am_panic_task(host)) + wait_for_completion(&mrq->completion); cmd = mrq->cmd; if (!cmd->error || !cmd->retries || -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 03/26] pstore: add flush
From: Adrian Hunter Let the back end know when writing has finished by adding a flush method. Signed-off-by: Adrian Hunter Signed-off-by: Irina Tirdea --- fs/pstore/platform.c |3 +++ include/linux/pstore.h |1 + 2 files changed, 4 insertions(+) diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c index b9ab942..97ae8a9 100644 --- a/fs/pstore/platform.c +++ b/fs/pstore/platform.c @@ -114,6 +114,9 @@ static void pstore_dump(struct kmsg_dumper *dumper, why = get_reason_str(reason); + if (psinfo->flush) + psinfo->flush(psinfo); + if (in_nmi()) { is_locked = spin_trylock(&psinfo->buf_lock); if (!is_locked) diff --git a/include/linux/pstore.h b/include/linux/pstore.h index 27f1995..3f93b4a 100644 --- a/include/linux/pstore.h +++ b/include/linux/pstore.h @@ -68,6 +68,7 @@ struct pstore_info { struct pstore_info *psi); int (*erase)(enum pstore_type_id type, u64 id, struct pstore_info *psi); + int (*flush)(struct pstore_info *psi); void*data; }; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 04/26] blkoops: add a block device oops / panic logger
From: Adrian Hunter blkoops is a pstore back end to write panic / oops logs to a block device. It is initially intended for use with eMMC as an alternative to using a crash kernel. Signed-off-by: Adrian Hunter Signed-off-by: Irina Tirdea --- Documentation/blockdev/00-INDEX|2 + Documentation/blockdev/blkoops.txt | 104 +++ drivers/block/Kconfig | 10 + drivers/block/Makefile |1 + drivers/block/blkoops.c| 1569 5 files changed, 1686 insertions(+) create mode 100644 Documentation/blockdev/blkoops.txt create mode 100644 drivers/block/blkoops.c diff --git a/Documentation/blockdev/00-INDEX b/Documentation/blockdev/00-INDEX index c08df56..c45cef8 100644 --- a/Documentation/blockdev/00-INDEX +++ b/Documentation/blockdev/00-INDEX @@ -2,6 +2,8 @@ - this file README.DAC960 - info on Mylex DAC960/DAC1100 PCI RAID Controller Driver for Linux. +blkoops.txt + - info on block device oops / panic logger cciss.txt - info, major/minor #'s for Compaq's SMART Array Controllers. cpqarray.txt diff --git a/Documentation/blockdev/blkoops.txt b/Documentation/blockdev/blkoops.txt new file mode 100644 index 000..fb08664 --- /dev/null +++ b/Documentation/blockdev/blkoops.txt @@ -0,0 +1,104 @@ +Block device oops / panic logger + + +Contents: + + 1) Overview + 2) Format + 3) Parameters + 4) blkoops and pstore + 5) debugfs + +1) Overview +--- + + blkoops is a pstore back end to write panic / oops logs to a block + device. It is initially intended for use with eMMC as an alternative to + using a crash kernel. + +2) Format +- + + Data is written in chunks called nodes which are preceded by a + header. The header is always aligned to a block boundary. Nodes are + written sequentially starting at the second block. The first block + contains a special node that fulfils 2 purposes: 1) the blkoops magic + number must be present or blkoops will not attach to the block device, + and 2) erase information is recorded there. Nodes can be arbitrarily + long. + + Nodes are identified by session number, file number and part number. + A session may have up to 2^32 - 1 files each with up to 2^32 - 1 parts. + + A new session begins when blkoops attaches to a block device and ends + when it detaches or there is a reboot. A new session overwrites the + previous session. Once the media is full no more nodes are written. + +3) Parameters +- + +devname + + Canonical block device name or number + + devname may be set on the kernel command line e.g. + + blkoops.devname=/dev/mmcblk0p7 + + or by writing to sysfs e.g. + + echo /dev/mmcblk0p1 > /sys/module/blkoops/parameters/devname + + devname is NOT the name of a file system object. e.g. /dev/mmcblk0p7 + does NOT mean the block device special file mmcblk0p7 in the /dev + directory. Instead it means partition 7 of the device named mmcblk0. + For more information see name_to_dev_t comment in init/do_mounts.c + + When devname is changed, the old devname (if any) is detached from + blkoops and the new devname (if any) is attached. + + blkoops will reject a block device that does not have the blkoops magic + number written on the 1st sector. For example, to prepare + /dev/mmcblk0p7 for blkoops: + + sudo bash -c "echo -e -n '\0034\0327\0130\0350' \ + | dd count=1 conv=sync \ + > /dev/mmcblk0p7" + +dump_oops + + set to 1 to dump oopses, 0 to dump only panics (default 1) + +4) blkoops and pstore +- + + pstore creates file names from pstore type code, back end name and + pstore 64-bit id. blkoops records the pstore type code, uses back end + name "blkoops", and creates the pstore 64-bit id from session number and + file number (session << 32 | file). blkoops concatenates all parts + together and presents them as one file. + + pstore noramally reads back end data entirely into memory when mounting. + However if a blkoops file is too big it will be read from media as + needed instead. + + blkoops suppreses pstore heading lines from dumped data. + + blkoops increases pstore default kmsg_bytes to ULONG_MAX. + +5) debugfs +-- + +blkoops/type + + pstore type code to use when dumping data via blkoops/data + +blkoops/reason + + kmsg dump reason code to use when dumping data via blkoops/data + +blkoops/data + + Data written to blkoops/data is dumped to the block device + using blkoops/type. blkoops/reason must be the numberical value of + KMSG_DUMP_PANIC or (if dump_oops is 1) KMSG_DUMP_OOPS. diff --git a
[PATCH 16/26] mmc: sdhci: panic write: no sleeping
From: Adrian Hunter Signed-off-by: Adrian Hunter Signed-off-by: Irina Tirdea --- drivers/mmc/host/sdhci.c | 26 +- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 1ed78f0..827e34f 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -1536,6 +1536,14 @@ static int sdhci_check_ro(struct sdhci_host *host) #define SAMPLE_COUNT 5 +static void sdhci_msleep(struct sdhci_host *host, unsigned int ms) +{ + if (mmc_am_panic_task(host->mmc)) + mdelay(ms); + else + msleep(ms); +} + static int sdhci_do_get_ro(struct sdhci_host *host) { int i, ro_count; @@ -1549,7 +1557,7 @@ static int sdhci_do_get_ro(struct sdhci_host *host) if (++ro_count > SAMPLE_COUNT / 2) return 1; } - msleep(30); + sdhci_msleep(host, 30); } return 0; } @@ -1605,6 +1613,14 @@ static void sdhci_enable_sdio_irq(struct mmc_host *mmc, int enable) sdhci_unlock_irqrestore(host, flags); } +#define sdhci_usleep_range(host, min, max) \ +do { \ + if (mmc_am_panic_task((host)->mmc)) \ + mdelay(DIV_ROUND_UP(min, 1000));\ + else\ + usleep_range(min, max); \ +} while (0) + static int sdhci_do_3_3v_signal_voltage_switch(struct sdhci_host *host, u16 ctrl) { @@ -1623,7 +1639,7 @@ static int sdhci_do_3_3v_signal_voltage_switch(struct sdhci_host *host, } } /* Wait for 5ms */ - usleep_range(5000, 5500); + sdhci_usleep_range(host, 5000, 5500); /* 3.3V regulator output should be stable within 5 ms */ ctrl = sdhci_readw(host, SDHCI_HOST_CONTROL2); @@ -1668,7 +1684,7 @@ static int sdhci_do_1_8v_signal_voltage_switch(struct sdhci_host *host, sdhci_writew(host, ctrl, SDHCI_HOST_CONTROL2); /* Wait for 5ms */ - usleep_range(5000, 5500); + sdhci_usleep_range(host, 5000, 5500); ctrl = sdhci_readw(host, SDHCI_HOST_CONTROL2); if (ctrl & SDHCI_CTRL_VDD_180) { @@ -1676,7 +1692,7 @@ static int sdhci_do_1_8v_signal_voltage_switch(struct sdhci_host *host, clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL); clk |= SDHCI_CLOCK_CARD_EN; sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL); - usleep_range(1000, 1500); + sdhci_usleep_range(host, 1000, 1500); /* * If DAT[3:0] level is b, then the card @@ -1703,7 +1719,7 @@ static int sdhci_do_1_8v_signal_voltage_switch(struct sdhci_host *host, regulator_disable(host->vmmc); /* Wait for 1ms as per the spec */ - usleep_range(1000, 1500); + sdhci_usleep_range(host, 1000, 1500); pwr |= SDHCI_POWER_ON; sdhci_writeb(host, pwr, SDHCI_POWER_CONTROL); if (host->vmmc) -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 17/26] mmc: sdhci: panic write: call tasklets inline
From: Adrian Hunter Signed-off-by: Adrian Hunter Signed-off-by: Irina Tirdea --- drivers/mmc/host/sdhci.c | 31 +-- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 827e34f..ff72e98 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -914,6 +914,17 @@ static void sdhci_set_transfer_mode(struct sdhci_host *host, sdhci_writew(host, mode, SDHCI_TRANSFER_MODE); } +static void sdhci_tasklet_card(unsigned long param); +static void sdhci_tasklet_finish(unsigned long param); + +#define sdhci_sched_tasklet(host, name)\ +{ \ + if (mmc_am_panic_task(host->mmc)) \ + sdhci_tasklet_##name((unsigned long)host); \ + else\ + tasklet_schedule(&host->name##_tasklet);\ +} + static void sdhci_finish_data(struct sdhci_host *host) { struct mmc_data *data; @@ -965,7 +976,7 @@ static void sdhci_finish_data(struct sdhci_host *host) sdhci_send_command(host, data->stop); } else - tasklet_schedule(&host->finish_tasklet); + sdhci_sched_tasklet(host, finish); } static void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd) @@ -994,7 +1005,7 @@ static void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd) "inhibit bit(s).\n", mmc_hostname(host->mmc)); sdhci_dumpregs(host); cmd->error = -EIO; - tasklet_schedule(&host->finish_tasklet); + sdhci_sched_tasklet(host, finish); return; } timeout--; @@ -1015,7 +1026,7 @@ static void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd) pr_err("%s: Unsupported response type!\n", mmc_hostname(host->mmc)); cmd->error = -EINVAL; - tasklet_schedule(&host->finish_tasklet); + sdhci_sched_tasklet(host, finish); return; } @@ -1076,7 +1087,7 @@ static void sdhci_finish_command(struct sdhci_host *host) sdhci_finish_data(host); if (!host->cmd->data) - tasklet_schedule(&host->finish_tasklet); + sdhci_sched_tasklet(host, finish); host->cmd = NULL; } @@ -1303,7 +1314,7 @@ static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq) if (!present || host->flags & SDHCI_DEVICE_DEAD) { host->mrq->cmd->error = -ENOMEDIUM; - tasklet_schedule(&host->finish_tasklet); + sdhci_sched_tasklet(host, finish); } else { u32 present_state; @@ -2079,7 +2090,7 @@ static void sdhci_tasklet_card(unsigned long param) sdhci_reset(host, SDHCI_RESET_DATA); host->mrq->cmd->error = -ENOMEDIUM; - tasklet_schedule(&host->finish_tasklet); + sdhci_sched_tasklet(host, finish); } sdhci_unlock_irqrestore(host, flags); @@ -2174,7 +2185,7 @@ static void sdhci_timeout_timer(unsigned long data) else host->mrq->cmd->error = -ETIMEDOUT; - tasklet_schedule(&host->finish_tasklet); + sdhci_sched_tasklet(host, finish); } } @@ -2221,7 +2232,7 @@ static void sdhci_cmd_irq(struct sdhci_host *host, u32 intmask) host->cmd->error = -EILSEQ; if (host->cmd->error) { - tasklet_schedule(&host->finish_tasklet); + sdhci_sched_tasklet(host, finish); return; } @@ -2429,7 +2440,7 @@ again: sdhci_writel(host, intmask & (SDHCI_INT_CARD_INSERT | SDHCI_INT_CARD_REMOVE), SDHCI_INT_STATUS); intmask &= ~(SDHCI_INT_CARD_INSERT | SDHCI_INT_CARD_REMOVE); - tasklet_schedule(&host->card_tasklet); + sdhci_sched_tasklet(host, card); } if (intmask & SDHCI_INT_CMD_MASK) { @@ -3192,7 +3203,7 @@ void sdhci_remove_host(struct sdhci_host *host, int dead) " transfer!\n", mmc_hostname(host->mmc)); host->mrq->cmd->error = -ENOMEDIUM; - tasklet_schedule(&host->finish_tasklet); + sdhci_sched_tasklet(host, finish); }
[PATCH 14/26] mmc: panic write: bypass bus ref locking
From: Adrian Hunter Signed-off-by: Adrian Hunter Signed-off-by: Irina Tirdea --- drivers/mmc/core/core.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 4fd7061..3daec19 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -1418,6 +1418,11 @@ static inline void mmc_bus_get(struct mmc_host *host) { unsigned long flags; + if (mmc_am_panic_task(host)) { + host->bus_refs++; + return; + } + spin_lock_irqsave(&host->lock, flags); host->bus_refs++; spin_unlock_irqrestore(&host->lock, flags); @@ -1431,6 +1436,11 @@ static inline void mmc_bus_put(struct mmc_host *host) { unsigned long flags; + if (mmc_am_panic_task(host)) { + host->bus_refs--; + return; + } + spin_lock_irqsave(&host->lock, flags); host->bus_refs--; if ((host->bus_refs == 0) && host->bus_ops) -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 00/26] pstore, mmc: add mmc as backend for pstore
These patches enable using the mmc card to store panic information. They include changes for pstore and mmc: - add block device backend for pstore - add logic in mmc for writing in panic mode Thanks, Irina Cc: Adrian Hunter Adrian Hunter (26): pstore: allow for big files pstore: add flags pstore: add flush blkoops: add a block device oops / panic logger block: add panic write mmc: block: add panic write support mmc: panic write: bypass host claiming mmc: panic write: bypass request completion mmc: panic write: suppress host not claimed warnings mmc: panic write: do not msleep mmc: panic write: bypass clock gating mmc: panic write: bypass regulators mmc: panic write: trap non panic tasks mmc: panic write: bypass bus ref locking mmc: sdhci: panic write: bypass spin lock mmc: sdhci: panic write: no sleeping mmc: sdhci: panic write: call tasklets inline mmc: sdhci: panic write: no timeout timer mmc: sdhci: panic write: no runtime pm mmc: sdhci: panic write: no tuning mmc: sdhci: panic write: poll interrupts mmc: sdhci: panic write: no dma mapping mmc: sdhci: panic write: resume suspended host mmc: sdhci: panic write: abort request in progress mmc: sdhci: panic write: trap nonpanic tasks mmc: sdhci-pci: add panic write support Documentation/blockdev/00-INDEX|2 + Documentation/blockdev/blkoops.txt | 104 +++ drivers/acpi/apei/erst.c | 16 +- drivers/block/Kconfig | 13 + drivers/block/Makefile |1 + drivers/block/blkoops.c| 1569 drivers/mmc/card/Kconfig | 11 + drivers/mmc/card/block.c | 257 +- drivers/mmc/core/core.c| 61 +- drivers/mmc/core/core.h|6 +- drivers/mmc/core/host.c| 11 + drivers/mmc/core/mmc.c |4 +- drivers/mmc/core/mmc_ops.c | 10 +- drivers/mmc/core/sd.c |4 +- drivers/mmc/core/sd_ops.c |2 +- drivers/mmc/core/sdio.c|4 +- drivers/mmc/core/sdio_irq.c|4 +- drivers/mmc/core/sdio_ops.c|2 +- drivers/mmc/host/sdhci-pci.c |5 + drivers/mmc/host/sdhci.c | 441 -- drivers/mmc/host/sdhci.h | 24 + fs/pstore/inode.c | 26 +- fs/pstore/internal.h |5 +- fs/pstore/platform.c | 23 +- fs/pstore/ram.c| 15 +- include/linux/blkdev.h | 77 ++ include/linux/genhd.h |3 + include/linux/mmc/host.h | 92 +++ include/linux/mmc/sdhci.h |9 + include/linux/pstore.h | 12 +- 30 files changed, 2690 insertions(+), 123 deletions(-) create mode 100644 Documentation/blockdev/blkoops.txt create mode 100644 drivers/block/blkoops.c -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v2 0/4] perf: android: configure hardcoded paths
From: Irina Tirdea This is version 2 of the set of patches that replace hardcoded paths used in perf with configurable options in the Makefile. First version can be found at https://lkml.org/lkml/2012/9/20/537. Thanks everybody for the reviews! This version fixes all issues mentioned in reviews. Changes for v2: () updated tools/perf/Documentation/jit-interface.txt regarding PERF_TMP_DIR (patch 1) () fixed hardcoded size for PERF_TMP_DIR"/perf-" (patch 1) () use PERF_SHELL_PATH instead of PERF_SHELL_DIR (patch 2) () use DEFAULT_OBJDUMP_PATH and DEFAULT_ADDR2LINE_PATH (patch 3,4) () add CROSS_COMPILE prefix to addr2line and objdump in Makefile (patch 3,4) Thanks, Irina Irina Tirdea (4): perf tools: configure tmp path at build time perf tools: configure shell path at compile time perf annotate: configure objdump path at compile time perf tools: configure addr2line path at compile time tools/perf/Documentation/jit-interface.txt |4 +++- tools/perf/Makefile| 30 ++-- tools/perf/builtin-help.c |2 +- tools/perf/builtin-script.c| 12 +-- tools/perf/perf-archive.sh | 13 ++-- tools/perf/util/annotate.c |5 +++-- tools/perf/util/dso-test-data.c|2 +- tools/perf/util/map.c |3 ++- tools/perf/util/pmu.c |2 +- tools/perf/util/sort.c |2 +- tools/perf/util/symbol.c |4 +++- tools/perf/util/trace-event-info.c |2 +- 12 files changed, 61 insertions(+), 20 deletions(-) -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v2 1/4] perf tools: configure tmp path at build time
From: Irina Tirdea Temporary perf files are hardcoded to point to /tmp. Android does not have a /tmp directory so it needs to set this path at compile time. Add a compile-time definition (PERF_TMP_DIR) in the Makefile that sets the path to temp directory. By default it points to /tmp. Signed-off-by: Irina Tirdea --- tools/perf/Documentation/jit-interface.txt |4 +++- tools/perf/Makefile| 16 +++- tools/perf/perf-archive.sh | 13 +++-- tools/perf/util/dso-test-data.c|2 +- tools/perf/util/map.c |3 ++- tools/perf/util/pmu.c |2 +- tools/perf/util/symbol.c |4 +++- tools/perf/util/trace-event-info.c |2 +- 8 files changed, 37 insertions(+), 9 deletions(-) diff --git a/tools/perf/Documentation/jit-interface.txt b/tools/perf/Documentation/jit-interface.txt index a8656f5..10cb6ec 100644 --- a/tools/perf/Documentation/jit-interface.txt +++ b/tools/perf/Documentation/jit-interface.txt @@ -1,7 +1,9 @@ perf supports a simple JIT interface to resolve symbols for dynamic code generated by a JIT. -The JIT has to write a /tmp/perf-%d.map (%d = pid of process) file +The JIT has to write a $PERF_TMP_DIR/perf-%d.map (%d = pid of process) file. +You can set $PERF_TMP_DIR at compile time in the Makefile. +By default it is /tmp. This is a text file. diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 5077f8e..eab4a36 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -139,6 +139,7 @@ sysconfdir = $(prefix)/etc ETC_PERFCONFIG = etc/perfconfig endif lib = lib +PERF_TMP_DIR = /tmp export prefix bindir sharedir sysconfdir @@ -246,7 +247,8 @@ $(OUTPUT)util/pmu-bison.c: util/pmu.y $(QUIET_BISON)$(BISON) -v util/pmu.y -d -o $(OUTPUT)util/pmu-bison.c $(OUTPUT)util/parse-events.o: $(OUTPUT)util/parse-events-flex.c $(OUTPUT)util/parse-events-bison.c -$(OUTPUT)util/pmu.o: $(OUTPUT)util/pmu-flex.c $(OUTPUT)util/pmu-bison.c +$(OUTPUT)util/pmu.o: $(OUTPUT)util/pmu.c $(OUTPUT)util/pmu-flex.c $(OUTPUT)util/pmu-bison.c $(OUTPUT)PERF-CFLAGS + $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DPERF_TMP_DIR='"$(PERF_TMP_DIR)"' $< LIB_FILE=$(OUTPUT)libperf.a @@ -880,6 +882,18 @@ $(OUTPUT)util/exec_cmd.o: util/exec_cmd.c $(OUTPUT)PERF-CFLAGS $(OUTPUT)util/config.o: util/config.c $(OUTPUT)PERF-CFLAGS $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $< +$(OUTPUT)util/dso-test-data.o: util/dso-test-data.c $(OUTPUT)PERF-CFLAGS + $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DPERF_TMP_DIR='"$(PERF_TMP_DIR)"' $< + +$(OUTPUT)util/map.o: util/map.c $(OUTPUT)PERF-CFLAGS + $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DPERF_TMP_DIR='"$(PERF_TMP_DIR)"' $< + +$(OUTPUT)util/symbol.o: util/symbol.c $(OUTPUT)PERF-CFLAGS + $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DPERF_TMP_DIR='"$(PERF_TMP_DIR)"' $< + +$(OUTPUT)util/trace-event-info.o: util/trace-event-info.c $(OUTPUT)PERF-CFLAGS + $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DPERF_TMP_DIR='"$(PERF_TMP_DIR)"' $< + $(OUTPUT)ui/browser.o: ui/browser.c $(OUTPUT)PERF-CFLAGS $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DENABLE_SLFUTURE_CONST $< diff --git a/tools/perf/perf-archive.sh b/tools/perf/perf-archive.sh index e919306..058c3b7 100644 --- a/tools/perf/perf-archive.sh +++ b/tools/perf/perf-archive.sh @@ -18,7 +18,16 @@ else PERF_BUILDID_DIR=$PERF_BUILDID_DIR/ fi -BUILDIDS=$(mktemp /tmp/perf-archive-buildids.XX) +# +# PERF_TMP_DIR environment variable set by perf +# path to temp directory, default to /tmp +# +if [ -z $PERF_TMP_DIR ]; then + PERF_TMP_DIR=/tmp +fi + + +BUILDIDS=$(mktemp $PERF_TMP_DIR/perf-archive-buildids.XX) NOBUILDID= perf buildid-list -i $PERF_DATA --with-hits | grep -v "^$NOBUILDID " > $BUILDIDS @@ -28,7 +37,7 @@ if [ ! -s $BUILDIDS ] ; then exit 1 fi -MANIFEST=$(mktemp /tmp/perf-archive-manifest.XX) +MANIFEST=$(mktemp $PERF_TMP_DIR/perf-archive-manifest.XX) PERF_BUILDID_LINKDIR=$(readlink -f $PERF_BUILDID_DIR)/ cut -d ' ' -f 1 $BUILDIDS | \ diff --git a/tools/perf/util/dso-test-data.c b/tools/perf/util/dso-test-data.c index c6caede..ca81e65 100644 --- a/tools/perf/util/dso-test-data.c +++ b/tools/perf/util/dso-test-data.c @@ -18,7 +18,7 @@ do { \ static char *test_file(int size) { - static char buf_templ[] = "/tmp/test-XX"; + static char buf_templ[] = PERF_TMP_DIR "/test-XX"; char *templ = buf_templ; int fd, i; unsigned char *buf; diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index b442ee4..c5b4632 100644 --- a/tools/perf/util/map.c +++ b/tools/p
[PATCH v2 2/4] perf tools: configure shell path at compile time
From: Irina Tirdea Shell path /bin/sh is hardcoded in various places in perf. Android has a different folder structure and does not have /bin/sh. Set the shell path at compile time in the Makefile by setting PERF_SHELL_PATH. By default it is set to /bin/sh. Signed-off-by: Irina Tirdea --- tools/perf/Makefile |6 +- tools/perf/builtin-help.c |2 +- tools/perf/builtin-script.c | 12 ++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/tools/perf/Makefile b/tools/perf/Makefile index eab4a36..fae52c8 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -828,7 +828,11 @@ $(OUTPUT)builtin-help.o: builtin-help.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFL $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \ '-DPERF_HTML_PATH="$(htmldir_SQ)"' \ '-DPERF_MAN_PATH="$(mandir_SQ)"' \ - '-DPERF_INFO_PATH="$(infodir_SQ)"' $< + '-DPERF_INFO_PATH="$(infodir_SQ)"' \ + '-DPERF_SHELL_PATH="/bin/sh"' $< + +$(OUTPUT)builtin-script.o: builtin-script.c $(OUTPUT)PERF-CFLAGS + $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DPERF_SHELL_PATH='"/bin/sh"' $< $(OUTPUT)builtin-timechart.o: builtin-timechart.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \ diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c index 25c8b94..e7d640c 100644 --- a/tools/perf/builtin-help.c +++ b/tools/perf/builtin-help.c @@ -171,7 +171,7 @@ static void exec_man_cmd(const char *cmd, const char *page) { struct strbuf shell_cmd = STRBUF_INIT; strbuf_addf(&shell_cmd, "%s %s", cmd, page); - execl("/bin/sh", "sh", "-c", shell_cmd.buf, NULL); + execl(PERF_SHELL_PATH, "sh", "-c", shell_cmd.buf, NULL); warning("failed to exec '%s': %s", cmd, strerror(errno)); } diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 1be843a..b626cf1 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -1326,7 +1326,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) goto out; } - __argv[j++] = "/bin/sh"; + __argv[j++] = PERF_SHELL_PATH; __argv[j++] = rec_script_path; if (system_wide) __argv[j++] = "-a"; @@ -1337,7 +1337,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) __argv[j++] = argv[i]; __argv[j++] = NULL; - execvp("/bin/sh", (char **)__argv); + execvp(PERF_SHELL_PATH, (char **)__argv); free(__argv); exit(-1); } @@ -1353,7 +1353,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) } j = 0; - __argv[j++] = "/bin/sh"; + __argv[j++] = PERF_SHELL_PATH; __argv[j++] = rep_script_path; for (i = 1; i < rep_args + 1; i++) __argv[j++] = argv[i]; @@ -1361,7 +1361,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) __argv[j++] = "-"; __argv[j++] = NULL; - execvp("/bin/sh", (char **)__argv); + execvp(PERF_SHELL_PATH, (char **)__argv); free(__argv); exit(-1); } @@ -1390,7 +1390,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) goto out; } - __argv[j++] = "/bin/sh"; + __argv[j++] = PERF_SHELL_PATH; __argv[j++] = script_path; if (system_wide) __argv[j++] = "-a"; @@ -1398,7 +1398,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) __argv[j++] = argv[i]; __argv[j++] = NULL; - execvp("/bin/sh", (char **)__argv); + execvp(PERF_SHELL_PATH, (char **)__argv); free(__argv); exit(-1); } -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v2 3/4] perf annotate: configure objdump path at compile time
From: Irina Tirdea The default name for objdump is "objdump". For cross-compiling the name of objdump will be different (e.g. arm-eabi-objdump in Android). Set the default objdump name in the Makefile with DEFAULT_OBJDUMP_PATH. Signed-off-by: Irina Tirdea --- tools/perf/Makefile|4 tools/perf/util/annotate.c |2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/perf/Makefile b/tools/perf/Makefile index fae52c8..7a3f572 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -140,6 +140,7 @@ ETC_PERFCONFIG = etc/perfconfig endif lib = lib PERF_TMP_DIR = /tmp +OBJDUMP = $(CROSS_COMPILE)objdump export prefix bindir sharedir sysconfdir @@ -883,6 +884,9 @@ $(OUTPUT)util/exec_cmd.o: util/exec_cmd.c $(OUTPUT)PERF-CFLAGS '-DPREFIX="$(prefix_SQ)"' \ $< +$(OUTPUT)util/annotate.o: util/annotate.c $(OUTPUT)PERF-CFLAGS + $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DDEFAULT_OBJDUMP_PATH='"$(OBJDUMP)"' $< + $(OUTPUT)util/config.o: util/config.c $(OUTPUT)PERF-CFLAGS $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $< diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index f0a9103..d7036b3 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -824,7 +824,7 @@ fallback: "%s %s%s --start-address=0x%016" PRIx64 " --stop-address=0x%016" PRIx64 " -d %s %s -C %s|grep -v %s|expand", -objdump_path ? objdump_path : "objdump", +objdump_path ? objdump_path : DEFAULT_OBJDUMP_PATH, disassembler_style ? "-M " : "", disassembler_style ? disassembler_style : "", map__rip_2objdump(map, sym->start), -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v2 4/4] perf tools: configure addr2line path at compile time
From: Irina Tirdea The default name for addr2line is hardcoded to "addr2line". When cross-compiling the name of addr2line will be different (e.g. arm-eabi-addr2line in Android). Sett the default addr2line name in the Makefile with DEFAULT_ADDR2LINE_PATH. Signed-off-by: Irina Tirdea --- tools/perf/Makefile|6 +- tools/perf/util/annotate.c |3 ++- tools/perf/util/sort.c |2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 7a3f572..745d12b 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -141,6 +141,7 @@ endif lib = lib PERF_TMP_DIR = /tmp OBJDUMP = $(CROSS_COMPILE)objdump +ADDR2LINE = $(CROSS_COMPILE)addr2line export prefix bindir sharedir sysconfdir @@ -885,7 +886,7 @@ $(OUTPUT)util/exec_cmd.o: util/exec_cmd.c $(OUTPUT)PERF-CFLAGS $< $(OUTPUT)util/annotate.o: util/annotate.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DDEFAULT_OBJDUMP_PATH='"$(OBJDUMP)"' $< + $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DDEFAULT_OBJDUMP_PATH='"$(OBJDUMP)"' -DDEFAULT_ADDR2LINE_PATH='"$(ADDR2LIN)"' $< $(OUTPUT)util/config.o: util/config.c $(OUTPUT)PERF-CFLAGS $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $< @@ -896,6 +897,9 @@ $(OUTPUT)util/dso-test-data.o: util/dso-test-data.c $(OUTPUT)PERF-CFLAGS $(OUTPUT)util/map.o: util/map.c $(OUTPUT)PERF-CFLAGS $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DPERF_TMP_DIR='"$(PERF_TMP_DIR)"' $< +$(OUTPUT)util/sort.o: util/sort.c $(OUTPUT)PERF-CFLAGS + $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DDEFAULT_ADDR2LINE_PATH='"$(addr2line)"' $< + $(OUTPUT)util/symbol.o: util/symbol.c $(OUTPUT)PERF-CFLAGS $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DPERF_TMP_DIR='"$(PERF_TMP_DIR)"' $< diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index d7036b3..7734a03 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -915,7 +915,8 @@ static int symbol__get_source_line(struct symbol *sym, struct map *map, continue; offset = start + i; - sprintf(cmd, "addr2line -e %s %016" PRIx64, filename, offset); + sprintf(cmd, DEFAULT_ADDR2LINE_PATH " -e %s %016" PRIx64, + filename, offset); fp = popen(cmd, "r"); if (!fp) continue; diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index b5b1b92..357dfc8 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -260,7 +260,7 @@ static int hist_entry__srcline_snprintf(struct hist_entry *self, char *bf, if (path != NULL) goto out_path; - snprintf(cmd, sizeof(cmd), "addr2line -e %s %016" PRIx64, + snprintf(cmd, sizeof(cmd), DEFAULT_ADDR2LINE_PATH " -e %s %016" PRIx64, self->ms.map->dso->long_name, self->ip); fp = popen(cmd, "r"); if (!fp) -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v3 4/4] perf tools: configure addr2line path at compile time
From: Irina Tirdea The default name for addr2line is hardcoded to "addr2line". When cross-compiling the name of addr2line will be different (e.g. arm-eabi-addr2line in Android). Set the default addr2line name in the Makefile with DEFAULT_ADDR2LINE_PATH. Signed-off-by: Irina Tirdea --- Changes in v3: () Fixed typo in commit message. tools/perf/Makefile|6 +- tools/perf/util/annotate.c |3 ++- tools/perf/util/sort.c |2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 7a3f572..745d12b 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -141,6 +141,7 @@ endif lib = lib PERF_TMP_DIR = /tmp OBJDUMP = $(CROSS_COMPILE)objdump +ADDR2LINE = $(CROSS_COMPILE)addr2line export prefix bindir sharedir sysconfdir @@ -885,7 +886,7 @@ $(OUTPUT)util/exec_cmd.o: util/exec_cmd.c $(OUTPUT)PERF-CFLAGS $< $(OUTPUT)util/annotate.o: util/annotate.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DDEFAULT_OBJDUMP_PATH='"$(OBJDUMP)"' $< + $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DDEFAULT_OBJDUMP_PATH='"$(OBJDUMP)"' -DDEFAULT_ADDR2LINE_PATH='"$(ADDR2LIN)"' $< $(OUTPUT)util/config.o: util/config.c $(OUTPUT)PERF-CFLAGS $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $< @@ -896,6 +897,9 @@ $(OUTPUT)util/dso-test-data.o: util/dso-test-data.c $(OUTPUT)PERF-CFLAGS $(OUTPUT)util/map.o: util/map.c $(OUTPUT)PERF-CFLAGS $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DPERF_TMP_DIR='"$(PERF_TMP_DIR)"' $< +$(OUTPUT)util/sort.o: util/sort.c $(OUTPUT)PERF-CFLAGS + $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DDEFAULT_ADDR2LINE_PATH='"$(addr2line)"' $< + $(OUTPUT)util/symbol.o: util/symbol.c $(OUTPUT)PERF-CFLAGS $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DPERF_TMP_DIR='"$(PERF_TMP_DIR)"' $< diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index d7036b3..7734a03 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -915,7 +915,8 @@ static int symbol__get_source_line(struct symbol *sym, struct map *map, continue; offset = start + i; - sprintf(cmd, "addr2line -e %s %016" PRIx64, filename, offset); + sprintf(cmd, DEFAULT_ADDR2LINE_PATH " -e %s %016" PRIx64, + filename, offset); fp = popen(cmd, "r"); if (!fp) continue; diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index b5b1b92..357dfc8 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -260,7 +260,7 @@ static int hist_entry__srcline_snprintf(struct hist_entry *self, char *bf, if (path != NULL) goto out_path; - snprintf(cmd, sizeof(cmd), "addr2line -e %s %016" PRIx64, + snprintf(cmd, sizeof(cmd), DEFAULT_ADDR2LINE_PATH " -e %s %016" PRIx64, self->ms.map->dso->long_name, self->ip); fp = popen(cmd, "r"); if (!fp) -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v2 1/1] perf stat: implement --big-num grouping
From: Irina Tirdea In glibc, printf supports ' to group numbers with thousands' grouping characters. Bionic does not support ' for printf. Implement thousands's grouping for numbers according to locale. The implementation uses the algorithm from glibc (http://www.gnu.org/software/libc/). Bionic does not implement locales, so we need to add a configuration option NO_LOCALE. If NO_LOCALE is defined, default values for thousands separator and grouping are used. Signed-off-by: Irina Tirdea --- Changes in v2: This is a rewrite of http://lkml.org/lkml/2012/9/13/574 Instead of disabling big num for Android, I added the implementation in perf (as Ingo suggested). tools/perf/Makefile |8 +++ tools/perf/builtin-stat.c | 112 --- tools/perf/config/feature-tests.mak | 18 ++ 3 files changed, 131 insertions(+), 7 deletions(-) diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 5077f8e..74e21cf 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -769,6 +769,14 @@ else endif endif +ifdef NO_LOCALE + BASIC_CFLAGS += -DNO_LOCALE +else + ifneq ($(call try-cc,$(SOURCE_LOCALE),),y) + BASIC_CFLAGS += -DNO_LOCALE + endif +endif + ifdef ASCIIDOC8 export ASCIIDOC8 endif diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index e0f65fe..cb8b399 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -60,6 +60,8 @@ #include #include +/* max double number have E+308 + \0 + sign */ +#define MAX_NR_STR 310 #define DEFAULT_SEPARATOR " " #define CNTR_NOT_SUPPORTED "" #define CNTR_NOT_COUNTED "" @@ -744,18 +746,112 @@ static void print_ll_cache_misses(int cpu, fprintf(output, " of all LL-cache hits "); } +/* Group the digits according to the grouping rules of the current locale. + The interpretation of GROUPING is as in `struct lconv' from . */ +static int group_number_locale(char *number, char **gnumber) +{ + const char *thousands_sep = NULL, *grouping = NULL; + int glen, tlen, dest_alloc_size, src_size, ret = 0, cnt; + char *dest_alloc_ptr, *dest_end, *src_start, *src_end; + +#ifdef NO_LOCALE + thousands_sep = ","; + grouping = "\x3"; +#else + struct lconv *lc = localeconv(); + if (lc != NULL) { + thousands_sep = lc->thousands_sep; + grouping = lc->grouping; + } +#endif + + *gnumber = NULL; + /* No grouping */ + if (thousands_sep == NULL || grouping == NULL || + *thousands_sep == '\0' || *grouping == CHAR_MAX || *grouping <= 0) { + *gnumber = strdup(number); + if (*gnumber == NULL) + ret = -ENOMEM; + goto out; + } + + glen = *grouping++; + tlen = strlen(thousands_sep); + + src_size = strlen(number); + /* Worst case scenario we have 1-character grouping */ + dest_alloc_size = (src_size + src_size * tlen) * sizeof(char); + dest_alloc_ptr = zalloc(dest_alloc_size); + if (dest_alloc_ptr == NULL) { + ret = -ENOMEM; + goto out; + } + /* -1 for '\0' */ + dest_end = dest_alloc_ptr + dest_alloc_size - 1; + + src_start = number; + src_end = number + src_size; + + while (src_end > src_start) { + *--dest_end = *--src_end; + if (--glen == 0 && src_end > src_start) { + /* A new group */ + cnt = tlen; + do + *--dest_end = thousands_sep[--cnt]; + while (cnt > 0); + + if (*grouping == CHAR_MAX || *grouping < 0) { + /* No further grouping to be done. + Copy the rest of the number. */ + do + *--dest_end = *--src_end; + while (src_end > src_start); + break; + } else if (*grouping != '\0') { + glen = *grouping++; + } else { + /* The previous grouping repeats ad infinitum */ + glen = grouping[-1]; + } + } + } + + /* Make a copy with the exact needed size of the grouped number */ + *gnumber = strdup(dest_end); + if (*gnumber == NULL) { + ret = -ENOMEM; + goto out_free_dest; + } + + /* fall through */ +out_free_dest: + free(dest_alloc_ptr); +out: + return ret; +} + static void abs_printout(int cpu, struct perf_evsel *ev
Re: [PATCH 11/13] perf tools: replace mempcpy with memcpy
> > Can you resubmit this in txt form? I applied some other patches from you > but you need to try to do it yourself, i.e. send just to you, then try > to save the patch and apply it... Sorry about this... I will check this myself from now on. I've seen you already merged this one, but I'll resubmit the others and make sure they apply properly. Thanks, Irina -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v2 00/12] Porting perf to Android
This is version 2 for the patches to port perf to Android. With these patches perf compiles on latest Android tree (JellyBean). The patches are on top of current perf/core branch of the tip tree. Changes for v2: () dropped the patch that replaced on_exit with at_exit. A better solution is the one in Bernhard's patch [1] () dropped one patch and removed unecessary code from patch 02 after the removal of unneeded network header files [2] () added two more patches in order to build perf in Android (patches 10 and 11) () fixed whitespace anc checkpatch issues for patch 12 () make sure all patches are in txt form and will apply properly [1] https://lkml.org/lkml/2012/8/23/316 [2] https://lkml.org/lkml/2012/8/29/150 Irina Tirdea (12): perf tools: include wrapper for magic.h perf tools: update types definitions for Android perf tools: include __WORDSIZE definition perf tools: fix ALIGN redefinition in system headers perf tools: include basename for non-glibc systems perf tools: fix missing winsize definition perf tools: include missing pthread.h header perf tools: fix no return in non-void function perf tools: replace mkostemp with mkstemp tools lib traceevent: replace mempcpy with memcpy perf tools: add NO_BACKTRACE for application self-debugging perf tools: Use __maybe_used for unused variables tools/lib/traceevent/event-parse.c | 12 ++- tools/lib/traceevent/event-parse.h |4 +- tools/perf/Makefile|9 ++ tools/perf/bench/bench.h |3 +- tools/perf/bench/mem-memcpy.c |2 +- tools/perf/bench/mem-memset.c |2 +- tools/perf/bench/sched-messaging.c |2 +- tools/perf/bench/sched-pipe.c |4 +- tools/perf/builtin-annotate.c |2 +- tools/perf/builtin-bench.c |2 +- tools/perf/builtin-buildid-cache.c |7 +- tools/perf/builtin-buildid-list.c |3 +- tools/perf/builtin-diff.c |4 +- tools/perf/builtin-evlist.c|2 +- tools/perf/builtin-help.c |2 +- tools/perf/builtin-inject.c| 24 +++-- tools/perf/builtin-kmem.c | 22 ++-- tools/perf/builtin-kvm.c |2 +- tools/perf/builtin-list.c |2 +- tools/perf/builtin-lock.c |4 +- tools/perf/builtin-probe.c | 24 ++--- tools/perf/builtin-record.c| 10 +- tools/perf/builtin-report.c| 11 +- tools/perf/builtin-sched.c | 69 +++-- tools/perf/builtin-script.c| 29 +++--- tools/perf/builtin-stat.c | 40 --- tools/perf/builtin-test.c |9 +- tools/perf/builtin-timechart.c | 30 +++--- tools/perf/builtin-top.c |7 +- tools/perf/config/feature-tests.mak| 14 +++ tools/perf/perf.c |1 + tools/perf/ui/browser.c|7 +- tools/perf/ui/browsers/annotate.c |6 +- tools/perf/ui/gtk/browser.c|5 +- tools/perf/ui/gtk/setup.c |2 +- tools/perf/ui/gtk/util.c |4 +- tools/perf/ui/helpline.c |2 +- tools/perf/ui/helpline.h |8 +- tools/perf/ui/tui/setup.c |4 +- tools/perf/util/alias.c|3 +- tools/perf/util/annotate.c |6 +- tools/perf/util/annotate.h | 14 +-- tools/perf/util/build-id.c | 11 +- tools/perf/util/cache.h|6 +- tools/perf/util/callchain.c|6 +- tools/perf/util/cgroup.c |4 +- tools/perf/util/config.c |6 +- tools/perf/util/debug.h|9 +- tools/perf/util/dso-test-data.c|2 +- tools/perf/util/event.c| 29 +++--- tools/perf/util/event.h|2 +- tools/perf/util/header.c | 109 +++- tools/perf/util/help.c |4 +- tools/perf/util/hist.c |2 +- tools/perf/util/hist.h | 32 +++--- tools/perf/util/include/linux/bitops.h |9 ++ tools/perf/util/include/linux/compiler.h |8 +- tools/perf/util/include/linux/kernel.h |
[PATCH v2 01/12] perf tools: include wrapper for magic.h
From: Irina Tirdea perf is currently including magic.h directly from the kernel. If the glibc magic.h is also included, this leads to warnings that the constants are redefined. This happens on some systems (e.g. Android). Redefinition errors on Android: In file included from util/util.h:79:0, from util/cache.h:5, from util/abspath.c:1: util/../../../include/linux/magic.h:5:0: error: "AFFS_SUPER_MAGIC" redefined [-Werror] bionic/libc/include/sys/vfs.h:53:0: note: this is the location of the previous definition util/../../../include/linux/magic.h:19:0: error: "EFS_SUPER_MAGIC" redefined [-Werror] bionic/libc/include/sys/vfs.h:61:0: note: this is the location of the previous definition util/../../../include/linux/magic.h:26:0: error: "HPFS_SUPER_MAGIC" redefined [-Werror] bionic/libc/include/sys/vfs.h:67:0: note: this is the location of the previous definition Only two constants from magic.h are used by perf (DEBUGFS_MAGIC and SYSFS_MAGIC). This fix provides a wrapper for magic.h that includes only these constants instead of including the kernel header file directly. Signed-off-by: Irina Tirdea --- tools/perf/Makefile |1 + tools/perf/util/include/linux/magic.h | 12 tools/perf/util/util.h|2 +- 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 tools/perf/util/include/linux/magic.h diff --git a/tools/perf/Makefile b/tools/perf/Makefile index afd5075..25d2bab 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -264,6 +264,7 @@ LIB_H += util/include/linux/ctype.h LIB_H += util/include/linux/kernel.h LIB_H += util/include/linux/list.h LIB_H += util/include/linux/export.h +LIB_H += util/include/linux/magic.h LIB_H += util/include/linux/poison.h LIB_H += util/include/linux/prefetch.h LIB_H += util/include/linux/rbtree.h diff --git a/tools/perf/util/include/linux/magic.h b/tools/perf/util/include/linux/magic.h new file mode 100644 index 000..58b64ed --- /dev/null +++ b/tools/perf/util/include/linux/magic.h @@ -0,0 +1,12 @@ +#ifndef _PERF_LINUX_MAGIC_H_ +#define _PERF_LINUX_MAGIC_H_ + +#ifndef DEBUGFS_MAGIC +#define DEBUGFS_MAGIC 0x64626720 +#endif + +#ifndef SYSFS_MAGIC +#define SYSFS_MAGIC0x62656572 +#endif + +#endif diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 67a3713..70fa70b 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -70,7 +70,7 @@ #include #include #include -#include "../../../include/linux/magic.h" +#include #include "types.h" #include -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v2 02/12] perf tools: update types definitions for Android
From: Irina Tirdea Some type definitions are missing from Android or are already defined in bionic and lead to redefinition errors. Android defines in types.h __le32. Since perf is wrapping with a local version, we need to define this constant in the local version too. Error in Android: In file included from bionic/libc/include/unistd.h:36:0, from external/perf/tools/perf/util/util.h:46, from external/perf/tools/perf/util/cache.h:5, from external/perf/tools/perf/util/abspath.c:1: bionic/libc/kernel/common/linux/capability.h:60:2: error: unknown type name '__le32' roundup() definition is missing: util/symbol.c: In function 'symbols__fixup_end': util/symbol.c:106: warning: implicit declaration of function 'roundup' util/symbol.c:106: warning: nested extern declaration of 'roundup' __force macro defined in perf is also defined in libc which leads to redefinition errors. In order to avoid these, we guard these definition with Signed-off-by: Irina Tirdea --- tools/perf/util/include/linux/compiler.h |4 tools/perf/util/include/linux/kernel.h |9 + tools/perf/util/include/linux/types.h|8 3 files changed, 21 insertions(+) diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h index 2dc8671..ce2367b 100644 --- a/tools/perf/util/include/linux/compiler.h +++ b/tools/perf/util/include/linux/compiler.h @@ -12,4 +12,8 @@ #define __used __attribute__((__unused__)) #define __packed __attribute__((__packed__)) +#ifndef __force +#define __force +#endif + #endif diff --git a/tools/perf/util/include/linux/kernel.h b/tools/perf/util/include/linux/kernel.h index b6842c1..466b51a 100644 --- a/tools/perf/util/include/linux/kernel.h +++ b/tools/perf/util/include/linux/kernel.h @@ -46,6 +46,15 @@ _min1 < _min2 ? _min1 : _min2; }) #endif +#ifndef roundup +#define roundup(x, y) (\ +{ \ + const typeof(y) __y = y; \ + (((x) + (__y - 1)) / __y) * __y; \ +} \ +) +#endif + #ifndef BUG_ON #define BUG_ON(cond) assert(!(cond)) #endif diff --git a/tools/perf/util/include/linux/types.h b/tools/perf/util/include/linux/types.h index 12de3b8..eb46478 100644 --- a/tools/perf/util/include/linux/types.h +++ b/tools/perf/util/include/linux/types.h @@ -3,6 +3,14 @@ #include +#ifndef __bitwise +#define __bitwise +#endif + +#ifndef __le32 +typedef __u32 __bitwise __le32; +#endif + #define DECLARE_BITMAP(name,bits) \ unsigned long name[BITS_TO_LONGS(bits)] -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v2 03/12] perf tools: include __WORDSIZE definition
From: Irina Tirdea __WORDSIZE is GLibC-specific and is not defined on all systems or glibc versions (e.g. Android's bionic does not define it). In file included from util/include/linux/bitmap.h:5:0, from util/header.h:10, from util/session.h:6, from util/build-id.h:4, from util/annotate.c:11: util/include/linux/bitops.h: In function 'set_bit': util/include/linux/bitops.h:25:12: error: '__WORDSIZE' undeclared (first use in this function) util/include/linux/bitops.h:25:12: note: each undeclared identifier is reported only once for each function it appears in util/include/linux/bitops.h:23:51: error: parameter 'addr' set but not used [-Werror=unused-but-set-parameter] util/include/linux/bitops.h: In function 'clear_bit': util/include/linux/bitops.h:30:12: error: '__WORDSIZE' undeclared (first use in this function) util/include/linux/bitops.h:28:53: error: parameter 'addr' set but not used [-Werror=unused-but-set-parameter] In file included from util/header.h:10:0, from util/session.h:6, from util/build-id.h:4, from util/annotate.c:11: util/include/linux/bitmap.h: In function 'bitmap_zero': util/include/linux/bitmap.h:22:6: error: '__WORDSIZE' undeclared (first use in this function) Defining __WORDSIZE in perf's headers if it is not already defined. Signed-off-by: Irina Tirdea --- tools/perf/util/include/linux/bitops.h |9 + 1 file changed, 9 insertions(+) diff --git a/tools/perf/util/include/linux/bitops.h b/tools/perf/util/include/linux/bitops.h index 587a230..91779ec 100644 --- a/tools/perf/util/include/linux/bitops.h +++ b/tools/perf/util/include/linux/bitops.h @@ -5,6 +5,15 @@ #include #include +#ifndef __WORDSIZE +#if defined(__x86_64__) +# define __WORDSIZE 64 +#endif +#if defined(__i386__) || defined(__arm__) +# define __WORDSIZE 32 +#endif +#endif + #define BITS_PER_LONG __WORDSIZE #define BITS_PER_BYTE 8 #define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v2 05/12] perf tools: include basename for non-glibc systems
From: Irina Tirdea perf uses the glibc version of basename(), by defining _GNU_SOURCE, including string.h and not including libgen.h. The glibc version of basename is better than the POSIX version since it does not modify its argument. Android has only one version of basename which is defined in libgen.h. This version is the same as the glibc version. Error on Android: util/annotate.c: In function 'symbol__annotate_printf': util/annotate.c:503:3: error: implicit declaration of function 'basename' [-Werror=implicit-function-declaration] util/annotate.c:503:3: error: nested extern declaration of 'basename' [-Werror=nested-externs] util/annotate.c:503:14: error: assignment makes pointer from integer without a cast [-Werror] On Android libgen.h should be included to define basename. Signed-off-by: Irina Tirdea --- tools/perf/util/symbol.h |3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index fc4b1e6..d3b330c 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h @@ -10,6 +10,9 @@ #include #include #include +#if defined(__BIONIC__) +#include +#endif #ifndef NO_LIBELF_SUPPORT #include -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v2 07/12] perf tools: include missing pthread.h header
From: Irina Tirdea pthread variables are used in some files without explicitely including pthread.h. This leads to compile errors on Android. e.g.: in annotate.h, error: unknown type name 'pthread_mutex_t' Including pthread.h explicitely in files that use it to have all definitions included. Signed-off-by: Irina Tirdea --- tools/perf/perf.c |1 + tools/perf/util/annotate.h |1 + 2 files changed, 2 insertions(+) diff --git a/tools/perf/perf.c b/tools/perf/perf.c index e7840e5..fb8578c 100644 --- a/tools/perf/perf.c +++ b/tools/perf/perf.c @@ -14,6 +14,7 @@ #include "util/run-command.h" #include "util/parse-events.h" #include "util/debugfs.h" +#include const char perf_usage_string[] = "perf [--version] [--help] COMMAND [ARGS]"; diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index a6d6bc5..62a6e7a 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h @@ -7,6 +7,7 @@ #include "symbol.h" #include #include +#include struct ins; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v2 08/12] perf tools: fix no return in non-void function
From: Irina Tirdea thread_func in builtin-sched.c has an internal loop and never returns. The only return from this thread are BUG_ON calls in case return values are not 0. The compiler on Android complains that the function needs to return a non-void value. Adding the noreturn function attribute to fix this error. Error in Android: target C: perf <= builtin-sched.c hardware/intel/linu/tools/perf/builtin-sched.c: In function 'thread_func': hardware/intel/linux/tools/perf/builtin-sched.c:476: error: no return statement in function returning non-void Signed-off-by: Irina Tirdea --- tools/perf/builtin-sched.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index a25a023..1fecc95 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -439,7 +439,7 @@ static u64 get_cpu_usage_nsec_self(int fd) return runtime; } -static void *thread_func(void *ctx) +static __attribute__ ((noreturn)) void *thread_func(void *ctx) { struct task_desc *this_task = ctx; u64 cpu_usage_0, cpu_usage_1; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v2 10/12] tools lib traceevent: replace mempcpy with memcpy
From: Irina Tirdea mempcpy is not supported by bionic in Android and will lead to compilation errors. Replacing mempcpy with memcpy so it will work in Android. Signed-off-by: Irina Tirdea --- tools/lib/traceevent/event-parse.c |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c index b5b4d80..c848fc3 100644 --- a/tools/lib/traceevent/event-parse.c +++ b/tools/lib/traceevent/event-parse.c @@ -4812,8 +4812,8 @@ int pevent_strerror(struct pevent *pevent, enum pevent_errno errnum, msg = strerror_r(errnum, buf, buflen); if (msg != buf) { size_t len = strlen(msg); - char *c = mempcpy(buf, msg, min(buflen-1, len)); - *c = '\0'; + memcpy(buf, msg, min(buflen - 1, len)); + *(buf + min(buflen - 1, len)) = '\0'; } return 0; } -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v2 11/12] perf tools: add NO_BACKTRACE for application self-debugging
From: Irina Tirdea perf has support for self-debugging by defining dump_stack function. This function uses backtrace and backtrace_symbols functions defined as GNU extensions. In Android, bionic does not offer support for these functions and compilation will fail with the following error: target C: libperf <= tools/perf/util/util.c tools/perf/util/util.c:4:22: fatal error: execinfo.h: No such file or directory compilation terminated. Add a compile-time option (NO_BACKTRACE) to enable or disable self-debugging functionality in perf. This can also help in debugging since it offers the possibility to turn on/off printing the backtrace. Signed-off-by: Irina Tirdea --- tools/perf/Makefile |8 tools/perf/config/feature-tests.mak | 14 ++ tools/perf/util/util.c |6 ++ 3 files changed, 28 insertions(+) diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 25d2bab..c0d2ce3 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -756,6 +756,14 @@ else endif endif +ifdef NO_BACKTRACE + BASIC_CFLAGS += -DNO_BACKTRACE +else + ifneq ($(call try-cc,$(SOURCE_BACKTRACE),),y) + BASIC_CFLAGS += -DNO_BACKTRACE + endif +endif + ifdef ASCIIDOC8 export ASCIIDOC8 endif diff --git a/tools/perf/config/feature-tests.mak b/tools/perf/config/feature-tests.mak index 2f1156a..116690a 100644 --- a/tools/perf/config/feature-tests.mak +++ b/tools/perf/config/feature-tests.mak @@ -179,3 +179,17 @@ int main(void) } endef endif + +ifndef NO_BACKTRACE +define SOURCE_BACKTRACE +#include +#include + +int main(void) +{ + backtrace(NULL, 0); + backtrace_symbols(NULL, 0); + return 0; +} +endef +endif diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index 1b8775c..2055cf3 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c @@ -1,7 +1,9 @@ #include "../perf.h" #include "util.h" #include +#ifndef NO_BACKTRACE #include +#endif #include #include @@ -163,6 +165,7 @@ size_t hex_width(u64 v) } /* Obtain a backtrace and print it to stdout. */ +#ifndef NO_BACKTRACE void dump_stack(void) { void *array[16]; @@ -177,3 +180,6 @@ void dump_stack(void) free(strings); } +#else +void dump_stack(void) {} +#endif -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v2 09/12] perf tools: replace mkostemp with mkstemp
From: Irina Tirdea mkostemp is only available in glibc. This leads to compile error in Android, since bionic is derived from BSD. Replacing mkostemp with mkstemp. mkstemp is available on both glibc and bionic. Signed-off-by: Irina Tirdea --- tools/perf/util/dso-test-data.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/dso-test-data.c b/tools/perf/util/dso-test-data.c index 541cdc7..c6caede 100644 --- a/tools/perf/util/dso-test-data.c +++ b/tools/perf/util/dso-test-data.c @@ -23,7 +23,7 @@ static char *test_file(int size) int fd, i; unsigned char *buf; - fd = mkostemp(templ, O_CREAT|O_WRONLY|O_TRUNC); + fd = mkstemp(templ); buf = malloc(size); if (!buf) { -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v2 06/12] perf tools: fix missing winsize definition
From: Irina Tirdea In Android, struct winsize is not defined in the headers already included in help.c. This leads to a compile error. Including termios.h fixes the compilation error since it defines struct winsize. Signed-off-by: Irina Tirdea --- tools/perf/util/help.c |1 + tools/perf/util/top.h |1 + 2 files changed, 2 insertions(+) diff --git a/tools/perf/util/help.c b/tools/perf/util/help.c index 6f2975a..4fa764d 100644 --- a/tools/perf/util/help.c +++ b/tools/perf/util/help.c @@ -3,6 +3,7 @@ #include "exec_cmd.h" #include "levenshtein.h" #include "help.h" +#include void add_cmdname(struct cmdnames *cmds, const char *name, size_t len) { diff --git a/tools/perf/util/top.h b/tools/perf/util/top.h index 33347ca..86ff1b1 100644 --- a/tools/perf/util/top.h +++ b/tools/perf/util/top.h @@ -5,6 +5,7 @@ #include "types.h" #include #include +#include struct perf_evlist; struct perf_evsel; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v2 04/12] perf tools: fix ALIGN redefinition in system headers
From: Irina Tirdea On some systems (e.g. Android), ALIGN is defined in system headers as ALIGN(p). The definition of ALIGN used in perf takes 2 parameters: ALIGN(x,a). This leads to redefinition conflicts. Redefinition error on Android: In file included from util/include/linux/list.h:1:0, from util/callchain.h:5, from util/hist.h:6, from util/session.h:4, from util/build-id.h:4, from util/annotate.c:11: util/include/linux/kernel.h:11:0: error: "ALIGN" redefined [-Werror] bionic/libc/include/sys/param.h:38:0: note: this is the location of the previous definition Conflics with system defined ALIGN in Android: util/event.c: In function 'perf_event__synthesize_comm': util/event.c:115:32: error: macro "ALIGN" passed 2 arguments, but takes just 1 util/event.c:115:9: error: 'ALIGN' undeclared (first use in this function) util/event.c:115:9: note: each undeclared identifier is reported only once for each function it appears in In order to avoid this redefinition, ALIGN is renamed to PERF_ALIGN. Signed-off-by: Irina Tirdea --- tools/perf/util/event.c| 10 +- tools/perf/util/event.h|2 +- tools/perf/util/header.c | 16 tools/perf/util/include/linux/kernel.h |4 ++-- tools/perf/util/session.c |4 ++-- tools/perf/util/symbol.c |2 +- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 84ff6f16..f7f4805 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -112,7 +112,7 @@ static pid_t perf_event__synthesize_comm(struct perf_tool *tool, event->comm.header.type = PERF_RECORD_COMM; size = strlen(event->comm.comm) + 1; - size = ALIGN(size, sizeof(u64)); + size = PERF_ALIGN(size, sizeof(u64)); memset(event->comm.comm + size, 0, machine->id_hdr_size); event->comm.header.size = (sizeof(event->comm) - (sizeof(event->comm.comm) - size) + @@ -145,7 +145,7 @@ static pid_t perf_event__synthesize_comm(struct perf_tool *tool, sizeof(event->comm.comm)); size = strlen(event->comm.comm) + 1; - size = ALIGN(size, sizeof(u64)); + size = PERF_ALIGN(size, sizeof(u64)); memset(event->comm.comm + size, 0, machine->id_hdr_size); event->comm.header.size = (sizeof(event->comm) - (sizeof(event->comm.comm) - size) + @@ -228,7 +228,7 @@ static int perf_event__synthesize_mmap_events(struct perf_tool *tool, size = strlen(execname); execname[size - 1] = '\0'; /* Remove \n */ memcpy(event->mmap.filename, execname, size); - size = ALIGN(size, sizeof(u64)); + size = PERF_ALIGN(size, sizeof(u64)); event->mmap.len -= event->mmap.start; event->mmap.header.size = (sizeof(event->mmap) - (sizeof(event->mmap.filename) - size)); @@ -282,7 +282,7 @@ int perf_event__synthesize_modules(struct perf_tool *tool, if (pos->dso->kernel) continue; - size = ALIGN(pos->dso->long_name_len + 1, sizeof(u64)); + size = PERF_ALIGN(pos->dso->long_name_len + 1, sizeof(u64)); event->mmap.header.type = PERF_RECORD_MMAP; event->mmap.header.size = (sizeof(event->mmap) - (sizeof(event->mmap.filename) - size)); @@ -494,7 +494,7 @@ int perf_event__synthesize_kernel_mmap(struct perf_tool *tool, map = machine->vmlinux_maps[MAP__FUNCTION]; size = snprintf(event->mmap.filename, sizeof(event->mmap.filename), "%s%s", mmap_name, symbol_name) + 1; - size = ALIGN(size, sizeof(u64)); + size = PERF_ALIGN(size, sizeof(u64)); event->mmap.header.type = PERF_RECORD_MMAP; event->mmap.header.size = (sizeof(event->mmap) - (sizeof(event->mmap.filename) - size) + machine->id_hdr_size); diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index 0e088d0..21b99e7 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h @@ -101,7 +101,7 @@ struct perf_sample { struct build_id_event { struct perf_event_header header; pid_tpid; - u8 build_id[ALIGN(BUILD_ID_SIZE, sizeof(u64))]; + u8 build_id[PERF_ALIGN(BUILD_ID_SIZE, sizeof(u64))]; char filename[]; }; diff --git a/tools/perf/util/header.c b/tools/perf/ut
Re: [PATCH] perf bench: fix assert when NDEBUG is defined
> Its valid (although admittedly dubious) to have BUG_ON with > side-effects. > > The 'right' fix would be something like: > > --- > #ifndef BUG_ON > +#ifdef NDEBUG > +#define BUG_ON(cond) do { if (cond) ; } while (0) > +#else > #define BUG_ON(cond) assert(!(cond)) > #endif > +#endif > This is indeed the right fix. I will use this approach, test it and resubmit. Thanks, Irina -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v3] perf bench: fix assert when NDEBUG is defined
From: Irina Tirdea When NDEBUG is defined, the assert macro will be expanded to nothing. Some assert calls used in perf are also including some functionality (e.g. system calls), not only validity checks. Therefore, if NDEBUG is defined, this functionality will be removed along with the assert. Perf also defines BUG_ON based on assert, so it has the same problem. Define BUG_ON so that the condition will be executed when NDEBUG is defined. Replace the assert statements that have these side effects with BUG_ON. For defining BUG_ON, use "if (cond) {}" insted of "if (cond) ;" because in the latter case build fails with "error: suggest braces around empty body in an ‘if’ statement [-Werror=empty-body]" Suggested-by: Peter Zijlstra Signed-off-by: Irina Tirdea --- Changes in v3: () ammend commit message with Suggested-by line Changes in v2: () redefine BUG_ON for NDEBUG instead of avoiding side-effects () replace assert with BUG_ON v1 change: () https://lkml.org/lkml/2012/9/2/189 tools/perf/bench/sched-pipe.c |6 +++--- tools/perf/util/include/linux/kernel.h |4 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/perf/bench/sched-pipe.c b/tools/perf/bench/sched-pipe.c index 0c7454f..15911e9 100644 --- a/tools/perf/bench/sched-pipe.c +++ b/tools/perf/bench/sched-pipe.c @@ -56,13 +56,13 @@ int bench_sched_pipe(int argc, const char **argv, * causes error in building environment for perf */ int __used ret, wait_stat; - pid_t pid, retpid; + pid_t pid, retpid __used; argc = parse_options(argc, argv, options, bench_sched_pipe_usage, 0); - assert(!pipe(pipe_1)); - assert(!pipe(pipe_2)); + BUG_ON(pipe(pipe_1)); + BUG_ON(pipe(pipe_2)); pid = fork(); assert(pid >= 0); diff --git a/tools/perf/util/include/linux/kernel.h b/tools/perf/util/include/linux/kernel.h index b6842c1..4af9a10 100644 --- a/tools/perf/util/include/linux/kernel.h +++ b/tools/perf/util/include/linux/kernel.h @@ -47,8 +47,12 @@ #endif #ifndef BUG_ON +#ifdef NDEBUG +#define BUG_ON(cond) do { if (cond) {} } while (0) +#else #define BUG_ON(cond) assert(!(cond)) #endif +#endif /* * Both need more care to handle endianness -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v2 03/12] perf tools: include __WORDSIZE definition
>> +#ifndef __WORDSIZE >> +#if defined(__x86_64__) >> +# define __WORDSIZE 64 >> +#endif >> +#if defined(__i386__) || defined(__arm__) >> +# define __WORDSIZE 32 >> +#endif >> +#endif > > Why not use "sizeof(unsigned long) * 8" ? I tried to do it this, but the compilation crashes because this value is tested in an #if: target C: libperf <= tools/perf/util/annotate.c In file included from tools/perf/util/include/linux/bitmap.h:5:0, from tools/perf/util/header.h:10, from tools/perf/util/session.h:6, from tools/perf/util/build-id.h:4, from tools/perf/util/annotate.c:11: tools/perf/util/include/linux/bitops.h: In function '__ffs': tools/perf/util/include/linux/bitops.h:62:5: warning: "sizeof" is not defined [-Wundef] tools/perf/util/include/linux/bitops.h:62:5: error: missing binary operator before token "(" Thanks, Irina -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 0/3] perf tool: basename cleanups
> Irina: Would you verify perf still compiles cleanly for Android. Thanks. > With these 3 patches perf still compiles cleanly for Android. Thanks for making the changes. Irina -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v2 01/12] perf tools: include wrapper for magic.h
On Sat, Sep 8, 2012 at 12:13 PM, Pekka Enberg wrote: > Hi Irina, > Hi Pekka, > I commented on some of the patches but overall, I think the series makes > sense: > > Acked-by: Pekka Enberg Thanks for reviewing it! Irina -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v2 03/12] perf tools: include __WORDSIZE definition
On Mon, Sep 10, 2012 at 5:44 PM, Peter Zijlstra wrote: > On Sun, 2012-09-09 at 01:19 +0300, Irina Tirdea wrote: >> >> +#ifndef __WORDSIZE >> >> +#if defined(__x86_64__) >> >> +# define __WORDSIZE 64 >> >> +#endif >> >> +#if defined(__i386__) || defined(__arm__) >> >> +# define __WORDSIZE 32 >> >> +#endif >> >> +#endif >> > >> > Why not use "sizeof(unsigned long) * 8" ? >> >> I tried to do it this, but the compilation crashes because this value >> is tested in an #if: >> >> target C: libperf <= tools/perf/util/annotate.c >> In file included from tools/perf/util/include/linux/bitmap.h:5:0, >> from tools/perf/util/header.h:10, >> from tools/perf/util/session.h:6, >> from tools/perf/util/build-id.h:4, >> from tools/perf/util/annotate.c:11: >> tools/perf/util/include/linux/bitops.h: In function '__ffs': >> tools/perf/util/include/linux/bitops.h:62:5: warning: "sizeof" is not >> defined [-Wundef] >> tools/perf/util/include/linux/bitops.h:62:5: error: missing binary >> operator before token "(" > > Use either: __SIZEOF_LONG__ (8) or __LP64__ (1) Thanks! Using __SIZEOF_LONG__ works. I'll update the patch. Thanks, Irina -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v3 0/6] Porting perf to Android
This is version 3 for the patches to port perf to Android. The patches are on top of current perf/core branch of the tip tree. Changes for v3: () update patch 3 according to suggestions from Pekka and Peter () update patch 6 to replace __used definitions from newly merged code () add ack from Pekka Changes for v2: () dropped the patch that replaced on_exit with at_exit. A better solution is the one in Bernhard's patch [1] () dropped one patch and removed unecessary code from patch 02 after the removal of unneeded network header files [2] () added two more patches in order to build perf in Android (patches 10 and 11) () fixed whitespace anc checkpatch issues for patch 12 () make sure all patches are in txt form and will apply properly [1] https://lkml.org/lkml/2012/8/23/316 [2] https://lkml.org/lkml/2012/8/29/150 Irina Tirdea (6): perf tools: include wrapper for magic.h perf tools: update types definitions for Android perf tools: include __WORDSIZE definition perf tools: fix ALIGN redefinition in system headers perf tools: fix no return in non-void function perf tools: Use __maybe_used for unused variables tools/lib/traceevent/event-parse.c |8 +- tools/lib/traceevent/event-parse.h |4 +- tools/perf/Makefile|1 + tools/perf/bench/bench.h |3 +- tools/perf/bench/mem-memcpy.c |2 +- tools/perf/bench/mem-memset.c |2 +- tools/perf/bench/sched-messaging.c |2 +- tools/perf/bench/sched-pipe.c |6 +- tools/perf/builtin-annotate.c |2 +- tools/perf/builtin-bench.c |2 +- tools/perf/builtin-buildid-cache.c |7 +- tools/perf/builtin-buildid-list.c |3 +- tools/perf/builtin-diff.c |4 +- tools/perf/builtin-evlist.c|2 +- tools/perf/builtin-help.c |2 +- tools/perf/builtin-inject.c| 24 +++-- tools/perf/builtin-kmem.c | 22 ++-- tools/perf/builtin-kvm.c |2 +- tools/perf/builtin-list.c |2 +- tools/perf/builtin-lock.c |4 +- tools/perf/builtin-probe.c | 24 ++--- tools/perf/builtin-record.c| 10 +- tools/perf/builtin-report.c| 11 +- tools/perf/builtin-sched.c | 69 +++-- tools/perf/builtin-script.c| 29 +++--- tools/perf/builtin-stat.c | 40 --- tools/perf/builtin-test.c |9 +- tools/perf/builtin-timechart.c | 30 +++--- tools/perf/builtin-top.c |7 +- tools/perf/ui/browser.c|7 +- tools/perf/ui/browsers/annotate.c |6 +- tools/perf/ui/gtk/browser.c|5 +- tools/perf/ui/gtk/setup.c |2 +- tools/perf/ui/gtk/util.c |4 +- tools/perf/ui/helpline.c |2 +- tools/perf/ui/helpline.h |8 +- tools/perf/ui/hist.c | 21 ++-- tools/perf/ui/tui/setup.c |4 +- tools/perf/util/alias.c|3 +- tools/perf/util/annotate.c |6 +- tools/perf/util/annotate.h | 13 +-- tools/perf/util/build-id.c | 11 +- tools/perf/util/cache.h|6 +- tools/perf/util/callchain.c|6 +- tools/perf/util/cgroup.c |4 +- tools/perf/util/config.c |6 +- tools/perf/util/debug.h|9 +- tools/perf/util/event.c| 29 +++--- tools/perf/util/event.h|2 +- tools/perf/util/header.c | 109 +++- tools/perf/util/help.c |3 +- tools/perf/util/hist.c |2 +- tools/perf/util/hist.h | 32 +++--- tools/perf/util/include/linux/bitops.h |4 + tools/perf/util/include/linux/compiler.h |8 +- tools/perf/util/include/linux/kernel.h | 13 ++- tools/perf/util/include/linux/magic.h | 12 +++ tools/perf/util/include/linux/types.h |8 ++ tools/perf/util/intlist.c |4 +- tools/perf/util/map.h |2 +- tools/perf/util/parse-events-test.c|6 +- tools
[PATCH v3 1/6] perf tools: include wrapper for magic.h
perf is currently including magic.h directly from the kernel. If the glibc magic.h is also included, this leads to warnings that the constants are redefined. This happens on some systems (e.g. Android). Redefinition errors on Android: In file included from util/util.h:79:0, from util/cache.h:5, from util/abspath.c:1: util/../../../include/linux/magic.h:5:0: error: "AFFS_SUPER_MAGIC" redefined [-Werror] bionic/libc/include/sys/vfs.h:53:0: note: this is the location of the previous definition util/../../../include/linux/magic.h:19:0: error: "EFS_SUPER_MAGIC" redefined [-Werror] bionic/libc/include/sys/vfs.h:61:0: note: this is the location of the previous definition util/../../../include/linux/magic.h:26:0: error: "HPFS_SUPER_MAGIC" redefined [-Werror] bionic/libc/include/sys/vfs.h:67:0: note: this is the location of the previous definition Only two constants from magic.h are used by perf (DEBUGFS_MAGIC and SYSFS_MAGIC). This fix provides a wrapper for magic.h that includes only these constants instead of including the kernel header file directly. Signed-off-by: Irina Tirdea Acked-by: Pekka Enberg --- tools/perf/Makefile |1 + tools/perf/util/include/linux/magic.h | 12 tools/perf/util/util.h|2 +- 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 tools/perf/util/include/linux/magic.h diff --git a/tools/perf/Makefile b/tools/perf/Makefile index e4b2e8f..1d2723c 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -264,6 +264,7 @@ LIB_H += util/include/linux/ctype.h LIB_H += util/include/linux/kernel.h LIB_H += util/include/linux/list.h LIB_H += util/include/linux/export.h +LIB_H += util/include/linux/magic.h LIB_H += util/include/linux/poison.h LIB_H += util/include/linux/prefetch.h LIB_H += util/include/linux/rbtree.h diff --git a/tools/perf/util/include/linux/magic.h b/tools/perf/util/include/linux/magic.h new file mode 100644 index 000..58b64ed --- /dev/null +++ b/tools/perf/util/include/linux/magic.h @@ -0,0 +1,12 @@ +#ifndef _PERF_LINUX_MAGIC_H_ +#define _PERF_LINUX_MAGIC_H_ + +#ifndef DEBUGFS_MAGIC +#define DEBUGFS_MAGIC 0x64626720 +#endif + +#ifndef SYSFS_MAGIC +#define SYSFS_MAGIC0x62656572 +#endif + +#endif diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 67a3713..70fa70b 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -70,7 +70,7 @@ #include #include #include -#include "../../../include/linux/magic.h" +#include #include "types.h" #include -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v3 2/6] perf tools: update types definitions for Android
Some type definitions are missing from Android or are already defined in bionic and lead to redefinition errors. Android defines in types.h __le32. Since perf is wrapping with a local version, we need to define this constant in the local version too. Error in Android: In file included from bionic/libc/include/unistd.h:36:0, from external/perf/tools/perf/util/util.h:46, from external/perf/tools/perf/util/cache.h:5, from external/perf/tools/perf/util/abspath.c:1: bionic/libc/kernel/common/linux/capability.h:60:2: error: unknown type name '__le32' roundup() definition is missing: util/symbol.c: In function 'symbols__fixup_end': util/symbol.c:106: warning: implicit declaration of function 'roundup' util/symbol.c:106: warning: nested extern declaration of 'roundup' __force macro defined in perf is also defined in libc which leads to redefinition errors. In order to avoid these, we guard these definition with Signed-off-by: Irina Tirdea Acked-by: Pekka Enberg --- tools/perf/util/include/linux/compiler.h |4 tools/perf/util/include/linux/kernel.h |9 + tools/perf/util/include/linux/types.h|8 3 files changed, 21 insertions(+) diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h index 2dc8671..ce2367b 100644 --- a/tools/perf/util/include/linux/compiler.h +++ b/tools/perf/util/include/linux/compiler.h @@ -12,4 +12,8 @@ #define __used __attribute__((__unused__)) #define __packed __attribute__((__packed__)) +#ifndef __force +#define __force +#endif + #endif diff --git a/tools/perf/util/include/linux/kernel.h b/tools/perf/util/include/linux/kernel.h index 4af9a10..a978f26 100644 --- a/tools/perf/util/include/linux/kernel.h +++ b/tools/perf/util/include/linux/kernel.h @@ -46,6 +46,15 @@ _min1 < _min2 ? _min1 : _min2; }) #endif +#ifndef roundup +#define roundup(x, y) (\ +{ \ + const typeof(y) __y = y; \ + (((x) + (__y - 1)) / __y) * __y; \ +} \ +) +#endif + #ifndef BUG_ON #ifdef NDEBUG #define BUG_ON(cond) do { if (cond) {} } while (0) diff --git a/tools/perf/util/include/linux/types.h b/tools/perf/util/include/linux/types.h index 12de3b8..eb46478 100644 --- a/tools/perf/util/include/linux/types.h +++ b/tools/perf/util/include/linux/types.h @@ -3,6 +3,14 @@ #include +#ifndef __bitwise +#define __bitwise +#endif + +#ifndef __le32 +typedef __u32 __bitwise __le32; +#endif + #define DECLARE_BITMAP(name,bits) \ unsigned long name[BITS_TO_LONGS(bits)] -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v3 3/6] perf tools: include __WORDSIZE definition
__WORDSIZE is GLibC-specific and is not defined on all systems or glibc versions (e.g. Android's bionic does not define it). In file included from util/include/linux/bitmap.h:5:0, from util/header.h:10, from util/session.h:6, from util/build-id.h:4, from util/annotate.c:11: util/include/linux/bitops.h: In function 'set_bit': util/include/linux/bitops.h:25:12: error: '__WORDSIZE' undeclared (first use in this function) util/include/linux/bitops.h:25:12: note: each undeclared identifier is reported only once for each function it appears in util/include/linux/bitops.h:23:51: error: parameter 'addr' set but not used [-Werror=unused-but-set-parameter] util/include/linux/bitops.h: In function 'clear_bit': util/include/linux/bitops.h:30:12: error: '__WORDSIZE' undeclared (first use in this function) util/include/linux/bitops.h:28:53: error: parameter 'addr' set but not used [-Werror=unused-but-set-parameter] In file included from util/header.h:10:0, from util/session.h:6, from util/build-id.h:4, from util/annotate.c:11: util/include/linux/bitmap.h: In function 'bitmap_zero': util/include/linux/bitmap.h:22:6: error: '__WORDSIZE' undeclared (first use in this function) Defining __WORDSIZE in perf's headers if it is not already defined. Signed-off-by: Irina Tirdea Suggested-by: Peter Zijlstra Suggested-by: Pekka Enberg --- tools/perf/util/include/linux/bitops.h |4 1 file changed, 4 insertions(+) diff --git a/tools/perf/util/include/linux/bitops.h b/tools/perf/util/include/linux/bitops.h index 587a230..a55d8cf 100644 --- a/tools/perf/util/include/linux/bitops.h +++ b/tools/perf/util/include/linux/bitops.h @@ -5,6 +5,10 @@ #include #include +#ifndef __WORDSIZE +#define __WORDSIZE (__SIZEOF_LONG__ * 8) +#endif + #define BITS_PER_LONG __WORDSIZE #define BITS_PER_BYTE 8 #define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v3 4/6] perf tools: fix ALIGN redefinition in system headers
On some systems (e.g. Android), ALIGN is defined in system headers as ALIGN(p). The definition of ALIGN used in perf takes 2 parameters: ALIGN(x,a). This leads to redefinition conflicts. Redefinition error on Android: In file included from util/include/linux/list.h:1:0, from util/callchain.h:5, from util/hist.h:6, from util/session.h:4, from util/build-id.h:4, from util/annotate.c:11: util/include/linux/kernel.h:11:0: error: "ALIGN" redefined [-Werror] bionic/libc/include/sys/param.h:38:0: note: this is the location of the previous definition Conflics with system defined ALIGN in Android: util/event.c: In function 'perf_event__synthesize_comm': util/event.c:115:32: error: macro "ALIGN" passed 2 arguments, but takes just 1 util/event.c:115:9: error: 'ALIGN' undeclared (first use in this function) util/event.c:115:9: note: each undeclared identifier is reported only once for each function it appears in In order to avoid this redefinition, ALIGN is renamed to PERF_ALIGN. Signed-off-by: Irina Tirdea Acked-by: Pekka Enberg --- tools/perf/util/event.c| 10 +- tools/perf/util/event.h|2 +- tools/perf/util/header.c | 16 tools/perf/util/include/linux/kernel.h |4 ++-- tools/perf/util/session.c |4 ++-- tools/perf/util/symbol.c |2 +- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 84ff6f16..f7f4805 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -112,7 +112,7 @@ static pid_t perf_event__synthesize_comm(struct perf_tool *tool, event->comm.header.type = PERF_RECORD_COMM; size = strlen(event->comm.comm) + 1; - size = ALIGN(size, sizeof(u64)); + size = PERF_ALIGN(size, sizeof(u64)); memset(event->comm.comm + size, 0, machine->id_hdr_size); event->comm.header.size = (sizeof(event->comm) - (sizeof(event->comm.comm) - size) + @@ -145,7 +145,7 @@ static pid_t perf_event__synthesize_comm(struct perf_tool *tool, sizeof(event->comm.comm)); size = strlen(event->comm.comm) + 1; - size = ALIGN(size, sizeof(u64)); + size = PERF_ALIGN(size, sizeof(u64)); memset(event->comm.comm + size, 0, machine->id_hdr_size); event->comm.header.size = (sizeof(event->comm) - (sizeof(event->comm.comm) - size) + @@ -228,7 +228,7 @@ static int perf_event__synthesize_mmap_events(struct perf_tool *tool, size = strlen(execname); execname[size - 1] = '\0'; /* Remove \n */ memcpy(event->mmap.filename, execname, size); - size = ALIGN(size, sizeof(u64)); + size = PERF_ALIGN(size, sizeof(u64)); event->mmap.len -= event->mmap.start; event->mmap.header.size = (sizeof(event->mmap) - (sizeof(event->mmap.filename) - size)); @@ -282,7 +282,7 @@ int perf_event__synthesize_modules(struct perf_tool *tool, if (pos->dso->kernel) continue; - size = ALIGN(pos->dso->long_name_len + 1, sizeof(u64)); + size = PERF_ALIGN(pos->dso->long_name_len + 1, sizeof(u64)); event->mmap.header.type = PERF_RECORD_MMAP; event->mmap.header.size = (sizeof(event->mmap) - (sizeof(event->mmap.filename) - size)); @@ -494,7 +494,7 @@ int perf_event__synthesize_kernel_mmap(struct perf_tool *tool, map = machine->vmlinux_maps[MAP__FUNCTION]; size = snprintf(event->mmap.filename, sizeof(event->mmap.filename), "%s%s", mmap_name, symbol_name) + 1; - size = ALIGN(size, sizeof(u64)); + size = PERF_ALIGN(size, sizeof(u64)); event->mmap.header.type = PERF_RECORD_MMAP; event->mmap.header.size = (sizeof(event->mmap) - (sizeof(event->mmap.filename) - size) + machine->id_hdr_size); diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index 0e088d0..21b99e7 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h @@ -101,7 +101,7 @@ struct perf_sample { struct build_id_event { struct perf_event_header header; pid_tpid; - u8 build_id[ALIGN(BUILD_ID_SIZE, sizeof(u64))]; + u8 build_id[PERF_ALIGN(BUILD_ID_SIZE, sizeof(u64))]; char filename[]; }; diff --git a/tools/perf/util/header.c b/tools/perf/ut
[PATCH v3 5/6] perf tools: fix no return in non-void function
thread_func in builtin-sched.c has an internal loop and never returns. The only return from this thread are BUG_ON calls in case return values are not 0. The compiler on Android complains that the function needs to return a non-void value. Adding the noreturn function attribute to fix this error. Error in Android: target C: perf <= builtin-sched.c hardware/intel/linu/tools/perf/builtin-sched.c: In function 'thread_func': hardware/intel/linux/tools/perf/builtin-sched.c:476: error: no return statement in function returning non-void Signed-off-by: Irina Tirdea Acked-by: Pekka Enberg --- tools/perf/builtin-sched.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index a25a023..1fecc95 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -439,7 +439,7 @@ static u64 get_cpu_usage_nsec_self(int fd) return runtime; } -static void *thread_func(void *ctx) +static __attribute__ ((noreturn)) void *thread_func(void *ctx) { struct task_desc *this_task = ctx; u64 cpu_usage_0, cpu_usage_1; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 0/8] perf tools: fixes for Android
From: Irina Tirdea Hi, I have gathered in this set all remaining patches with Android fixes. Starting from Bernhard's patch [1], I added 2 patches (patch 1 and 2) that include on_exit implementation and Android support in the Makefile. I have also added some documentation on building for Android (patch 3). I have included version 3 for the patchset "perf: android: configure hardcoded paths" [2]. Changes for v3: () add documentation and update Makefile for Android for patch 4 and 5 () move the detection of cross-build objdump path in one file (common.c) so that is available for addr2line as well. (patch 6) () implement detection of cross-build path for addr2line (patch 7) I have also included version 3 for the patch "perf stat: implement --big-num grouping" [3] (patch 8). Changes for v3: () replace LOCALE_SUPPORT with NO_LOCALE for consistency with recent changes done by Namhyung Thanks, Irina [1] https://lkml.org/lkml/2012/8/23/316 [2] https://lkml.org/lkml/2012/9/23/100 [3] https://lkml.org/lkml/2012/9/23/128 Bernhard Rosenkraenzer (1): perf tools: add on_exit implementation Irina Tirdea (6): perf tools: update Makefile for Android Documentation: add documentation on compiling for Android perf tools: configure tmp path at build time perf tools: configure shell path at compile time perf tools: configure addr2line for cross-compiling perf stat: implement --big-num grouping Namhyung Kim (1): perf tools: Try to find cross-built objdump path tools/perf/Documentation/android.txt | 94 tools/perf/Documentation/jit-interface.txt |4 +- tools/perf/Documentation/perf-annotate.txt |2 + tools/perf/Documentation/perf-report.txt |2 + tools/perf/Makefile| 64 +-- tools/perf/arch/common.c | 164 tools/perf/arch/common.h | 12 ++ tools/perf/builtin-annotate.c |9 ++ tools/perf/builtin-help.c |2 +- tools/perf/builtin-record.c| 32 ++ tools/perf/builtin-report.c|7 ++ tools/perf/builtin-script.c| 12 +- tools/perf/builtin-stat.c | 112 +-- tools/perf/config/feature-tests.mak| 38 ++- tools/perf/perf-archive.sh | 13 ++- tools/perf/util/annotate.c | 13 ++- tools/perf/util/annotate.h |1 - tools/perf/util/dso-test-data.c|2 +- tools/perf/util/map.c |3 +- tools/perf/util/pmu.c |2 +- tools/perf/util/sort.c | 16 ++- tools/perf/util/symbol.c |4 +- tools/perf/util/trace-event-info.c |2 +- 23 files changed, 574 insertions(+), 36 deletions(-) create mode 100644 tools/perf/Documentation/android.txt create mode 100644 tools/perf/arch/common.c create mode 100644 tools/perf/arch/common.h -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 1/8] perf tools: add on_exit implementation
From: Bernhard Rosenkraenzer on_exit() is only available in new versions of glibc. It is not implemented in Bionic and will lead to linking errors when compiling for Android. Implement a wrapper for on_exit using atexit. The implementation for on_exit is the one sent by Bernhard Rosenkraenzer in https://lkml.org/lkml/2012/8/23/316. The configuration part from the Makefile is different than the one from the original patch. Signed-off-by: Bernhard Rosenkraenzer Signed-off-by: Irina Tirdea --- tools/perf/Makefile |6 ++ tools/perf/builtin-record.c | 32 tools/perf/config/feature-tests.mak | 11 ++- 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/tools/perf/Makefile b/tools/perf/Makefile index f9126f8..0e468b5 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -751,6 +751,12 @@ ifndef NO_STRLCPY endif endif +ifndef NO_ON_EXIT + ifeq ($(call try-cc,$(SOURCE_ON_EXIT),),y) + BASIC_CFLAGS += -DHAVE_ON_EXIT + endif +endif + ifndef NO_BACKTRACE ifeq ($(call try-cc,$(SOURCE_BACKTRACE),),y) BASIC_CFLAGS += -DBACKTRACE_SUPPORT diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index e9231659..73b5d7f 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -31,6 +31,38 @@ #include #include +#ifndef HAVE_ON_EXIT +#ifndef ATEXIT_MAX +#define ATEXIT_MAX 32 +#endif +static int __on_exit_count = 0; +typedef void (*on_exit_func_t) (int, void *); +static on_exit_func_t __on_exit_funcs[ATEXIT_MAX]; +static void *__on_exit_args[ATEXIT_MAX]; +static int __exitcode = 0; +static void __handle_on_exit_funcs(void); +static int on_exit(on_exit_func_t function, void *arg); +#define exit(x) (exit)(__exitcode = (x)) + +static int on_exit(on_exit_func_t function, void *arg) +{ + if (__on_exit_count == ATEXIT_MAX) + return -ENOMEM; + else if (__on_exit_count == 0) + atexit(__handle_on_exit_funcs); + __on_exit_funcs[__on_exit_count] = function; + __on_exit_args[__on_exit_count++] = arg; + return 0; +} + +static void __handle_on_exit_funcs(void) +{ + int i; + for (i = 0; i < __on_exit_count; i++) + __on_exit_funcs[i] (__exitcode, __on_exit_args[i]); +} +#endif + enum write_mode_t { WRITE_FORCE, WRITE_APPEND diff --git a/tools/perf/config/feature-tests.mak b/tools/perf/config/feature-tests.mak index 4add41b..eaeb0fd 100644 --- a/tools/perf/config/feature-tests.mak +++ b/tools/perf/config/feature-tests.mak @@ -203,4 +203,13 @@ int main(void) return audit_open(); } endef -endif \ No newline at end of file +endif + +define SOURCE_ON_EXIT +#include + +int main(void) +{ + return on_exit(NULL, NULL); +} +endef -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 2/8] perf tools: update Makefile for Android
From: Irina Tirdea For cross-compiling on Android, some specific changes are needed in the Makefile. Update the Makefile to support cross-compiling for Android. The original ideea for this was send by Bernhard Rosenkraenzer in https://lkml.org/lkml/2012/8/23/316, but this is a rewrite. Changes: () support bionic in addition to glibc () remove rt and pthread libraries that do not exist in Android () use $(CFLAGS) when detecting initial compiler flags. This is needed when setting CFLAGS as an argument of make (e.g. for setting --sysroot). () include perf's local directory when building for Android to be able to find relative paths if using --sysroot (e.g.: ../../include/linux/perf_event.h) Signed-off-by: Bernhard Rosenkraenzer Signed-off-by: Irina Tirdea --- tools/perf/Makefile | 25 +++-- tools/perf/config/feature-tests.mak |9 + 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 0e468b5..1a23118 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -155,15 +155,15 @@ SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__ -include config/feature-tests.mak -ifeq ($(call try-cc,$(SOURCE_HELLO),-Werror -fstack-protector-all),y) +ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -fstack-protector-all),y) CFLAGS := $(CFLAGS) -fstack-protector-all endif -ifeq ($(call try-cc,$(SOURCE_HELLO),-Werror -Wstack-protector),y) +ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -Wstack-protector),y) CFLAGS := $(CFLAGS) -Wstack-protector endif -ifeq ($(call try-cc,$(SOURCE_HELLO),-Werror -Wvolatile-register-var),y) +ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -Wvolatile-register-var),y) CFLAGS := $(CFLAGS) -Wvolatile-register-var endif @@ -172,6 +172,13 @@ endif BASIC_CFLAGS = -Iutil/include -Iarch/$(ARCH)/include -I$(OUTPUT)util -I$(TRACE_EVENT_DIR) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE BASIC_LDFLAGS = +ifeq ($(call try-cc,$(SOURCE_BIONIC),$(CFLAGS)),y) + BIONIC := 1 + EXTLIBS := $(filter-out -lrt,$(EXTLIBS)) + EXTLIBS := $(filter-out -lpthread,$(EXTLIBS)) + BASIC_CFLAGS += -I. +endif + # Guard against environment variables BUILTIN_OBJS = LIB_H = @@ -467,12 +474,18 @@ else FLAGS_LIBELF=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) ifneq ($(call try-cc,$(SOURCE_LIBELF),$(FLAGS_LIBELF)),y) FLAGS_GLIBC=$(ALL_CFLAGS) $(ALL_LDFLAGS) - ifneq ($(call try-cc,$(SOURCE_GLIBC),$(FLAGS_GLIBC)),y) - msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static); - else + ifeq ($(call try-cc,$(SOURCE_GLIBC),$(FLAGS_GLIBC)),y) + LIBC_SUPPORT := 1 + endif + ifeq ($(BIONIC),1) + LIBC_SUPPORT := 1 + endif + ifeq ($(LIBC_SUPPORT),1) NO_LIBELF := 1 NO_DWARF := 1 NO_DEMANGLE := 1 + else + msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static); endif else FLAGS_DWARF=$(ALL_CFLAGS) -ldw -lelf $(ALL_LDFLAGS) $(EXTLIBS) diff --git a/tools/perf/config/feature-tests.mak b/tools/perf/config/feature-tests.mak index eaeb0fd..3ef5ec9 100644 --- a/tools/perf/config/feature-tests.mak +++ b/tools/perf/config/feature-tests.mak @@ -43,6 +43,15 @@ int main(void) } endef +define SOURCE_BIONIC +#include + +int main(void) +{ + return __ANDROID_API__; +} +endef + define SOURCE_ELF_MMAP #include int main(void) -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 3/8] Documentation: add documentation on compiling for Android
From: Irina Tirdea Add documentation for cross-compiling on Android including: () instructions on how to set the Android NDK environment () how to cross-compile perf for Android () how to install on an Android device/emulator, set the runtime environment and run it Signed-off-by: Irina Tirdea --- tools/perf/Documentation/android.txt | 75 ++ 1 file changed, 75 insertions(+) create mode 100644 tools/perf/Documentation/android.txt diff --git a/tools/perf/Documentation/android.txt b/tools/perf/Documentation/android.txt new file mode 100644 index 000..a39dbbb --- /dev/null +++ b/tools/perf/Documentation/android.txt @@ -0,0 +1,75 @@ +How to compile perf for Android += + +I. Set the Android NDK environment + + +(a). Use the Android NDK + +1. You need to download and install the Android Native Development Kit (NDK). +Set the NDK variable to point to the path where you installed the NDK: + export NDK=/path/to/android-ndk + +2. Set cross-compiling environment variables for NDK toolchain and sysroot. +For arm: + export NDK_TOOLCHAIN=${NDK}/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/arm-linux-androideabi- + export NDK_SYSROOT=${NDK}/platforms/android-9/arch-arm +For x86: + export NDK_TOOLCHAIN=${NDK}/toolchains/x86-4.6/prebuilt/linux-x86/bin/i686-linux-android- + export NDK_SYSROOT=${NDK}/platforms/android-9/arch-x86 + +This method is not working for Android NDK versions up to Revision 8b. +perf uses some bionic enhancements that are not included in these NDK versions. +You can use method (b) described below instead. + +(b). Use the Android source tree +--- +1. Download the master branch of the Android source tree. +Set the environment for the target you want using: + source build/envsetup.sh + lunch + +2. Build your own NDK sysroot to contain latest bionic changes and set the +NDK sysroot environment variable. + cd ${ANDROID_BUILD_TOP}/ndk +For arm: + ./build/tools/build-ndk-sysroot.sh --abi=arm + export NDK_SYSROOT=${ANDROID_BUILD_TOP}/ndk/build/platforms/android-3/arch-arm +For x86: + ./build/tools/build-ndk-sysroot.sh --abi=x86 + export NDK_SYSROOT=${ANDROID_BUILD_TOP}/ndk/build/platforms/android-3/arch-x86 + +3. Set the NDK toolchain environment variable. +For arm: + export NDK_TOOLCHAIN=${ANDROID_TOOLCHAIN}/arm-linux-androideabi- +For x86: + export NDK_TOOLCHAIN=${ANDROID_TOOLCHAIN}/i686-linux-android- + +II. Compile perf for Android + +You need to run make with the NDK toolchain and sysroot defined above: + make CROSS_COMPILE=${NDK_TOOLCHAIN} CFLAGS="--sysroot=${NDK_SYSROOT}" + +III. Install perf +--- +You need to connect to your Android device/emulator using adb. +Install perf using: + adb push perf /data/perf + +If you also want to use perf-archive you need busybox tools for Android. +For installing perf-archive, you first need to replace #!/bin/bash with #!/system/bin/sh: + sed 's/#!\/bin\/bash/#!\/system\/bin\/sh/g' perf-archive >> /tmp/perf-archive + chmod +x /tmp/perf-archive + adb push /tmp/perf-archive /data/perf-archive + +IV. Environment settings for running perf + +Some perf features need environment variables to run properly. +You need to set these before running perf on the target: + adb shell + # PERF_PAGER=cat + +IV. Run perf + +Run perf on your device/emulator to which you previously connected using adb: + # ./data/perf -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v3 5/8] perf tools: configure shell path at compile time
From: Irina Tirdea Shell path /bin/sh is hardcoded in various places in perf. Android has a different folder structure and does not have /bin/sh. Set the shell path at compile time in the Makefile by setting PERF_SHELL_PATH. By default it is set to /bin/sh. Signed-off-by: Irina Tirdea --- tools/perf/Makefile |8 +++- tools/perf/builtin-help.c |2 +- tools/perf/builtin-script.c | 12 ++-- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 9b1f84c..29caf9a 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -142,6 +142,7 @@ ETC_PERFCONFIG = etc/perfconfig endif lib = lib PERF_TMP_DIR = /tmp +PERF_SHELL_PATH = /bin/sh export prefix bindir sharedir sysconfdir @@ -179,6 +180,7 @@ ifeq ($(call try-cc,$(SOURCE_BIONIC),$(CFLAGS)),y) EXTLIBS := $(filter-out -lpthread,$(EXTLIBS)) BASIC_CFLAGS += -I. PERF_TMP_DIR = /data/local/tmp + PERF_SHELL_PATH = /system/bin/sh endif # Guard against environment variables @@ -836,7 +838,11 @@ $(OUTPUT)builtin-help.o: builtin-help.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFL $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \ '-DPERF_HTML_PATH="$(htmldir_SQ)"' \ '-DPERF_MAN_PATH="$(mandir_SQ)"' \ - '-DPERF_INFO_PATH="$(infodir_SQ)"' $< + '-DPERF_INFO_PATH="$(infodir_SQ)"' \ + '-DPERF_SHELL_PATH="$(PERF_SHELL_PATH)"' $< + +$(OUTPUT)builtin-script.o: builtin-script.c $(OUTPUT)PERF-CFLAGS + $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DPERF_SHELL_PATH='"$(PERF_SHELL_PATH)"' $< $(OUTPUT)builtin-timechart.o: builtin-timechart.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \ diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c index 411ee56..542b752 100644 --- a/tools/perf/builtin-help.c +++ b/tools/perf/builtin-help.c @@ -154,7 +154,7 @@ static void exec_man_cmd(const char *cmd, const char *page) { struct strbuf shell_cmd = STRBUF_INIT; strbuf_addf(&shell_cmd, "%s %s", cmd, page); - execl("/bin/sh", "sh", "-c", shell_cmd.buf, NULL); + execl(PERF_SHELL_PATH, "sh", "-c", shell_cmd.buf, NULL); warning("failed to exec '%s': %s", cmd, strerror(errno)); } diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index fb96250..01b289b 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -1320,7 +1320,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) goto out; } - __argv[j++] = "/bin/sh"; + __argv[j++] = PERF_SHELL_PATH; __argv[j++] = rec_script_path; if (system_wide) __argv[j++] = "-a"; @@ -1331,7 +1331,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) __argv[j++] = argv[i]; __argv[j++] = NULL; - execvp("/bin/sh", (char **)__argv); + execvp(PERF_SHELL_PATH, (char **)__argv); free(__argv); exit(-1); } @@ -1347,7 +1347,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) } j = 0; - __argv[j++] = "/bin/sh"; + __argv[j++] = PERF_SHELL_PATH; __argv[j++] = rep_script_path; for (i = 1; i < rep_args + 1; i++) __argv[j++] = argv[i]; @@ -1355,7 +1355,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) __argv[j++] = "-"; __argv[j++] = NULL; - execvp("/bin/sh", (char **)__argv); + execvp(PERF_SHELL_PATH, (char **)__argv); free(__argv); exit(-1); } @@ -1384,7 +1384,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) goto out; } - __argv[j++] = "/bin/sh"; + __argv[j++] = PERF_SHELL_PATH; __argv[j++] = script_path; if (system_wide) __argv[j++] = "-a"; @@ -1392,7 +1392,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) __argv[j++] = argv[i]; __argv[j++] = NULL; - execvp("/bin/sh", (char **)__argv); +
[PATCH v3 6/8] perf tools: Try to find cross-built objdump path
From: Namhyung Kim As we have architecture information of saved perf.data file, we can try to find cross-built objdump path. The triplets include support for Android (arm, x86 and mips architectures). Signed-off-by: Namhyung Kim Signed-off-by: Irina Tirdea --- tools/perf/Makefile |2 + tools/perf/arch/common.c | 159 + tools/perf/arch/common.h | 10 +++ tools/perf/builtin-annotate.c |4 ++ tools/perf/builtin-report.c |1 + tools/perf/util/annotate.h|1 - 6 files changed, 176 insertions(+), 1 deletion(-) create mode 100644 tools/perf/arch/common.c create mode 100644 tools/perf/arch/common.h diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 29caf9a..5149b8a 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -426,6 +426,8 @@ LIB_OBJS += $(OUTPUT)ui/helpline.o LIB_OBJS += $(OUTPUT)ui/hist.o LIB_OBJS += $(OUTPUT)ui/stdio/hist.o +LIB_OBJS += $(OUTPUT)arch/common.o + BUILTIN_OBJS += $(OUTPUT)builtin-annotate.o BUILTIN_OBJS += $(OUTPUT)builtin-bench.o # Benchmark modules diff --git a/tools/perf/arch/common.c b/tools/perf/arch/common.c new file mode 100644 index 000..1db891f --- /dev/null +++ b/tools/perf/arch/common.c @@ -0,0 +1,159 @@ +#include +#include +#include "common.h" + +const char *const arm_triplets[] = { + "arm-eabi-", + "arm-linux-androideabi-", + "arm-unknown-linux-", + "arm-unknown-linux-gnu-", + "arm-unknown-linux-gnueabi-", + NULL +}; + +const char *const powerpc_triplets[] = { + "powerpc-unknown-linux-gnu-", + "powerpc64-unknown-linux-gnu-", + NULL +}; + +const char *const s390_triplets[] = { + "s390-ibm-linux-", + NULL +}; + +const char *const sh_triplets[] = { + "sh-unknown-linux-gnu-", + "sh64-unknown-linux-gnu-", + NULL +}; + +const char *const sparc_triplets[] = { + "sparc-unknown-linux-gnu-", + "sparc64-unknown-linux-gnu-", + NULL +}; + +const char *const x86_triplets[] = { + "x86_64-pc-linux-gnu-", + "x86_64-unknown-linux-gnu-", + "i686-pc-linux-gnu-", + "i586-pc-linux-gnu-", + "i486-pc-linux-gnu-", + "i386-pc-linux-gnu-", + "i686-linux-android-", + "i686-android-linux-", + NULL +}; + +const char *const mips_triplets[] = { + "mips-unknown-linux-gnu-", + "mipsel-linux-android-", + NULL +}; + +static bool lookup_path(char *name) +{ + bool found = false; + char *path, *tmp; + char buf[PATH_MAX]; + char *env = getenv("PATH"); + + if (!env) + return false; + + env = strdup(env); + if (!env) + return false; + + path = strtok_r(env, ":", &tmp); + while (path) { + scnprintf(buf, sizeof(buf), "%s/%s", path, name); + if (access(buf, F_OK) == 0) { + found = true; + break; + } + path = strtok_r(NULL, ":", &tmp); + } + free(env); + return found; +} + +static int lookup_triplets(const char *const *triplets, const char *name) +{ + int i; + char buf[PATH_MAX]; + + for (i = 0; triplets[i] != NULL; i++) { + scnprintf(buf, sizeof(buf), "%s%s", triplets[i], name); + if (lookup_path(buf)) + return i; + } + return -1; +} + +static char *try_binutils_path(struct perf_session *session, const char *name) +{ + int idx; + char *arch, *env; + struct utsname uts; + const char *const *path_list; + char buf[PATH_MAX]; + + if (uname(&uts) < 0) + return NULL; + + /* +* We don't need to try to find objdump path for native system. +* Just use default "objdump". +*/ + if (!strcmp(uts.machine, session->header.env.arch)) + return NULL; + + env = getenv("CROSS_COMPILE"); + if (env) { + scnprintf(buf, sizeof(buf), "%s%s", env, name); + if (buf[0] == '/') { + if (access(buf, F_OK) == 0) + return strdup(buf); + + return NULL; + } + + if (lookup_path(buf)) + return strdup(buf); + } + + arch = session->header.env.arch; + + if (!strcmp(arch, "arm")) + path_list = arm_triplets; + else if (!strcmp(arch, "powerpc")) + path_list = powerpc_triplets; + else if (!strcmp(arch, "sh&quo
[PATCH v3 8/8] perf stat: implement --big-num grouping
From: Irina Tirdea In glibc, printf supports ' to group numbers with thousands' grouping characters. Bionic does not support ' for printf. Implement thousands's grouping for numbers according to locale. The implementation uses the algorithm from glibc (http://www.gnu.org/software/libc/). Bionic does not implement locales, so we need to add a configuration option LOCALE_SUPPORT. If it is not defined, default values for thousands separator and grouping are used. Signed-off-by: Irina Tirdea --- tools/perf/Makefile |6 ++ tools/perf/builtin-stat.c | 112 --- tools/perf/config/feature-tests.mak | 18 ++ 3 files changed, 129 insertions(+), 7 deletions(-) diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 5149b8a..bc75b2a 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -783,6 +783,12 @@ ifndef NO_BACKTRACE endif endif +ifndef NO_LOCALE + ifeq ($(call try-cc,$(SOURCE_LOCALE),),y) + BASIC_CFLAGS += -DLOCALE_SUPPORT + endif +endif + ifdef ASCIIDOC8 export ASCIIDOC8 endif diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 93b9011..855e918 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -60,6 +60,8 @@ #include #include +/* max double number have E+308 + \0 + sign */ +#define MAX_NR_STR 310 #define DEFAULT_SEPARATOR " " #define CNTR_NOT_SUPPORTED "" #define CNTR_NOT_COUNTED "" @@ -631,18 +633,112 @@ static void print_ll_cache_misses(int cpu, fprintf(output, " of all LL-cache hits "); } +/* Group the digits according to the grouping rules of the current locale. + The interpretation of GROUPING is as in `struct lconv' from . */ +static int group_number_locale(char *number, char **gnumber) +{ + const char *thousands_sep = NULL, *grouping = NULL; + int glen, tlen, dest_alloc_size, src_size, ret = 0, cnt; + char *dest_alloc_ptr, *dest_end, *src_start, *src_end; + +#ifndef LOCALE_SUPPORT + thousands_sep = ","; + grouping = "\x3"; +#else + struct lconv *lc = localeconv(); + if (lc != NULL) { + thousands_sep = lc->thousands_sep; + grouping = lc->grouping; + } +#endif + + *gnumber = NULL; + /* No grouping */ + if (thousands_sep == NULL || grouping == NULL || + *thousands_sep == '\0' || *grouping == CHAR_MAX || *grouping <= 0) { + *gnumber = strdup(number); + if (*gnumber == NULL) + ret = -ENOMEM; + goto out; + } + + glen = *grouping++; + tlen = strlen(thousands_sep); + + src_size = strlen(number); + /* Worst case scenario we have 1-character grouping */ + dest_alloc_size = (src_size + src_size * tlen) * sizeof(char); + dest_alloc_ptr = zalloc(dest_alloc_size); + if (dest_alloc_ptr == NULL) { + ret = -ENOMEM; + goto out; + } + /* -1 for '\0' */ + dest_end = dest_alloc_ptr + dest_alloc_size - 1; + + src_start = number; + src_end = number + src_size; + + while (src_end > src_start) { + *--dest_end = *--src_end; + if (--glen == 0 && src_end > src_start) { + /* A new group */ + cnt = tlen; + do + *--dest_end = thousands_sep[--cnt]; + while (cnt > 0); + + if (*grouping == CHAR_MAX || *grouping < 0) { + /* No further grouping to be done. + Copy the rest of the number. */ + do + *--dest_end = *--src_end; + while (src_end > src_start); + break; + } else if (*grouping != '\0') { + glen = *grouping++; + } else { + /* The previous grouping repeats ad infinitum */ + glen = grouping[-1]; + } + } + } + + /* Make a copy with the exact needed size of the grouped number */ + *gnumber = strdup(dest_end); + if (*gnumber == NULL) { + ret = -ENOMEM; + goto out_free_dest; + } + + /* fall through */ +out_free_dest: + free(dest_alloc_ptr); +out: + return ret; +} + static void abs_printout(int cpu, struct perf_evsel *evsel, double avg) { double total, ratio = 0.0; char cpustr[16] = { '\0', }; const char *fmt; + char avgstr[MAX_NR_STR], *pavgstr; + int ret; -
[PATCH v3 7/8] perf tools: configure addr2line for cross-compiling
From: Irina Tirdea When analyzing data recorded on a target with a different architecture than the host, we must use addr2line from the toolchain for that architecture. Add a command line option to set addr2line at runtime. As we have architecture information of saved perf.data file, we can also try to find cross-built addr2line path. The predefined triplets include support for Android (arm, x86 and mips architectures). Signed-off-by: Irina Tirdea --- tools/perf/Documentation/android.txt | 18 ++ tools/perf/Documentation/perf-annotate.txt |2 ++ tools/perf/Documentation/perf-report.txt |2 ++ tools/perf/arch/common.c |5 + tools/perf/arch/common.h |2 ++ tools/perf/builtin-annotate.c |5 + tools/perf/builtin-report.c|6 ++ tools/perf/util/annotate.c | 13 - tools/perf/util/sort.c | 16 +--- 9 files changed, 65 insertions(+), 4 deletions(-) diff --git a/tools/perf/Documentation/android.txt b/tools/perf/Documentation/android.txt index 24fd01c..c2a8017 100644 --- a/tools/perf/Documentation/android.txt +++ b/tools/perf/Documentation/android.txt @@ -74,3 +74,21 @@ IV. Run perf Run perf on your device/emulator to which you previously connected using adb: # ./data/perf + +V. Analyze data recorded in Android on the host + +perf report and perf annotate use objdump and addr2line tools from Linux. +For analyzing data recorded for a different architecture you need to use the +versions provided in the toolchain for that architecture. The detection of the +proper toolchain is done at runtime; all you need to do is set some environment +variables before running perf annotate/report: +1. set CROSS_COMPILE + export CROSS_COMPILE=${NDK_TOOLCHAIN} +or +2. add the path to the toolchain to PATH + export PATH=$PATH:${ANDROID_TOOLCHAIN} +or +3. set the Android environment if you have the source tree +(this will set $PATH for you as mentioned above) + source build/envsetup.sh + lunch diff --git a/tools/perf/Documentation/perf-annotate.txt b/tools/perf/Documentation/perf-annotate.txt index c8ffd9f..177906a 100644 --- a/tools/perf/Documentation/perf-annotate.txt +++ b/tools/perf/Documentation/perf-annotate.txt @@ -87,6 +87,8 @@ OPTIONS --objdump=:: Path to objdump binary. +--addr2line=:: +Path to addr2line binary. SEE ALSO diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt index f4d91be..b6bb26e 100644 --- a/tools/perf/Documentation/perf-report.txt +++ b/tools/perf/Documentation/perf-report.txt @@ -170,6 +170,8 @@ OPTIONS --objdump=:: Path to objdump binary. +--addr2line=:: +Path to addr2line binary. SEE ALSO diff --git a/tools/perf/arch/common.c b/tools/perf/arch/common.c index 1db891f..e84b139 100644 --- a/tools/perf/arch/common.c +++ b/tools/perf/arch/common.c @@ -157,3 +157,8 @@ void try_objdump_path(struct perf_session *session) { objdump_path = try_binutils_path(session, "objdump"); } + +void try_addr2line_path(struct perf_session *session) +{ + addr2line_path = try_binutils_path(session, "addr2line"); +} diff --git a/tools/perf/arch/common.h b/tools/perf/arch/common.h index d88ecc3..ca95f0a 100644 --- a/tools/perf/arch/common.h +++ b/tools/perf/arch/common.h @@ -4,7 +4,9 @@ #include "session.h" extern const char *objdump_path; +extern const char *addr2line_path; void try_objdump_path(struct perf_session *session); +void try_addr2line_path(struct perf_session *session); #endif /* ARCH_PERF_COMMON_H */ diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index 8d90ab5..6f3b21a 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c @@ -189,6 +189,8 @@ static int __cmd_annotate(struct perf_annotate *ann) if (!objdump_path) try_objdump_path(session); + if (!addr2line_path) + try_addr2line_path(session); ret = perf_session__process_events(session, &ann->tool); if (ret) @@ -288,6 +290,9 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused) "Specify disassembler style (e.g. -M intel for intel syntax)"), OPT_STRING(0, "objdump", &objdump_path, "path", "objdump binary to use for disassembly and annotations"), + OPT_STRING(0, "addr2line", &addr2line_path, "path", + "addr2line binary to use for obtaining " + "file names and line numbers"), OPT_END() }; diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index e1549
[PATCH v3 4/8] perf tools: configure tmp path at build time
From: Irina Tirdea Temporary perf files are hardcoded to point to /tmp. Android does not have a /tmp directory so it needs to set this path at compile time. Add a compile-time definition (PERF_TMP_DIR) in the Makefile that sets the path to temp directory. By default it points to /tmp. Signed-off-by: Irina Tirdea --- tools/perf/Documentation/android.txt |1 + tools/perf/Documentation/jit-interface.txt |4 +++- tools/perf/Makefile| 17 - tools/perf/perf-archive.sh | 13 +++-- tools/perf/util/dso-test-data.c|2 +- tools/perf/util/map.c |3 ++- tools/perf/util/pmu.c |2 +- tools/perf/util/symbol.c |4 +++- tools/perf/util/trace-event-info.c |2 +- 9 files changed, 39 insertions(+), 9 deletions(-) diff --git a/tools/perf/Documentation/android.txt b/tools/perf/Documentation/android.txt index a39dbbb..24fd01c 100644 --- a/tools/perf/Documentation/android.txt +++ b/tools/perf/Documentation/android.txt @@ -68,6 +68,7 @@ Some perf features need environment variables to run properly. You need to set these before running perf on the target: adb shell # PERF_PAGER=cat + # PERF_TMP_DIR=/data/local/tmp IV. Run perf diff --git a/tools/perf/Documentation/jit-interface.txt b/tools/perf/Documentation/jit-interface.txt index a8656f5..10cb6ec 100644 --- a/tools/perf/Documentation/jit-interface.txt +++ b/tools/perf/Documentation/jit-interface.txt @@ -1,7 +1,9 @@ perf supports a simple JIT interface to resolve symbols for dynamic code generated by a JIT. -The JIT has to write a /tmp/perf-%d.map (%d = pid of process) file +The JIT has to write a $PERF_TMP_DIR/perf-%d.map (%d = pid of process) file. +You can set $PERF_TMP_DIR at compile time in the Makefile. +By default it is /tmp. This is a text file. diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 1a23118..9b1f84c 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -141,6 +141,7 @@ sysconfdir = $(prefix)/etc ETC_PERFCONFIG = etc/perfconfig endif lib = lib +PERF_TMP_DIR = /tmp export prefix bindir sharedir sysconfdir @@ -177,6 +178,7 @@ ifeq ($(call try-cc,$(SOURCE_BIONIC),$(CFLAGS)),y) EXTLIBS := $(filter-out -lrt,$(EXTLIBS)) EXTLIBS := $(filter-out -lpthread,$(EXTLIBS)) BASIC_CFLAGS += -I. + PERF_TMP_DIR = /data/local/tmp endif # Guard against environment variables @@ -255,7 +257,8 @@ $(OUTPUT)util/pmu-bison.c: util/pmu.y $(QUIET_BISON)$(BISON) -v util/pmu.y -d -o $(OUTPUT)util/pmu-bison.c $(OUTPUT)util/parse-events.o: $(OUTPUT)util/parse-events-flex.c $(OUTPUT)util/parse-events-bison.c -$(OUTPUT)util/pmu.o: $(OUTPUT)util/pmu-flex.c $(OUTPUT)util/pmu-bison.c +$(OUTPUT)util/pmu.o: $(OUTPUT)util/pmu.c $(OUTPUT)util/pmu-flex.c $(OUTPUT)util/pmu-bison.c $(OUTPUT)PERF-CFLAGS + $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DPERF_TMP_DIR='"$(PERF_TMP_DIR)"' $< LIB_FILE=$(OUTPUT)libperf.a @@ -887,6 +890,18 @@ $(OUTPUT)util/exec_cmd.o: util/exec_cmd.c $(OUTPUT)PERF-CFLAGS $(OUTPUT)util/config.o: util/config.c $(OUTPUT)PERF-CFLAGS $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $< +$(OUTPUT)util/dso-test-data.o: util/dso-test-data.c $(OUTPUT)PERF-CFLAGS + $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DPERF_TMP_DIR='"$(PERF_TMP_DIR)"' $< + +$(OUTPUT)util/map.o: util/map.c $(OUTPUT)PERF-CFLAGS + $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DPERF_TMP_DIR='"$(PERF_TMP_DIR)"' $< + +$(OUTPUT)util/symbol.o: util/symbol.c $(OUTPUT)PERF-CFLAGS + $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DPERF_TMP_DIR='"$(PERF_TMP_DIR)"' $< + +$(OUTPUT)util/trace-event-info.o: util/trace-event-info.c $(OUTPUT)PERF-CFLAGS + $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DPERF_TMP_DIR='"$(PERF_TMP_DIR)"' $< + $(OUTPUT)ui/browser.o: ui/browser.c $(OUTPUT)PERF-CFLAGS $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DENABLE_SLFUTURE_CONST $< diff --git a/tools/perf/perf-archive.sh b/tools/perf/perf-archive.sh index e919306..058c3b7 100644 --- a/tools/perf/perf-archive.sh +++ b/tools/perf/perf-archive.sh @@ -18,7 +18,16 @@ else PERF_BUILDID_DIR=$PERF_BUILDID_DIR/ fi -BUILDIDS=$(mktemp /tmp/perf-archive-buildids.XX) +# +# PERF_TMP_DIR environment variable set by perf +# path to temp directory, default to /tmp +# +if [ -z $PERF_TMP_DIR ]; then + PERF_TMP_DIR=/tmp +fi + + +BUILDIDS=$(mktemp $PERF_TMP_DIR/perf-archive-buildids.XX) NOBUILDID= perf buildid-list -i $PERF_DATA --with-hits | grep -v "^$NOBUILDID " > $BUILDIDS @@ -28,7 +37,7 @@ if [ ! -s $BUILDIDS ] ; then exit 1 fi
Re: [PATCH v4 1/6] perf tools: configure tmp path at build time
On Tue, Oct 16, 2012 at 6:18 PM, Arnaldo Carvalho de Melo wrote: > Em Tue, Oct 16, 2012 at 02:33:35AM +0300, Irina Tirdea escreveu: >> From: Irina Tirdea >> >> Temporary perf files are hardcoded to point to /tmp. Android does not have >> a /tmp directory so it needs to set this path at compile time. >> >> Add a compile-time definition (PERF_TMP_DIR) in the Makefile that sets the >> path >> to temp directory. By default it points to /tmp. >> >> $(OUTPUT)util/parse-events.o: $(OUTPUT)util/parse-events-flex.c >> $(OUTPUT)util/parse-events-bison.c >> -$(OUTPUT)util/pmu.o: $(OUTPUT)util/pmu-flex.c $(OUTPUT)util/pmu-bison.c >> +$(OUTPUT)util/pmu.o: util/pmu.c $(OUTPUT)util/pmu-flex.c >> $(OUTPUT)util/pmu-bison.c $(OUTPUT)PERF-CFLAGS >> + $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) >> -DPERF_TMP_DIR='"$(PERF_TMP_DIR)"' $< >> >> LIB_FILE=$(OUTPUT)libperf.a >> >> @@ -889,6 +892,21 @@ $(OUTPUT)util/exec_cmd.o: util/exec_cmd.c >> $(OUTPUT)PERF-CFLAGS >> $(OUTPUT)util/config.o: util/config.c $(OUTPUT)PERF-CFLAGS >> $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) >> -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $< > > Humm, so we need to add an specific rule for each source file that needs > PERF_TMP_DIR? Why not make it available to all source files? > I've seen this is the way other defines are handled (PERF_HTML_PATH, PERF_INFO_PATH, etc). But PERF_TMP_DIR is used in more places so it makes sense to make it available to all source files. I'll make the changes (for both PERF_TMP_DIR and PERF_SHELL_PATH) and resubmit. >> +$(OUTPUT)util/dso-test-data.o: util/dso-test-data.c $(OUTPUT)PERF-CFLAGS >> + $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) >> -DPERF_TMP_DIR='"$(PERF_TMP_DIR)"' $< >> + >> +$(OUTPUT)util/map.o: util/map.c $(OUTPUT)PERF-CFLAGS >> + $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) >> -DPERF_TMP_DIR='"$(PERF_TMP_DIR)"' $< >> + >> +$(OUTPUT)util/symbol.o: util/symbol.c $(OUTPUT)PERF-CFLAGS >> + $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) >> -DPERF_TMP_DIR='"$(PERF_TMP_DIR)"' $< >> + >> +$(OUTPUT)util/trace-event-info.o: util/trace-event-info.c >> $(OUTPUT)PERF-CFLAGS >> + $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) >> -DPERF_TMP_DIR='"$(PERF_TMP_DIR)"' $< >> + >> +$(OUTPUT)util/vdso.o: util/vdso.c $(OUTPUT)PERF-CFLAGS >> + $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) >> -DPERF_TMP_DIR='"$(PERF_TMP_DIR)"' $< >> + >> $(OUTPUT)ui/browser.o: ui/browser.c $(OUTPUT)PERF-CFLAGS >> $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DENABLE_SLFUTURE_CONST $< >> Thanks, Irina -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v4 3/6] perf tools: add --addr2line command line option
On Tue, Oct 16, 2012 at 6:21 PM, Arnaldo Carvalho de Melo wrote: > Em Tue, Oct 16, 2012 at 02:33:37AM +0300, Irina Tirdea escreveu: >> From: Irina Tirdea >> >> When analyzing data recorded on a target with a different architecture >> than the host, we must use addr2line from the toolchain for that >> architecture. >> >> Add a command line option to allow setting addr2line at runtime. > > You're doing two things here: > > 1. Adding --addr2line > > 2. fixing a bug for unresolved symbols > > Please try not to do that, instead provide two patches, one addressing > each issue. > You're absolutely right. Missed this. > Furthermore, Namhyung fixed #2 already: > > commit a2c1311c4cbd47a087e95be18fee79ead3d0744b > Author: Namhyung Kim > Date: Mon Oct 15 12:39:42 2012 +0900 > > perf tools: Fix segfault when using srcline sort key > > - Arnaldo Thanks, Irina -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v5 0/6] perf tools: fixes for Android
From: Irina Tirdea This is version 5 for the Android fixes. Previous version can be found at [1]. The patches are on top of current perf/core branch from Arnaldo's git tree (git.kernel.org/pub/scm/linux/kernel/git/acme/linux). Changes v4->v5: () make PERF_TMP_DIR and PERF_SHELL_PATH available to all source files (patch 1 & 2) (Arnaldo) () split addr2line changes in 2 patches (patch 3 & 5) (Arnaldo) Changes v3->v4: () patch 1: fixed compilation issue when calling make from kernel root directory () patch 4: renamed try_binutils_path to perf_session_env__lookup_binutils_path () patch 4: replaced scnprintf + strdup with asprintf () patch 4: handle errors and print messages in case cross-built objdump is not found () patch 3,5: split patch with addr2line changes in 2 patches () patch 6: set default ret to -ENOMEM in order to avoid setting it every time Thanks, Irina [1] https://lkml.org/lkml/2012/10/15/633 Irina Tirdea (6): perf tools: configure tmp path at build time perf tools: configure shell path at compile time perf tools: add --addr2line command line option perf tools: Try to find cross-built addr2line path perf tools: fix using --sysroot with addr2line perf stat: implement --big-num grouping tools/perf/Documentation/android.txt | 19 + tools/perf/Documentation/jit-interface.txt |4 +- tools/perf/Documentation/perf-annotate.txt |2 + tools/perf/Documentation/perf-report.txt |2 + tools/perf/Makefile| 12 +++- tools/perf/arch/common.c |6 ++ tools/perf/arch/common.h |2 + tools/perf/builtin-annotate.c |9 +++ tools/perf/builtin-help.c |2 +- tools/perf/builtin-report.c|9 +++ tools/perf/builtin-script.c| 12 ++-- tools/perf/builtin-stat.c | 106 ++-- tools/perf/config/feature-tests.mak| 18 + tools/perf/perf-archive.sh | 13 +++- tools/perf/util/annotate.c | 13 +++- tools/perf/util/dso-test-data.c|2 +- tools/perf/util/map.c |3 +- tools/perf/util/pmu.c |2 +- tools/perf/util/sort.c | 17 - tools/perf/util/symbol.c |4 +- tools/perf/util/trace-event-info.c |2 +- tools/perf/util/vdso.c |2 +- 22 files changed, 233 insertions(+), 28 deletions(-) -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v5 1/6] perf tools: configure tmp path at build time
From: Irina Tirdea Temporary perf files are hardcoded to point to /tmp. Android does not have a /tmp directory so it needs to set this path at compile time. Add a compile-time definition (PERF_TMP_DIR) in the Makefile that sets the path to temp directory. By default it points to /tmp. Signed-off-by: Irina Tirdea --- tools/perf/Documentation/android.txt |1 + tools/perf/Documentation/jit-interface.txt |4 +++- tools/perf/Makefile|4 +++- tools/perf/perf-archive.sh | 13 +++-- tools/perf/util/dso-test-data.c|2 +- tools/perf/util/map.c |3 ++- tools/perf/util/pmu.c |2 +- tools/perf/util/sort.c |4 +++- tools/perf/util/symbol.c |4 +++- tools/perf/util/trace-event-info.c |2 +- tools/perf/util/vdso.c |2 +- 11 files changed, 30 insertions(+), 11 deletions(-) diff --git a/tools/perf/Documentation/android.txt b/tools/perf/Documentation/android.txt index a39dbbb..24fd01c 100644 --- a/tools/perf/Documentation/android.txt +++ b/tools/perf/Documentation/android.txt @@ -68,6 +68,7 @@ Some perf features need environment variables to run properly. You need to set these before running perf on the target: adb shell # PERF_PAGER=cat + # PERF_TMP_DIR=/data/local/tmp IV. Run perf diff --git a/tools/perf/Documentation/jit-interface.txt b/tools/perf/Documentation/jit-interface.txt index a8656f5..10cb6ec 100644 --- a/tools/perf/Documentation/jit-interface.txt +++ b/tools/perf/Documentation/jit-interface.txt @@ -1,7 +1,9 @@ perf supports a simple JIT interface to resolve symbols for dynamic code generated by a JIT. -The JIT has to write a /tmp/perf-%d.map (%d = pid of process) file +The JIT has to write a $PERF_TMP_DIR/perf-%d.map (%d = pid of process) file. +You can set $PERF_TMP_DIR at compile time in the Makefile. +By default it is /tmp. This is a text file. diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 76190a7..5429b5b 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -141,6 +141,7 @@ sysconfdir = $(prefix)/etc ETC_PERFCONFIG = etc/perfconfig endif lib = lib +PERF_TMP_DIR = /tmp export prefix bindir sharedir sysconfdir @@ -169,7 +170,7 @@ endif ### --- END CONFIGURATION SECTION --- -BASIC_CFLAGS = -Iutil/include -Iarch/$(ARCH)/include -I$(OUTPUT)util -I$(TRACE_EVENT_DIR) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE +BASIC_CFLAGS = -Iutil/include -Iarch/$(ARCH)/include -I$(OUTPUT)util -I$(TRACE_EVENT_DIR) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -DPERF_TMP_DIR='"$(PERF_TMP_DIR)"' BASIC_LDFLAGS = ifeq ($(call try-cc,$(SOURCE_BIONIC),$(CFLAGS),bionic),y) @@ -177,6 +178,7 @@ ifeq ($(call try-cc,$(SOURCE_BIONIC),$(CFLAGS),bionic),y) EXTLIBS := $(filter-out -lrt,$(EXTLIBS)) EXTLIBS := $(filter-out -lpthread,$(EXTLIBS)) BASIC_CFLAGS += -I. + PERF_TMP_DIR = /data/local/tmp endif # Guard against environment variables diff --git a/tools/perf/perf-archive.sh b/tools/perf/perf-archive.sh index e919306..058c3b7 100644 --- a/tools/perf/perf-archive.sh +++ b/tools/perf/perf-archive.sh @@ -18,7 +18,16 @@ else PERF_BUILDID_DIR=$PERF_BUILDID_DIR/ fi -BUILDIDS=$(mktemp /tmp/perf-archive-buildids.XX) +# +# PERF_TMP_DIR environment variable set by perf +# path to temp directory, default to /tmp +# +if [ -z $PERF_TMP_DIR ]; then + PERF_TMP_DIR=/tmp +fi + + +BUILDIDS=$(mktemp $PERF_TMP_DIR/perf-archive-buildids.XX) NOBUILDID= perf buildid-list -i $PERF_DATA --with-hits | grep -v "^$NOBUILDID " > $BUILDIDS @@ -28,7 +37,7 @@ if [ ! -s $BUILDIDS ] ; then exit 1 fi -MANIFEST=$(mktemp /tmp/perf-archive-manifest.XX) +MANIFEST=$(mktemp $PERF_TMP_DIR/perf-archive-manifest.XX) PERF_BUILDID_LINKDIR=$(readlink -f $PERF_BUILDID_DIR)/ cut -d ' ' -f 1 $BUILDIDS | \ diff --git a/tools/perf/util/dso-test-data.c b/tools/perf/util/dso-test-data.c index c6caede..ca81e65 100644 --- a/tools/perf/util/dso-test-data.c +++ b/tools/perf/util/dso-test-data.c @@ -18,7 +18,7 @@ do { \ static char *test_file(int size) { - static char buf_templ[] = "/tmp/test-XX"; + static char buf_templ[] = PERF_TMP_DIR "/test-XX"; char *templ = buf_templ; int fd, i; unsigned char *buf; diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index 6109fa4..4e69b57 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c @@ -59,7 +59,8 @@ struct map *map__new(struct list_head *dsos__list, u64 start, u64 len, no_dso = is_no_dso_memory(filename); if (anon) { - snprintf(newfilename, sizeof(newfilename), "/tmp/perf
[PATCH v5 2/6] perf tools: configure shell path at compile time
From: Irina Tirdea Shell path /bin/sh is hardcoded in various places in perf. Android has a different folder structure and does not have /bin/sh. Set the shell path at compile time in the Makefile by setting PERF_SHELL_PATH. By default it is set to /bin/sh. Signed-off-by: Irina Tirdea --- tools/perf/Makefile |4 +++- tools/perf/builtin-help.c |2 +- tools/perf/builtin-script.c | 12 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 5429b5b..78fc6b9 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -142,6 +142,7 @@ ETC_PERFCONFIG = etc/perfconfig endif lib = lib PERF_TMP_DIR = /tmp +PERF_SHELL_PATH = /bin/sh export prefix bindir sharedir sysconfdir @@ -170,7 +171,7 @@ endif ### --- END CONFIGURATION SECTION --- -BASIC_CFLAGS = -Iutil/include -Iarch/$(ARCH)/include -I$(OUTPUT)util -I$(TRACE_EVENT_DIR) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -DPERF_TMP_DIR='"$(PERF_TMP_DIR)"' +BASIC_CFLAGS = -Iutil/include -Iarch/$(ARCH)/include -I$(OUTPUT)util -I$(TRACE_EVENT_DIR) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -DPERF_TMP_DIR='"$(PERF_TMP_DIR)"' -DPERF_SHELL_PATH='"$(PERF_SHELL_PATH)"' BASIC_LDFLAGS = ifeq ($(call try-cc,$(SOURCE_BIONIC),$(CFLAGS),bionic),y) @@ -179,6 +180,7 @@ ifeq ($(call try-cc,$(SOURCE_BIONIC),$(CFLAGS),bionic),y) EXTLIBS := $(filter-out -lpthread,$(EXTLIBS)) BASIC_CFLAGS += -I. PERF_TMP_DIR = /data/local/tmp + PERF_SHELL_PATH = /system/bin/sh endif # Guard against environment variables diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c index 411ee56..542b752 100644 --- a/tools/perf/builtin-help.c +++ b/tools/perf/builtin-help.c @@ -154,7 +154,7 @@ static void exec_man_cmd(const char *cmd, const char *page) { struct strbuf shell_cmd = STRBUF_INIT; strbuf_addf(&shell_cmd, "%s %s", cmd, page); - execl("/bin/sh", "sh", "-c", shell_cmd.buf, NULL); + execl(PERF_SHELL_PATH, "sh", "-c", shell_cmd.buf, NULL); warning("failed to exec '%s': %s", cmd, strerror(errno)); } diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 04ceb07..d0d3a21 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -1320,7 +1320,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) goto out; } - __argv[j++] = "/bin/sh"; + __argv[j++] = PERF_SHELL_PATH; __argv[j++] = rec_script_path; if (system_wide) __argv[j++] = "-a"; @@ -1331,7 +1331,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) __argv[j++] = argv[i]; __argv[j++] = NULL; - execvp("/bin/sh", (char **)__argv); + execvp(PERF_SHELL_PATH, (char **)__argv); free(__argv); exit(-1); } @@ -1347,7 +1347,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) } j = 0; - __argv[j++] = "/bin/sh"; + __argv[j++] = PERF_SHELL_PATH; __argv[j++] = rep_script_path; for (i = 1; i < rep_args + 1; i++) __argv[j++] = argv[i]; @@ -1355,7 +1355,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) __argv[j++] = "-"; __argv[j++] = NULL; - execvp("/bin/sh", (char **)__argv); + execvp(PERF_SHELL_PATH, (char **)__argv); free(__argv); exit(-1); } @@ -1384,7 +1384,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) goto out; } - __argv[j++] = "/bin/sh"; + __argv[j++] = PERF_SHELL_PATH; __argv[j++] = script_path; if (system_wide) __argv[j++] = "-a"; @@ -1392,7 +1392,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) __argv[j++] = argv[i]; __argv[j++] = NULL; - execvp("/bin/sh", (char **)__argv); + execvp(PERF_SHELL_PATH, (char **)__argv); free(__argv); exit(-1); } -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v5 3/6] perf tools: add --addr2line command line option
From: Irina Tirdea When analyzing data recorded on a target with a different architecture than the host, we must use addr2line from the toolchain for that architecture. Add a command line option to allow setting addr2line at runtime. Signed-off-by: Irina Tirdea --- tools/perf/Documentation/perf-annotate.txt |2 ++ tools/perf/Documentation/perf-report.txt |2 ++ tools/perf/builtin-annotate.c |3 +++ tools/perf/builtin-report.c|3 +++ tools/perf/util/annotate.c |5 - tools/perf/util/sort.c |3 ++- tools/perf/util/sort.h |1 + 7 files changed, 17 insertions(+), 2 deletions(-) diff --git a/tools/perf/Documentation/perf-annotate.txt b/tools/perf/Documentation/perf-annotate.txt index c8ffd9f..177906a 100644 --- a/tools/perf/Documentation/perf-annotate.txt +++ b/tools/perf/Documentation/perf-annotate.txt @@ -87,6 +87,8 @@ OPTIONS --objdump=:: Path to objdump binary. +--addr2line=:: +Path to addr2line binary. SEE ALSO diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt index f4d91be..b6bb26e 100644 --- a/tools/perf/Documentation/perf-report.txt +++ b/tools/perf/Documentation/perf-report.txt @@ -170,6 +170,8 @@ OPTIONS --objdump=:: Path to objdump binary. +--addr2line=:: +Path to addr2line binary. SEE ALSO diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index c4bb645..e4df5da 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c @@ -292,6 +292,9 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused) "Specify disassembler style (e.g. -M intel for intel syntax)"), OPT_STRING(0, "objdump", &objdump_path, "path", "objdump binary to use for disassembly and annotations"), + OPT_STRING(0, "addr2line", &addr2line_path, "path", + "addr2line binary to use for obtaining " + "file names and line numbers"), OPT_END() }; diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 90d1162..9c0fe68 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -642,6 +642,9 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused) "use branch records for histogram filling", parse_branch_mode), OPT_STRING(0, "objdump", &objdump_path, "path", "objdump binary to use for disassembly and annotations"), + OPT_STRING(0, "addr2line", &addr2line_path, "path", + "addr2line binary to use for obtaining " + "file names and line numbers"), OPT_END() }; diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index f0a9103..9c0fa54 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -18,6 +18,7 @@ const char *disassembler_style; const char *objdump_path; +const char *addr2line_path; static struct ins *ins__find(const char *name); static int disasm_line__parse(char *line, char **namep, char **rawp); @@ -915,7 +916,9 @@ static int symbol__get_source_line(struct symbol *sym, struct map *map, continue; offset = start + i; - sprintf(cmd, "addr2line -e %s %016" PRIx64, filename, offset); + sprintf(cmd, "%s -e %s %016" PRIx64, + addr2line_path ? addr2line_path : "addr2line", + filename, offset); fp = popen(cmd, "r"); if (!fp) continue; diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index d579406..19cc046 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -268,7 +268,8 @@ static int hist_entry__srcline_snprintf(struct hist_entry *self, char *bf, strlen(PERF_TMP_DIR "/perf-"))) goto out_ip; - snprintf(cmd, sizeof(cmd), "addr2line -e %s %016" PRIx64, + snprintf(cmd, sizeof(cmd), "%s -e %s %016" PRIx64, +addr2line_path ? addr2line_path : "addr2line", self->ms.map->dso->long_name, self->ip); fp = popen(cmd, "r"); if (!fp) diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h index 13761d8..c8e58f6 100644 --- a/tools/perf/util/sort.h +++ b/tools/perf/util/sort.h @@ -139,6 +139,7 @@ struct sort_entry { extern struct sort_entry sort_thread; extern struct list_head hist_entry__sort_list; +extern const char *addr2line_path; void setup_sortin