Re: [RFC][PATCH 5/9] rbtree: Make lockless searches non-fatal
From: Peter Zijlstra
Date: Mon Mar 02 2015 - 03:27:57 EST
On Sun, Mar 01, 2015 at 01:52:09PM +0000, Mathieu Desnoyers wrote:
> > 2) there must not be (temporary) loops in the tree structure in the
> > modifier's program order, this would cause a lookup which
> > interrupts the modifier to get stuck indefinitely.
>
> For (2), I don't think this is how the situation should be described.
>
> Let's consider a scenario where an interrupt nests over the modification.
> First, the modification will switch the latch to the other version of the
> tree. Therefore, the interrupt will see a fully consistent tree, not the
> tree being modified. Therefore, a temporary loop in the tree should not
> be an issue for that peculiar situation.
>
> However, if we have another thread traversing the tree while we
> concurrently switch the latch and modify one version of the tree,
> creating a temporary loop in the tree, this thread could possibly:
>
> A) deadlock with the modification if there is a locking dependency
> between tree modification, tree read, and another lock (transitive
> dependency).
> B) have the modifier starved by the other thread, if that thread has
> a higher scheduling priority (e.g. RT) than the modifier. The high
> priority thread would then use all its CPU time to perform the
> temporary loop.
>
> So I agree that loops are unwanted there: it allows us to never have
> to care about situations A and B. However, the explanation about why
> should not involve, AFAIU, an interrupt handler nesting over the tree
> modification, because this is precisely one scenario that should not
> care about loops.
>
> Thoughs ?
This is true for the (later) proposed latched RB-tree, the description
is however true in general. If you somehow did a lookup while doing the
modification and you have loops in program order, you're stuck.
So in the interest of robustness I think we want this property
nonetheless. And its 'free', I didn't have to change any code for this.
I shall however clarify this point in the latched RB-tree patch.
--
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/