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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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().

Signed-off-by: SeongJae Park <sj38.park@xxxxxxxxx>
---
 CodeSamples/defer/rcutorture.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/CodeSamples/defer/rcutorture.h b/CodeSamples/defer/rcutorture.h
index 6ea0c09..c5bc87e 100644
--- a/CodeSamples/defer/rcutorture.h
+++ b/CodeSamples/defer/rcutorture.h
@@ -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();
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe perfbook" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux