Wang Nan
07bc5c699a
perf tools: Make fetch_kernel_version() publicly available
...
There are 2 places in llvm-utils.c which find kernel version information
through uname. This patch extracts the uname related code into a
fetch_kernel_version() function and puts it into util.h so it can be
reused.
Signed-off-by: Wang Nan <[email protected] >
Cc: Jiri Olsa <[email protected] >
Cc: Namhyung Kim <[email protected] >
Cc: Zefan Li <[email protected] >
Cc: [email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2015-11-06 15:57:18 -03:00
Namhyung Kim
792aeafa8e
perf tools: Defaults to 'caller' callchain order only if --children is enabled
...
The caller callchain order is useful with --children option since it can
show 'overview' style output, but other commands which don't use
--children feature like 'perf script' or even 'perf report/top' without
--children are better to keep callee order.
Signed-off-by: Namhyung Kim <[email protected] >
Acked-by: Brendan Gregg <[email protected] >
Acked-by: Frederic Weisbecker <[email protected] >
Acked-by: Ingo Molnar <[email protected] >
Cc: Adrian Hunter <[email protected] >
Cc: Borislav Petkov <[email protected] >
Cc: Chandler Carruth <[email protected] >
Cc: David Ahern <[email protected] >
Cc: Jiri Olsa <[email protected] >
Cc: Peter Zijlstra <[email protected] >
Cc: Stephane Eranian <[email protected] >
Cc: Wang Nan <[email protected] >
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2015-10-22 15:40:11 -03:00
Arnaldo Carvalho de Melo
def02db0d6
perf callchain: Switch default to 'graph,0.5,caller'
...
Which is the most common default found in other similar tools.
Requested-by: Ingo Molnar <[email protected] >
Cc: Adrian Hunter <[email protected] >
Cc: Borislav Petkov <[email protected] >
Cc: Chandler Carruth <[email protected] >
Cc: David Ahern <[email protected] >
Cc: Frederic Weisbecker <[email protected] >
Cc: Jiri Olsa <[email protected] >
Cc: Namhyung Kim <[email protected] >
Cc: Stephane Eranian <[email protected] >
Cc: Wang Nan <[email protected] >
Link: https://www.youtube.com/watch?v=nXaxk27zwlk
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2015-10-05 17:59:43 -03:00
Ingo Molnar
02386c356a
Merge branch 'perf/urgent' into perf/core, to pick up fixes before applying new changes
...
Signed-off-by: Ingo Molnar <[email protected] >
2015-09-18 09:24:01 +02:00
Peter Senna Tschudin
bf6445631c
perf tools: Bool functions shouldn't return -1
...
Returning a negative value for a boolean function seem to have the
undesired effect of returning true. Replace -1 by false in a
bool-returning function.
The diff of the .s file before and after the change (for x86_64):
3907c3907
< movl $1, %ebx
---
> xorl %ebx, %ebx
while if -1 is replaced by true, the diff is empty.
This issue was found by the following Coccinelle semantic patch:
<smpl>
@@
identifier f;
constant C;
typedef bool;
@@
bool f (...){
<+...
* return -C;
...+>
}
</smpl>
Signed-off-by: Peter Senna Tschudin <[email protected] >
Cc: Jiri Olsa <[email protected] >
Cc: Kan Liang <[email protected] >
Cc: Matt Fleming <[email protected] >
Cc: Milos Vyletel <[email protected] >
Cc: Namhyung Kim <[email protected] >
Cc: Peter Zijlstra <[email protected] >
Cc: Steven Rostedt <[email protected] >
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2015-09-17 15:31:52 -03:00
Jiri Olsa
592d5a6ba8
tools lib api fs: Move tracing_path interface into api/fs/tracing_path.c
...
Moving tracing_path interface into api/fs/tracing_path.c out of util.c.
It seems generic enough to be used by others, and I couldn't think of
better place.
Signed-off-by: Jiri Olsa <[email protected] >
Reviewed-by: Matt Fleming <[email protected] >
Reviewed-by: Raphael Beamonte <[email protected] >
Cc: David Ahern <[email protected] >
Cc: Namhyung Kim <[email protected] >
Cc: Peter Zijlstra <[email protected] >
Cc: Steven Rostedt <[email protected] >
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2015-09-04 12:00:45 -03:00
Jiri Olsa
65d4b26510
perf tools: Move tracing_path stuff under same namespace
...
Renaming all functions touching tracing_path under same namespace. New
interface is:
char tracing_path[];
- tracing mount path
char tracing_events_path[];
- tracing mount/events path
void tracing_path_set(const char *mountpoint);
- setting directly tracing_path(_events), used by --debugfs-dir option
const char *tracing_path_mount(void);
- initial setup of tracing_(events)_path, called from perf.c
mounts debugfs/tracefs if needed and possible
char *get_tracing_file(const char *name);
void put_tracing_file(char *file);
- get/put tracing file path
Signed-off-by: Jiri Olsa <[email protected] >
Cc: Raphael Beamonte <[email protected] >
Cc: David Ahern <[email protected] >
Cc: Matt Fleming <[email protected] >
Cc: Namhyung Kim <[email protected] >
Cc: Peter Zijlstra <[email protected] >
Cc: Steven Rostedt <[email protected] >
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2015-09-02 16:30:47 -03:00
Jiri Olsa
f6a09af7de
perf tools: Remove mountpoint arg from perf_debugfs_mount
...
It's not used by any caller. We either detect the mountpoint or use
hardcoded one.
Signed-off-by: Jiri Olsa <[email protected] >
Cc: Raphael Beamonte <[email protected] >
Cc: David Ahern <[email protected] >
Cc: Matt Fleming <[email protected] >
Cc: Namhyung Kim <[email protected] >
Cc: Peter Zijlstra <[email protected] >
Cc: Steven Rostedt <[email protected] >
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2015-09-02 16:30:47 -03:00
Jiri Olsa
9f30fffc78
perf tools: Do not change lib/api/fs/debugfs directly
...
The tracing_events_path is the variable we want to change via
--debugfs-dir option, not the debugfs_mountpoint.
Signed-off-by: Jiri Olsa <[email protected] >
Reviewed-by: Matt Fleming <[email protected] >
Cc: Raphael Beamonte <[email protected] >
Cc: David Ahern <[email protected] >
Cc: Namhyung Kim <[email protected] >
Cc: Peter Zijlstra <[email protected] >
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2015-08-28 14:53:53 -03:00
Jiri Olsa
9f44f0cc1c
perf tools: Add tracing_path and remove unneeded functions
...
There's no need for find_tracing_dir, because perf already searches for
debugfs/tracefs mount on start and populate tracing_events_path.
Adding tracing_path to carry tracing dir string to be used in
get_tracing_file instead of calling find_tracing_dir.
Signed-off-by: Jiri Olsa <[email protected] >
Cc: Raphael Beamonte <[email protected] >
Cc: David Ahern <[email protected] >
Cc: Matt Fleming <[email protected] >
Cc: Namhyung Kim <[email protected] >
Cc: Peter Zijlstra <[email protected] >
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2015-08-28 14:53:51 -03:00
Kan Liang
076a30c411
perf callchain: Move option parsing code to util.c
...
Move callchain option parse related code to util.c, to avoid dragging
more object files into the python binding.
Signed-off-by: Kan Liang <[email protected] >
Cc: Andi Kleen <[email protected] >
Cc: Jiri Olsa <[email protected] >
Cc: Namhyung Kim <[email protected] >
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2015-08-08 14:16:49 -03:00
Milos Vyletel
d7c72606d9
perf tools: Avoid possible race condition in copyfile()
...
Use unique temporary files when copying to buildid dir to prevent races
in case multiple instances are trying to copy same file. This is done by
- creating template in form <path>/.<filename>.XXXXXX where the suffix is
used by mkstemp() to create unique file
- change file mode
- copy content
- if successful link temp file to target file
- unlink temp file
At this point the only file left at target path should be the desired
one either created by us or other instance if we raced. This should also
prevent not yet fully copied files to be visible to to other perf
instances that could try to parse them.
On top of that slow_copyfile no longer needs to deal with file mode when
creating file since temporary file is already created and mode is set.
Succesfully tested by myself by running perf record, archive and reading
the data on other system and by running perf buildid-cache on perf
binary itself. I also did revert fix from 0635b0f that to exposes
previously fixed race with EEXIST and recreator test passed sucessfully.
Signed-off-by: Milos Vyletel <[email protected] >
Acked-by: Ingo Molnar <[email protected] >
Cc: Andy Shevchenko <[email protected] >
Cc: Don Zickus <[email protected] >
Cc: Jiri Olsa <[email protected] >
Cc: Namhyung Kim <[email protected] >
Cc: Peter Zijlstra <[email protected] >
Cc: Steven Rostedt <[email protected] >
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2015-06-10 11:51:24 -03:00
Namhyung Kim
9c9f5a2f19
perf tools: Introduce copyfile_offset() function
...
The copyfile_offset() function is to copy source data from given offset
to a destination file with an offset. It'll be used to build an indexed
data file.
Signed-off-by: Namhyung Kim <[email protected] >
Acked-by: Jiri Olsa <[email protected] >
Cc: Adrian Hunter <[email protected] >
Cc: Andi Kleen <[email protected] >
Cc: David Ahern <[email protected] >
Cc: Frederic Weisbecker <[email protected] >
Cc: Peter Zijlstra <[email protected] >
Cc: Stephane Eranian <[email protected] >
Link: http://lkml.kernel.org/r/[email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2015-05-18 10:17:35 -03:00
Namhyung Kim
0b1de0be1e
perf tools: Add rm_rf() utility function
...
The rm_rf() function does same as the shell command 'rm -rf' which
removes all directory entries recursively.
Signed-off-by: Namhyung Kim <[email protected] >
Acked-by: Jiri Olsa <[email protected] >
Cc: Adrian Hunter <[email protected] >
Cc: Andi Kleen <[email protected] >
Cc: David Ahern <[email protected] >
Cc: Frederic Weisbecker <[email protected] >
Cc: Peter Zijlstra <[email protected] >
Cc: Stephane Eranian <[email protected] >
Link: http://lkml.kernel.org/r/[email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2015-05-18 10:17:34 -03:00
Arnaldo Carvalho de Melo
07c1a0dadf
perf tools: Introduce dump_stack signal helper
...
To use in stdio based tools, like 'trace'.
Cc: Adrian Hunter <[email protected] >
Cc: Borislav Petkov <[email protected] >
Cc: David Ahern <[email protected] >
Cc: Don Zickus <[email protected] >
Cc: Frederic Weisbecker <[email protected] >
Cc: Jiri Olsa <[email protected] >
Cc: Namhyung Kim <[email protected] >
Cc: Stephane Eranian <[email protected] >
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2015-02-24 15:34:23 -03:00
Steven Rostedt (Red Hat)
23773ca18b
perf tools: Make perf aware of tracefs
...
As tracefs may be mounted instead of debugfs to get to the event
directories, have perf know about tracefs, and use that file system over
debugfs if it is present.
Signed-off-by: Steven Rostedt <[email protected] >
Acked-by: Jiri Olsa <[email protected] >
Cc: Andrew Morton <[email protected] >
Cc: Ingo Molnar <[email protected] >
Cc: Masami Hiramatsu <[email protected] >
Cc: Namhyung Kim <[email protected] >
Link: http://lkml.kernel.org/r/[email protected]
[ Fixed up error messages about tracefs pointed out by Namhyung ]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2015-02-11 12:37:08 -03:00
Arnaldo Carvalho de Melo
ce27309f67
perf tools: Use sysctl__read_int instead of ad-hoc copies
...
Cc: Adrian Hunter <[email protected] >
Cc: Borislav Petkov <[email protected] >
Cc: David Ahern <[email protected] >
Cc: Don Zickus <[email protected] >
Cc: Frederic Weisbecker <[email protected] >
Cc: Jiri Olsa <[email protected] >
Cc: Mike Galbraith <[email protected] >
Cc: Namhyung Kim <[email protected] >
Cc: Paul Mackerras <[email protected] >
Cc: Peter Zijlstra <[email protected] >
Cc: Stephane Eranian <[email protected] >
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2014-12-11 17:53:04 -03:00
Arnaldo Carvalho de Melo
3a351127cb
tools lib fs: Adopt filename__read_int from tools/perf/
...
Will be useful for new helpers to read sysctl values.
Cc: Adrian Hunter <[email protected] >
Cc: Borislav Petkov <[email protected] >
Cc: David Ahern <[email protected] >
Cc: Don Zickus <[email protected] >
Cc: Frederic Weisbecker <[email protected] >
Cc: Jiri Olsa <[email protected] >
Cc: Mike Galbraith <[email protected] >
Cc: Namhyung Kim <[email protected] >
Cc: Paul Mackerras <[email protected] >
Cc: Peter Zijlstra <[email protected] >
Cc: Stephane Eranian <[email protected] >
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2014-12-11 13:17:46 -03:00
Jiri Olsa
23aadb1fcd
perf callchain: Move callchain_param to util object in to fix python test
...
In following commit we changed the location of callchains data:
72a128aa08
perf tools: Move callchain config from record_opts to callchain_param
Now all callchains stuff stays in callchain_param struct, which adds its
dependency for evsel.c object and breaks python perf.so usage
(unresolved callchain_param).
Moving callchain_param into callchain.c and adding it into
python-ext-sources unleash just another dependency hell, so I ended up
adding callchain_param into util.c for now.
Signed-off-by: Jiri Olsa <[email protected] >
Cc: Adrian Hunter <[email protected] >
Cc: Corey Ashford <[email protected] >
Cc: David Ahern <[email protected] >
Cc: Frederic Weisbecker <[email protected] >
Cc: Ingo Molnar <[email protected] >
Cc: Milian Wolff <[email protected] >
Cc: Namhyung Kim <[email protected] >
Cc: Paul Mackerras <[email protected] >
Cc: Peter Zijlstra <[email protected] >
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2014-10-03 09:39:48 -03:00
Masami Hiramatsu
6e81c74cbf
perf util: Replace strerror with strerror_r for thread-safety
...
Replaces all strerror with strerror_r in util for making the perf lib
thread-safe.
Signed-off-by: Masami Hiramatsu <[email protected] >
Cc: Ingo Molnar <[email protected] >
Cc: Namhyung Kim <[email protected] >
Cc: Naohiro Aota <[email protected] >
Cc: Paul Mackerras <[email protected] >
Cc: Peter Zijlstra <[email protected] >
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2014-08-15 10:58:35 -03:00
Jiri Olsa
9398c484f8
perf tools: Introduce set_term_quiet_input helper function
...
Adding set_term_quiet_input helper to set the terminal quiet, out from
'perf top', used in following patches in 'perf kvm'.
Signed-off-by: Jiri Olsa <[email protected] >
Cc: Adrian Hunter <[email protected] >
Cc: Corey Ashford <[email protected] >
Cc: David Ahern <[email protected] >
Cc: Frederic Weisbecker <[email protected] >
Cc: Ingo Molnar <[email protected] >
Cc: Jean Pihet <[email protected] >
Cc: Namhyung Kim <[email protected] >
Cc: Paul Mackerras <[email protected] >
Cc: Peter Zijlstra <[email protected] >
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2014-08-13 11:14:22 -03:00
Jiri Olsa
63914aca8f
perf tools: Show better error message in case we fail to open counters due to EBUSY error
...
Showing better error message in case we fail to open counters due to the
EBUSY error. If we detect oprofile daemon process running, we now
display following message for EBUSY error:
$ perf record ls
Error:
The PMU counters are busy/taken by another profiler.
We found oprofile daemon running, please stop it and try again.
In case oprofiled was not detected the current error message stays:
$ perf record ls
Error:
The sys_perf_event_open() syscall returned with 16 (Device or resource busy) for event (cycles).
/bin/dmesg may provide additional information.
No CONFIG_PERF_EVENTS=y kernel support configured?
Also changing PERF_FLAG_FD_CLOEXEC detection code not to display error
in case of EBUSY error, as it currently does:
$ perf record ls
Error:
perf_event_open(..., PERF_FLAG_FD_CLOEXEC) failed with unexpected error 16 (Device or resource busy)
perf_event_open(..., 0) failed unexpectedly with error 16 (Device or resource busy)
The PMU counters are busy/taken by another profiler.
We found oprofile daemon running, please stop it and try again.
Signed-off-by: Jiri Olsa <[email protected] >
Cc: Adrian Hunter <[email protected] >
Cc: David Ahern <[email protected] >
Cc: Frederic Weisbecker <[email protected] >
Cc: Namhyung Kim <[email protected] >
Cc: Paul Mackerras <[email protected] >
Cc: Peter Zijlstra <[email protected] >
Cc: Stephane Eranian <[email protected] >
Cc: William Cohen <[email protected] >
Cc: Yann Droneaud <[email protected] >
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2014-08-12 12:03:02 -03:00
Jiri Olsa
84f5d36f48
perf tools: Move pr_* debug macros into debug object
...
Moving pr_* debug macros to have it with in same object as debug
variables, becase we will change them to use verbose variable in next
patch.
Signed-off-by: Jiri Olsa <[email protected] >
Cc: Corey Ashford <[email protected] >
Cc: David Ahern <[email protected] >
Cc: Frederic Weisbecker <[email protected] >
Cc: Ingo Molnar <[email protected] >
Cc: Namhyung Kim <[email protected] >
Cc: Paul Mackerras <[email protected] >
Cc: Peter Zijlstra <[email protected] >
Link: http://lkml.kernel.org/r/[email protected]
[ Add missing debug.h include in python scripting glue and in the libdw unwind lib ]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2014-07-17 12:58:39 -03:00
Andy Shevchenko
d400a68d1f
perf tools: Convert open coded equivalents to asprintf()
...
The following snippet
V = malloc(S);
if (!V) { }
sprintf(V, ...)
Can be easily changed to a one line:
if (asprintf(&V, ...) < 0) { }
Signed-off-by: Andy Shevchenko <[email protected] >
Cc: Adrian Hunter <[email protected] >
Link: http://lkml.kernel.org/r/1404474229-15272-1-git-send-email-andriy.shevchenko@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2014-07-07 16:55:24 -03:00
Don Zickus
2b1b71003e
perf tools: Add support to dynamically get cacheline size
...
Different arches may have different cacheline sizes. Look it up and set
a global variable for reference.
Signed-off-by: Don Zickus <[email protected] >
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Jiri Olsa <[email protected] >
2014-06-09 13:34:48 +02:00
Namhyung Kim
e148c76083
perf tools: Handle EINTR error for readn/writen
...
Those readn/writen functions are to ensure read/write does I/O for
a given size exactly. But ion() - its implementation - does not
handle in case it returns prematurely due to a signal. As it's not
an error itself so just retry the operation.
Signed-off-by: Namhyung Kim <[email protected] >
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Jiri Olsa <[email protected] >
2014-04-29 14:26:30 +02:00
Borislav Petkov
cd0cfad74e
perf tools: Move fs.* to lib/api/fs/
...
Move to generic library and kill magic.h as it is needed only in fs.h.
Signed-off-by: Borislav Petkov <[email protected] >
Cc: Adrian Hunter <[email protected] >
Cc: Andi Kleen <[email protected] >
Cc: Arjan van de Ven <[email protected] >
Cc: David Ahern <[email protected] >
Cc: Frederic Weisbecker <[email protected] >
Cc: Jiri Olsa <[email protected] >
Cc: Mike Galbraith <[email protected] >
Cc: Namhyung Kim <[email protected] >
Cc: Paul Mackerras <[email protected] >
Cc: Pekka Enberg <[email protected] >
Cc: Peter Zijlstra <[email protected] >
Cc: Robert Richter <[email protected] >
Cc: Stanislav Fomichev <[email protected] >
Cc: Stephane Eranian <[email protected] >
Cc: Steven Rostedt <[email protected] >
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2014-02-18 09:34:49 -03:00
Adrian Hunter
71db07b12e
perf tools: Move mem_bswap32/64 to util.c
...
Move functions mem_bswap_32() and mem_bswap_64() so they can be reused.
Signed-off-by: Adrian Hunter <[email protected] >
Cc: Andi Kleen <[email protected] >
Cc: David Ahern <[email protected] >
Cc: Frederic Weisbecker <[email protected] >
Cc: Ingo Molnar <[email protected] >
Cc: Jiri Olsa <[email protected] >
Cc: Mike Galbraith <[email protected] >
Cc: Namhyung Kim <[email protected] >
Cc: Paul Mackerras <[email protected] >
Cc: Peter Zijlstra <[email protected] >
Cc: Stephane Eranian <[email protected] >
Link: http://lkml.kernel.org/r/1386765443-26966-21-git-send-email-alexander.shishkin@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2013-12-13 10:30:21 -03:00
Adrian Hunter
1a47245d2f
perf tools: Add perf_event_paranoid()
...
Add a function to return the value of
/proc/sys/kernel/perf_event_paranoid.
This will be used to determine default values for mmap size because perf
is not subject to mmap limits when perf_event_paranoid is less than
zero.
Signed-off-by: Adrian Hunter <[email protected] >
Cc: Andi Kleen <[email protected] >
Cc: David Ahern <[email protected] >
Cc: Frederic Weisbecker <[email protected] >
Cc: Ingo Molnar <[email protected] >
Cc: Jiri Olsa <[email protected] >
Cc: Mike Galbraith <[email protected] >
Cc: Namhyung Kim <[email protected] >
Cc: Paul Mackerras <[email protected] >
Cc: Peter Zijlstra <[email protected] >
Cc: Stephane Eranian <[email protected] >
Link: http://lkml.kernel.org/r/1386765443-26966-12-git-send-email-alexander.shishkin@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2013-12-13 10:30:20 -03:00
Dongsheng Yang
e1a2b174db
perf kvm: Move code to generate filename for perf-kvm to function.
...
The code in builtin-kvm.c to generate filename for perf-kvm is useful to
other command such as builtin-diff.
This patch move the related code form builtin-kvm.c to util/util.c and
wrap them in a function named get_filename_for_perf_kvm.
Signed-off-by: Dongsheng Yang <[email protected] >
Link: http://lkml.kernel.org/r/5e09a5c47e8a495e888cbdc65a6fafb2c950f529.1386368672.git.yangds.fnst@cn.fujitsu.com
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2013-12-09 15:23:56 -03:00
Jiri Olsa
cef82c9f5a
perf tools: Add filename__read_str util function
...
Adding filename__read_str util function to read
text file and return it in the char array.
The interface is:
int filename__read_str(const char *filename, char **buf, size_t *sizep)
Returns 0/-1 if the read suceeded/fail respectively.
buf - place to store the data pointer
size - place to store data size
v2 change:
- better error handling suggested by Namhyung Kim.
Signed-off-by: Jiri Olsa <[email protected] >
Cc: Corey Ashford <[email protected] >
Cc: David Ahern <[email protected] >
Cc: Frederic Weisbecker <[email protected] >
Cc: Ingo Molnar <[email protected] >
Cc: Namhyung Kim <[email protected] >
Cc: Paul Mackerras <[email protected] >
Cc: Peter Zijlstra <[email protected] >
Cc: Steven Rostedt <[email protected] >
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2013-12-04 15:20:12 -03:00
Jiri Olsa
bc3a502bc2
perf tools: Add writen function
...
Adding 'writen' function as a synchronous wrapper for write syscall with
following prototype:
ssize_t writen(int fd, void *buf, size_t n)
Returns the number of bytes written on success or -1 in case of err.
Signed-off-by: Jiri Olsa <[email protected] >
Requested-by: Arnaldo Carvalho de Melo <[email protected] >
Cc: Adrian Hunter <[email protected] >
Cc: David Ahern <[email protected] >
Cc: Frederic Weisbecker <[email protected] >
Cc: Ingo Molnar <[email protected] >
Cc: Mike Galbraith <[email protected] >
Cc: Namhyung Kim <[email protected] >
Cc: Peter Zijlstra <[email protected] >
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2013-12-02 09:22:46 -03:00
Jiri Olsa
838d145202
perf tools: Fine tune readn function
...
Added a 'left' variable to make the flow clearer, and added a debug
check for the return value - returning 'n' is more obvious.
Added small comment for readn.
Signed-off-by: Jiri Olsa <[email protected] >
Original-patch-by: Ingo Molnar <[email protected] >
Cc: Adrian Hunter <[email protected] >
Cc: David Ahern <[email protected] >
Cc: Frederic Weisbecker <[email protected] >
Cc: Ingo Molnar <[email protected] >
Cc: Mike Galbraith <[email protected] >
Cc: Namhyung Kim <[email protected] >
Cc: Peter Zijlstra <[email protected] >
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2013-12-02 09:22:46 -03:00
Jiri Olsa
727ebd544f
perf tools: Use correct return type for readn function
...
Changing readn function return type to ssize_t because read returns
ssize_t not int.
Changing callers holding variable types as well.
Signed-off-by: Jiri Olsa <[email protected] >
Cc: Adrian Hunter <[email protected] >
Cc: David Ahern <[email protected] >
Cc: Frederic Weisbecker <[email protected] >
Cc: Ingo Molnar <[email protected] >
Cc: Mike Galbraith <[email protected] >
Cc: Namhyung Kim <[email protected] >
Cc: Peter Zijlstra <[email protected] >
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2013-12-02 09:22:45 -03:00
Adrian Hunter
56921becdd
perf tools: Do not accept parse_tag_value() overflow
...
parse_tag_value() accepts an "unsigned long" and multiplies it according
to a tag character. Do not accept the value if the multiplication
overflows.
Signed-off-by: Adrian Hunter <[email protected] >
Cc: David Ahern <[email protected] >
Cc: Frederic Weisbecker <[email protected] >
Cc: Ingo Molnar <[email protected] >
Cc: Jiri Olsa <[email protected] >
Cc: Mike Galbraith <[email protected] >
Cc: Namhyung Kim <[email protected] >
Cc: Paul Mackerras <[email protected] >
Cc: Peter Zijlstra <[email protected] >
Cc: Stephane Eranian <[email protected] >
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2013-10-23 10:59:09 -03:00
Arnaldo Carvalho de Melo
97a07f10c3
perf tools: Introduce filename__read_int helper
...
Just opens a file and calls atoi() in at most its first 64 bytes.
To read things like /proc/sys/kernel/perf_event_paranoid.
Cc: Adrian Hunter <[email protected] >
Cc: David Ahern <[email protected] >
Cc: Frederic Weisbecker <[email protected] >
Cc: Jiri Olsa <[email protected] >
Cc: Mike Galbraith <[email protected] >
Cc: Paul Mackerras <[email protected] >
Cc: Peter Zijlstra <[email protected] >
Cc: Stephane Eranian <[email protected] >
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2013-10-17 16:33:43 -03:00
Adrian Hunter
9a17d7268d
perf tools: Add copyfile_mode()
...
Add a function to copy a file specifying the permissions to use for the
created file.
Signed-off-by: Adrian Hunter <[email protected] >
Cc: David Ahern <[email protected] >
Cc: Frederic Weisbecker <[email protected] >
Cc: Jiri Olsa <[email protected] >
Cc: Mike Galbraith <[email protected] >
Cc: Namhyung Kim <[email protected] >
Cc: Paul Mackerras <[email protected] >
Cc: Peter Zijlstra <[email protected] >
Cc: Stephane Eranian <[email protected] >
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2013-10-14 10:29:23 -03:00
Jiri Olsa
27050f530d
perf tools: Add possibility to specify mmap size
...
Adding possibility to specify mmap size via -m/--mmap-pages
by appending unit size character (B/K/M/G) to the
number, like:
$ perf record -m 8K ls
$ perf record -m 2M ls
The size is rounded up appropriately to follow perf
mmap restrictions.
If no unit is specified the number provides pages as
of now, like:
$ perf record -m 8 ls
Signed-off-by: Jiri Olsa <[email protected] >
Cc: Andi Kleen <[email protected] >
Cc: Corey Ashford <[email protected] >
Cc: David Ahern <[email protected] >
Cc: Frederic Weisbecker <[email protected] >
Cc: Ingo Molnar <[email protected] >
Cc: Namhyung Kim <[email protected] >
Cc: Paul Mackerras <[email protected] >
Cc: Peter Zijlstra <[email protected] >
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2013-10-09 11:24:20 -03:00
Ingo Molnar
89fe808ae7
tools/perf: Standardize feature support define names to: HAVE_{FEATURE}_SUPPORT
...
Standardize all the feature flags based on the HAVE_{FEATURE}_SUPPORT naming convention:
HAVE_ARCH_X86_64_SUPPORT
HAVE_BACKTRACE_SUPPORT
HAVE_CPLUS_DEMANGLE_SUPPORT
HAVE_DWARF_SUPPORT
HAVE_ELF_GETPHDRNUM_SUPPORT
HAVE_GTK2_SUPPORT
HAVE_GTK_INFO_BAR_SUPPORT
HAVE_LIBAUDIT_SUPPORT
HAVE_LIBELF_MMAP_SUPPORT
HAVE_LIBELF_SUPPORT
HAVE_LIBNUMA_SUPPORT
HAVE_LIBUNWIND_SUPPORT
HAVE_ON_EXIT_SUPPORT
HAVE_PERF_REGS_SUPPORT
HAVE_SLANG_SUPPORT
HAVE_STRLCPY_SUPPORT
Cc: Arnaldo Carvalho de Melo <[email protected] >
Cc: Peter Zijlstra <[email protected] >
Cc: Namhyung Kim <[email protected] >
Cc: David Ahern <[email protected] >
Cc: Jiri Olsa <[email protected] >
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected] >
2013-10-09 08:48:28 +02:00
Namhyung Kim
3b47abe1b5
perf util: Add parse_nsec_time() function
...
The parse_nsec_time() function is for parsing a string of time into
64-bit nsec value. It's a preparation of time filtering in some of perf
commands.
Signed-off-by: Namhyung Kim <[email protected] >
Tested-by: David Ahern <[email protected] >
Acked-by: David Ahern <[email protected] >
Cc: Andi Kleen <[email protected] >
Cc: David Ahern <[email protected] >
Cc: Ingo Molnar <[email protected] >
Cc: Jiri Olsa <[email protected] >
Cc: Paul Mackerras <[email protected] >
Cc: Peter Zijlstra <[email protected] >
Cc: Stephane Eranian <[email protected] >
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2013-08-07 17:35:26 -03:00
Namhyung Kim
167aedc44e
perf util: Move debugfs/tracing helper functions to util.c
...
Since they're generic helpers move them to util.c so that they can be
used by others.
Signed-off-by: Namhyung Kim <[email protected] >
Cc: David Ahern <[email protected] >
Cc: Frederic Weisbecker <[email protected] >
Cc: Ingo Molnar <[email protected] >
Cc: Jiri Olsa <[email protected] >
Cc: Paul Mackerras <[email protected] >
Cc: Peter Zijlstra <[email protected] >
Cc: Stephane Eranian <[email protected] >
Cc: Steven Rostedt <[email protected] >
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2013-07-12 13:46:00 -03:00
Borislav Petkov
1355915ac6
perf tools: Extract perf-specific stuff from debugfs.c
...
Move them to util.c and simplify code a bit.
Signed-off-by: Borislav Petkov <[email protected] >
Cc: Ingo Molnar <[email protected] >
Cc: Steven Rostedt <[email protected] >
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2013-03-15 13:06:01 -03:00
David Ahern
2c803e5248
perf tools: Move get_term_dimensions from top to util.c
...
It is used by util/help.c so it should be a lib function and included in
libperf.a. Code move only.
Signed-off-by: David Ahern <[email protected] >
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2013-01-24 16:40:34 -03:00
Arnaldo Carvalho de Melo
0c6332e9d8
perf python: Fix breakage introduced by the test_attr infrastructure
...
The test_attr infrastructure hooks on the sys_perf_event_open call,
checking if a variable is set and if so calling a function to intercept
calls and do the checking.
But both the variable and the function aren't on objects that are
linked on the python binding, breaking it:
# perf test -v 15
15: Try 'use perf' in python, checking link problems :
--- start ---
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: /home/acme/git/build/perf//python/perf.so: undefined symbol: test_attr__enabled
---- end ----
Try 'use perf' in python, checking link problems: FAILED!
#
Fix it by moving the variable to one of the linked object files and
providing a stub for the function in the python.o object, that is only
linked in the python binding.
Now 'perf test' is happy again:
# perf test 15
15: Try 'use perf' in python, checking link problems : Ok
#
Cc: David Ahern <[email protected] >
Cc: Frederic Weisbecker <[email protected] >
Cc: Jiri Olsa <[email protected] >
Cc: Mike Galbraith <[email protected] >
Cc: Namhyung Kim <[email protected] >
Cc: Paul Mackerras <[email protected] >
Cc: Peter Zijlstra <[email protected] >
Cc: Stephane Eranian <[email protected] >
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2013-01-24 16:40:09 -03:00
Jiri Olsa
b2aff5f615
perf tools: Move hex2u64 into util object
...
Moving hex2u64 function into util object.
Signed-off-by: Jiri Olsa <[email protected] >
Reviewed-by: Namhyung Kim <[email protected] >
Tested-by: Namhyung Kim <[email protected] >
Cc: Corey Ashford <[email protected] >
Cc: Frederic Weisbecker <[email protected] >
Cc: Ingo Molnar <[email protected] >
Cc: Namhyung Kim <[email protected] >
Cc: Paul Mackerras <[email protected] >
Cc: Peter Zijlstra <[email protected] >
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2012-10-29 11:36:02 -02:00
Arnaldo Carvalho de Melo
0c1fe6b2f3
perf tools: Have the page size value available for all tools
...
Its such a common need that we might as well have a global with that
value.
Cc: David Ahern <[email protected] >
Cc: Frederic Weisbecker <[email protected] >
Cc: Jiri Olsa <[email protected] >
Cc: Mike Galbraith <[email protected] >
Cc: Namhyung Kim <[email protected] >
Cc: Paul Mackerras <[email protected] >
Cc: Peter Zijlstra <[email protected] >
Cc: Stephane Eranian <[email protected] >
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2012-10-06 16:33:14 -03:00
Namhyung Kim
4e34d9588b
perf tools: Convert to BACKTRACE_SUPPORT
...
For building perf without stack backtrace debug, we can set
NO_BACKTRACE=1 as a argument of make. It then defines NO_BACKTRACE
macro for C code to do the proper handling. However it usually used in
a negative semantics - e.g. #ifndef - so we saw double negations which
can be misleading. Convert it to a positive form to make it more
readable and add _SUPPORT suffix for consistency.
Signed-off-by: Namhyung Kim <[email protected] >
Cc: Ingo Molnar <[email protected] >
Cc: Irina Tirdea <[email protected] >
Cc: Irina Tirdea <[email protected] >
Cc: Paul Mackerras <[email protected] >
Cc: Peter Zijlstra <[email protected] >
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2012-10-02 18:36:45 -03:00
Irina Tirdea
c9f08bee50
perf tools: add NO_BACKTRACE for application self-debugging
...
perf has support for self-debugging by defining dump_stack function.
This function uses backtrace and backtrace_symbols functions defined as
GNU extensions.
In Android, bionic does not offer support for these functions and
compilation will fail with the following error:
target C: libperf <= tools/perf/util/util.c
tools/perf/util/util.c:4:22: fatal error: execinfo.h: No such file or directory
compilation terminated.
Add a compile-time option (NO_BACKTRACE) to enable or disable
self-debugging functionality in perf. This can also help in debugging
since it offers the possibility to turn on/off printing the backtrace.
Signed-off-by: Irina Tirdea <[email protected] >
Cc: David Ahern <[email protected] >
Cc: Ingo Molnar <[email protected] >
Cc: Namhyung Kim <[email protected] >
Cc: Paul Mackerras <[email protected] >
Cc: Peter Zijlstra <[email protected] >
Cc: Steven Rostedt <[email protected] >
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2012-09-07 22:12:30 -03:00
Arnaldo Carvalho de Melo
dc4552bf71
perf tools: Add dump_stack function
...
To help in debugging the tools, provides functionality roughly similar
to the function with the same name in the kernel.
Copied from glibc backtrace function man page.
Cc: David Ahern <[email protected] >
Cc: Frederic Weisbecker <[email protected] >
Cc: Jiri Olsa <[email protected] >
Cc: Mike Galbraith <[email protected] >
Cc: Namhyung Kim <[email protected] >
Cc: Paul Mackerras <[email protected] >
Cc: Peter Zijlstra <[email protected] >
Cc: Stephane Eranian <[email protected] >
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2012-08-07 23:32:05 -03:00
Arnaldo Carvalho de Melo
61e04b332e
perf annotate browser: Align jump labels
...
Find out at browser startup the max width and use it when rendering jump
labels on the screen.
Cc: David Ahern <[email protected] >
Cc: Frederic Weisbecker <[email protected] >
Cc: Mike Galbraith <[email protected] >
Cc: Namhyung Kim <[email protected] >
Cc: Paul Mackerras <[email protected] >
Cc: Peter Zijlstra <[email protected] >
Cc: Stephane Eranian <[email protected] >
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2012-04-19 13:15:24 -03:00