[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y+/ZW/8WXzrkQnUT@casper.infradead.org>
Date: Fri, 17 Feb 2023 19:45:31 +0000
From: Matthew Wilcox <willy@...radead.org>
To: Danilo Krummrich <dakr@...hat.com>
Cc: airlied@...il.com, daniel@...ll.ch, tzimmermann@...e.de,
mripard@...nel.org, corbet@....net, christian.koenig@....com,
bskeggs@...hat.com, Liam.Howlett@...cle.com,
matthew.brost@...el.com, boris.brezillon@...labora.com,
alexdeucher@...il.com, ogabbay@...nel.org, bagasdotme@...il.com,
jason@...kstrand.net, dri-devel@...ts.freedesktop.org,
nouveau@...ts.freedesktop.org, linux-doc@...r.kernel.org,
linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH drm-next v2 03/16] maple_tree: split up MA_STATE() macro
On Fri, Feb 17, 2023 at 02:44:09PM +0100, Danilo Krummrich wrote:
> \#define SAMPLE_ITER(name, __mgr) \
> struct sample_iter name = { \
> .mas = __MA_STATE(&(__mgr)->mt, 0, 0),
This is usually called MA_STATE_INIT()
> #define sample_iter_for_each_range(it__, start__, end__) \
> for ((it__).mas.index = start__, (it__).entry = mas_find(&(it__).mas, end__ - 1); \
> (it__).entry; (it__).entry = mas_find(&(it__).mas, end__ - 1))
This is a bad iterator design. It's usually best to do this:
struct sample *sample;
SAMPLE_ITERATOR(si, min);
sample_iter_for_each(&si, sample, max) {
frob(mgr, sample);
}
I don't mind splitting apart MA_STATE_INIT from MA_STATE, and if you
do that, we can also use it in VMA_ITERATOR.
Powered by blists - more mailing lists