Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752294AbdIVPl4 (ORCPT ); Fri, 22 Sep 2017 11:41:56 -0400 Received: from mail-pf0-f178.google.com ([209.85.192.178]:47301 "EHLO mail-pf0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751876AbdIVPlz (ORCPT ); Fri, 22 Sep 2017 11:41:55 -0400 X-Google-Smtp-Source: AOwi7QCbkbRI37ZZ/mCDP/nozMISu9F/4PZQuZ0XY+LdZ9DNc2HZQZ3FVPAzGXUj5zhTd8z2PReqaA== Subject: Re: [PATCH] selftests: timers: set-timer-lat: fix hang when std out/err are redirected To: Shuah Khan , john.stultz@linaro.org, tglx@linutronix.de, sboyd@codeaurora.org, shuah@kernel.org Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org References: <20170921201046.16953-1-shuahkh@osg.samsung.com> <2717b5ae-fe0e-8b52-f297-90f3b4fb9b56@osg.samsung.com> From: Greg Hackmann Message-ID: <533bb979-4d64-96b2-e8ca-78f1c649d16e@google.com> Date: Fri, 22 Sep 2017 08:41:52 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <2717b5ae-fe0e-8b52-f297-90f3b4fb9b56@osg.samsung.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1801 Lines: 53 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 >> --- >> 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