perf report: Fix -F for branch & mem modes
diff mbox series

Message ID 20210304062958.85465-1-ravi.bangoria@linux.ibm.com
State Accepted
Commit 6740a4e70e5d1b9d8e7fe41fd46dd5656d65dadf
Headers show
Series
  • perf report: Fix -F for branch & mem modes
Related show

Commit Message

Ravi Bangoria March 4, 2021, 6:29 a.m. UTC
perf report fails to add valid additional fields with -F when
used with branch or mem modes. Fix it.

Before patch:

  $ ./perf record -b
  $ ./perf report -b -F +srcline_from --stdio
  Error:
  Invalid --fields key: `srcline_from'

After patch:

  $ ./perf report -b -F +srcline_from --stdio
  # Samples: 8K of event 'cycles'
  # Event count (approx.): 8784
  ...

Reported-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Fixes: aa6b3c99236b ("perf report: Make -F more strict like -s")
Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
---
 tools/perf/util/sort.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Athira Rajeev March 4, 2021, 6:45 a.m. UTC | #1
> On 04-Mar-2021, at 11:59 AM, Ravi Bangoria <ravi.bangoria@linux.ibm.com> wrote:
> 
> perf report fails to add valid additional fields with -F when
> used with branch or mem modes. Fix it.
> 
> Before patch:
> 
>  $ ./perf record -b
>  $ ./perf report -b -F +srcline_from --stdio
>  Error:
>  Invalid --fields key: `srcline_from'
> 
> After patch:
> 
>  $ ./perf report -b -F +srcline_from --stdio
>  # Samples: 8K of event 'cycles'
>  # Event count (approx.): 8784
>  ...
> 
> Reported-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
> Fixes: aa6b3c99236b ("perf report: Make -F more strict like -s")
> Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>

Thanks for the fix Ravi.

Reviewed-and-tested-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>

> ---
> tools/perf/util/sort.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
> index 0d5ad42812b9..552b590485bf 100644
> --- a/tools/perf/util/sort.c
> +++ b/tools/perf/util/sort.c
> @@ -3140,7 +3140,7 @@ int output_field_add(struct perf_hpp_list *list, char *tok)
> 		if (strncasecmp(tok, sd->name, strlen(tok)))
> 			continue;
> 
> -		if (sort__mode != SORT_MODE__MEMORY)
> +		if (sort__mode != SORT_MODE__BRANCH)
> 			return -EINVAL;
> 
> 		return __sort_dimension__add_output(list, sd);
> @@ -3152,7 +3152,7 @@ int output_field_add(struct perf_hpp_list *list, char *tok)
> 		if (strncasecmp(tok, sd->name, strlen(tok)))
> 			continue;
> 
> -		if (sort__mode != SORT_MODE__BRANCH)
> +		if (sort__mode != SORT_MODE__MEMORY)
> 			return -EINVAL;
> 
> 		return __sort_dimension__add_output(list, sd);
> -- 
> 2.29.2
>
Arnaldo Carvalho de Melo March 4, 2021, 5:05 p.m. UTC | #2
Em Thu, Mar 04, 2021 at 12:15:58PM +0530, Athira Rajeev escreveu:
> > On 04-Mar-2021, at 11:59 AM, Ravi Bangoria <ravi.bangoria@linux.ibm.com> wrote:
> > 
> > perf report fails to add valid additional fields with -F when
> > used with branch or mem modes. Fix it.
> > 
> > Before patch:
> > 
> >  $ ./perf record -b
> >  $ ./perf report -b -F +srcline_from --stdio
> >  Error:
> >  Invalid --fields key: `srcline_from'
> > 
> > After patch:
> > 
> >  $ ./perf report -b -F +srcline_from --stdio
> >  # Samples: 8K of event 'cycles'
> >  # Event count (approx.): 8784
> >  ...
> > 
> > Reported-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
> > Fixes: aa6b3c99236b ("perf report: Make -F more strict like -s")
> > Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
> 
> Thanks for the fix Ravi.
> 
> Reviewed-and-tested-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>

Thanks, applied.

- Arnaldo

 
> > ---
> > tools/perf/util/sort.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
> > index 0d5ad42812b9..552b590485bf 100644
> > --- a/tools/perf/util/sort.c
> > +++ b/tools/perf/util/sort.c
> > @@ -3140,7 +3140,7 @@ int output_field_add(struct perf_hpp_list *list, char *tok)
> > 		if (strncasecmp(tok, sd->name, strlen(tok)))
> > 			continue;
> > 
> > -		if (sort__mode != SORT_MODE__MEMORY)
> > +		if (sort__mode != SORT_MODE__BRANCH)
> > 			return -EINVAL;
> > 
> > 		return __sort_dimension__add_output(list, sd);
> > @@ -3152,7 +3152,7 @@ int output_field_add(struct perf_hpp_list *list, char *tok)
> > 		if (strncasecmp(tok, sd->name, strlen(tok)))
> > 			continue;
> > 
> > -		if (sort__mode != SORT_MODE__BRANCH)
> > +		if (sort__mode != SORT_MODE__MEMORY)
> > 			return -EINVAL;
> > 
> > 		return __sort_dimension__add_output(list, sd);
> > -- 
> > 2.29.2
> > 
>

Patch
diff mbox series

diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 0d5ad42812b9..552b590485bf 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -3140,7 +3140,7 @@  int output_field_add(struct perf_hpp_list *list, char *tok)
 		if (strncasecmp(tok, sd->name, strlen(tok)))
 			continue;
 
-		if (sort__mode != SORT_MODE__MEMORY)
+		if (sort__mode != SORT_MODE__BRANCH)
 			return -EINVAL;
 
 		return __sort_dimension__add_output(list, sd);
@@ -3152,7 +3152,7 @@  int output_field_add(struct perf_hpp_list *list, char *tok)
 		if (strncasecmp(tok, sd->name, strlen(tok)))
 			continue;
 
-		if (sort__mode != SORT_MODE__BRANCH)
+		if (sort__mode != SORT_MODE__MEMORY)
 			return -EINVAL;
 
 		return __sort_dimension__add_output(list, sd);