Linux btrace development
 help / color / mirror / Atom feed
* [PATCH] fix hang when BLKTRACESETUP fails and "-o -" is used
@ 2024-06-06  4:07 Eric Sandeen
  2024-06-06 11:32 ` Jeff Moyer
  2024-06-12 20:46 ` Jens Axboe
  0 siblings, 2 replies; 5+ messages in thread
From: Eric Sandeen @ 2024-06-06  4:07 UTC (permalink / raw)
  To: linux-btrace@vger.kernel.org; +Cc: axboe

# blktrace -o - /dev/sda /dev/sdb /dev/sdc

has to be SIGKILLed if BLKTRACESETUP fails for any or all of the devices
listed. (I simulated this by just catching one of the devices in
setup_buts(), skipping the ioctl, and doing ret++).

This seems to be because with "-o -" on the command line, use_tracer_devpaths()
sees piped_output set, so we call process_trace_bufs which ends up waiting on
(!done) and "done" is never set. i.e.

atexit(exit_tracing)
	wait_tracers
		if (use_tracer_devpaths()) // true because "-o -"
			process_trace_bufs
				while (wait_empty_entries())
					wait_empty_entries
						while (!done ... )
							<loop forever>

I think this can be avoided by just setting "done = 1" before returning
when setup_buts() fails in run_tracers().

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

diff --git a/blktrace.c b/blktrace.c
index 3444fbb..038b2cb 100644
--- a/blktrace.c
+++ b/blktrace.c
@@ -2684,8 +2684,10 @@ static int run_tracers(void)
 	if (net_mode == Net_client)
 		printf("blktrace: connecting to %s\n", hostname);
 
-	if (setup_buts())
+	if (setup_buts()) {
+		done = 1;
 		return 1;
+	}
 
 	if (use_tracer_devpaths()) {
 		if (setup_tracer_devpaths())


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] fix hang when BLKTRACESETUP fails and "-o -" is used
  2024-06-06  4:07 [PATCH] fix hang when BLKTRACESETUP fails and "-o -" is used Eric Sandeen
@ 2024-06-06 11:32 ` Jeff Moyer
  2024-06-06 13:05   ` Eric Sandeen
  2024-06-12 20:46 ` Jens Axboe
  1 sibling, 1 reply; 5+ messages in thread
From: Jeff Moyer @ 2024-06-06 11:32 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: linux-btrace@vger.kernel.org, axboe

Hi, Eric,

This looks like a repost?  I mentioned that we should also set done = 1
for a failed setup_tracer_devpaths() call, and I was hoping you'd
include that in a new version (or at least comment on whether you
thought it was a good idea).  Sorry if that wasn't clear!

The change here looks good to me.

-Jeff

Eric Sandeen <sandeen@redhat.com> writes:

> # blktrace -o - /dev/sda /dev/sdb /dev/sdc
>
> has to be SIGKILLed if BLKTRACESETUP fails for any or all of the devices
> listed. (I simulated this by just catching one of the devices in
> setup_buts(), skipping the ioctl, and doing ret++).
>
> This seems to be because with "-o -" on the command line, use_tracer_devpaths()
> sees piped_output set, so we call process_trace_bufs which ends up waiting on
> (!done) and "done" is never set. i.e.
>
> atexit(exit_tracing)
> 	wait_tracers
> 		if (use_tracer_devpaths()) // true because "-o -"
> 			process_trace_bufs
> 				while (wait_empty_entries())
> 					wait_empty_entries
> 						while (!done ... )
> 							<loop forever>
>
> I think this can be avoided by just setting "done = 1" before returning
> when setup_buts() fails in run_tracers().
>
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---
>
> diff --git a/blktrace.c b/blktrace.c
> index 3444fbb..038b2cb 100644
> --- a/blktrace.c
> +++ b/blktrace.c
> @@ -2684,8 +2684,10 @@ static int run_tracers(void)
>  	if (net_mode == Net_client)
>  		printf("blktrace: connecting to %s\n", hostname);
>  
> -	if (setup_buts())
> +	if (setup_buts()) {
> +		done = 1;
>  		return 1;
> +	}
>  
>  	if (use_tracer_devpaths()) {
>  		if (setup_tracer_devpaths())


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] fix hang when BLKTRACESETUP fails and "-o -" is used
  2024-06-06 11:32 ` Jeff Moyer
@ 2024-06-06 13:05   ` Eric Sandeen
  2024-06-06 13:11     ` Jeff Moyer
  0 siblings, 1 reply; 5+ messages in thread
From: Eric Sandeen @ 2024-06-06 13:05 UTC (permalink / raw)
  To: Jeff Moyer, Eric Sandeen; +Cc: linux-btrace@vger.kernel.org, axboe

On 6/6/24 6:32 AM, Jeff Moyer wrote:
> Hi, Eric,
> 
> This looks like a repost?  I mentioned that we should also set done = 1
> for a failed setup_tracer_devpaths() call, and I was hoping you'd
> include that in a new version (or at least comment on whether you
> thought it was a good idea).  Sorry if that wasn't clear!

The first one was a question, this one was a patch :)

I'm sorry, I have not had time to look into or test for failed
setup_tracer_devpaths() calls, and hoped to just fix the bug
I had encountered.
 
> The change here looks good to me.

Thanks,
-Eric

> -Jeff
> 
> Eric Sandeen <sandeen@redhat.com> writes:
> 
>> # blktrace -o - /dev/sda /dev/sdb /dev/sdc
>>
>> has to be SIGKILLed if BLKTRACESETUP fails for any or all of the devices
>> listed. (I simulated this by just catching one of the devices in
>> setup_buts(), skipping the ioctl, and doing ret++).
>>
>> This seems to be because with "-o -" on the command line, use_tracer_devpaths()
>> sees piped_output set, so we call process_trace_bufs which ends up waiting on
>> (!done) and "done" is never set. i.e.
>>
>> atexit(exit_tracing)
>> 	wait_tracers
>> 		if (use_tracer_devpaths()) // true because "-o -"
>> 			process_trace_bufs
>> 				while (wait_empty_entries())
>> 					wait_empty_entries
>> 						while (!done ... )
>> 							<loop forever>
>>
>> I think this can be avoided by just setting "done = 1" before returning
>> when setup_buts() fails in run_tracers().
>>
>> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
>> ---
>>
>> diff --git a/blktrace.c b/blktrace.c
>> index 3444fbb..038b2cb 100644
>> --- a/blktrace.c
>> +++ b/blktrace.c
>> @@ -2684,8 +2684,10 @@ static int run_tracers(void)
>>  	if (net_mode == Net_client)
>>  		printf("blktrace: connecting to %s\n", hostname);
>>  
>> -	if (setup_buts())
>> +	if (setup_buts()) {
>> +		done = 1;
>>  		return 1;
>> +	}
>>  
>>  	if (use_tracer_devpaths()) {
>>  		if (setup_tracer_devpaths())
> 
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] fix hang when BLKTRACESETUP fails and "-o -" is used
  2024-06-06 13:05   ` Eric Sandeen
@ 2024-06-06 13:11     ` Jeff Moyer
  0 siblings, 0 replies; 5+ messages in thread
From: Jeff Moyer @ 2024-06-06 13:11 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: Eric Sandeen, linux-btrace@vger.kernel.org, axboe

Eric Sandeen <sandeen@sandeen.net> writes:

> On 6/6/24 6:32 AM, Jeff Moyer wrote:
>> Hi, Eric,
>> 
>> This looks like a repost?  I mentioned that we should also set done = 1
>> for a failed setup_tracer_devpaths() call, and I was hoping you'd
>> include that in a new version (or at least comment on whether you
>> thought it was a good idea).  Sorry if that wasn't clear!
>
> The first one was a question, this one was a patch :)

Ah, ok.  :)

> I'm sorry, I have not had time to look into or test for failed
> setup_tracer_devpaths() calls, and hoped to just fix the bug
> I had encountered.

That's fair.

Reviewed-by: Jeff Moyer <jmoyer@redhat.com>

Thanks!

>  
>> The change here looks good to me.
>
> Thanks,
> -Eric
>
>> -Jeff
>> 
>> Eric Sandeen <sandeen@redhat.com> writes:
>> 
>>> # blktrace -o - /dev/sda /dev/sdb /dev/sdc
>>>
>>> has to be SIGKILLed if BLKTRACESETUP fails for any or all of the devices
>>> listed. (I simulated this by just catching one of the devices in
>>> setup_buts(), skipping the ioctl, and doing ret++).
>>>
>>> This seems to be because with "-o -" on the command line, use_tracer_devpaths()
>>> sees piped_output set, so we call process_trace_bufs which ends up waiting on
>>> (!done) and "done" is never set. i.e.
>>>
>>> atexit(exit_tracing)
>>> 	wait_tracers
>>> 		if (use_tracer_devpaths()) // true because "-o -"
>>> 			process_trace_bufs
>>> 				while (wait_empty_entries())
>>> 					wait_empty_entries
>>> 						while (!done ... )
>>> 							<loop forever>
>>>
>>> I think this can be avoided by just setting "done = 1" before returning
>>> when setup_buts() fails in run_tracers().
>>>
>>> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
>>> ---
>>>
>>> diff --git a/blktrace.c b/blktrace.c
>>> index 3444fbb..038b2cb 100644
>>> --- a/blktrace.c
>>> +++ b/blktrace.c
>>> @@ -2684,8 +2684,10 @@ static int run_tracers(void)
>>>  	if (net_mode == Net_client)
>>>  		printf("blktrace: connecting to %s\n", hostname);
>>>  
>>> -	if (setup_buts())
>>> +	if (setup_buts()) {
>>> +		done = 1;
>>>  		return 1;
>>> +	}
>>>  
>>>  	if (use_tracer_devpaths()) {
>>>  		if (setup_tracer_devpaths())
>> 
>> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] fix hang when BLKTRACESETUP fails and "-o -" is used
  2024-06-06  4:07 [PATCH] fix hang when BLKTRACESETUP fails and "-o -" is used Eric Sandeen
  2024-06-06 11:32 ` Jeff Moyer
@ 2024-06-12 20:46 ` Jens Axboe
  1 sibling, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2024-06-12 20:46 UTC (permalink / raw)
  To: linux-btrace, Eric Sandeen


On Wed, 05 Jun 2024 23:07:27 -0500, Eric Sandeen wrote:
> # blktrace -o - /dev/sda /dev/sdb /dev/sdc
> 
> has to be SIGKILLed if BLKTRACESETUP fails for any or all of the devices
> listed. (I simulated this by just catching one of the devices in
> setup_buts(), skipping the ioctl, and doing ret++).
> 
> This seems to be because with "-o -" on the command line, use_tracer_devpaths()
> sees piped_output set, so we call process_trace_bufs which ends up waiting on
> (!done) and "done" is never set. i.e.
> 
> [...]

Applied, thanks!

[1/1] fix hang when BLKTRACESETUP fails and "-o -" is used
      commit: 1836be5d99c9362f1e2b39206c95270f19cb7faa

Best regards,
-- 
Jens Axboe




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-06-12 20:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-06  4:07 [PATCH] fix hang when BLKTRACESETUP fails and "-o -" is used Eric Sandeen
2024-06-06 11:32 ` Jeff Moyer
2024-06-06 13:05   ` Eric Sandeen
2024-06-06 13:11     ` Jeff Moyer
2024-06-12 20:46 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox