Skip to content

Commit

Permalink
uftrace: Change opts->kernel as bool
Browse files Browse the repository at this point in the history
It's more reasonal to treat this option as a boolean.

But it affects the timeout of writer threads.  I think it's ok as
there's no observable difference in the output - it still has LOST
records before and after the change for some large kernel depth.  I
still need to increse the kernel buffer size to avoid that.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
  • Loading branch information
namhyung committed Sep 23, 2016
1 parent 42c49e8 commit c45b247
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 16 deletions.
4 changes: 2 additions & 2 deletions cmd-dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ static void dump_raw(int argc, char *argv[], struct opts *opts,
}
}

if (opts->kernel == 0 || handle->kern == NULL || ftrace_done)
if (!opts->kernel || handle->kern == NULL || ftrace_done)
return;

pr_out("\n");
Expand Down Expand Up @@ -576,7 +576,7 @@ static void dump_chrome_trace(int argc, char *argv[], struct opts *opts,
}
}

if (opts->kernel == 0 || handle->kern == NULL || ftrace_done)
if (!opts->kernel || handle->kern == NULL || ftrace_done)
goto json_footer;

pr_out(",\n");
Expand Down
19 changes: 7 additions & 12 deletions cmd-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,23 +424,18 @@ void *writer_thread(void *arg)
goto out;
}

/* check kernel data every 1ms (or 10us) */
/* check kernel data every 1ms */
clock_gettime(CLOCK_REALTIME, &timeout);
switch (opts->kernel) {
case 1:
timeout.tv_nsec += 990000;
/* fall through */
case 2:
timeout.tv_nsec += 10000;
if (opts->kernel) {
timeout.tv_nsec += 100000;

if (timeout.tv_nsec > NSEC_PER_SEC) {
timeout.tv_nsec -= NSEC_PER_SEC;
timeout.tv_sec++;
}
break;
default:
}
else {
timeout.tv_sec++;
break;
}

pthread_cond_timedwait(&write_cond, &write_list_lock,
Expand Down Expand Up @@ -1398,7 +1393,7 @@ int command_record(int argc, char *argv[], struct opts *opts)
kern.bufsize = opts->kernel_bufsize;

if (setup_kernel_tracing(&kern, opts->filter) < 0) {
opts->kernel = 0;
opts->kernel = false;
pr_log("kernel tracing disabled due to an error\n");
}
}
Expand Down Expand Up @@ -1445,7 +1440,7 @@ int command_record(int argc, char *argv[], struct opts *opts)
}

if (opts->kernel && start_kernel_tracing(&kern) < 0) {
opts->kernel = 0;
opts->kernel = false;
pr_log("kernel tracing disabled due to an error\n");
}

Expand Down
2 changes: 1 addition & 1 deletion cmd-replay.c
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ static bool skip_sys_exit(struct opts *opts, struct ftrace_task_handle *task)
unsigned long ip = task->func_stack[0].addr;

/* skip 'sys_exit[_group] at last for kernel tracing */
if (opts->kernel == 0 || task->user_stack_count != 0)
if (!opts->kernel || task->user_stack_count != 0)
return false;

if (is_kernel_address(ip)) {
Expand Down
2 changes: 1 addition & 1 deletion uftrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ struct opts {
int depth;
int kernel_depth;
int max_stack;
int kernel;
int port;
int color;
int column_offset;
Expand Down Expand Up @@ -173,6 +172,7 @@ struct opts {
bool chrome_trace;
bool comment;
bool libmcount_single;
bool kernel;
bool kernel_skip_out;
bool kernel_only;
};
Expand Down

0 comments on commit c45b247

Please sign in to comment.