Re: [PATCH] maple_tree: Fix sparse reported issues

From: Liam Howlett
Date: Tue Jul 12 2022 - 11:44:29 EST


* Matthew Wilcox <willy@xxxxxxxxxxxxx> [220712 10:54]:
> On Tue, Jul 12, 2022 at 02:24:55PM +0000, Liam Howlett wrote:
> > When building with C=1, the maple tree had some rcu type mismatch &
> > locking mismatches in the destroy functions. There were cosmetic only
> > since this happens after the nodes are removed from the tree.
>
> ... in the current use-case. It's a legitimate use of the API to do:
>
> ma_init();
> ma_store();
> ma_destroy();
> ma_store();
>
> Can you add a new test that does that?

I can add this, but a few notes on it.

The function names are mt_init(), mtree_store(), and mtree_destroy().
There is an internal/advanced __mt_destroy(). Both destroy functions
clear the flags - which I think is desirable.

>
> > @@ -5524,13 +5526,17 @@ static void mt_destroy_walk(struct maple_enode *enode, unsigned char ma_flags,
> >
> > type = mte_node_type(mas.node);
> > slots = ma_slots(mte_to_node(mas.node), type);
> > - if ((offset < mt_slots[type]) && mte_node_type(slots[offset]) &&
> > - mte_to_node(slots[offset])) {
> > - struct maple_enode *parent = mas.node;
> > + if (offset >= mt_slots[type])
> > + goto next;
> >
> > - mas.node = mas_slot_locked(&mas, slots, offset);
> > + tmp = mas_slot_locked(&mas, slots, offset);
> > + if (mte_node_type(tmp) && mte_to_node(tmp)) {
> > +
>
> Unnecessary blank line?

ack, I'll remove that.


>
> > + parent = mas.node;
> > + mas.node = tmp;
> > slots = mas_destroy_descend(&mas, parent, offset);
> > }
> > +next:
> > node = mas_mn(&mas);
> > } while (start != mas.node);
> >
> > --
> > 2.35.1
> >
>
> --
> maple-tree mailing list
> maple-tree@xxxxxxxxxxxxxxxxxxx
> https://lists.infradead.org/mailman/listinfo/maple-tree