All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] selftests: timers: set-timer-lat: fix hang when std out/err are redirected
@ 2017-09-21 20:10 Shuah Khan
  2017-09-22 14:42 ` Shuah Khan
  0 siblings, 1 reply; 4+ messages in thread
From: Shuah Khan @ 2017-09-21 20:10 UTC (permalink / raw)
  To: john.stultz, tglx, sboyd, ghackmann, shuah
  Cc: Shuah Khan, linux-kernel, linux-kselftest

do_timer_oneshot() uses select() as a timer with FD_SETSIZE and readfs
is cleared with FD_ZERO without FD_SET.

When stdout and stderr are redirected, the test hangs in select forever.
Fix the problem calling select() with readfds empty and nfds zero. This
is sufficient for using select() for timer.

With this fix "./set-timer-lat > /dev/null 2>&1" no longer hangs.

Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
---
 tools/testing/selftests/timers/set-timer-lat.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/tools/testing/selftests/timers/set-timer-lat.c b/tools/testing/selftests/timers/set-timer-lat.c
index ab2fe225e051..3c248f0dc0d5 100644
--- a/tools/testing/selftests/timers/set-timer-lat.c
+++ b/tools/testing/selftests/timers/set-timer-lat.c
@@ -229,7 +229,6 @@ int do_timer_oneshot(int clock_id, int flags)
 	timer_t tm1;
 	const int interval = 0;
 	struct timeval timeout;
-	fd_set fds;
 	int err;
 
 	err = setup_timer(clock_id, flags, interval, &tm1);
@@ -238,9 +237,8 @@ int do_timer_oneshot(int clock_id, int flags)
 
 	memset(&timeout, 0, sizeof(timeout));
 	timeout.tv_sec = 5;
-	FD_ZERO(&fds);
 	do {
-		err = select(FD_SETSIZE, &fds, NULL, NULL, &timeout);
+		err = select(0, NULL, NULL, NULL, &timeout);
 	} while (err == -1 && errno == EINTR);
 
 	timer_delete(tm1);
-- 
2.11.0

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

* Re: [PATCH] selftests: timers: set-timer-lat: fix hang when std out/err are redirected
  2017-09-21 20:10 [PATCH] selftests: timers: set-timer-lat: fix hang when std out/err are redirected Shuah Khan
@ 2017-09-22 14:42 ` Shuah Khan
  2017-09-22 15:41   ` Greg Hackmann
  2017-09-22 17:31   ` John Stultz
  0 siblings, 2 replies; 4+ messages in thread
From: Shuah Khan @ 2017-09-22 14:42 UTC (permalink / raw)
  To: john.stultz, tglx, sboyd, ghackmann, shuah
  Cc: linux-kernel, linux-kselftest, Shuah Khan, Shuah Khan

Hi John/Greg,

On 09/21/2017 02:10 PM, Shuah Khan wrote:
> do_timer_oneshot() uses select() as a timer with FD_SETSIZE and readfs
> is cleared with FD_ZERO without FD_SET.
> 
> When stdout and stderr are redirected, the test hangs in select forever.
> Fix the problem calling select() with readfds empty and nfds zero. This
> is sufficient for using select() for timer.
> 
> With this fix "./set-timer-lat > /dev/null 2>&1" no longer hangs.
> 
> Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
> ---
>  tools/testing/selftests/timers/set-timer-lat.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/tools/testing/selftests/timers/set-timer-lat.c b/tools/testing/selftests/timers/set-timer-lat.c
> index ab2fe225e051..3c248f0dc0d5 100644
> --- a/tools/testing/selftests/timers/set-timer-lat.c
> +++ b/tools/testing/selftests/timers/set-timer-lat.c
> @@ -229,7 +229,6 @@ int do_timer_oneshot(int clock_id, int flags)
>  	timer_t tm1;
>  	const int interval = 0;
>  	struct timeval timeout;
> -	fd_set fds;
>  	int err;
>  
>  	err = setup_timer(clock_id, flags, interval, &tm1);
> @@ -238,9 +237,8 @@ int do_timer_oneshot(int clock_id, int flags)
>  
>  	memset(&timeout, 0, sizeof(timeout));
>  	timeout.tv_sec = 5;
> -	FD_ZERO(&fds);
>  	do {
> -		err = select(FD_SETSIZE, &fds, NULL, NULL, &timeout);
> +		err = select(0, NULL, NULL, NULL, &timeout);
>  	} while (err == -1 && errno == EINTR);
>  
>  	timer_delete(tm1);
> 

I assume you are good with this fix. I plan to apply it to linux-kselftest fixes
today. Please let me know if you have any objections.

thanks,
-- Shuah

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

* Re: [PATCH] selftests: timers: set-timer-lat: fix hang when std out/err are redirected
  2017-09-22 14:42 ` Shuah Khan
@ 2017-09-22 15:41   ` Greg Hackmann
  2017-09-22 17:31   ` John Stultz
  1 sibling, 0 replies; 4+ messages in thread
From: Greg Hackmann @ 2017-09-22 15:41 UTC (permalink / raw)
  To: Shuah Khan, john.stultz, tglx, sboyd, shuah; +Cc: linux-kernel, linux-kselftest

On 09/22/2017 07:42 AM, Shuah Khan wrote:
> Hi John/Greg,
> 
> On 09/21/2017 02:10 PM, Shuah Khan wrote:
>> do_timer_oneshot() uses select() as a timer with FD_SETSIZE and readfs
>> is cleared with FD_ZERO without FD_SET.
>>
>> When stdout and stderr are redirected, the test hangs in select forever.
>> Fix the problem calling select() with readfds empty and nfds zero. This
>> is sufficient for using select() for timer.
>>
>> With this fix "./set-timer-lat > /dev/null 2>&1" no longer hangs.
>>
>> Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
>> ---
>>   tools/testing/selftests/timers/set-timer-lat.c | 4 +---
>>   1 file changed, 1 insertion(+), 3 deletions(-)
>>
>> diff --git a/tools/testing/selftests/timers/set-timer-lat.c b/tools/testing/selftests/timers/set-timer-lat.c
>> index ab2fe225e051..3c248f0dc0d5 100644
>> --- a/tools/testing/selftests/timers/set-timer-lat.c
>> +++ b/tools/testing/selftests/timers/set-timer-lat.c
>> @@ -229,7 +229,6 @@ int do_timer_oneshot(int clock_id, int flags)
>>   	timer_t tm1;
>>   	const int interval = 0;
>>   	struct timeval timeout;
>> -	fd_set fds;
>>   	int err;
>>   
>>   	err = setup_timer(clock_id, flags, interval, &tm1);
>> @@ -238,9 +237,8 @@ int do_timer_oneshot(int clock_id, int flags)
>>   
>>   	memset(&timeout, 0, sizeof(timeout));
>>   	timeout.tv_sec = 5;
>> -	FD_ZERO(&fds);
>>   	do {
>> -		err = select(FD_SETSIZE, &fds, NULL, NULL, &timeout);
>> +		err = select(0, NULL, NULL, NULL, &timeout);
>>   	} while (err == -1 && errno == EINTR);
>>   
>>   	timer_delete(tm1);
>>
> 
> I assume you are good with this fix. I plan to apply it to linux-kselftest fixes
> today. Please let me know if you have any objections.
> 
> thanks,
> -- Shuah
> 

Thanks for looking into this.

Acked-by: Greg Hackmann <ghackmann@google.com>

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

* Re: [PATCH] selftests: timers: set-timer-lat: fix hang when std out/err are redirected
  2017-09-22 14:42 ` Shuah Khan
  2017-09-22 15:41   ` Greg Hackmann
@ 2017-09-22 17:31   ` John Stultz
  1 sibling, 0 replies; 4+ messages in thread
From: John Stultz @ 2017-09-22 17:31 UTC (permalink / raw)
  To: Shuah Khan
  Cc: Thomas Gleixner, Stephen Boyd, Greg Hackmann, Shuah Khan, lkml,
	linux-kselftest

On Fri, Sep 22, 2017 at 7:42 AM, Shuah Khan <shuahkh@osg.samsung.com> wrote:
> Hi John/Greg,
>
> On 09/21/2017 02:10 PM, Shuah Khan wrote:
>> do_timer_oneshot() uses select() as a timer with FD_SETSIZE and readfs
>> is cleared with FD_ZERO without FD_SET.
>>
>> When stdout and stderr are redirected, the test hangs in select forever.
>> Fix the problem calling select() with readfds empty and nfds zero. This
>> is sufficient for using select() for timer.
>>
>> With this fix "./set-timer-lat > /dev/null 2>&1" no longer hangs.
>>
>> Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
>> ---
>>  tools/testing/selftests/timers/set-timer-lat.c | 4 +---
>>  1 file changed, 1 insertion(+), 3 deletions(-)
>>
>> diff --git a/tools/testing/selftests/timers/set-timer-lat.c b/tools/testing/selftests/timers/set-timer-lat.c
>> index ab2fe225e051..3c248f0dc0d5 100644
>> --- a/tools/testing/selftests/timers/set-timer-lat.c
>> +++ b/tools/testing/selftests/timers/set-timer-lat.c
>> @@ -229,7 +229,6 @@ int do_timer_oneshot(int clock_id, int flags)
>>       timer_t tm1;
>>       const int interval = 0;
>>       struct timeval timeout;
>> -     fd_set fds;
>>       int err;
>>
>>       err = setup_timer(clock_id, flags, interval, &tm1);
>> @@ -238,9 +237,8 @@ int do_timer_oneshot(int clock_id, int flags)
>>
>>       memset(&timeout, 0, sizeof(timeout));
>>       timeout.tv_sec = 5;
>> -     FD_ZERO(&fds);
>>       do {
>> -             err = select(FD_SETSIZE, &fds, NULL, NULL, &timeout);
>> +             err = select(0, NULL, NULL, NULL, &timeout);
>>       } while (err == -1 && errno == EINTR);
>>
>>       timer_delete(tm1);
>>
>
> I assume you are good with this fix. I plan to apply it to linux-kselftest fixes
> today. Please let me know if you have any objections.

No objections from me, just has been a busy few days and haven't had a
chance to test.

thanks
-john

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

end of thread, other threads:[~2017-09-22 17:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-21 20:10 [PATCH] selftests: timers: set-timer-lat: fix hang when std out/err are redirected Shuah Khan
2017-09-22 14:42 ` Shuah Khan
2017-09-22 15:41   ` Greg Hackmann
2017-09-22 17:31   ` John Stultz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.