diff options
author | Steven Rostedt <srostedt@redhat.com> | 2010-04-07 12:14:15 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2010-04-07 12:14:15 -0400 |
commit | 94ea9b96207b73c4368882c459552b36ec91dfe6 (patch) | |
tree | 53be9dabd5b20a86433f96032eb20643b05e2554 | |
parent | 1f3dc4fdbdcea345828376f72738ee36b63f6c43 (diff) |
trace-cmd: Add '-r' to record to set priority of capture threads
Add the option '-r' to the trace-cmd record that will set the
trace capture threads to that real-time FIFO priority.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r-- | Documentation/trace-cmd-record.1.txt | 7 | ||||
-rw-r--r-- | trace-cmd.c | 21 | ||||
-rw-r--r-- | trace-usage.c | 3 |
3 files changed, 29 insertions, 2 deletions
diff --git a/Documentation/trace-cmd-record.1.txt b/Documentation/trace-cmd-record.1.txt index 4707605..4e09389 100644 --- a/Documentation/trace-cmd-record.1.txt +++ b/Documentation/trace-cmd-record.1.txt | |||
@@ -125,6 +125,13 @@ OPTIONS | |||
125 | This is the time each recording process will sleep before waking up to | 125 | This is the time each recording process will sleep before waking up to |
126 | record any new data that was written to the ring buffer. | 126 | record any new data that was written to the ring buffer. |
127 | 127 | ||
128 | *-r* 'priority':: | ||
129 | The priority to run the capture threads at. In a busy system the trace | ||
130 | capturing threads may be staved and events can be lost. This increases | ||
131 | the priority of those threads to the real time (FIFO) priority. | ||
132 | But use this option with care, it can also change the behaviour of | ||
133 | the system being traced. | ||
134 | |||
128 | *-b* 'size':: | 135 | *-b* 'size':: |
129 | This sets the ring buffer size to 'size' kilobytes. Because the Ftrace | 136 | This sets the ring buffer size to 'size' kilobytes. Because the Ftrace |
130 | ring buffer is per CPU, this size is the size of each per CPU ring buffer | 137 | ring buffer is per CPU, this size is the size of each per CPU ring buffer |
diff --git a/trace-cmd.c b/trace-cmd.c index 4db8e8c..7c13264 100644 --- a/trace-cmd.c +++ b/trace-cmd.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <fcntl.h> | 33 | #include <fcntl.h> |
34 | #include <unistd.h> | 34 | #include <unistd.h> |
35 | #include <ctype.h> | 35 | #include <ctype.h> |
36 | #include <sched.h> | ||
36 | #include <errno.h> | 37 | #include <errno.h> |
37 | #include <glob.h> | 38 | #include <glob.h> |
38 | 39 | ||
@@ -54,6 +55,8 @@ | |||
54 | int silence_warnings; | 55 | int silence_warnings; |
55 | int show_status; | 56 | int show_status; |
56 | 57 | ||
58 | static int rt_prio; | ||
59 | |||
57 | static int use_tcp; | 60 | static int use_tcp; |
58 | 61 | ||
59 | static unsigned int page_size; | 62 | static unsigned int page_size; |
@@ -963,6 +966,16 @@ static void connect_port(int cpu) | |||
963 | client_ports[cpu] = sfd; | 966 | client_ports[cpu] = sfd; |
964 | } | 967 | } |
965 | 968 | ||
969 | static void set_prio(int prio) | ||
970 | { | ||
971 | struct sched_param sp; | ||
972 | |||
973 | memset(&sp, 0, sizeof(sp)); | ||
974 | sp.sched_priority = prio; | ||
975 | if (sched_setscheduler(0, SCHED_FIFO, &sp) < 0) | ||
976 | warning("failed to set priority"); | ||
977 | } | ||
978 | |||
966 | static int create_recorder(int cpu) | 979 | static int create_recorder(int cpu) |
967 | { | 980 | { |
968 | char *file; | 981 | char *file; |
@@ -978,6 +991,9 @@ static int create_recorder(int cpu) | |||
978 | signal(SIGINT, finish); | 991 | signal(SIGINT, finish); |
979 | signal(SIGUSR1, flush); | 992 | signal(SIGUSR1, flush); |
980 | 993 | ||
994 | if (rt_prio) | ||
995 | set_prio(rt_prio); | ||
996 | |||
981 | /* do not kill tasks on error */ | 997 | /* do not kill tasks on error */ |
982 | cpu_count = 0; | 998 | cpu_count = 0; |
983 | 999 | ||
@@ -1325,7 +1341,7 @@ int main (int argc, char **argv) | |||
1325 | (strcmp(argv[1], "start") == 0) || | 1341 | (strcmp(argv[1], "start") == 0) || |
1326 | ((extract = strcmp(argv[1], "extract") == 0))) { | 1342 | ((extract = strcmp(argv[1], "extract") == 0))) { |
1327 | 1343 | ||
1328 | while ((c = getopt(argc-1, argv+1, "+he:f:Fp:do:O:s:vg:l:n:P:N:tb:")) >= 0) { | 1344 | while ((c = getopt(argc-1, argv+1, "+he:f:Fp:do:O:s:r:vg:l:n:P:N:tb:")) >= 0) { |
1329 | switch (c) { | 1345 | switch (c) { |
1330 | case 'h': | 1346 | case 'h': |
1331 | usage(argv); | 1347 | usage(argv); |
@@ -1418,6 +1434,9 @@ int main (int argc, char **argv) | |||
1418 | usage(argv); | 1434 | usage(argv); |
1419 | sleep_time = atoi(optarg); | 1435 | sleep_time = atoi(optarg); |
1420 | break; | 1436 | break; |
1437 | case 'r': | ||
1438 | rt_prio = atoi(optarg); | ||
1439 | break; | ||
1421 | case 'N': | 1440 | case 'N': |
1422 | if (!record) | 1441 | if (!record) |
1423 | die("-N only available with record"); | 1442 | die("-N only available with record"); |
diff --git a/trace-usage.c b/trace-usage.c index e834d44..9df19eb 100644 --- a/trace-usage.c +++ b/trace-usage.c | |||
@@ -18,7 +18,7 @@ static struct usage_help usage_help[] = { | |||
18 | "record a trace into a trace.dat file", | 18 | "record a trace into a trace.dat file", |
19 | " %s record [-v][-e event [-f filter]][-p plugin][-F][-d][-o file] \\\n" | 19 | " %s record [-v][-e event [-f filter]][-p plugin][-F][-d][-o file] \\\n" |
20 | " [-s usecs][-O option ][-l func][-g func][-n func] \\\n" | 20 | " [-s usecs][-O option ][-l func][-g func][-n func] \\\n" |
21 | " [-P pid][-N host:port][-t][-b size][command ...]\n" | 21 | " [-P pid][-N host:port][-t][-r prio][-b size][command ...]\n" |
22 | " -e run command with event enabled\n" | 22 | " -e run command with event enabled\n" |
23 | " -f filter for previous -e event\n" | 23 | " -f filter for previous -e event\n" |
24 | " -p run command with plugin enabled\n" | 24 | " -p run command with plugin enabled\n" |
@@ -31,6 +31,7 @@ static struct usage_help usage_help[] = { | |||
31 | " -d disable function tracer when running\n" | 31 | " -d disable function tracer when running\n" |
32 | " -o data output file [default trace.dat]\n" | 32 | " -o data output file [default trace.dat]\n" |
33 | " -O option to enable (or disable)\n" | 33 | " -O option to enable (or disable)\n" |
34 | " -r real time priority to run the capture threads\n" | ||
34 | " -s sleep interval between recording (in usecs) [default: 1000]\n" | 35 | " -s sleep interval between recording (in usecs) [default: 1000]\n" |
35 | " -N host:port to connect to (see listen)\n" | 36 | " -N host:port to connect to (see listen)\n" |
36 | " -t used with -N, forces use of tcp in live trace\n" | 37 | " -t used with -N, forces use of tcp in live trace\n" |