From: Arnd Bergmann <arnd@arndb.de>
To: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: Arnd Bergmann <arnd@arndb.de>, Boqun Feng <boqun.feng@gmail.com>,
Josh Triplett <josh@joshtriplett.org>,
linux-kernel@vger.kernel.org
Subject: [PATCH] torture: use ktime_t consistently
Date: Mon, 20 Jun 2016 17:56:40 +0200 [thread overview]
Message-ID: <20160620155651.2497676-1-arnd@arndb.de> (raw)
A recent change accidentally introduced a 64-bit division in torture_shutdown,
which fails to build on 32-bit architectures:
kernel/built-in.o: In function `torture_shutdown':
:(.text+0x4b29a): undefined reference to `__aeabi_uldivmod'
This converts the function to use ktime_t instead, which also simplifies
it a little.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: b4aa201e0c7c ("torture: Convert torture_shutdown() to hrtimer")
---
kernel/torture.c | 25 ++++++++++---------------
1 file changed, 10 insertions(+), 15 deletions(-)
diff --git a/kernel/torture.c b/kernel/torture.c
index 55f0a317fbb5..bbcc92088bf9 100644
--- a/kernel/torture.c
+++ b/kernel/torture.c
@@ -448,7 +448,7 @@ EXPORT_SYMBOL_GPL(torture_shuffle_cleanup);
*/
static int shutdown_secs; /* desired test duration in seconds. */
static struct task_struct *shutdown_task;
-static unsigned long shutdown_time; /* jiffies to system shutdown. */
+static ktime_t shutdown_time; /* time of system shutdown. */
static void (*torture_shutdown_hook)(void);
/*
@@ -471,24 +471,19 @@ EXPORT_SYMBOL_GPL(torture_shutdown_absorb);
*/
static int torture_shutdown(void *arg)
{
- unsigned long long delta;
- unsigned long jiffies_snap;
- ktime_t wait_duration;
+ ktime_t now, delta;
VERBOSE_TOROUT_STRING("torture_shutdown task started");
- jiffies_snap = jiffies;
- while (ULONG_CMP_LT(jiffies_snap, shutdown_time) &&
- !torture_must_stop()) {
- delta = shutdown_time - jiffies_snap;
+ now = ktime_get();
+ while (ktime_before(now, shutdown_time) && !torture_must_stop()) {
+ delta = ktime_sub(shutdown_time, now);
if (verbose)
pr_alert("%s" TORTURE_FLAG
- "torture_shutdown task: %llu jiffies remaining\n",
- torture_type, delta);
- delta = delta * 1000ULL * 1000ULL * 1000ULL / HZ;
- wait_duration = ns_to_ktime(delta);
+ "torture_shutdown task: %llu ms remaining\n",
+ torture_type, ktime_to_ms(delta));
set_current_state(TASK_INTERRUPTIBLE);
- schedule_hrtimeout(&wait_duration, HRTIMER_MODE_REL);
- jiffies_snap = jiffies;
+ schedule_hrtimeout(&delta, HRTIMER_MODE_REL);
+ now = ktime_get();
}
if (torture_must_stop()) {
torture_kthread_stopping("torture_shutdown");
@@ -518,7 +513,7 @@ int torture_shutdown_init(int ssecs, void (*cleanup)(void))
shutdown_secs = ssecs;
torture_shutdown_hook = cleanup;
if (shutdown_secs > 0) {
- shutdown_time = jiffies + shutdown_secs * HZ;
+ shutdown_time = ktime_add(ktime_get(), ktime_set(ssecs, 0));
ret = torture_create_kthread(torture_shutdown, NULL,
shutdown_task);
}
--
2.9.0
next reply other threads:[~2016-06-20 15:56 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-20 15:56 Arnd Bergmann [this message]
2016-06-20 18:21 ` [PATCH] torture: use ktime_t consistently Paul E. McKenney
2016-06-20 18:29 ` Arnd Bergmann
2016-06-20 18:37 ` Paul E. McKenney
2016-06-20 19:29 ` Arnd Bergmann
2016-06-21 18:39 ` Paul E. McKenney
2016-06-22 2:00 ` Boqun Feng
2016-06-22 3:27 ` Paul E. McKenney
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=20160620155651.2497676-1-arnd@arndb.de \
--to=arnd@arndb.de \
--cc=boqun.feng@gmail.com \
--cc=josh@joshtriplett.org \
--cc=linux-kernel@vger.kernel.org \
--cc=paulmck@linux.vnet.ibm.com \
/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;
as well as URLs for NNTP newsgroup(s).