mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg Hackmann <ghackmann@google.com>
To: Shuah Khan <shuahkh@osg.samsung.com>,
	john.stultz@linaro.org, tglx@linutronix.de, sboyd@codeaurora.org,
	shuah@kernel.org
Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH] selftests: timers: set-timer-lat: fix hang when std out/err are redirected
Date: Fri, 22 Sep 2017 08:41:52 -0700	[thread overview]
Message-ID: <533bb979-4d64-96b2-e8ca-78f1c649d16e@google.com> (raw)
In-Reply-To: <2717b5ae-fe0e-8b52-f297-90f3b4fb9b56@osg.samsung.com>

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>

  reply	other threads:[~2017-09-22 15:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-21 20:10 Shuah Khan
2017-09-22 14:42 ` Shuah Khan
2017-09-22 15:41   ` Greg Hackmann [this message]
2017-09-22 17:31   ` John Stultz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=533bb979-4d64-96b2-e8ca-78f1c649d16e@google.com \
    --to=ghackmann@google.com \
    --cc=john.stultz@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=sboyd@codeaurora.org \
    --cc=shuah@kernel.org \
    --cc=shuahkh@osg.samsung.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome