diff mbox series

[v4,linux-kselftest-test,4/6] kunit: remove timeout dependence on sysctl_hung_task_timeout_seconds

Message ID 1573812972-10529-5-git-send-email-alan.maguire@oracle.com (mailing list archive)
State New
Headers show
Series kunit: support building core/tests as modules | expand

Commit Message

Alan Maguire Nov. 15, 2019, 10:16 a.m. UTC
In discussion of how to handle timeouts, it was noted that if
sysctl_hung_task_timeout_seconds is exceeded for a kunit test,
the test task will be killed and an oops generated.  This should
suffice as a means of debugging such timeout issues for now.

Hence remove use of sysctl_hung_task_timeout_secs, which has the
added benefit of avoiding the need to export that symbol from
the core kernel.

Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
Signed-off-by: Knut Omang <knut.omang@oracle.com>
---
 lib/kunit/try-catch.c | 22 ++++------------------
 1 file changed, 4 insertions(+), 18 deletions(-)

Comments

Luis Chamberlain Nov. 18, 2019, 10:09 p.m. UTC | #1
On Fri, Nov 15, 2019 at 10:16:10AM +0000, Alan Maguire wrote:
> In discussion of how to handle timeouts, it was noted that if
> sysctl_hung_task_timeout_seconds is exceeded for a kunit test,
> the test task will be killed and an oops generated.  This should
> suffice as a means of debugging such timeout issues for now.
> 
> Hence remove use of sysctl_hung_task_timeout_secs, which has the
> added benefit of avoiding the need to export that symbol from
> the core kernel.
> 
> Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
> Signed-off-by: Knut Omang <knut.omang@oracle.com>

This seems like a workaround for sysctl_hung_task_timeout_secs not being
exported. If true, this can be addressed by creating a symbol namespace
(new) and using that namespace on this path.

  Luis
Brendan Higgins Nov. 19, 2019, 1:24 a.m. UTC | #2
On Mon, Nov 18, 2019 at 2:10 PM Luis Chamberlain <mcgrof@kernel.org> wrote:
>
> On Fri, Nov 15, 2019 at 10:16:10AM +0000, Alan Maguire wrote:
> > In discussion of how to handle timeouts, it was noted that if
> > sysctl_hung_task_timeout_seconds is exceeded for a kunit test,
> > the test task will be killed and an oops generated.  This should
> > suffice as a means of debugging such timeout issues for now.
> >
> > Hence remove use of sysctl_hung_task_timeout_secs, which has the
> > added benefit of avoiding the need to export that symbol from
> > the core kernel.
> >
> > Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
> > Signed-off-by: Knut Omang <knut.omang@oracle.com>
>
> This seems like a workaround for sysctl_hung_task_timeout_secs not being
> exported. If true, this can be addressed by creating a symbol namespace
> (new) and using that namespace on this path.

It is; as discussed on in v3[1]. I don't really feel strongly one way
or the other, I can see arguments for either side. Still, I don't want
to give Alan the run-around. I think this is the 3rd or 4th time he
has tried to address this issue.

[1] https://lore.kernel.org/linux-kselftest/CAFd5g44esDP6WFmkjOiH+my_4iBeqMpFoScMCm_hQ0aFwNS9qw@mail.gmail.com/
Stephen Boyd Nov. 19, 2019, 9:06 p.m. UTC | #3
Quoting Alan Maguire (2019-11-15 02:16:10)
> In discussion of how to handle timeouts, it was noted that if
> sysctl_hung_task_timeout_seconds is exceeded for a kunit test,
> the test task will be killed and an oops generated.  This should
> suffice as a means of debugging such timeout issues for now.
> 
> Hence remove use of sysctl_hung_task_timeout_secs, which has the
> added benefit of avoiding the need to export that symbol from
> the core kernel.
> 
> Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
> Signed-off-by: Knut Omang <knut.omang@oracle.com>
> ---

Reviewed-by: Stephen Boyd <sboyd@kernel.org>
diff mbox series

Patch

diff --git a/lib/kunit/try-catch.c b/lib/kunit/try-catch.c
index 0247a28..0dd434e 100644
--- a/lib/kunit/try-catch.c
+++ b/lib/kunit/try-catch.c
@@ -11,7 +11,6 @@ 
 #include <linux/completion.h>
 #include <linux/kernel.h>
 #include <linux/kthread.h>
-#include <linux/sched/sysctl.h>
 
 #include "try-catch-impl.h"
 
@@ -33,8 +32,6 @@  static int kunit_generic_run_threadfn_adapter(void *data)
 
 static unsigned long kunit_test_timeout(void)
 {
-	unsigned long timeout_msecs;
-
 	/*
 	 * TODO(brendanhiggins@google.com): We should probably have some type of
 	 * variable timeout here. The only question is what that timeout value
@@ -51,22 +48,11 @@  static unsigned long kunit_test_timeout(void)
 	 *
 	 * For more background on this topic, see:
 	 * https://mike-bland.com/2011/11/01/small-medium-large.html
+	 *
+	 * If tests timeout due to exceeding sysctl_hung_task_timeout_secs,
+	 * the task will be killed and an oops generated.
 	 */
-	if (sysctl_hung_task_timeout_secs) {
-		/*
-		 * If sysctl_hung_task is active, just set the timeout to some
-		 * value less than that.
-		 *
-		 * In regards to the above TODO, if we decide on variable
-		 * timeouts, this logic will likely need to change.
-		 */
-		timeout_msecs = (sysctl_hung_task_timeout_secs - 1) *
-				MSEC_PER_SEC;
-	} else {
-		timeout_msecs = 300 * MSEC_PER_SEC; /* 5 min */
-	}
-
-	return timeout_msecs;
+	return 300 * MSEC_PER_SEC; /* 5 min */
 }
 
 void kunit_try_catch_run(struct kunit_try_catch *try_catch, void *context)