* [PATCH] perf tools: ensure return negitive value when write header error @ 2014-10-16 3:08 Wang Nan 2014-10-22 7:00 ` Namhyung Kim 2014-10-30 6:45 ` [tip:perf/core] perf tools: Ensure return negative " tip-bot for Wang Nan 0 siblings, 2 replies; 6+ messages in thread From: Wang Nan @ 2014-10-16 3:08 UTC (permalink / raw) To: Peter Zijlstra, Paul Mackerras, Ingo Molnar, Arnaldo Carvalho de Melo, Jiri Olsa, Adrian Hunter, Namhyung Kim, Wang Nan, Waiman Long Cc: linux-kernel, Li Zefan When 'perf record' write headers, it calls write_xxx in tools/perf/util/header.c, and check return value. It rolls back all working only when return value is negative. This patch ensures write_cpudesc() and write_total_mem() return negative number when error. Without this patch, headers reported by 'perf report' header is error in some platform. Following output is caputured on ARM, which doesn't contain "Processor" field in /proc/cpuinfo. See "cpudesc", "total memory" and "cmdline" field. bash-4.2# perf record ls ... [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.001 MB perf.data (~36 samples) ] bash-4.2# perf report --stdio --header Error: The perf.data file has no samples! # ======== # captured on: Fri Sep 12 10:09:10 2014 # hostname : arma15el # os release : 3.17.0+ # perf version : 3.10.53 # arch : armv7l # nrcpus online : 4 # nrcpus avail : 1 # cpudesc : (null) # total memory : 0 kB # cmdline : # event : name = cycles, type = 0, config = 0x0, config1 = 0x0, config2 = 0x0, excl_usr = 0, excl_kern = 0, excl_host = 0, excl_guest = 1, precise_ip = 0 # pmu mappings: not available # ======== # Signed-off-by: Wang Nan <wangnan0@huawei.com> --- tools/perf/util/header.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index ce0de00..39b80ac 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -605,8 +605,10 @@ static int write_cpudesc(int fd, struct perf_header *h __maybe_unused, break; } - if (ret) + if (ret) { + ret = -1; goto done; + } s = buf; @@ -950,7 +952,8 @@ static int write_total_mem(int fd, struct perf_header *h __maybe_unused, n = sscanf(buf, "%*s %"PRIu64, &mem); if (n == 1) ret = do_write(fd, &mem, sizeof(mem)); - } + } else + ret = -1; free(buf); fclose(fp); return ret; -- 1.8.4 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] perf tools: ensure return negitive value when write header error 2014-10-16 3:08 [PATCH] perf tools: ensure return negitive value when write header error Wang Nan @ 2014-10-22 7:00 ` Namhyung Kim 2014-10-22 7:52 ` Wang Nan ` (2 more replies) 2014-10-30 6:45 ` [tip:perf/core] perf tools: Ensure return negative " tip-bot for Wang Nan 1 sibling, 3 replies; 6+ messages in thread From: Namhyung Kim @ 2014-10-22 7:00 UTC (permalink / raw) To: Wang Nan Cc: Peter Zijlstra, Paul Mackerras, Ingo Molnar, Arnaldo Carvalho de Melo, Jiri Olsa, Adrian Hunter, Namhyung Kim, Waiman Long, linux-kernel, Li Zefan On Thu, 16 Oct 2014 11:08:29 +0800, Wang Nan wrote: > When 'perf record' write headers, it calls write_xxx in > tools/perf/util/header.c, and check return value. It rolls back all > working only when return value is negative. > > This patch ensures write_cpudesc() and write_total_mem() return negative number > when error. Without this patch, headers reported by 'perf report' header is > error in some platform. Following output is caputured on ARM, which doesn't > contain "Processor" field in /proc/cpuinfo. See "cpudesc", "total memory" and > "cmdline" field. > > bash-4.2# perf record ls > ... > [ perf record: Woken up 1 times to write data ] > [ perf record: Captured and wrote 0.001 MB perf.data (~36 samples) ] > bash-4.2# perf report --stdio --header > Error: > The perf.data file has no samples! > # ======== > # captured on: Fri Sep 12 10:09:10 2014 > # hostname : arma15el > # os release : 3.17.0+ > # perf version : 3.10.53 > # arch : armv7l > # nrcpus online : 4 > # nrcpus avail : 1 > # cpudesc : (null) > # total memory : 0 kB > # cmdline : > # event : name = cycles, type = 0, config = 0x0, config1 = 0x0, config2 = 0x0, excl_usr = 0, excl_kern = 0, excl_host = 0, excl_guest = 1, precise_ip = 0 > # pmu mappings: not available > # ======== > # > > Signed-off-by: Wang Nan <wangnan0@huawei.com> I guess the total_memory, cmdline and pmu mappings are somehow affected by the broken cpudesc. Do they have their own problem on ARM? Anyway I think it's good to check the result properly, so Acked-by: Namhyung Kim <namhyung@kernel.org> Thanks, Namhyung > --- > tools/perf/util/header.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c > index ce0de00..39b80ac 100644 > --- a/tools/perf/util/header.c > +++ b/tools/perf/util/header.c > @@ -605,8 +605,10 @@ static int write_cpudesc(int fd, struct perf_header *h __maybe_unused, > break; > } > > - if (ret) > + if (ret) { > + ret = -1; > goto done; > + } > > s = buf; > > @@ -950,7 +952,8 @@ static int write_total_mem(int fd, struct perf_header *h __maybe_unused, > n = sscanf(buf, "%*s %"PRIu64, &mem); > if (n == 1) > ret = do_write(fd, &mem, sizeof(mem)); > - } > + } else > + ret = -1; > free(buf); > fclose(fp); > return ret; ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] perf tools: ensure return negitive value when write header error 2014-10-22 7:00 ` Namhyung Kim @ 2014-10-22 7:52 ` Wang Nan 2014-10-23 2:19 ` Wang Nan 2014-10-23 21:47 ` Arnaldo Carvalho de Melo 2 siblings, 0 replies; 6+ messages in thread From: Wang Nan @ 2014-10-22 7:52 UTC (permalink / raw) To: Namhyung Kim Cc: Peter Zijlstra, Paul Mackerras, Ingo Molnar, Arnaldo Carvalho de Melo, Jiri Olsa, Adrian Hunter, Namhyung Kim, Waiman Long, linux-kernel, Li Zefan On 2014/10/22 15:00, Namhyung Kim wrote: > On Thu, 16 Oct 2014 11:08:29 +0800, Wang Nan wrote: >> When 'perf record' write headers, it calls write_xxx in >> tools/perf/util/header.c, and check return value. It rolls back all >> working only when return value is negative. >> >> This patch ensures write_cpudesc() and write_total_mem() return negative number >> when error. Without this patch, headers reported by 'perf report' header is >> error in some platform. Following output is caputured on ARM, which doesn't >> contain "Processor" field in /proc/cpuinfo. See "cpudesc", "total memory" and >> "cmdline" field. >> >> bash-4.2# perf record ls >> ... >> [ perf record: Woken up 1 times to write data ] >> [ perf record: Captured and wrote 0.001 MB perf.data (~36 samples) ] >> bash-4.2# perf report --stdio --header >> Error: >> The perf.data file has no samples! >> # ======== >> # captured on: Fri Sep 12 10:09:10 2014 >> # hostname : arma15el >> # os release : 3.17.0+ >> # perf version : 3.10.53 >> # arch : armv7l >> # nrcpus online : 4 >> # nrcpus avail : 1 >> # cpudesc : (null) >> # total memory : 0 kB >> # cmdline : >> # event : name = cycles, type = 0, config = 0x0, config1 = 0x0, config2 = 0x0, excl_usr = 0, excl_kern = 0, excl_host = 0, excl_guest = 1, precise_ip = 0 >> # pmu mappings: not available >> # ======== >> # >> >> Signed-off-by: Wang Nan <wangnan0@huawei.com> > > I guess the total_memory, cmdline and pmu mappings are somehow affected > by the broken cpudesc. Do they have their own problem on ARM? > The buggy output is caused by cpudesc's problem. I didn't trigger their own problem on ARM because 'total memory' and cmdline are always success. I find the error in write_total_mem() by checking code by hand. Thanks. > Anyway I think it's good to check the result properly, so > > Acked-by: Namhyung Kim <namhyung@kernel.org> > > Thanks, > Namhyung > > >> --- >> tools/perf/util/header.c | 7 +++++-- >> 1 file changed, 5 insertions(+), 2 deletions(-) >> >> diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c >> index ce0de00..39b80ac 100644 >> --- a/tools/perf/util/header.c >> +++ b/tools/perf/util/header.c >> @@ -605,8 +605,10 @@ static int write_cpudesc(int fd, struct perf_header *h __maybe_unused, >> break; >> } >> >> - if (ret) >> + if (ret) { >> + ret = -1; >> goto done; >> + } >> >> s = buf; >> >> @@ -950,7 +952,8 @@ static int write_total_mem(int fd, struct perf_header *h __maybe_unused, >> n = sscanf(buf, "%*s %"PRIu64, &mem); >> if (n == 1) >> ret = do_write(fd, &mem, sizeof(mem)); >> - } >> + } else >> + ret = -1; >> free(buf); >> fclose(fp); >> return ret; ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] perf tools: ensure return negitive value when write header error 2014-10-22 7:00 ` Namhyung Kim 2014-10-22 7:52 ` Wang Nan @ 2014-10-23 2:19 ` Wang Nan 2014-10-23 21:47 ` Arnaldo Carvalho de Melo 2 siblings, 0 replies; 6+ messages in thread From: Wang Nan @ 2014-10-23 2:19 UTC (permalink / raw) To: Ingo Molnar; +Cc: Namhyung Kim, linux-kernel, Li Zefan Hi Ingo, Could you please collect this patch which fixes a perf problem? Thanks. On 2014/10/22 15:00, Namhyung Kim wrote: > On Thu, 16 Oct 2014 11:08:29 +0800, Wang Nan wrote: >> When 'perf record' write headers, it calls write_xxx in >> tools/perf/util/header.c, and check return value. It rolls back all >> working only when return value is negative. >> >> This patch ensures write_cpudesc() and write_total_mem() return negative number >> when error. Without this patch, headers reported by 'perf report' header is >> error in some platform. Following output is caputured on ARM, which doesn't >> contain "Processor" field in /proc/cpuinfo. See "cpudesc", "total memory" and >> "cmdline" field. >> >> bash-4.2# perf record ls >> ... >> [ perf record: Woken up 1 times to write data ] >> [ perf record: Captured and wrote 0.001 MB perf.data (~36 samples) ] >> bash-4.2# perf report --stdio --header >> Error: >> The perf.data file has no samples! >> # ======== >> # captured on: Fri Sep 12 10:09:10 2014 >> # hostname : arma15el >> # os release : 3.17.0+ >> # perf version : 3.10.53 >> # arch : armv7l >> # nrcpus online : 4 >> # nrcpus avail : 1 >> # cpudesc : (null) >> # total memory : 0 kB >> # cmdline : >> # event : name = cycles, type = 0, config = 0x0, config1 = 0x0, config2 = 0x0, excl_usr = 0, excl_kern = 0, excl_host = 0, excl_guest = 1, precise_ip = 0 >> # pmu mappings: not available >> # ======== >> # >> >> Signed-off-by: Wang Nan <wangnan0@huawei.com> > > I guess the total_memory, cmdline and pmu mappings are somehow affected > by the broken cpudesc. Do they have their own problem on ARM? > > Anyway I think it's good to check the result properly, so > > Acked-by: Namhyung Kim <namhyung@kernel.org> > > Thanks, > Namhyung > > >> --- >> tools/perf/util/header.c | 7 +++++-- >> 1 file changed, 5 insertions(+), 2 deletions(-) >> >> diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c >> index ce0de00..39b80ac 100644 >> --- a/tools/perf/util/header.c >> +++ b/tools/perf/util/header.c >> @@ -605,8 +605,10 @@ static int write_cpudesc(int fd, struct perf_header *h __maybe_unused, >> break; >> } >> >> - if (ret) >> + if (ret) { >> + ret = -1; >> goto done; >> + } >> >> s = buf; >> >> @@ -950,7 +952,8 @@ static int write_total_mem(int fd, struct perf_header *h __maybe_unused, >> n = sscanf(buf, "%*s %"PRIu64, &mem); >> if (n == 1) >> ret = do_write(fd, &mem, sizeof(mem)); >> - } >> + } else >> + ret = -1; >> free(buf); >> fclose(fp); >> return ret; ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] perf tools: ensure return negitive value when write header error 2014-10-22 7:00 ` Namhyung Kim 2014-10-22 7:52 ` Wang Nan 2014-10-23 2:19 ` Wang Nan @ 2014-10-23 21:47 ` Arnaldo Carvalho de Melo 2 siblings, 0 replies; 6+ messages in thread From: Arnaldo Carvalho de Melo @ 2014-10-23 21:47 UTC (permalink / raw) To: Namhyung Kim Cc: Wang Nan, Peter Zijlstra, Paul Mackerras, Ingo Molnar, Jiri Olsa, Adrian Hunter, Namhyung Kim, Waiman Long, linux-kernel, Li Zefan Em Wed, Oct 22, 2014 at 04:00:12PM +0900, Namhyung Kim escreveu: > On Thu, 16 Oct 2014 11:08:29 +0800, Wang Nan wrote: > > When 'perf record' write headers, it calls write_xxx in > > tools/perf/util/header.c, and check return value. It rolls back all > > working only when return value is negative. > > > > This patch ensures write_cpudesc() and write_total_mem() return negative number > > when error. Without this patch, headers reported by 'perf report' header is > > error in some platform. Following output is caputured on ARM, which doesn't > > contain "Processor" field in /proc/cpuinfo. See "cpudesc", "total memory" and > > "cmdline" field. > > > > bash-4.2# perf record ls > > ... > > [ perf record: Woken up 1 times to write data ] > > [ perf record: Captured and wrote 0.001 MB perf.data (~36 samples) ] > > bash-4.2# perf report --stdio --header > > Error: > > The perf.data file has no samples! > > # ======== > > # captured on: Fri Sep 12 10:09:10 2014 > > # hostname : arma15el > > # os release : 3.17.0+ > > # perf version : 3.10.53 > > # arch : armv7l > > # nrcpus online : 4 > > # nrcpus avail : 1 > > # cpudesc : (null) > > # total memory : 0 kB > > # cmdline : > > # event : name = cycles, type = 0, config = 0x0, config1 = 0x0, config2 = 0x0, excl_usr = 0, excl_kern = 0, excl_host = 0, excl_guest = 1, precise_ip = 0 > > # pmu mappings: not available > > # ======== > > # > > > > Signed-off-by: Wang Nan <wangnan0@huawei.com> > > I guess the total_memory, cmdline and pmu mappings are somehow affected > by the broken cpudesc. Do they have their own problem on ARM? > > Anyway I think it's good to check the result properly, so > > Acked-by: Namhyung Kim <namhyung@kernel.org> Thanks, applied - Arnaldo ^ permalink raw reply [flat|nested] 6+ messages in thread
* [tip:perf/core] perf tools: Ensure return negative value when write header error 2014-10-16 3:08 [PATCH] perf tools: ensure return negitive value when write header error Wang Nan 2014-10-22 7:00 ` Namhyung Kim @ 2014-10-30 6:45 ` tip-bot for Wang Nan 1 sibling, 0 replies; 6+ messages in thread From: tip-bot for Wang Nan @ 2014-10-30 6:45 UTC (permalink / raw) To: linux-tip-commits Cc: linux-kernel, a.p.zijlstra, hpa, jolsa, mingo, adrian.hunter, mingo, tglx, Waiman.Long, acme, paulus, lizefan, namhyung.kim, wangnan0 Commit-ID: ed3077585f2f041e0db0fc41060b69673e98963b Gitweb: http://git.kernel.org/tip/ed3077585f2f041e0db0fc41060b69673e98963b Author: Wang Nan <wangnan0@huawei.com> AuthorDate: Thu, 16 Oct 2014 11:08:29 +0800 Committer: Arnaldo Carvalho de Melo <acme@redhat.com> CommitDate: Wed, 29 Oct 2014 10:32:48 -0200 perf tools: Ensure return negative value when write header error When 'perf record' write headers, it calls write_xxx in tools/perf/util/header.c, and check return value. It rolls back all working only when return value is negative. This patch ensures write_cpudesc() and write_total_mem() return negative number when error. Without this patch, headers reported by 'perf report' header is error in some platform. Following output is caputured on ARM, which doesn't contain "Processor" field in /proc/cpuinfo. See "cpudesc", "total memory" and "cmdline" field. bash-4.2# perf record ls ... [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.001 MB perf.data (~36 samples) ] bash-4.2# perf report --stdio --header Error: The perf.data file has no samples! # ======== # captured on: Fri Sep 12 10:09:10 2014 # hostname : arma15el # os release : 3.17.0+ # perf version : 3.10.53 # arch : armv7l # nrcpus online : 4 # nrcpus avail : 1 # cpudesc : (null) # total memory : 0 kB # cmdline : # event : name = cycles, type = 0, config = 0x0, config1 = 0x0, config2 = 0x0, excl_usr = 0, excl_kern = 0, excl_host = 0, excl_guest = 1, precise_ip = 0 # pmu mappings: not available # ======== # Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Li Zefan <lizefan@huawei.com> Cc: Namhyung Kim <namhyung.kim@lge.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Waiman Long <Waiman.Long@hp.com> Link: http://lkml.kernel.org/r/1413428909-80017-1-git-send-email-wangnan0@huawei.com Signed-off-by: Wang Nan <wangnan0@huawei.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> --- tools/perf/util/header.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 26f5b2f..0ecf4a3 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -601,8 +601,10 @@ static int __write_cpudesc(int fd, const char *cpuinfo_proc) break; } - if (ret) + if (ret) { + ret = -1; goto done; + } s = buf; @@ -965,7 +967,8 @@ static int write_total_mem(int fd, struct perf_header *h __maybe_unused, n = sscanf(buf, "%*s %"PRIu64, &mem); if (n == 1) ret = do_write(fd, &mem, sizeof(mem)); - } + } else + ret = -1; free(buf); fclose(fp); return ret; ^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-10-30 6:45 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-10-16 3:08 [PATCH] perf tools: ensure return negitive value when write header error Wang Nan 2014-10-22 7:00 ` Namhyung Kim 2014-10-22 7:52 ` Wang Nan 2014-10-23 2:19 ` Wang Nan 2014-10-23 21:47 ` Arnaldo Carvalho de Melo 2014-10-30 6:45 ` [tip:perf/core] perf tools: Ensure return negative " tip-bot for Wang Nan
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox