From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754333AbcFTT2x (ORCPT ); Mon, 20 Jun 2016 15:28:53 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:53946 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753328AbcFTT2e (ORCPT ); Mon, 20 Jun 2016 15:28:34 -0400 From: Arnd Bergmann To: paulmck@linux.vnet.ibm.com Cc: Boqun Feng , Josh Triplett , linux-kernel@vger.kernel.org Subject: Re: [PATCH] torture: use ktime_t consistently Date: Mon, 20 Jun 2016 21:29:56 +0200 Message-ID: <17304047.6zmVOzdKjg@wuerfel> User-Agent: KMail/5.1.3 (Linux/4.4.0-22-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: <20160620183757.GX3923@linux.vnet.ibm.com> References: <20160620155651.2497676-1-arnd@arndb.de> <7277827.7A0WjZ9kZU@wuerfel> <20160620183757.GX3923@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:Qf1BqOqoXQqGA8wHaKOlHkIB3WTcT/GW1QHSKsS9X31stPKDjMe oyVVJMIHMWVlZCXe+sxymh5Ur1BIJdEiFulBtn940EeRWsR83BNuSRzHVAAuts44YQpuaC5 idLxs0mnKSfovcF0B2p+7Hl8pY+77EwownW3BOjkrPJL8gDB5PQykf35IeQWtr8HLyBswXO KSP8Bxz4tZyUiPqeMe0Dg== X-UI-Out-Filterresults: notjunk:1;V01:K0:ECw2LurBHpc=:bbBhoV0Wzw8pyAa0Dt1hsH /X21SMqGCdaP2DM+BZE0U2INWTqTU3mKHmjYoR4+G3nMXfXEgLx1E76rRL8fiztkZdXfjONDw RZmKz26wAHep9MV921ZcnQT05kCPTi+shJpTkIY57gIqOW/h/z6aNgeIotzt7RHNVaYnJborp /tZASN4HOjI0hsOe+ETMrjjerN+joMiF1GMldggWDPzk9TUquJBZs1LucjHbT/SCWfxLi41LX 0VLCMg7rzYKr0NdOzsdAYgf4aqBuchQv7F6XdndLCUdFoUn/V0hXAmzkzPFJFcgX4w30E75W8 abdTqCBtibgLlUbCGNDktIF2VqvHOHqzdU6LvCAU72jaoGv6gU0i1wZMT4iefxlct1gfUZBoV Jo7UWatQrNCuOJhHBE5VBayWvw2RY7R6F1lcmU1uV/WQK+VrPHt1Du30UqTIK4rZZawVnVMYk 7ZICwBOeZClgsxO4r8ZYmxzU9pygpzGA0J/GBywJJqvlusV5vcq567HDq3OxNO6EzhHLimQEW l7lQmPVkwl8ZnJntvur3YpO/T9h4u42EeWZ5Omz4zqz5pWodi/AbSpadV05AZl3IhSxgHY+y6 soeT4GUAMRH8DDWNg4igREoXJuYrSCaZwfoND/yy0hHdhqhNc7bq0UZX57bz5wAOB4JSbt6ye mk9MY7SIXiKg+y5/kYU5ohcYwfE37eLBv8pUD27YoSksUnSTy7FEcQm1y10YRgkx9owdmIirr z33PlIKJIlThfY1s Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Monday, June 20, 2016 11:37:57 AM CEST Paul E. McKenney wrote: > On Mon, Jun 20, 2016 at 08:29:48PM +0200, Arnd Bergmann wrote: > > 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. > > The comment is certainly now wrong, good catch! > > If there was an s_to_ktime(), I would have kept the old name, but I could > not find one. Possibly due to me being blind... I used "ktime_set(ssecs, 0)", which is almost what you want. Given that the majority of users of ktime_set() actually pass a zero nanoseconds portion, it would probably be nice to add secs_to_ktime() as well. > > > @@ -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. > > Thank you for looking it over! My I apply your Acked-by:, Reviewed-by:, > or some such? I had not looked over the original changes before, but have done that now, please add my Acked-by: Arnd Bergmann I found one small detail that you could change: instead of using HRTIMER_MODE_REL, you could actually use HRTIME_MODE_ABS and just pass the end time instead of computing the difference every time. You still need to take the difference for printing, but you could do that in place then: if (verbose) pr_alert("%s" TORTURE_FLAG "torture_shutdown task: %llu ms remaining\n", torture_type, ktime_ms_delta(shutdown_time, ktime_get())); Arnd