Re: [RFC PATCH 5/5 single-thread-version] implement per-domainsingle-thread state machine call_srcu()

From: Peter Zijlstra
Date: Thu Mar 08 2012 - 08:09:11 EST


On Wed, 2012-03-07 at 11:54 +0800, Lai Jiangshan wrote:
> This patch is on the top of the 4 previous patches(1/6, 2/6, 3/6, 4/6).
>
> o state machine is light way and single-threaded, it is preemptible when checking.
>
> o state machine is a work_struct. So, there is no thread occupied
> by SRCU when the srcu is not actived(no callback). And it does
> not sleep(avoid to occupy a thread when sleep).
>
> o state machine is the only thread can flip/check/write(*) the srcu_struct,
> so we don't need any mutex.
> (write(*): except ->per_cpu_ref, ->running, ->batch_queue)
>
> o synchronize_srcu() is always call call_srcu().
> synchronize_srcu_expedited() is also.
> It is OK for mb()-based srcu are extremely fast.
>
> o In current kernel, we can expect that there are only 1 callback per gp.
> so callback is probably called in the same CPU when it is queued.
>
> The trip of a callback:
> 1) ->batch_queue when call_srcu()
>
> 2) ->batch_check0 when try to do check_zero
>
> 3) ->batch_check1 after finish its first check_zero and the flip
>
> 4) ->batch_done after finish its second check_zero
>
> The current requirement of the callbacks:
> The callback will be called inside process context.
> The callback should be fast without any sleeping path.
>
> Signed-off-by: Lai Jiangshan <laijs@xxxxxxxxxxxxxx>

Aside from the nit on srcu_advance_batches() this seems like a nice
implementation. Thanks!

I didn't fully verify the srcu state machine, but it looks about
right :-)

Acked-by: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/