Skip to contentSkip to conversation

Polish rcutorture.h

PATCH In review SeongJae Park 2 participants 5 messages Aug 7, 2016

lore
Share & tools
lore
#0 lore raw

cover Polish rcutorture.h

This patchset contains few fixups for trivial nitpicks of rcutorture.

SeongJae Park (3):
rcutorture: Update usage
rcutorture: Remove redundant n_read_pt initialization
rcutorture: Protect fake workload from compiler optimization

 CodeSamples/defer/rcutorture.h | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/3 rcutorture: Update usage

Commit ca4aa79d18ba ("Add read-only and update-only perf test to rcutorture.h.") and commit 5f66427aeb6b ("Fix false-sharing and thread-affinity problems, use pthread_setspecific().") have introduced additional arguments for additional workloads and cpustride. However, its usage message does not updated for them. This commit updates rcutorture usage message to indicate their existence.

---
 CodeSamples/defer/rcutorture.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
CodeSamples/defer/rcutorture.h +2 -1
index 3d9842f..2feb4ad 100644
@@ -387,7 +387,8 @@ void stresstest(int nreaders)
 
 void usage(int argc, char *argv[])
 {
-	fprintf(stderr, "Usage: %s [nreaders [ perf | stress ] ]\n", argv[0]);
+	fprintf(stderr, "Usage: %s [nreaders [ perf | rperf | uperf | stress [cpustride] ] ]\n",
+			argv[0]);
 	exit(-1);
 }
 
Signature · 1 line
1.9.1
#2 lore raw

PATCH 2/3 rcutorture: Remove redundant n_read_pt initialization

In reply to SeongJae Park

Per-thread read count variable, n_reads_pt is redundantly initalized inside rperftest() and uperftest() though perftestinit() do initialize both of n_reads_pt and n_updates_pt before. This commit removes the redundancy.

---
 CodeSamples/defer/rcutorture.h | 2 --
 1 file changed, 2 deletions(-)
CodeSamples/defer/rcutorture.h +0 -2
index 2feb4ad..6ea0c09 100644
@@ -213,7 +213,6 @@ void rperftest(int nreaders, int cpustride)
 	long arg;
 
 	perftestinit();
-	init_per_thread(n_reads_pt, 0LL);
 	for (i = 0; i < nreaders; i++) {
 		arg = (long)(i * cpustride);
 		create_thread(rcu_read_perf_test, (void *)arg);
@@ -227,7 +226,6 @@ void uperftest(int nupdaters, int cpustride)
 	long arg;
 
 	perftestinit();
-	init_per_thread(n_reads_pt, 0LL);
 	for (i = 0; i < nupdaters; i++) {
 		arg = (long)(i * cpustride);
 		create_thread(rcu_update_perf_test, (void *)arg);
Signature · 1 line
1.9.1
#3 lore raw

PATCH 3/3 rcutorture: Protect fake workload from compiler optimization

In reply to SeongJae Park

Fake workload for read-side critical section of rcutorture stress test is implemented as a loop of hundred meaningless iterations. However, the loop can be optimized out by compiler because there is nothing to avoid such optimization. This commit protect the fake workload by using a compiler memory barrier, ACCESS_ONCE().

---
 CodeSamples/defer/rcutorture.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
CodeSamples/defer/rcutorture.h +1 -1
index 6ea0c09..c5bc87e 100644
@@ -271,7 +271,7 @@ void *rcu_read_stress_test(void *arg)
 			n_mberror++;
 		rcu_read_lock_nest();
 		for (i = 0; i < 100; i++)
-			garbage++;
+			ACCESS_ONCE(garbage)++;
 		rcu_read_unlock_nest();
 		pc = p->pipe_count;
 		rcu_read_unlock();
Signature · 1 line
1.9.1
#4 lore raw
In reply to SeongJae Park
Quoted 1 line · SeongJae Park

This patchset contains few fixups for trivial nitpicks of rcutorture.

Good catches, applied and pushed.

Thanx, Paul

Quoted 11 lines

SeongJae Park (3):
rcutorture: Update usage
rcutorture: Remove redundant n_read_pt initialization
rcutorture: Protect fake workload from compiler optimization

 CodeSamples/defer/rcutorture.h | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
Signature · 1 line
1.9.1