[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f727adcf-5967-0b71-92a8-3269c0256948@suse.cz>
Date: Wed, 15 Dec 2021 13:54:45 +0100
From: Vlastimil Babka <vbabka@...e.cz>
To: Liam Howlett <liam.howlett@...cle.com>,
"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>
Cc: 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
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.
> + */
> +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