perf_counter tools: remove glib dependency and fix bugs in kerneltop.c
The glib dependency in kerneltop.c is only for a little bit of list
manipulation, and I find it inconvenient. This adds a 'next' field to
struct source_line, which lets us link them together into a list. The
code to do the linking ourselves turns out to be no longer or more
difficult than using glib.
This also fixes a few other problems:
- We need to #include <limits.h> to get PATH_MAX on powerpc.
- We need to #include <linux/types.h> rather than have our own
definitions of __u64 and __s64; on powerpc the installed headers
define them to be unsigned long and long respectively, and if we
have our own, different definition here that causes a compile error.
- This takes out the x86 setting of errno from -ret in
sys_perf_counter_open. My experiments on x86 indicate that the
glibc syscall() does this for us already.
- We had two CPU migration counters in the default set, which seems
unnecessary; I changed one of them to a context switch counter.
- In perfstat mode we were printing CPU cycles and instructions as
milliseconds, and the cpu clock and task clock counters as events.
This fixes that.
- In perfstat mode we were still printing a blank line after the first
counter, which was a holdover from when a task clock counter was
automatically included as the first counter. This removes the blank
line.
- On a test machine here, parse_symbols() and parse_vmlinux() were
taking long enough (almost 0.5 seconds) for the mmap buffer to
overflow before we got to the first mmap_read() call, so this moves
them before we open all the counters.
- The error message if sys_perf_counter_open fails needs to use errno,
not -fd[i][counter].
Signed-off-by: Paul Mackerras <paulus@samba.org>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Acked-by: Mike Galbraith <efault@gmx.de>
Cc: Arjan van de Ven <arjan@linux.intel.com>
Orig-LKML-Reference: <18888.29986.340328.540512@cargo.ozlabs.ibm.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>