QSBR offline thread micro-optimization
authorMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Wed, 16 Sep 2009 13:39:20 +0000 (09:39 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Wed, 16 Sep 2009 13:39:20 +0000 (09:39 -0400)
> That's an interesting paper for sure. I had one micro-optimization in
> mind when I read the paper for QSBR, you can decide that making a CPU
> offline can be done by writing 0 to the per thread counter, instead of
> reading the global counter. It saves a load from a shared variable,
> which probably helps in its tiny way.
>

In wait_for_quiescent_state, the test for Q.S. is :

                while (rcu_gp_ongoing(index->rcu_reader_qs_gp) &&
                       (*index->rcu_reader_qs_gp - urcu_gp_ctr < 0))
                        cpu_relax();

where :

static inline int rcu_gp_ongoing(long *value)
{
        if (value == NULL)
                return 0;

        return LOAD_SHARED(*value) & 1;
}

Your proposal would work for the rcu_gp_ongoing test, as it only checks
for the parity. Given this test is enough to guarantee that we skip the
reader thread, then yes, it seems to work just fine.

Proposed-by: Pierre Habouzit <madcoder@debian.org>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
urcu-qsbr-static.h

index 752d4b9aced8630a94fca3bcf1e6338b012d0e36..86ae7d4aca91a6dd0ac998e5bf425b054a152716 100644 (file)
@@ -196,7 +196,7 @@ static inline void _rcu_quiescent_state(void)
 static inline void _rcu_thread_offline(void)
 {
        smp_mb();
-       rcu_reader_qs_gp = ACCESS_ONCE(urcu_gp_ctr);
+       rcu_reader_qs_gp = 0;
 }
 
 static inline void _rcu_thread_online(void)
This page took 0.026407 seconds and 4 git commands to generate.