Skip to content

Commit

Permalink
trace-cmd: top: A new interface to detect peak memory
Browse files Browse the repository at this point in the history
A new interface "trace-cmd top" has been introduced in this patch to
know peak memory usage of any task.

$ trace-cmd top -s "/tmp/socket"
It will start to gather statistics of all the process which will be
scheduled after this command execution.
$ trace-cmd top -p "/tmp/socket"
It will print peak memory usage(in KB) against each scheduled task.
$ trace-cmd top -e "/tmp/socket"
It will print peak memory usage(in KB) against each scheduled task and
will stop gathering statistics. It will also kill the child process
initiated by -s option.

 # ./trace-cmd top -s "/tmp/socket"
 # ./trace-cmd top -e "/tmp/socket"

pid             comm            peak memory(in KB)
37              rcuos/3                 0
1979            gnome-shell             374444
6286            bash                    6444
7972            trace-cmd               204
10244           thunderbird             830632
10264           Socket Thread           830632
10281           Timer                   830632
16806           kworker/1:0             0
21528           firefox                 1747356
32110           minicom                 6988

Signed-off-by: Pratyush Anand <panand@redhat.com>
  • Loading branch information
Pratyush Anand committed Apr 27, 2017
1 parent 013205a commit 602c2cd
Show file tree
Hide file tree
Showing 6 changed files with 699 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -331,7 +331,7 @@ TRACE_GUI_OBJS = trace-filter.o trace-compat.o trace-filter-hash.o trace-dialog.
trace-xml.o
TRACE_CMD_OBJS = trace-cmd.o trace-record.o trace-read.o trace-split.o trace-listen.o \
trace-stack.o trace-hist.o trace-mem.o trace-snapshot.o trace-stat.o \
trace-hash.o trace-profile.o trace-stream.o
trace-hash.o trace-profile.o trace-stream.o trace-top.o
TRACE_VIEW_OBJS = trace-view.o trace-view-store.o
TRACE_GRAPH_OBJS = trace-graph.o trace-plot.o trace-plot-cpu.o trace-plot-task.o
TRACE_VIEW_MAIN_OBJS = trace-view-main.o $(TRACE_VIEW_OBJS) $(TRACE_GUI_OBJS)
Expand Down
4 changes: 4 additions & 0 deletions trace-cmd.c
Expand Up @@ -495,6 +495,10 @@ int main (int argc, char **argv)
trace_stat(argc, argv);
exit(0);

} else if (strcmp(argv[1], "top") == 0) {
trace_top(argc, argv);
exit(0);

} else if (strcmp(argv[1], "options") == 0) {
show_plugin_options();
exit(0);
Expand Down
3 changes: 3 additions & 0 deletions trace-local.h
Expand Up @@ -74,6 +74,8 @@ void trace_mem(int argc, char **argv);

void trace_stat(int argc, char **argv);

void trace_top(int argc, char **argv);

struct hook_list;

int trace_profile_record(struct tracecmd_input *handle,
Expand Down Expand Up @@ -184,5 +186,6 @@ void update_first_instance(struct buffer_instance *instance, int topt);

void show_instance_file(struct buffer_instance *instance, const char *name);
int count_cpus(void);
char *read_file(char *file, int *psize);

#endif /* __TRACE_LOCAL_H */
2 changes: 1 addition & 1 deletion trace-record.c
Expand Up @@ -3323,7 +3323,7 @@ static char *read_instance_file(struct buffer_instance *instance, char *file, in
return buf;
}

static char *read_file(char *file, int *psize)
char *read_file(char *file, int *psize)
{
return read_instance_file(&top_instance, file, psize);
}
Expand Down

0 comments on commit 602c2cd

Please sign in to comment.