Skip to content

Commit

Permalink
trace-cmd library: Set recorder to nonblock when finished
Browse files Browse the repository at this point in the history
When the recorder is signaled to stop, make sure it only reads in
non-blocking mode.

Link: https://lore.kernel.org/linux-trace-devel/[email protected]

Signed-off-by: Steven Rostedt (Google) <[email protected]>
  • Loading branch information
rostedt committed Jan 9, 2023
1 parent 422d374 commit 85f7590
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/trace-cmd/trace-recorder.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,11 +317,12 @@ static inline void update_fd(struct tracecmd_recorder *recorder, int size)
*/
static long read_data(struct tracecmd_recorder *recorder)
{
bool nonblock = recorder->stop;
char buf[recorder->subbuf_size];
long left;
long r, w;

r = tracefs_cpu_read(recorder->tcpu, buf, false);
r = tracefs_cpu_read(recorder->tcpu, buf, nonblock);

left = r;
do {
Expand All @@ -344,11 +345,13 @@ static long read_data(struct tracecmd_recorder *recorder)
*/
static long direct_splice_data(struct tracecmd_recorder *recorder)
{
return tracefs_cpu_pipe(recorder->tcpu, recorder->fd, false);
bool nonblock = recorder->stop;
return tracefs_cpu_pipe(recorder->tcpu, recorder->fd, nonblock);
}

static long move_data(struct tracecmd_recorder *recorder)
{
bool nonblock = recorder->stop;
long ret;

if (recorder->flags & TRACECMD_RECORD_NOSPLICE)
Expand All @@ -357,7 +360,7 @@ static long move_data(struct tracecmd_recorder *recorder)
if (recorder->flags & TRACECMD_RECORD_NOBRASS)
return direct_splice_data(recorder);

ret = tracefs_cpu_write(recorder->tcpu, recorder->fd, false);
ret = tracefs_cpu_write(recorder->tcpu, recorder->fd, nonblock);
if (ret > 0)
update_fd(recorder, ret);
return ret;
Expand Down

0 comments on commit 85f7590

Please sign in to comment.