linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf auxtrace: Alter addr_filter__entire_dso() to work if there are no symbols
@ 2018-11-27  8:46 Adrian Hunter
  2018-11-27 12:42 ` Arnaldo Carvalho de Melo
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Adrian Hunter @ 2018-11-27  8:46 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo; +Cc: Jiri Olsa, linux-kernel

addr_filter__entire_dso() uses the first and last symbols from a dso,
and so does not work when there are no symbols.  Alter it to filter the
whole file instead.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 tools/perf/util/auxtrace.c | 11 ++++-------
 tools/perf/util/dso.c      |  6 +++---
 tools/perf/util/dso.h      |  1 +
 3 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c
index 72d5ba2479bf..f69961c4a4f3 100644
--- a/tools/perf/util/auxtrace.c
+++ b/tools/perf/util/auxtrace.c
@@ -1983,17 +1983,14 @@ static int find_dso_sym(struct dso *dso, const char *sym_name, u64 *start,
 
 static int addr_filter__entire_dso(struct addr_filter *filt, struct dso *dso)
 {
-	struct symbol *first_sym = dso__first_symbol(dso);
-	struct symbol *last_sym = dso__last_symbol(dso);
-
-	if (!first_sym || !last_sym) {
-		pr_err("Failed to determine filter for %s\nNo symbols found.\n",
+	if (dso__data_file_size(dso, NULL)) {
+		pr_err("Failed to determine filter for %s\nCannot determine file size.\n",
 		       filt->filename);
 		return -EINVAL;
 	}
 
-	filt->addr = first_sym->start;
-	filt->size = last_sym->end - first_sym->start;
+	filt->addr = 0;
+	filt->size = dso->data.file_size;
 
 	return 0;
 }
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index bbed90e5d9bb..721f3d583945 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -894,7 +894,7 @@ static ssize_t cached_read(struct dso *dso, struct machine *machine,
 	return r;
 }
 
-static int data_file_size(struct dso *dso, struct machine *machine)
+int dso__data_file_size(struct dso *dso, struct machine *machine)
 {
 	int ret = 0;
 	struct stat st;
@@ -943,7 +943,7 @@ static int data_file_size(struct dso *dso, struct machine *machine)
  */
 off_t dso__data_size(struct dso *dso, struct machine *machine)
 {
-	if (data_file_size(dso, machine))
+	if (dso__data_file_size(dso, machine))
 		return -1;
 
 	/* For now just estimate dso data size is close to file size */
@@ -953,7 +953,7 @@ off_t dso__data_size(struct dso *dso, struct machine *machine)
 static ssize_t data_read_offset(struct dso *dso, struct machine *machine,
 				u64 offset, u8 *data, ssize_t size)
 {
-	if (data_file_size(dso, machine))
+	if (dso__data_file_size(dso, machine))
 		return -1;
 
 	/* Check the offset sanity. */
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
index c5380500bed4..8c8a7abe809d 100644
--- a/tools/perf/util/dso.h
+++ b/tools/perf/util/dso.h
@@ -322,6 +322,7 @@ int dso__data_get_fd(struct dso *dso, struct machine *machine);
 void dso__data_put_fd(struct dso *dso);
 void dso__data_close(struct dso *dso);
 
+int dso__data_file_size(struct dso *dso, struct machine *machine);
 off_t dso__data_size(struct dso *dso, struct machine *machine);
 ssize_t dso__data_read_offset(struct dso *dso, struct machine *machine,
 			      u64 offset, u8 *data, ssize_t size);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] perf auxtrace: Alter addr_filter__entire_dso() to work if there are no symbols
  2018-11-27  8:46 [PATCH] perf auxtrace: Alter addr_filter__entire_dso() to work if there are no symbols Adrian Hunter
@ 2018-11-27 12:42 ` Arnaldo Carvalho de Melo
  2018-12-10 13:17   ` Adrian Hunter
  2018-12-20 17:57 ` [tip:perf/core] perf dso: Export data_file_size() method " tip-bot for Adrian Hunter
  2018-12-20 17:58 ` [tip:perf/core] perf auxtrace: Alter addr_filter__entire_dso() to work if " tip-bot for Adrian Hunter
  2 siblings, 1 reply; 6+ messages in thread
From: Arnaldo Carvalho de Melo @ 2018-11-27 12:42 UTC (permalink / raw)
  To: Adrian Hunter; +Cc: Jiri Olsa, linux-kernel

Em Tue, Nov 27, 2018 at 10:46:34AM +0200, Adrian Hunter escreveu:
> addr_filter__entire_dso() uses the first and last symbols from a dso,
> and so does not work when there are no symbols.  Alter it to filter the
> whole file instead.

I'm splitting this patch into a first prep one that renames and exports
the static function dso__data_file_size() and a second that does what
this commig log message states.

The reason is that sometimes we find out that the main part of the patch
is wrong and we then decide to revert the patch, only to realize that
the exported function is by that time already used elsewhere.

- Arnaldo
 
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
> ---
>  tools/perf/util/auxtrace.c | 11 ++++-------
>  tools/perf/util/dso.c      |  6 +++---
>  tools/perf/util/dso.h      |  1 +
>  3 files changed, 8 insertions(+), 10 deletions(-)
> 
> diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c
> index 72d5ba2479bf..f69961c4a4f3 100644
> --- a/tools/perf/util/auxtrace.c
> +++ b/tools/perf/util/auxtrace.c
> @@ -1983,17 +1983,14 @@ static int find_dso_sym(struct dso *dso, const char *sym_name, u64 *start,
>  
>  static int addr_filter__entire_dso(struct addr_filter *filt, struct dso *dso)
>  {
> -	struct symbol *first_sym = dso__first_symbol(dso);
> -	struct symbol *last_sym = dso__last_symbol(dso);
> -
> -	if (!first_sym || !last_sym) {
> -		pr_err("Failed to determine filter for %s\nNo symbols found.\n",
> +	if (dso__data_file_size(dso, NULL)) {
> +		pr_err("Failed to determine filter for %s\nCannot determine file size.\n",
>  		       filt->filename);
>  		return -EINVAL;
>  	}
>  
> -	filt->addr = first_sym->start;
> -	filt->size = last_sym->end - first_sym->start;
> +	filt->addr = 0;
> +	filt->size = dso->data.file_size;
>  
>  	return 0;
>  }
> diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
> index bbed90e5d9bb..721f3d583945 100644
> --- a/tools/perf/util/dso.c
> +++ b/tools/perf/util/dso.c
> @@ -894,7 +894,7 @@ static ssize_t cached_read(struct dso *dso, struct machine *machine,
>  	return r;
>  }
>  
> -static int data_file_size(struct dso *dso, struct machine *machine)
> +int dso__data_file_size(struct dso *dso, struct machine *machine)
>  {
>  	int ret = 0;
>  	struct stat st;
> @@ -943,7 +943,7 @@ static int data_file_size(struct dso *dso, struct machine *machine)
>   */
>  off_t dso__data_size(struct dso *dso, struct machine *machine)
>  {
> -	if (data_file_size(dso, machine))
> +	if (dso__data_file_size(dso, machine))
>  		return -1;
>  
>  	/* For now just estimate dso data size is close to file size */
> @@ -953,7 +953,7 @@ off_t dso__data_size(struct dso *dso, struct machine *machine)
>  static ssize_t data_read_offset(struct dso *dso, struct machine *machine,
>  				u64 offset, u8 *data, ssize_t size)
>  {
> -	if (data_file_size(dso, machine))
> +	if (dso__data_file_size(dso, machine))
>  		return -1;
>  
>  	/* Check the offset sanity. */
> diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
> index c5380500bed4..8c8a7abe809d 100644
> --- a/tools/perf/util/dso.h
> +++ b/tools/perf/util/dso.h
> @@ -322,6 +322,7 @@ int dso__data_get_fd(struct dso *dso, struct machine *machine);
>  void dso__data_put_fd(struct dso *dso);
>  void dso__data_close(struct dso *dso);
>  
> +int dso__data_file_size(struct dso *dso, struct machine *machine);
>  off_t dso__data_size(struct dso *dso, struct machine *machine);
>  ssize_t dso__data_read_offset(struct dso *dso, struct machine *machine,
>  			      u64 offset, u8 *data, ssize_t size);
> -- 
> 2.17.1

-- 

- Arnaldo

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] perf auxtrace: Alter addr_filter__entire_dso() to work if there are no symbols
  2018-11-27 12:42 ` Arnaldo Carvalho de Melo
@ 2018-12-10 13:17   ` Adrian Hunter
  2018-12-10 13:39     ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 6+ messages in thread
From: Adrian Hunter @ 2018-12-10 13:17 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo; +Cc: Jiri Olsa, linux-kernel

On 27/11/18 2:42 PM, Arnaldo Carvalho de Melo wrote:
> Em Tue, Nov 27, 2018 at 10:46:34AM +0200, Adrian Hunter escreveu:
>> addr_filter__entire_dso() uses the first and last symbols from a dso,
>> and so does not work when there are no symbols.  Alter it to filter the
>> whole file instead.
> 
> I'm splitting this patch into a first prep one that renames and exports
> the static function dso__data_file_size() and a second that does what
> this commig log message states.
> 
> The reason is that sometimes we find out that the main part of the patch
> is wrong and we then decide to revert the patch, only to realize that
> the exported function is by that time already used elsewhere.

Thanks for looking at this, but did it get lost?  I don't see it in your tree.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] perf auxtrace: Alter addr_filter__entire_dso() to work if there are no symbols
  2018-12-10 13:17   ` Adrian Hunter
@ 2018-12-10 13:39     ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 6+ messages in thread
From: Arnaldo Carvalho de Melo @ 2018-12-10 13:39 UTC (permalink / raw)
  To: Adrian Hunter; +Cc: Jiri Olsa, linux-kernel, Masami Hiramatsu, Mathieu Poirier

Em Mon, Dec 10, 2018 at 03:17:05PM +0200, Adrian Hunter escreveu:
> On 27/11/18 2:42 PM, Arnaldo Carvalho de Melo wrote:
> > Em Tue, Nov 27, 2018 at 10:46:34AM +0200, Adrian Hunter escreveu:
> >> addr_filter__entire_dso() uses the first and last symbols from a dso,
> >> and so does not work when there are no symbols.  Alter it to filter the
> >> whole file instead.

> > I'm splitting this patch into a first prep one that renames and exports
> > the static function dso__data_file_size() and a second that does what
> > this commig log message states.

> > The reason is that sometimes we find out that the main part of the patch
> > is wrong and we then decide to revert the patch, only to realize that
> > the exported function is by that time already used elsewhere.
 
> Thanks for looking at this, but did it get lost?  I don't see it in your tree.

Yeah, my bad, thanks for the reminder, did the split and added to my
perf/core branch,

Also I'm adding this:

  Cc: Masami Hiramatsu <mhiramat@kernel.org>
  Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
  Fixes: 1b36c03e3569 ("perf record: Add support for using symbols in address filters")

So that people that were involved in the patch that introduced this
feature gets notified of this fix, also for backporters to take notice,
please try to do this in the future.

Thanks,

- Arnaldo

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [tip:perf/core] perf dso: Export data_file_size() method there are no symbols
  2018-11-27  8:46 [PATCH] perf auxtrace: Alter addr_filter__entire_dso() to work if there are no symbols Adrian Hunter
  2018-11-27 12:42 ` Arnaldo Carvalho de Melo
@ 2018-12-20 17:57 ` tip-bot for Adrian Hunter
  2018-12-20 17:58 ` [tip:perf/core] perf auxtrace: Alter addr_filter__entire_dso() to work if " tip-bot for Adrian Hunter
  2 siblings, 0 replies; 6+ messages in thread
From: tip-bot for Adrian Hunter @ 2018-12-20 17:57 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, adrian.hunter, mingo, jolsa, hpa, acme, tglx

Commit-ID:  b5c2161cc415babb84d2b49599df8bd03b2b9b69
Gitweb:     https://git.kernel.org/tip/b5c2161cc415babb84d2b49599df8bd03b2b9b69
Author:     Adrian Hunter <adrian.hunter@intel.com>
AuthorDate: Tue, 27 Nov 2018 10:46:34 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 18 Dec 2018 12:21:44 -0300

perf dso: Export data_file_size() method there are no symbols

Will be used outside dso.c in a followup patch, so rename it and make it
non-static.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/20181127084634.12469-1-adrian.hunter@intel.com
[ split from a larger patch ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/dso.c | 6 +++---
 tools/perf/util/dso.h | 1 +
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index cee717a3794f..62c8cf622607 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -894,7 +894,7 @@ static ssize_t cached_read(struct dso *dso, struct machine *machine,
 	return r;
 }
 
-static int data_file_size(struct dso *dso, struct machine *machine)
+int dso__data_file_size(struct dso *dso, struct machine *machine)
 {
 	int ret = 0;
 	struct stat st;
@@ -943,7 +943,7 @@ out:
  */
 off_t dso__data_size(struct dso *dso, struct machine *machine)
 {
-	if (data_file_size(dso, machine))
+	if (dso__data_file_size(dso, machine))
 		return -1;
 
 	/* For now just estimate dso data size is close to file size */
@@ -953,7 +953,7 @@ off_t dso__data_size(struct dso *dso, struct machine *machine)
 static ssize_t data_read_offset(struct dso *dso, struct machine *machine,
 				u64 offset, u8 *data, ssize_t size)
 {
-	if (data_file_size(dso, machine))
+	if (dso__data_file_size(dso, machine))
 		return -1;
 
 	/* Check the offset sanity. */
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
index c5380500bed4..8c8a7abe809d 100644
--- a/tools/perf/util/dso.h
+++ b/tools/perf/util/dso.h
@@ -322,6 +322,7 @@ int dso__data_get_fd(struct dso *dso, struct machine *machine);
 void dso__data_put_fd(struct dso *dso);
 void dso__data_close(struct dso *dso);
 
+int dso__data_file_size(struct dso *dso, struct machine *machine);
 off_t dso__data_size(struct dso *dso, struct machine *machine);
 ssize_t dso__data_read_offset(struct dso *dso, struct machine *machine,
 			      u64 offset, u8 *data, ssize_t size);

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [tip:perf/core] perf auxtrace: Alter addr_filter__entire_dso() to work if there are no symbols
  2018-11-27  8:46 [PATCH] perf auxtrace: Alter addr_filter__entire_dso() to work if there are no symbols Adrian Hunter
  2018-11-27 12:42 ` Arnaldo Carvalho de Melo
  2018-12-20 17:57 ` [tip:perf/core] perf dso: Export data_file_size() method " tip-bot for Adrian Hunter
@ 2018-12-20 17:58 ` tip-bot for Adrian Hunter
  2 siblings, 0 replies; 6+ messages in thread
From: tip-bot for Adrian Hunter @ 2018-12-20 17:58 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: mathieu.poirier, hpa, mingo, linux-kernel, jolsa, mhiramat,
	adrian.hunter, tglx, acme

Commit-ID:  571766010ea6bf9726b288eb2db1abb59b1841af
Gitweb:     https://git.kernel.org/tip/571766010ea6bf9726b288eb2db1abb59b1841af
Author:     Adrian Hunter <adrian.hunter@intel.com>
AuthorDate: Tue, 27 Nov 2018 10:46:34 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 18 Dec 2018 12:21:44 -0300

perf auxtrace: Alter addr_filter__entire_dso() to work if there are no symbols

addr_filter__entire_dso() uses the first and last symbols from a dso,
and so does not work when there are no symbols.  Alter it to filter the
whole file instead.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Fixes: 1b36c03e3569 ("perf record: Add support for using symbols in address filters")
Link: http://lkml.kernel.org/r/20181127084634.12469-1-adrian.hunter@intel.com
[ split from a larger patch ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/auxtrace.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c
index 72d5ba2479bf..f69961c4a4f3 100644
--- a/tools/perf/util/auxtrace.c
+++ b/tools/perf/util/auxtrace.c
@@ -1983,17 +1983,14 @@ static int find_dso_sym(struct dso *dso, const char *sym_name, u64 *start,
 
 static int addr_filter__entire_dso(struct addr_filter *filt, struct dso *dso)
 {
-	struct symbol *first_sym = dso__first_symbol(dso);
-	struct symbol *last_sym = dso__last_symbol(dso);
-
-	if (!first_sym || !last_sym) {
-		pr_err("Failed to determine filter for %s\nNo symbols found.\n",
+	if (dso__data_file_size(dso, NULL)) {
+		pr_err("Failed to determine filter for %s\nCannot determine file size.\n",
 		       filt->filename);
 		return -EINVAL;
 	}
 
-	filt->addr = first_sym->start;
-	filt->size = last_sym->end - first_sym->start;
+	filt->addr = 0;
+	filt->size = dso->data.file_size;
 
 	return 0;
 }

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-12-20 17:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-27  8:46 [PATCH] perf auxtrace: Alter addr_filter__entire_dso() to work if there are no symbols Adrian Hunter
2018-11-27 12:42 ` Arnaldo Carvalho de Melo
2018-12-10 13:17   ` Adrian Hunter
2018-12-10 13:39     ` Arnaldo Carvalho de Melo
2018-12-20 17:57 ` [tip:perf/core] perf dso: Export data_file_size() method " tip-bot for Adrian Hunter
2018-12-20 17:58 ` [tip:perf/core] perf auxtrace: Alter addr_filter__entire_dso() to work if " tip-bot for Adrian Hunter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).