Re: [PATCH] torture: use ktime_t consistently

From: Arnd Bergmann
Date: Mon Jun 20 2016 - 14:35:43 EST


On Monday, June 20, 2016 11:21:05 AM CEST Paul E. McKenney wrote:
> On Mon, Jun 20, 2016 at 05:56:40PM +0200, Arnd Bergmann wrote:
>
> @@ -446,9 +447,9 @@ EXPORT_SYMBOL_GPL(torture_shuffle_cleanup);
> * Variables for auto-shutdown. This allows "lights out" torture runs
> * to be fully scripted.
> */
> -static int shutdown_secs; /* desired test duration in seconds. */
> +static ktime_t shutdown_ms; /* desired test duration in seconds. */

the variable name is a bit odd.

> @@ -511,10 +513,10 @@ int torture_shutdown_init(int ssecs, void (*cleanup)(void))
> {
> int ret = 0;
>
> - shutdown_secs = ssecs;
> torture_shutdown_hook = cleanup;
> - if (shutdown_secs > 0) {
> - shutdown_time = jiffies + shutdown_secs * HZ;
> + if (ssecs > 0) {
> + shutdown_ms = ms_to_ktime(ssecs * 1000ULL);
> + shutdown_time = ktime_add(ktime_get(), shutdown_ms);
> ret = torture_create_kthread(torture_shutdown, NULL,
> shutdown_task);

and I picked ktime_set(ssecs, 0) instead of ms_to_ktime(ssecs * 1000ULL), but
both differences are just cosmetic and should end up in exactly the
same object code that I suggested. Unless we both made the same mistake,
your version should be good too.

Thanks,

Arnd