linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Jin Yao <yao.jin@linux.intel.com>,
	Thomas Richter <tmricht@linux.ibm.com>
Cc: Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>,
	linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
	svens@linux.ibm.com, gor@linux.ibm.com, sumanthk@linux.ibm.com,
	heiko.carstens@de.ibm.com
Subject: Re: [PATCH] Fix s390x compile error on F32 utils/stat-display.c
Date: Wed, 12 Aug 2020 08:27:08 -0300	[thread overview]
Message-ID: <20200812112708.GA13995@kernel.org> (raw)
In-Reply-To: <20200722092053.22345-1-tmricht@linux.ibm.com>

Em Wed, Jul 22, 2020 at 11:20:53AM +0200, Thomas Richter escreveu:
> Fix a compile error on F32 and gcc version 10.1 on s390 in file
> utils/stat-display.c.  The error does not show up with make DEBUG=y.
> In fact the issue shows up when using both compiler options
> -O6 and -D_FORTIFY_SOURCE=2 (which are omitted with DEBUG=Y).
> 
> This is the offending call chain:
> print_counter_aggr()
>   printout(config, -1, 0, ...)  with 2nd parm id set to -1
>     aggr_printout(config, x, id --> -1, ...) which leads to this code:
> 		case AGGR_NONE:
>                 if (evsel->percore && !config->percore_show_thread) {
>                         ....
>                 } else {
>                         fprintf(config->output, "CPU%*d%s",
>                                 config->csv_output ? 0 : -7,
>                                 evsel__cpus(evsel)->map[id],
> 				                        ^^ id is -1 !!!!
>                                 config->csv_sep);
>                 }
> 
> This is a compiler inlining issue which is detected on s390 but not on
> other plattforms.

What is the sequence of events that gets to this? I.e. is it valid to
get a config->aggr_mode == AGGR_NONE, then have evsel not be percore and
config->percore_show_thread to be false?

I wonder if this won't be papering over some bug :-\

Jin?

This is where this came from:
commit 4fc4d8dfa056dfd48afe73b9ea3b7570ceb80b9c (tag: perf-core-for-mingo-5.2-20190517)
Author: Jin Yao <yao.jin@linux.intel.com>
Date:   Fri Apr 12 21:59:49 2019 +0800

    perf stat: Support 'percore' event qualifier

    With this patch, we can use the 'percore' event qualifier in perf-stat.

---

Also please add at least Jiri and Namhyung on the CC list, having the
person that added that array usage also helps.

[acme@quaco perf]$ scripts/get_maintainer.pl tools/perf | grep reviewer
Mark Rutland <mark.rutland@arm.com> (reviewer:PERFORMANCE EVENTS SUBSYSTEM)
Alexander Shishkin <alexander.shishkin@linux.intel.com> (reviewer:PERFORMANCE EVENTS SUBSYSTEM)
Jiri Olsa <jolsa@redhat.com> (reviewer:PERFORMANCE EVENTS SUBSYSTEM)
Namhyung Kim <namhyung@kernel.org> (reviewer:PERFORMANCE EVENTS SUBSYSTEM)
[acme@quaco perf]$

Thanks,

- Arnaldo
 
> Output before:
>  # make util/stat-display.o
>     .....
> 
>   util/stat-display.c: In function ‘perf_evlist__print_counters’:
>   util/stat-display.c:121:4: error: array subscript -1 is below array
>       bounds of ‘int[]’ [-Werror=array-bounds]
>   121 |    fprintf(config->output, "CPU%*d%s",
>       |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>   122 |     config->csv_output ? 0 : -7,
>       |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>   123 |     evsel__cpus(evsel)->map[id],
>       |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>   124 |     config->csv_sep);
>       |     ~~~~~~~~~~~~~~~~
>   In file included from util/evsel.h:13,
>                  from util/evlist.h:13,
>                  from util/stat-display.c:9:
>   /root/linux/tools/lib/perf/include/internal/cpumap.h:10:7:
>   note: while referencing ‘map’
>    10 |  int  map[];
>       |       ^~~
>   cc1: all warnings being treated as errors
>   mv: cannot stat 'util/.stat-display.o.tmp': No such file or directory
>   make[3]: *** [/root/linux/tools/build/Makefile.build:97: util/stat-display.o]
>   Error 1
>   make[2]: *** [Makefile.perf:716: util/stat-display.o] Error 2
>   make[1]: *** [Makefile.perf:231: sub-make] Error 2
>   make: *** [Makefile:110: util/stat-display.o] Error 2
>   [root@t35lp46 perf]#
> 
> Output after:
>   # make util/stat-display.o
>     .....
>   CC       util/stat-display.o
>   [root@t35lp46 perf]#
> 
> Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
> ---
>  tools/perf/util/stat-display.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c
> index 57d0706e1330..e49e544188e4 100644
> --- a/tools/perf/util/stat-display.c
> +++ b/tools/perf/util/stat-display.c
> @@ -118,10 +118,11 @@ static void aggr_printout(struct perf_stat_config *config,
>  				config->csv_output ? 0 : -3,
>  				cpu_map__id_to_cpu(id), config->csv_sep);
>  		} else {
> -			fprintf(config->output, "CPU%*d%s",
> -				config->csv_output ? 0 : -7,
> -				evsel__cpus(evsel)->map[id],
> -				config->csv_sep);
> +			if (id > -1)
> +				fprintf(config->output, "CPU%*d%s",
> +					config->csv_output ? 0 : -7,
> +					evsel__cpus(evsel)->map[id],
> +					config->csv_sep);
>  		}
>  		break;
>  	case AGGR_THREAD:
> -- 
> 2.26.2
> 

-- 

- Arnaldo

  reply	other threads:[~2020-08-12 11:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-22  9:20 [PATCH] Fix s390x compile error on F32 utils/stat-display.c Thomas Richter
2020-08-12 11:27 ` Arnaldo Carvalho de Melo [this message]
2020-08-24 14:44   ` Thomas Richter
2020-08-24 20:22   ` Jiri Olsa
2020-08-25  6:15     ` Thomas Richter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200812112708.GA13995@kernel.org \
    --to=acme@kernel.org \
    --cc=gor@linux.ibm.com \
    --cc=heiko.carstens@de.ibm.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=namhyung@kernel.org \
    --cc=sumanthk@linux.ibm.com \
    --cc=svens@linux.ibm.com \
    --cc=tmricht@linux.ibm.com \
    --cc=yao.jin@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).