[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20211215175139.nndgst2mbdudu2dx@revolver>
Date: Wed, 15 Dec 2021 17:52:08 +0000
From: Liam Howlett <liam.howlett@...cle.com>
To: Vlastimil Babka <vbabka@...e.cz>
CC: "maple-tree@...ts.infradead.org" <maple-tree@...ts.infradead.org>,
"linux-mm@...ck.org" <linux-mm@...ck.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Song Liu <songliubraving@...com>,
Davidlohr Bueso <dave@...olabs.net>,
"Paul E . McKenney" <paulmck@...nel.org>,
Matthew Wilcox <willy@...radead.org>,
Laurent Dufour <ldufour@...ux.ibm.com>,
David Rientjes <rientjes@...gle.com>,
Axel Rasmussen <axelrasmussen@...gle.com>,
Suren Baghdasaryan <surenb@...gle.com>,
Rik van Riel <riel@...riel.com>,
Peter Zijlstra <peterz@...radead.org>,
Michel Lespinasse <walken.cr@...il.com>,
Jerome Glisse <jglisse@...hat.com>,
Minchan Kim <minchan@...gle.com>,
Joel Fernandes <joelaf@...gle.com>,
Rom Lemarchand <romlem@...gle.com>
Subject: Re: [PATCH v4 05/66] Maple Tree: Add new data structure
* Vlastimil Babka <vbabka@...e.cz> [211215 07:54]:
> On 12/1/21 15:29, Liam Howlett wrote:
> > +/*
> > + * mt_find() - Search from the start up until an entry is found.
> > + * @mt: The maple tree
> > + * @*index: Pointer which contains the start location of the search
> > + * @max: The maximum value to check
> > + *
> > + * Handles locking.
> > + *
> > + * Return: The entry at or after the @*index or %NULL
>
> Noticed later that the comment doesn't say how *index is updated.
Good point. I will add to the comment what happens to *index.
>
> > + */
> > +void *mt_find(struct maple_tree *mt, unsigned long *index, unsigned long max)
> > +{
> > + MA_STATE(mas, mt, *index, *index);
> > + void *entry;
> > +#ifdef CONFIG_DEBUG_MAPLE_TREE
> > + unsigned long copy = *index;
> > +#endif
> > +
> > + trace_ma_read(__func__, &mas);
> > +
> > + if ((*index) > max)
> > + return NULL;
> > +
> > + rcu_read_lock();
> > +retry:
> > + entry = mas_state_walk(&mas);
> > + if (mas_is_start(&mas))
> > + goto retry;
> > +
> > + if (unlikely(xa_is_zero(entry)))
> > + entry = NULL;
> > +
> > + if (entry)
> > + goto unlock;
> > +
> > + while (mas_searchable(&mas) && (mas.index < max)) {
> > + entry = mas_next_entry(&mas, max);
> > + if (likely(entry && !xa_is_zero(entry)))
> > + break;
> > + }
> > +
> > + if (unlikely(xa_is_zero(entry)))
> > + entry = NULL;
> > +unlock:
> > + rcu_read_unlock();
> > + if (likely(entry)) {
> > + *index = mas.last + 1;
> > +#ifdef CONFIG_DEBUG_MAPLE_TREE
> > + if ((*index) && (*index) <= copy)
> > + printk("index not increased! %lx <= %lx\n",
> > + *index, copy);
> > + MT_BUG_ON(mt, (*index) && ((*index) <= copy));
> > +#endif
> > + }
> > +
> > + return entry;
> > +}
> > +EXPORT_SYMBOL(mt_find);
>
Powered by blists - more mailing lists