mirror of
https://github.com/adulau/aha.git
synced 2024-12-28 11:46:19 +00:00
perf_counter tools: add 'perf record' command
Move perf-record.c into the perf suite of commands. Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
parent
1d8c8b209e
commit
e33e0a4373
6 changed files with 73 additions and 30 deletions
63
Documentation/perf_counter/Documentation/perf-record.txt
Normal file
63
Documentation/perf_counter/Documentation/perf-record.txt
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
perf-record(1)
|
||||||
|
==========
|
||||||
|
|
||||||
|
NAME
|
||||||
|
----
|
||||||
|
perf-record - Run a command and record its profile into output.perf
|
||||||
|
|
||||||
|
SYNOPSIS
|
||||||
|
--------
|
||||||
|
[verse]
|
||||||
|
'perf record' [-e <EVENT> | --event=EVENT] [-l] [-a] <command>
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
-----------
|
||||||
|
This command runs a command and gathers a performance counter profile
|
||||||
|
from it, into output.perf - without displaying anything.
|
||||||
|
|
||||||
|
This file can then be inspected later on, using 'perf report'.
|
||||||
|
|
||||||
|
|
||||||
|
OPTIONS
|
||||||
|
-------
|
||||||
|
<command>...::
|
||||||
|
Any command you can specify in a shell.
|
||||||
|
|
||||||
|
-e::
|
||||||
|
--event=::
|
||||||
|
0:0: cpu-cycles
|
||||||
|
0:0: cycles
|
||||||
|
0:1: instructions
|
||||||
|
0:2: cache-references
|
||||||
|
0:3: cache-misses
|
||||||
|
0:4: branch-instructions
|
||||||
|
0:4: branches
|
||||||
|
0:5: branch-misses
|
||||||
|
0:6: bus-cycles
|
||||||
|
1:0: cpu-clock
|
||||||
|
1:1: task-clock
|
||||||
|
1:2: page-faults
|
||||||
|
1:2: faults
|
||||||
|
1:5: minor-faults
|
||||||
|
1:6: major-faults
|
||||||
|
1:3: context-switches
|
||||||
|
1:3: cs
|
||||||
|
1:4: cpu-migrations
|
||||||
|
1:4: migrations
|
||||||
|
rNNN: raw PMU events (eventsel+umask)
|
||||||
|
|
||||||
|
-a::
|
||||||
|
system-wide collection
|
||||||
|
|
||||||
|
-l::
|
||||||
|
scale counter values
|
||||||
|
|
||||||
|
Configuration
|
||||||
|
-------------
|
||||||
|
|
||||||
|
EXAMPLES
|
||||||
|
--------
|
||||||
|
|
||||||
|
SEE ALSO
|
||||||
|
--------
|
||||||
|
linkperf:git-stat[1]
|
|
@ -309,6 +309,7 @@ LIB_OBJS += usage.o
|
||||||
LIB_OBJS += wrapper.o
|
LIB_OBJS += wrapper.o
|
||||||
|
|
||||||
BUILTIN_OBJS += builtin-help.o
|
BUILTIN_OBJS += builtin-help.o
|
||||||
|
BUILTIN_OBJS += builtin-record.o
|
||||||
BUILTIN_OBJS += builtin-stat.o
|
BUILTIN_OBJS += builtin-stat.o
|
||||||
BUILTIN_OBJS += builtin-top.o
|
BUILTIN_OBJS += builtin-top.o
|
||||||
|
|
||||||
|
|
|
@ -81,16 +81,12 @@
|
||||||
(void) (&_min1 == &_min2); \
|
(void) (&_min1 == &_min2); \
|
||||||
_min1 < _min2 ? _min1 : _min2; })
|
_min1 < _min2 ? _min1 : _min2; })
|
||||||
|
|
||||||
asmlinkage int sys_perf_counter_open(
|
extern asmlinkage int sys_perf_counter_open(
|
||||||
struct perf_counter_hw_event *hw_event_uptr __user,
|
struct perf_counter_hw_event *hw_event_uptr __user,
|
||||||
pid_t pid,
|
pid_t pid,
|
||||||
int cpu,
|
int cpu,
|
||||||
int group_fd,
|
int group_fd,
|
||||||
unsigned long flags)
|
unsigned long flags);
|
||||||
{
|
|
||||||
return syscall(
|
|
||||||
__NR_perf_counter_open, hw_event_uptr, pid, cpu, group_fd, flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
#define MAX_COUNTERS 64
|
#define MAX_COUNTERS 64
|
||||||
#define MAX_NR_CPUS 256
|
#define MAX_NR_CPUS 256
|
||||||
|
@ -119,26 +115,6 @@ const unsigned int default_count[] = {
|
||||||
10000,
|
10000,
|
||||||
};
|
};
|
||||||
|
|
||||||
static char *hw_event_names[] = {
|
|
||||||
"CPU cycles",
|
|
||||||
"instructions",
|
|
||||||
"cache references",
|
|
||||||
"cache misses",
|
|
||||||
"branches",
|
|
||||||
"branch misses",
|
|
||||||
"bus cycles",
|
|
||||||
};
|
|
||||||
|
|
||||||
static char *sw_event_names[] = {
|
|
||||||
"cpu clock ticks",
|
|
||||||
"task clock ticks",
|
|
||||||
"pagefaults",
|
|
||||||
"context switches",
|
|
||||||
"CPU migrations",
|
|
||||||
"minor faults",
|
|
||||||
"major faults",
|
|
||||||
};
|
|
||||||
|
|
||||||
struct event_symbol {
|
struct event_symbol {
|
||||||
__u64 event;
|
__u64 event;
|
||||||
char *symbol;
|
char *symbol;
|
||||||
|
@ -414,7 +390,7 @@ static void sigchld_handler(int sig)
|
||||||
done = 1;
|
done = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int cmd_record(int argc, const char **argv)
|
||||||
{
|
{
|
||||||
struct pollfd event_array[MAX_NR_CPUS * MAX_COUNTERS];
|
struct pollfd event_array[MAX_NR_CPUS * MAX_COUNTERS];
|
||||||
struct mmap_data mmap_array[MAX_NR_CPUS][MAX_COUNTERS];
|
struct mmap_data mmap_array[MAX_NR_CPUS][MAX_COUNTERS];
|
|
@ -14,6 +14,7 @@ extern void prune_packed_objects(int);
|
||||||
extern int read_line_with_nul(char *buf, int size, FILE *file);
|
extern int read_line_with_nul(char *buf, int size, FILE *file);
|
||||||
extern int check_pager_config(const char *cmd);
|
extern int check_pager_config(const char *cmd);
|
||||||
|
|
||||||
extern int cmd_top(int argc, const char **argv, const char *prefix);
|
extern int cmd_record(int argc, const char **argv, const char *prefix);
|
||||||
extern int cmd_stat(int argc, const char **argv, const char *prefix);
|
extern int cmd_stat(int argc, const char **argv, const char *prefix);
|
||||||
|
extern int cmd_top(int argc, const char **argv, const char *prefix);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# List of known perf commands.
|
# List of known perf commands.
|
||||||
# command name category [deprecated] [common]
|
# command name category [deprecated] [common]
|
||||||
perf-top mainporcelain common
|
perf-record mainporcelain common
|
||||||
perf-stat mainporcelain common
|
perf-stat mainporcelain common
|
||||||
|
perf-top mainporcelain common
|
||||||
|
|
||||||
|
|
|
@ -248,8 +248,9 @@ static void handle_internal_command(int argc, const char **argv)
|
||||||
{
|
{
|
||||||
const char *cmd = argv[0];
|
const char *cmd = argv[0];
|
||||||
static struct cmd_struct commands[] = {
|
static struct cmd_struct commands[] = {
|
||||||
{ "top", cmd_top, 0 },
|
{ "record", cmd_record, 0 },
|
||||||
{ "stat", cmd_stat, 0 },
|
{ "stat", cmd_stat, 0 },
|
||||||
|
{ "top", cmd_top, 0 },
|
||||||
};
|
};
|
||||||
int i;
|
int i;
|
||||||
static const char ext[] = STRIP_EXTENSION;
|
static const char ext[] = STRIP_EXTENSION;
|
||||||
|
|
Loading…
Reference in a new issue