aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2015-09-11 12:36:12 -0300
committerBen Hutchings <ben@decadent.org.uk>2015-10-13 03:46:09 +0100
commit749b5bac8b672a027e1615c163c1ccc21d544550 (patch)
treebff7c833e3a7cdff6481b39be8422686e542b522
parentd46a34909db526644edf8ae62058d8371dd5f7e9 (diff)
downloadkernel_samsung_smdk4412-749b5bac8b672a027e1615c163c1ccc21d544550.zip
kernel_samsung_smdk4412-749b5bac8b672a027e1615c163c1ccc21d544550.tar.gz
kernel_samsung_smdk4412-749b5bac8b672a027e1615c163c1ccc21d544550.tar.bz2
perf header: Fixup reading of HEADER_NRCPUS feature
commit caa470475d9b59eeff093ae650800d34612c4379 upstream. The original patch introducing this header wrote the number of CPUs available and online in one order and then swapped those values when reading, fix it. Before: # perf record usleep 1 # perf report --header-only | grep 'nrcpus \(online\|avail\)' # nrcpus online : 4 # nrcpus avail : 4 # echo 0 > /sys/devices/system/cpu/cpu2/online # perf record usleep 1 # perf report --header-only | grep 'nrcpus \(online\|avail\)' # nrcpus online : 4 # nrcpus avail : 3 # echo 0 > /sys/devices/system/cpu/cpu1/online # perf record usleep 1 # perf report --header-only | grep 'nrcpus \(online\|avail\)' # nrcpus online : 4 # nrcpus avail : 2 After the fix, bringing back the CPUs online: # perf report --header-only | grep 'nrcpus \(online\|avail\)' # nrcpus online : 2 # nrcpus avail : 4 # echo 1 > /sys/devices/system/cpu/cpu2/online # perf record usleep 1 # perf report --header-only | grep 'nrcpus \(online\|avail\)' # nrcpus online : 3 # nrcpus avail : 4 # echo 1 > /sys/devices/system/cpu/cpu1/online # perf record usleep 1 # perf report --header-only | grep 'nrcpus \(online\|avail\)' # nrcpus online : 4 # nrcpus avail : 4 Acked-by: Namhyung Kim <namhyung@kernel.org> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Borislav Petkov <bp@suse.de> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Kan Liang <kan.liang@intel.com> Cc: Stephane Eranian <eranian@google.com> Cc: Wang Nan <wangnan0@huawei.com> Fixes: fbe96f29ce4b ("perf tools: Make perf.data more self-descriptive (v8)") Link: http://lkml.kernel.org/r/20150911153323.GP23511@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> [bwh: Backported to 3.2: print_nrcpus() reads and prints these fields immediately, so read both of them into an array before printing them in reverse order.] Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-rw-r--r--tools/perf/util/header.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 2cd88c1..7a75ecb 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -796,25 +796,19 @@ static void print_cpudesc(struct perf_header *ph, int fd, FILE *fp)
static void print_nrcpus(struct perf_header *ph, int fd, FILE *fp)
{
ssize_t ret;
- u32 nr;
+ u32 nr[2];
ret = read(fd, &nr, sizeof(nr));
if (ret != (ssize_t)sizeof(nr))
- nr = -1; /* interpreted as error */
+ nr[0] = nr[1] = -1; /* interpreted as error */
- if (ph->needs_swap)
- nr = bswap_32(nr);
-
- fprintf(fp, "# nrcpus online : %u\n", nr);
-
- ret = read(fd, &nr, sizeof(nr));
- if (ret != (ssize_t)sizeof(nr))
- nr = -1; /* interpreted as error */
-
- if (ph->needs_swap)
- nr = bswap_32(nr);
+ if (ph->needs_swap) {
+ nr[0] = bswap_32(nr[0]);
+ nr[1] = bswap_32(nr[1]);
+ }
- fprintf(fp, "# nrcpus avail : %u\n", nr);
+ fprintf(fp, "# nrcpus online : %u\n", nr[1]);
+ fprintf(fp, "# nrcpus avail : %u\n", nr[0]);
}
static void print_version(struct perf_header *ph, int fd, FILE *fp)