From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: linux-kernel@vger.kernel.org
Cc: mingo@kernel.org, jiangshanlai@gmail.com, dipankar@in.ibm.com,
akpm@linux-foundation.org, mathieu.desnoyers@efficios.com,
josh@joshtriplett.org, tglx@linutronix.de, peterz@infradead.org,
rostedt@goodmis.org, dhowells@redhat.com, edumazet@google.com,
dvhart@linux.intel.com, fweisbec@gmail.com, oleg@redhat.com,
bobby.prani@gmail.com,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Subject: [PATCH tip/core/rcu 4/8] waketorture: Add utilization measurement
Date: Wed, 15 Jun 2016 15:28:24 -0700 [thread overview]
Message-ID: <1466029708-11359-4-git-send-email-paulmck@linux.vnet.ibm.com> (raw)
In-Reply-To: <20160615222756.GA10695@linux.vnet.ibm.com>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
---
kernel/rcu/waketorture.c | 29 ++++++++++++++++++++++++++++-
lib/Kconfig.debug | 1 +
2 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/kernel/rcu/waketorture.c b/kernel/rcu/waketorture.c
index 75bc547206cc..3068a5c858c8 100644
--- a/kernel/rcu/waketorture.c
+++ b/kernel/rcu/waketorture.c
@@ -81,7 +81,9 @@ static unsigned long *waiter_iter; /* Number of wait iterations. */
static bool *waiter_cts; /* Waiter already checked. */
static unsigned long *waiter_kicks; /* Number of waiter starvations. */
static unsigned long *waiter_ts; /* Jiffies last run. */
-DEFINE_MUTEX(waiter_mutex);
+static DEFINE_MUTEX(waiter_mutex);
+static DEFINE_PER_CPU(u64, waiter_cputime); /* Nanoseconds. */
+static u64 starttime;
static int torture_runnable = IS_ENABLED(MODULE);
module_param(torture_runnable, int, 0444);
@@ -133,16 +135,23 @@ static int wake_torture_waiter(void *arg)
{
int i;
long me = (long)arg;
+ u64 ts;
VERBOSE_TOROUT_STRING("wake_torture_waiter task started");
set_user_nice(current, MAX_NICE);
+ preempt_disable();
+ ts = trace_clock_local();
do {
waiter_ts[me] = jiffies;
smp_mb(); /* Ensure waiter_ts[] written before waiter_cts[]. */
/* Pairs with [A]. */
waiter_cts[me] = false;
+ __this_cpu_add(waiter_cputime, trace_clock_local() - ts);
+ preempt_enable();
cur_ops->wait(wait_duration);
+ preempt_disable();
+ ts = trace_clock_local();
waiter_iter[me]++;
for (i = 0; i < nrealwaiters; i++) {
if (waiter_done[i] ||
@@ -164,8 +173,14 @@ static int wake_torture_waiter(void *arg)
mutex_unlock(&waiter_mutex);
}
}
+ __this_cpu_add(waiter_cputime, trace_clock_local() - ts);
+ preempt_enable();
torture_shutdown_absorb("wake_torture_waiter");
+ preempt_disable();
+ ts = trace_clock_local();
} while (!torture_must_stop());
+ __this_cpu_add(waiter_cputime, trace_clock_local() - ts);
+ preempt_enable();
mutex_lock(&waiter_mutex);
waiter_done[me] = true;
mutex_unlock(&waiter_mutex);
@@ -189,6 +204,8 @@ wake_torture_stats_print(void)
{
int i;
bool tardy = false;
+ u64 timediff;
+ u64 timetot;
if (!waiter_done || !waiter_iter || !waiter_cts ||
!waiter_kicks || !waiter_ts) {
@@ -212,6 +229,15 @@ wake_torture_stats_print(void)
pr_cont("\n");
else
TOROUT_STRING(" No tardy kthreads");
+ timediff = (trace_clock_global() - starttime) / 1000;
+ timetot = 0;
+ for_each_possible_cpu(i)
+ timetot += READ_ONCE(per_cpu(waiter_cputime, i));
+ timetot /= nr_cpu_ids;
+ timetot /= timediff;
+ pr_alert("%s" TORTURE_FLAG " timediff: %llu utilization: %llu.%llu nr_cpu_ids: %d\n",
+ torture_type, timediff,
+ timetot / 1000ULL, timetot % 1000ULL, nr_cpu_ids);
}
/*
@@ -290,6 +316,7 @@ wake_torture_init(void)
if (!torture_init_begin(torture_type, verbose, &torture_runnable))
return -EBUSY;
+ starttime = trace_clock_global();
/* Process args and tell the world that the torturer is on the job. */
for (i = 0; i < ARRAY_SIZE(torture_ops); i++) {
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index f0dcb4c0fe96..c8fb7dad5062 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -1403,6 +1403,7 @@ config WAKE_TORTURE_TEST
tristate "Torture test for wakeups and CPU hotplug"
depends on DEBUG_KERNEL
depends on 64BIT
+ depends on TRACE_CLOCK
select TORTURE_TEST
default n
help
--
2.5.2
next prev parent reply other threads:[~2016-06-15 22:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-15 22:27 [PATCH RFC tip/core/rcu 0/8] Waketorture, not for inclusion Paul E. McKenney
2016-06-15 22:28 ` [PATCH tip/core/rcu 1/8] waketorture: Add a wakeup-torture module Paul E. McKenney
2016-06-15 22:28 ` [PATCH tip/core/rcu 2/8] waketorture: Update scripting to accommodate waketorture Paul E. McKenney
2016-06-15 22:28 ` [PATCH tip/core/rcu 3/8] waketorture: Don't kick unless grace period or request Paul E. McKenney
2016-06-15 22:28 ` Paul E. McKenney [this message]
2016-06-15 22:28 ` [PATCH tip/core/rcu 5/8] waketorture: Add hrtimer support Paul E. McKenney
2016-06-15 22:28 ` [PATCH tip/core/rcu 6/8] torture: Make waketorture always hotplug the same CPU Paul E. McKenney
2016-06-15 22:28 ` [PATCH tip/core/rcu 7/8] torture: Make waketorture kill test if no hotpluggable CPUs Paul E. McKenney
2016-06-15 22:28 ` [PATCH tip/core/rcu 8/8] torture: Affinity waiter tasks away from hotpluggable CPU 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=1466029708-11359-4-git-send-email-paulmck@linux.vnet.ibm.com \
--to=paulmck@linux.vnet.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=bobby.prani@gmail.com \
--cc=dhowells@redhat.com \
--cc=dipankar@in.ibm.com \
--cc=dvhart@linux.intel.com \
--cc=edumazet@google.com \
--cc=fweisbec@gmail.com \
--cc=jiangshanlai@gmail.com \
--cc=josh@joshtriplett.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mingo@kernel.org \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
/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
Powered by JetHome