* [PATCH 0/2] perf tools: improve perf support on Android @ 2014-05-16 23:14 Stephane Eranian 2014-05-16 23:14 ` [PATCH 1/2] perf tools: add cat as fallback pager Stephane Eranian 2014-05-16 23:14 ` [PATCH 2/2] perf tools: add automatic remapping of Android libraries Stephane Eranian 0 siblings, 2 replies; 6+ messages in thread From: Stephane Eranian @ 2014-05-16 23:14 UTC (permalink / raw) To: linux-kernel; +Cc: peterz, mingo, acme, jolsa, namhyung.kim, Michael Lentine From: Michael Lentine <mlentine@google.com> This short series of patches allow for the execution of perf natively on the android devices. The following changes are implemented: - Have cat be the default page. Android does not have less or more pager. this is a generic change which cleans up the code a bit - Remap library paths to allow for data reporting on a linux pc with data collected from an android device. Patches relative to tip.git. Signed-off-by: Michael Lentine <mlentine@google.com> Michael Lentine (2): perf tools: add a fallback for pager to use cat if less does not exist. perf tools: add automatic remapping of Android libraries tools/perf/util/map.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++- tools/perf/util/pager.c | 12 +++---- 2 files changed, 94 insertions(+), 7 deletions(-) -- 1.9.1.423.g4596e3a ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] perf tools: add cat as fallback pager 2014-05-16 23:14 [PATCH 0/2] perf tools: improve perf support on Android Stephane Eranian @ 2014-05-16 23:14 ` Stephane Eranian 2014-05-17 1:55 ` David Ahern 2014-05-16 23:14 ` [PATCH 2/2] perf tools: add automatic remapping of Android libraries Stephane Eranian 1 sibling, 1 reply; 6+ messages in thread From: Stephane Eranian @ 2014-05-16 23:14 UTC (permalink / raw) To: linux-kernel; +Cc: peterz, mingo, acme, jolsa, namhyung.kim, Michael Lentine From: Michael Lentine <mlentine@google.com> This patch adds a fallback to cat for the pager. This is useful on environmnents, such as Android, where less does not exist. It is better to default to cat than to abort. Reviewed-by: Stephane Eranian <eranian@google.com> Signed-off-by: Michael Lentine <mlentine@google.com> --- tools/perf/util/pager.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/perf/util/pager.c b/tools/perf/util/pager.c index 3322b84..5feec3d 100644 --- a/tools/perf/util/pager.c +++ b/tools/perf/util/pager.c @@ -57,13 +57,13 @@ void setup_pager(void) } if (!pager) pager = getenv("PAGER"); - if (!pager) { - if (!access("/usr/bin/pager", X_OK)) - pager = "/usr/bin/pager"; - } - if (!pager) + if (!(pager || access("/usr/bin/pager", X_OK))) + pager = "/usr/bin/pager"; + if (!(pager || access("/usr/bin/less", X_OK))) pager = "less"; - else if (!*pager || !strcmp(pager, "cat")) + if (!pager) + pager = "cat"; + if (!*pager || !strcmp(pager, "cat")) return; spawned_pager = 1; /* means we are emitting to terminal */ -- 1.9.1.423.g4596e3a ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] perf tools: add cat as fallback pager 2014-05-16 23:14 ` [PATCH 1/2] perf tools: add cat as fallback pager Stephane Eranian @ 2014-05-17 1:55 ` David Ahern 0 siblings, 0 replies; 6+ messages in thread From: David Ahern @ 2014-05-17 1:55 UTC (permalink / raw) To: Stephane Eranian, linux-kernel Cc: peterz, mingo, acme, jolsa, namhyung.kim, Michael Lentine On 5/16/14, 5:14 PM, Stephane Eranian wrote: > From: Michael Lentine <mlentine@google.com> > > This patch adds a fallback to cat for the pager. This is useful > on environmnents, such as Android, where less does not exist. > It is better to default to cat than to abort. > > Reviewed-by: Stephane Eranian <eranian@google.com> > Signed-off-by: Michael Lentine <mlentine@google.com> > --- > tools/perf/util/pager.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/tools/perf/util/pager.c b/tools/perf/util/pager.c > index 3322b84..5feec3d 100644 > --- a/tools/perf/util/pager.c > +++ b/tools/perf/util/pager.c > @@ -57,13 +57,13 @@ void setup_pager(void) > } > if (!pager) > pager = getenv("PAGER"); > - if (!pager) { > - if (!access("/usr/bin/pager", X_OK)) > - pager = "/usr/bin/pager"; > - } > - if (!pager) > + if (!(pager || access("/usr/bin/pager", X_OK))) > + pager = "/usr/bin/pager"; > + if (!(pager || access("/usr/bin/less", X_OK))) > pager = "less"; If you check for /usr/bin/less shouldn't the full path be used here? David ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] perf tools: add automatic remapping of Android libraries 2014-05-16 23:14 [PATCH 0/2] perf tools: improve perf support on Android Stephane Eranian 2014-05-16 23:14 ` [PATCH 1/2] perf tools: add cat as fallback pager Stephane Eranian @ 2014-05-16 23:14 ` Stephane Eranian 2014-05-19 9:58 ` Jiri Olsa 1 sibling, 1 reply; 6+ messages in thread From: Stephane Eranian @ 2014-05-16 23:14 UTC (permalink / raw) To: linux-kernel; +Cc: peterz, mingo, acme, jolsa, namhyung.kim, Michael Lentine From: Michael Lentine <mlentine@google.com> This patch automtically adjusts the path of MMAP records associated with Android system libraries. It enables running perf reporting tools directly on the Android system natively. Reviewed-by: Stephane Eranian <eranian@google.com> Signed-off-by: Michael Lentine <mlentine@google.com> --- tools/perf/util/map.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 88 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index ba5f5c0c..1960883 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c @@ -32,6 +32,86 @@ static inline int is_no_dso_memory(const char *filename) !strcmp(filename, "[heap]"); } +static inline int is_android_lib(const char *filename) +{ + return !strncmp(filename, "/data/app-lib", 13) || + !strncmp(filename, "/system/lib", 11); +} + +static inline bool replace_android_lib(const char *filename, char **newfilename) +{ + const char *libname; + char *app_abi; + size_t app_abi_length, new_length; + size_t lib_length = 0; + + libname = strrchr(filename, '/'); + if (libname) + lib_length = strlen(libname); + + app_abi = getenv("APP_ABI"); + if (!app_abi) + return false; + + app_abi_length = strlen(app_abi); + + if (!strncmp(filename, "/data/app-lib", 13)) { + char *apk_path; + + if (!app_abi_length) + return false; + + new_length = 7 + app_abi_length + lib_length; + + apk_path = getenv("APK_PATH"); + if(apk_path) { + snprintf(*newfilename, new_length + strlen(apk_path) + 1, + "%s/libs/%s/%s", apk_path, app_abi, libname); + } else { + snprintf(*newfilename, new_length, + "libs/%s/%s", app_abi, libname); + } + return true; + } + + if (!strncmp(filename, "/system/lib/", 11)) { + char *ndk, *app; + const char *arch; + size_t ndk_length; + size_t app_length; + + ndk = getenv("NDK_ROOT"); + app = getenv("APP_PLATFORM"); + + if (!(ndk && app)) + return false; + + ndk_length = strlen(ndk); + app_length = strlen(app); + + if (!(ndk_length && app_length && app_abi_length)) + return false; + + arch = !strncmp(app_abi, "arm", 3) ? "arm" : + !strncmp(app_abi, "mips", 4) ? "mips" : + !strncmp(app_abi, "x86", 3) ? "x86" : NULL; + + if (!arch) + return false; + + new_length = 27 + ndk_length + + app_length + lib_length + + strlen(arch); + + snprintf(*newfilename, new_length, + "%s/platforms/%s/arch-%s/usr/lib/%s", + ndk, app, arch, libname); + + return true; + } + return false; +} + void map__init(struct map *map, enum map_type type, u64 start, u64 end, u64 pgoff, struct dso *dso) { @@ -59,8 +139,9 @@ struct map *map__new(struct list_head *dsos__list, u64 start, u64 len, if (map != NULL) { char newfilename[PATH_MAX]; struct dso *dso; - int anon, no_dso, vdso; + int anon, no_dso, vdso, android; + android = is_android_lib(filename); anon = is_anon_memory(filename); vdso = is_vdso_map(filename); no_dso = is_no_dso_memory(filename); @@ -75,6 +156,12 @@ struct map *map__new(struct list_head *dsos__list, u64 start, u64 len, filename = newfilename; } + if (android) { + char *newfilename_ptr = newfilename; + if (replace_android_lib(filename, &newfilename_ptr)) + filename = newfilename; + } + if (vdso) { pgoff = 0; dso = vdso__dso_findnew(dsos__list); -- 1.9.1.423.g4596e3a ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] perf tools: add automatic remapping of Android libraries 2014-05-16 23:14 ` [PATCH 2/2] perf tools: add automatic remapping of Android libraries Stephane Eranian @ 2014-05-19 9:58 ` Jiri Olsa 0 siblings, 0 replies; 6+ messages in thread From: Jiri Olsa @ 2014-05-19 9:58 UTC (permalink / raw) To: Stephane Eranian Cc: linux-kernel, peterz, mingo, acme, namhyung.kim, Michael Lentine On Sat, May 17, 2014 at 01:14:47AM +0200, Stephane Eranian wrote: > From: Michael Lentine <mlentine@google.com> > > This patch automtically adjusts the path of MMAP records > associated with Android system libraries. It enables running > perf reporting tools directly on the Android system natively. could the changelog have more info about the lib name changes? SNIP > + > + if (!strncmp(filename, "/data/app-lib", 13)) { > + char *apk_path; > + > + if (!app_abi_length) > + return false; > + > + new_length = 7 + app_abi_length + lib_length; > + > + apk_path = getenv("APK_PATH"); > + if(apk_path) { > + snprintf(*newfilename, new_length + strlen(apk_path) + 1, > + "%s/libs/%s/%s", apk_path, app_abi, libname); > + } else { > + snprintf(*newfilename, new_length, > + "libs/%s/%s", app_abi, libname); > + } missing check for overflowing PATH_MAX for 'new_length' and 'new_length + strlen(apk_path) + 1' > + return true; > + } > + > + if (!strncmp(filename, "/system/lib/", 11)) { > + char *ndk, *app; > + const char *arch; > + size_t ndk_length; > + size_t app_length; > + > + ndk = getenv("NDK_ROOT"); > + app = getenv("APP_PLATFORM"); > + > + if (!(ndk && app)) > + return false; > + > + ndk_length = strlen(ndk); > + app_length = strlen(app); > + > + if (!(ndk_length && app_length && app_abi_length)) > + return false; > + > + arch = !strncmp(app_abi, "arm", 3) ? "arm" : > + !strncmp(app_abi, "mips", 4) ? "mips" : > + !strncmp(app_abi, "x86", 3) ? "x86" : NULL; > + > + if (!arch) > + return false; > + > + new_length = 27 + ndk_length + > + app_length + lib_length > + + strlen(arch); missing check for overflowing PATH_MAX for 'new_length' > + > + snprintf(*newfilename, new_length, > + "%s/platforms/%s/arch-%s/usr/lib/%s", > + ndk, app, arch, libname); > + > + return true; > + } > + return false; > +} > + SNIP > + if (android) { > + char *newfilename_ptr = newfilename; > + if (replace_android_lib(filename, &newfilename_ptr)) > + filename = newfilename; Why is the newfilename_ptr needed? We could pass newfilename directly to replace_android_lib function if (replace_android_lib(filename, newfilename)) filename = newfilename; thanks, jirka ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 0/2] perf tools: improve perf support on Android @ 2014-05-16 23:15 Stephane Eranian 2014-05-16 23:15 ` [PATCH 1/2] perf tools: add cat as fallback pager Stephane Eranian 0 siblings, 1 reply; 6+ messages in thread From: Stephane Eranian @ 2014-05-16 23:15 UTC (permalink / raw) To: linux-kernel; +Cc: peterz, mingo, acme, jolsa, namhyung, Michael Lentine From: Michael Lentine <mlentine@google.com> This short series of patches allow for the execution of perf natively on the android devices. The following changes are implemented: - Have cat be the default page. Android does not have less or more pager. this is a generic change which cleans up the code a bit - Remap library paths to allow for data reporting on a linux pc with data collected from an android device. Patches relative to tip.git. Signed-off-by: Michael Lentine <mlentine@google.com> Michael Lentine (2): perf tools: add a fallback for pager to use cat if less does not exist. perf tools: add automatic remapping of Android libraries tools/perf/util/map.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++- tools/perf/util/pager.c | 12 +++---- 2 files changed, 94 insertions(+), 7 deletions(-) -- 1.9.1.423.g4596e3a ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] perf tools: add cat as fallback pager 2014-05-16 23:15 [PATCH 0/2] perf tools: improve perf support on Android Stephane Eranian @ 2014-05-16 23:15 ` Stephane Eranian 0 siblings, 0 replies; 6+ messages in thread From: Stephane Eranian @ 2014-05-16 23:15 UTC (permalink / raw) To: linux-kernel; +Cc: peterz, mingo, acme, jolsa, namhyung, Michael Lentine From: Michael Lentine <mlentine@google.com> This patch adds a fallback to cat for the pager. This is useful on environmnents, such as Android, where less does not exist. It is better to default to cat than to abort. Reviewed-by: Stephane Eranian <eranian@google.com> Signed-off-by: Michael Lentine <mlentine@google.com> --- tools/perf/util/pager.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/perf/util/pager.c b/tools/perf/util/pager.c index 3322b84..5feec3d 100644 --- a/tools/perf/util/pager.c +++ b/tools/perf/util/pager.c @@ -57,13 +57,13 @@ void setup_pager(void) } if (!pager) pager = getenv("PAGER"); - if (!pager) { - if (!access("/usr/bin/pager", X_OK)) - pager = "/usr/bin/pager"; - } - if (!pager) + if (!(pager || access("/usr/bin/pager", X_OK))) + pager = "/usr/bin/pager"; + if (!(pager || access("/usr/bin/less", X_OK))) pager = "less"; - else if (!*pager || !strcmp(pager, "cat")) + if (!pager) + pager = "cat"; + if (!*pager || !strcmp(pager, "cat")) return; spawned_pager = 1; /* means we are emitting to terminal */ -- 1.9.1.423.g4596e3a ^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-05-19 9:59 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-05-16 23:14 [PATCH 0/2] perf tools: improve perf support on Android Stephane Eranian 2014-05-16 23:14 ` [PATCH 1/2] perf tools: add cat as fallback pager Stephane Eranian 2014-05-17 1:55 ` David Ahern 2014-05-16 23:14 ` [PATCH 2/2] perf tools: add automatic remapping of Android libraries Stephane Eranian 2014-05-19 9:58 ` Jiri Olsa -- strict thread matches above, loose matches on Subject: below -- 2014-05-16 23:15 [PATCH 0/2] perf tools: improve perf support on Android Stephane Eranian 2014-05-16 23:15 ` [PATCH 1/2] perf tools: add cat as fallback pager Stephane Eranian
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.