libtracefs: Fixups to tracefs_cpu_stop()
cover libtracefs: Fixups to tracefs_cpu_stop()
From: "Steven Rostedt (Google)" <[email protected]>
Working on trace-cmd stream, there were some issues with stopping the recorders, as they were getting stuck in the read state. It appears that tracefs_cpu_stop() doesn't guarantee that the readers are awake. Until it can be straiten out, always tell the callers that there needs to be a nudge to the readers (ie. a signal).
Steven Rostedt (Google) (2):
libtracefs: Have tracefs_cpu_stop() do nothing only with PERM_NONBLOCK
libtracefs: Have tracefs_cpu_stop() always suggesting nudging
src/tracefs-record.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
Signature · 1 line
2.35.1
PATCH 1/2 libtracefs: Have tracefs_cpu_stop() do nothing only with PERM_NONBLOCK
From: "Steven Rostedt (Google)" <[email protected]>
As NONBLOCK can be set temporarily, if that's the state do not skip trying to wake up the reader if its set. It may still need a kick.
--- src/tracefs-record.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
src/tracefs-record.c +1 -1
@@ -421,7 +421,7 @@ int tracefs_cpu_stop(struct tracefs_cpu *tcpu) {int ret =1 ; -if (tcpu->flags &TC_NONBLOCK ) +if (tcpu->flags &TC_PERM_NONBLOCK )return 0 ; ret =write (tcpu->ctrl_pipe[1 ], &ret,1 );
Signature · 1 line
2.35.1
PATCH 2/2 libtracefs: Have tracefs_cpu_stop() always suggesting nudging
In reply to Steven RostedtFrom: "Steven Rostedt (Google)" <[email protected]>
The man page of tracefs_cpu_stop() states that if it returns 0 that it guaranteed to wake up a reader. Well, that doesn't appear to always be the case. Return 1 until we can figure it out.
--- src/tracefs-record.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
src/tracefs-record.c +2 -6
@@ -429,15 +429,11 @@ int tracefs_cpu_stop(struct tracefs_cpu *tcpu)return ret;/* Calling ioctl() on recent kernels will wake up the waiters */ - ret =ioctl (tcpu->fd,0 ); -if (ret <0 ) - ret =1 ; -else - ret =0 ; +ioctl (tcpu->fd,0 );set_nonblock (tcpu); -return ret; +return 1 ; }/**
Signature · 1 line
2.35.1
Re: [PATCH 2/2] libtracefs: Have tracefs_cpu_stop() always suggesting nudging
Quoted 6 lines · On Thu, 5 Jan 2023 16:52:52 -0500 Steven Rostedt <[email protected]> wrote:
From: "Steven Rostedt (Google)" <[email protected]>
The man page of
tracefs_cpu_stop()states that if it returns 0 that it guaranteed to wake up a reader. Well, that doesn't appear to always be the case. Return 1 until we can figure it out.
Hmm, I got my application working again without this change.
I'll hold off from applying it. Perhaps it was the application fault and not the library.
-- Steve
Quoted 27 lines
Signed-off-by Steven Rostedt (Google) <[email protected]>--- src/tracefs-record.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)src/tracefs-record.c +2
-6@@ -429,15 +429,11 @@ int tracefs_cpu_stop(struct tracefs_cpu *tcpu)return ret;/* Calling ioctl() on recent kernels will wake up the waiters */ - ret =ioctl (tcpu->fd,0 ); -if (ret <0 ) - ret =1 ; -else - ret =0 ; +ioctl (tcpu->fd,0 );set_nonblock (tcpu); -return ret; +return 1 ; }/**