linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: paulmck@kernel.org
To: rcu@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com,
	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,
	fweisbec@gmail.com, oleg@redhat.com, joel@joelfernandes.org,
	"Paul E. McKenney" <paulmck@kernel.org>
Subject: [PATCH tip/core/rcu 09/30] refperf: Provide module parameter to specify number of experiments
Date: Mon, 22 Jun 2020 17:29:52 -0700	[thread overview]
Message-ID: <20200623003013.26252-9-paulmck@kernel.org> (raw)
In-Reply-To: <20200623002941.GA26089@paulmck-ThinkPad-P72>

From: "Paul E. McKenney" <paulmck@kernel.org>

The current code uses the number of threads both to limit the number
of threads and to specify the number of experiments, but also varies
the number of threads as the experiments progress.  This commit takes
a different approach by adding an refperf.nruns module parameter that
specifies the number of experiments, and furthermore uses the same
number of threads for each experiment.

Cc: Joel Fernandes (Google) <joel@joelfernandes.org>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 kernel/rcu/refperf.c | 43 +++++++++++++++++++++++--------------------
 1 file changed, 23 insertions(+), 20 deletions(-)

diff --git a/kernel/rcu/refperf.c b/kernel/rcu/refperf.c
index 020e55a..6324449 100644
--- a/kernel/rcu/refperf.c
+++ b/kernel/rcu/refperf.c
@@ -83,12 +83,6 @@ struct reader_task {
 	atomic_t start;
 	wait_queue_head_t wq;
 	u64 last_duration_ns;
-
-	// The average latency When 1..<this reader> are concurrently
-	// running an experiment. For example, if this reader_task is
-	// of index 5 in the reader_tasks array, then result is for
-	// 6 cores.
-	u64 result_avg;
 };
 
 static struct task_struct *shutdown_task;
@@ -289,12 +283,12 @@ ref_perf_reader(void *arg)
 	return 0;
 }
 
-void reset_readers(int n)
+void reset_readers(void)
 {
 	int i;
 	struct reader_task *rt;
 
-	for (i = 0; i < n; i++) {
+	for (i = 0; i < nreaders; i++) {
 		rt = &(reader_tasks[i]);
 
 		rt->last_duration_ns = 0;
@@ -314,7 +308,7 @@ u64 process_durations(int n)
 	sprintf(buf, "Experiment #%d (Format: <THREAD-NUM>:<Total loop time in ns>)",
 		exp_idx);
 
-	for (i = 0; i <= n && !torture_must_stop(); i++) {
+	for (i = 0; i < n && !torture_must_stop(); i++) {
 		rt = &(reader_tasks[i]);
 		sprintf(buf1, "%d: %llu\t", i, rt->last_duration_ns);
 
@@ -342,11 +336,15 @@ static int main_func(void *arg)
 	int exp, r;
 	char buf1[64];
 	char buf[512];
+	u64 *result_avg;
 
 	set_cpus_allowed_ptr(current, cpumask_of(nreaders % nr_cpu_ids));
 	set_user_nice(current, MAX_NICE);
 
 	VERBOSE_PERFOUT("main_func task started");
+	result_avg = kzalloc(nruns * sizeof(*result_avg), GFP_KERNEL);
+	if (!result_avg)
+		VERBOSE_PERFOUT_ERRSTRING("out of memory");
 	atomic_inc(&n_init);
 
 	// Wait for all threads to start.
@@ -355,22 +353,24 @@ static int main_func(void *arg)
 		schedule_timeout_interruptible(holdoff * HZ);
 
 	// Start exp readers up per experiment
-	for (exp = 0; exp < nreaders && !torture_must_stop(); exp++) {
+	for (exp = 0; exp < nruns && !torture_must_stop(); exp++) {
+		if (!result_avg)
+			break;
 		if (torture_must_stop())
 			goto end;
 
-		reset_readers(exp);
-		atomic_set(&nreaders_exp, exp + 1);
+		reset_readers();
+		atomic_set(&nreaders_exp, nreaders);
 
 		exp_idx = exp;
 
-		for (r = 0; r <= exp; r++) {
+		for (r = 0; r < nreaders; r++) {
 			atomic_set(&reader_tasks[r].start, 1);
 			wake_up(&reader_tasks[r].wq);
 		}
 
 		VERBOSE_PERFOUT("main_func: experiment started, waiting for %d readers",
-				exp);
+				nreaders);
 
 		wait_event(main_wq,
 			   !atomic_read(&nreaders_exp) || torture_must_stop());
@@ -380,7 +380,7 @@ static int main_func(void *arg)
 		if (torture_must_stop())
 			goto end;
 
-		reader_tasks[exp].result_avg = 1000 * process_durations(exp) / ((exp + 1) * loops);
+		result_avg[exp] = 1000 * process_durations(nreaders) / (nreaders * loops);
 	}
 
 	// Print the average of all experiments
@@ -390,12 +390,15 @@ static int main_func(void *arg)
 	strcat(buf, "\n");
 	strcat(buf, "Threads\tTime(ns)\n");
 
-	for (exp = 0; exp < nreaders; exp++) {
-		sprintf(buf1, "%d\t%llu.%03d\n", exp + 1, reader_tasks[exp].result_avg / 1000, (int)(reader_tasks[exp].result_avg % 1000));
+	for (exp = 0; exp < nruns; exp++) {
+		if (!result_avg)
+			break;
+		sprintf(buf1, "%d\t%llu.%03d\n", exp + 1, result_avg[exp] / 1000, (int)(result_avg[exp] % 1000));
 		strcat(buf, buf1);
 	}
 
-	PERFOUT("%s", buf);
+	if (result_avg)
+		PERFOUT("%s", buf);
 
 	// This will shutdown everything including us.
 	if (shutdown) {
@@ -416,8 +419,8 @@ static void
 ref_perf_print_module_parms(struct ref_perf_ops *cur_ops, const char *tag)
 {
 	pr_alert("%s" PERF_FLAG
-		 "--- %s:  verbose=%d shutdown=%d holdoff=%d loops=%ld nreaders=%d\n", perf_type, tag,
-		 verbose, shutdown, holdoff, loops, nreaders);
+		 "--- %s:  verbose=%d shutdown=%d holdoff=%d loops=%ld nreaders=%d nruns=%d\n", perf_type, tag,
+		 verbose, shutdown, holdoff, loops, nreaders, nruns);
 }
 
 static void
-- 
2.9.5


  parent reply	other threads:[~2020-06-23  0:30 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-23  0:29 [PATCH tip/core/rcu 0/30] Add read-side scalability tests for v5.9 Paul E. McKenney
2020-06-23  0:29 ` [PATCH tip/core/rcu 01/30] rcuperf: Remove useless while loops around wait_event paulmck
2020-06-23  0:29 ` [PATCH tip/core/rcu 02/30] refperf: Add a test to measure performance of read-side synchronization paulmck
2020-06-23  0:29 ` [PATCH tip/core/rcu 03/30] rcuperf: Add comments explaining the high reader overhead paulmck
2020-06-23  0:29 ` [PATCH tip/core/rcu 04/30] torture: Add refperf to the rcutorture scripting paulmck
2020-06-23  0:29 ` [PATCH tip/core/rcu 05/30] refperf: Add holdoff parameter to allow CPUs to come online paulmck
2020-06-23  0:29 ` [PATCH tip/core/rcu 06/30] refperf: Hoist function-pointer calls out of the loop paulmck
2020-06-23  0:29 ` [PATCH tip/core/rcu 07/30] refperf: Allow decimal nanoseconds paulmck
2020-06-23  0:29 ` [PATCH tip/core/rcu 08/30] refperf: Convert nreaders to a module parameter paulmck
2020-06-23  0:29 ` paulmck [this message]
2020-06-23  0:29 ` [PATCH tip/core/rcu 10/30] refperf: Dynamically allocate experiment-summary output buffer paulmck
2020-06-23  0:29 ` [PATCH tip/core/rcu 11/30] refperf: Dynamically allocate thread-summary " paulmck
2020-06-23  0:29 ` [PATCH tip/core/rcu 12/30] refperf: Make functions static paulmck
2020-06-23  0:29 ` [PATCH tip/core/rcu 13/30] refperf: Tune reader measurement interval paulmck
2020-06-23  0:29 ` [PATCH tip/core/rcu 14/30] refperf: Convert reader_task structure's "start" field to int paulmck
2020-06-23  0:29 ` [PATCH tip/core/rcu 15/30] refperf: More closely synchronize reader start times paulmck
2020-06-23  0:29 ` [PATCH tip/core/rcu 16/30] refperf: Add warmup and cooldown processing phases paulmck
2020-06-23  0:30 ` [PATCH tip/core/rcu 17/30] refperf: Label experiment-number column "Runs" paulmck
2020-06-23  0:30 ` [PATCH tip/core/rcu 18/30] refperf: Output per-experiment data points paulmck
2020-06-23  0:30 ` [PATCH tip/core/rcu 19/30] refperf: Simplify initialization-time wakeup protocol paulmck
2020-06-23  0:30 ` [PATCH tip/core/rcu 20/30] refperf: Add read-side delay module parameter paulmck
2020-06-23  0:30 ` [PATCH tip/core/rcu 21/30] refperf: Adjust refperf.loop default value paulmck
2020-06-23  0:30 ` [PATCH tip/core/rcu 22/30] doc: Document rcuperf's module parameters paulmck
2020-06-23  0:30 ` [PATCH tip/core/rcu 23/30] refperf: Work around 64-bit division paulmck
2020-06-23  0:30 ` [PATCH tip/core/rcu 24/30] refperf: Change readdelay module parameter to nanoseconds paulmck
2020-06-23  0:30 ` [PATCH tip/core/rcu 25/30] refperf: Add test for RCU Tasks Trace readers paulmck
2020-06-23  0:30 ` [PATCH tip/core/rcu 26/30] refperf: Add test for RCU Tasks readers paulmck
2020-06-23  0:30 ` [PATCH tip/core/rcu 27/30] rcu-tasks: Fix synchronize_rcu_tasks_trace() header comment paulmck
2020-06-23  0:30 ` [PATCH tip/core/rcu 28/30] refperf: Rename RCU_REF_PERF_TEST to RCU_REF_SCALE_TEST paulmck
2020-06-23  0:30 ` [PATCH tip/core/rcu 29/30] refperf: Rename refperf.c to refscale.c and change internal names paulmck
2020-06-23  0:30 ` [PATCH tip/core/rcu 30/30] refscale: Change --torture type from refperf to refscale paulmck

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=20200623003013.26252-9-paulmck@kernel.org \
    --to=paulmck@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=dhowells@redhat.com \
    --cc=dipankar@in.ibm.com \
    --cc=edumazet@google.com \
    --cc=fweisbec@gmail.com \
    --cc=jiangshanlai@gmail.com \
    --cc=joel@joelfernandes.org \
    --cc=josh@joshtriplett.org \
    --cc=kernel-team@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mingo@kernel.org \
    --cc=oleg@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rcu@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).